/* Student → owner message form, and the modal shell it opens in.
   Pages provide the common colour variables (--accent, --ink, --line, --card,
   …) in their own :root, exactly like student-nav.css does.

   The form is mounted in two different places by design: inline inside the
   /requests card, and inside the modal on every other top-level page. Both use
   the same markup, so everything here is scoped to .msg-form and stays neutral
   about the surrounding card. */

.msg-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.75rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.msg-field { display: grid; gap: 0.35rem; }

.msg-label {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}
/* The "(optional)" qualifier is part of the label rather than placeholder text:
   a placeholder disappears the moment the student starts typing, which is the
   worst time to stop telling them the field can be left blank. */
.msg-optional {
  margin-left: 0.35rem;
  color: var(--ink-3);
  font-size: 0.78rem;
  font-weight: 600;
}

.msg-input,
.msg-textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  font: inherit;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.msg-textarea { min-height: 8.5rem; resize: vertical; }
.msg-input:focus,
.msg-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.msg-counter {
  justify-self: end;
  color: var(--ink-3);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}
.msg-counter.is-low { color: var(--accent-dark); font-weight: 700; }

.msg-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.msg-submit {
  padding: 0.72rem 1.15rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.msg-submit:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
.msg-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.msg-submit:disabled { opacity: 0.6; cursor: default; transform: none; }

/* One live region for both outcomes, styled by class rather than by element,
   so a screen reader announces the result exactly once either way. */
.msg-note { font-size: 0.88rem; line-height: 1.45; }
.msg-note[hidden] { display: none; }
.msg-note.is-error { color: #b3261e; font-weight: 600; }
.msg-note.is-success { color: #146c43; font-weight: 700; }

/* --- The modal shell ------------------------------------------------------
   Backdrop, z-index and centring mirror .br-modal-backdrop in brainrot.css so
   the two dialogs sit at the same layer and dismiss the same way. The card
   itself deliberately does NOT copy the game's fixed 420×560 box: this is a
   form, so it sizes to its content and scrolls when the keyboard shrinks the
   viewport on a phone. */
.msg-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 25, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.msg-modal-backdrop[hidden] { display: none; }

.msg-modal {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.6rem clamp(1.1rem, 4vw, 1.9rem) 1.75rem;
  color: var(--ink);
  background: var(--card, #fff);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.msg-modal:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.msg-modal-title {
  margin-right: 2.5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.msg-modal-intro {
  margin-top: 0.5rem;
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.6;
}
/* The modal's form has the title above it, so it needs less lead-in than the
   inline copy sitting under a paragraph of prose. */
.msg-modal .msg-form { margin-top: 1.1rem; }

.msg-modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.msg-modal-close:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.msg-modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The secondary "or email me directly" line under the inline form on
   /requests. Subdued on purpose: the form is the primary path now, and this is
   the fallback for someone who would rather use their own mail client. */
.msg-mailto {
  margin-top: 1.5rem;
  color: var(--ink-2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.88rem;
  line-height: 1.6;
}
.msg-mailto a { color: var(--accent); font-weight: 600; }

@media (max-width: 560px) {
  .msg-modal { padding: 1.35rem 1.05rem 1.5rem; border-radius: 14px; }
  .msg-submit { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .msg-input, .msg-textarea, .msg-submit, .msg-modal-close { transition: none; }
}
