/* ==========================================================================
   Matt & Lexi · server-rendered pages (sign-in, Your Invitation, admin)
   Uses only the tokens and components of the approved prototype 3 stylesheet;
   this file adds layout for the real forms, nothing new in colour or type.
   ========================================================================== */

[hidden] { display: none !important; }

.app-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; max-width: 40rem; margin-inline: auto; }
.app-wrap--wide { max-width: 54rem; }
.admin-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; max-width: 72rem; margin-inline: auto; }

.app-card {
  min-width: 0;
  overflow-wrap: anywhere;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  background: var(--ivory-50);
  border: 1px solid var(--ivory-300);
  box-shadow: 0 30px 60px -45px rgb(20 40 31 / .45);
}
.app-card > :first-child { margin-top: 0; }
.app-card > :last-child { margin-bottom: 0; }
.app-card p { margin: 0 0 1rem; }
.app-title {
  margin: 0 0 .75rem;
  font: 400 clamp(1.8rem, 4vw, 2.4rem)/1.08 var(--serif);
  color: var(--forest-900);
  text-wrap: balance;
}
.admin-h {
  margin: 2rem 0 .25rem;
  font: 400 clamp(1.6rem, 3vw, 2rem)/1.1 var(--serif);
  color: var(--forest-900);
}
.admin-h:first-child { margin-top: 0; }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; margin: 1.25rem 0; }
.app-choice { width: 100%; text-transform: none; letter-spacing: .02em; font-size: .95rem; }
.app-links { margin-top: 1.25rem; font-size: .95rem; }
.app-links a, .contact-line a { color: var(--forest-800); font-weight: 500; }

.button--small { min-height: 2.75rem; padding: .6rem 1rem; font-size: .7rem; letter-spacing: .12em; }

/* Notices */
.notice:focus { outline: none; }
.notice--saved { border-left-color: var(--forest-800); background: rgb(27 58 44 / .08); }
.notice--conflict { border-left-color: #a1341e; background: rgb(161 52 30 / .07); }
.notice ul { margin: .5rem 0; padding-left: 1.2rem; }
.error-summary {
  margin: 0 0 1.5rem;
  padding: 1.1rem 1.25rem;
  border: 2px solid #a1341e;
  background: #fff;
}
.error-summary:focus { outline: 3px solid var(--copper-dark); outline-offset: 2px; }
.error-summary h2 { margin: 0 0 .5rem; font: 600 1.05rem/1.3 var(--sans); color: #a1341e; }
.error-summary ul { margin: 0 0 .5rem; padding-left: 1.2rem; }
.error-summary a { color: #a1341e; font-weight: 600; }
.error-summary p { margin: 0; font-size: .9rem; }

/* Your Invitation */
.reply-status__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .5rem; }
.reply-status__head .app-title { margin: 0; }
.still-needed { margin: 0 0 1rem; }
.still-needed summary { cursor: pointer; font-weight: 600; color: var(--forest-800); min-height: 2.75rem; display: flex; align-items: center; }
.still-needed ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.contact-line { padding-top: 1rem; border-top: 1px solid var(--rule-light); font-size: .95rem; }
.summary-card > summary { cursor: pointer; font-weight: 600; color: var(--forest-800); min-height: 2.75rem; display: flex; align-items: center; }

.reply-form .person { margin-top: 1.5rem; }
.reply-form .person:first-of-type { margin-top: 0; }
.person--guest { border-style: dashed; border-color: var(--copper); }
.q--event .q__sub { margin-top: .1rem; }
.q--diet { border-top: 1px solid var(--rule-light); }
.field--follow { max-width: none; margin: .9rem 0 .25rem; }
.all-three { margin: .25rem 0 1rem; }
.name-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 36rem) { .name-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.name-pair .field { margin: .75rem 0; }
.reply-form .actions { margin-top: 1.5rem; }
.reply-form .actions .hint { flex: 1 1 18rem; }
.ans--maybe { color: var(--copper-dark); }
.ans--maybe::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); border: 1.5px solid currentColor; }

/* Admin */
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll:focus-visible { outline: 2px solid var(--copper-dark); outline-offset: 2px; }
.filter-links { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.filter-links a {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: .45rem .9rem;
  border: 1px solid #8a8b84; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .85rem; font-weight: 500;
}
.filter-links a[aria-current="page"] { color: var(--ivory); background: var(--forest-800); border-color: var(--forest-800); }
.inline-form { display: inline-block; margin: 0; }
.invite-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }
/* A control's label never breaks inside a word: on the table the Invitation column is as wide as its
   widest label (the region scrolls sideways if the screen is narrower), and on the cards below the
   controls wrap between words only. */
.invite-table .button, .invite-table .copy { overflow-wrap: normal; white-space: nowrap; }
.invite-text { flex-basis: 100%; font-size: .9rem; }
.invite-text summary { display: flex; align-items: center; cursor: pointer; color: var(--forest-800); }
.invite-text__body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; padding: .75rem; background: #fff; border: 1px solid var(--ivory-300); }
.adult-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 52rem) { .adult-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adult-card h3 { margin: 0 0 .5rem; font: 400 1.5rem/1.15 var(--serif); color: var(--forest-900); }
.audit { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.audit li { padding: .75rem 1rem; background: #fff; border: 1px solid var(--ivory-300); font-size: .92rem; }
.audit ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.audit__meta { margin: 0; color: var(--muted); font-size: .82rem; }
.export-list { display: grid; gap: 1rem; padding: 0; list-style: none; }
.export-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.export-list span { flex: 1 1 20rem; }
.invite-table td { vertical-align: top; }

/* Invitations on narrow screens: each row is a card. The guest's name heads it, the mobile number
   and status follow with their labels (side by side when there is room), and the controls share a
   grid of equal, adequate widths (two per row on most phones, one at 320 px or with enlarged text).
   The table keeps its semantics through the explicit roles in the markup; the column headings are
   kept for assistive technology and each cell's label is drawn from data-label (without an
   accessible name where the browser supports that, so headings are not announced twice). */
@media (max-width: 47.99rem) {
  .invite-table, .invite-table tbody, .invite-table th, .invite-table td { display: block; }
  .invite-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .invite-table tbody tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: .4rem .75rem;
    padding: 1rem 0 1.15rem;
    border-bottom: 1px solid var(--rule-light);
  }
  .invite-table th, .invite-table td { min-width: 0; padding: 0; border: 0; }
  .invite-table td[data-label] { text-align: left; } /* the narrow-screen table rule right-aligns a row's last cell */
  .invite-table th[scope="row"] { grid-column: 1 / -1; font-size: 1.05rem; }
  .invite-table td[data-label="Invitation"] { grid-column: 1 / -1; margin-top: .2rem; }
  .invite-table td::before { content: attr(data-label); display: block; margin-bottom: .1rem; font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  @supports (content: "a" / "b") { .invite-table td::before { content: attr(data-label) / ""; } }
  .invite-table .inline-form { display: grid; } /* so a form's button stretches to its row's height like the others */
  .invite-table .button, .invite-table .copy { width: 100%; white-space: normal; }
  .invite-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); align-items: stretch; margin-top: .4rem; }
  .invite-text summary { min-height: 2.75rem; } /* a touch target beside the Copy message button */
  .invite-controls .invite-text[open] { grid-column: 1 / -1; } /* the opened message takes the card's width, below Copy message */
}

/* Admin set-up */
.qr { width: min(15rem, 100%); margin: 1rem 0; padding: .75rem; background: #fff; border: 1px solid var(--ivory-300); }
.qr svg { display: block; width: 100%; height: auto; }
.setup-key { font-size: 1rem; letter-spacing: .08em; word-spacing: .2em; }
.steps { margin: 1rem 0 .25rem; padding-left: 1.4rem; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; padding: 0; list-style: none; }
.recovery-codes code { display: block; padding: .5rem .75rem; background: #fff; border: 1px solid var(--ivory-300); font-size: 1rem; letter-spacing: .05em; }

/* Dietary questions: requirements and allergies are separate groups */
.form-note { margin: 0 0 1.25rem; font-size: .92rem; color: var(--muted); }
.q--allergy { border-top: 1px solid var(--rule-light); }
.follow { margin-top: .75rem; }
.follow .checks { padding-top: .25rem; border-top: 0; }
.follow .checks legend { font-size: .92rem; font-weight: 600; }
.check--hint { align-items: flex-start; padding: .35rem 0; }
.check--hint input { margin-top: .2rem; }
.check__hint { display: block; font-size: .82rem; color: var(--muted); font-weight: 400; }
.field__req { font-weight: 400; color: var(--muted); }
.q .error { margin: 0 0 .6rem; }

/* Saved progress versus a complete reply */
.notice--progress { border-left-color: var(--copper); background: rgb(217 164 124 / .12); }
.still-needed__h { margin: .9rem 0 .25rem; font: 600 .95rem/1.3 var(--sans); color: var(--forest-900); }
.still-needed__h:first-child { margin-top: 0; }

/* Admin contact details */
.contact-edit-wrap { margin-top: .75rem; font-size: .92rem; }
.contact-edit-wrap > summary { cursor: pointer; color: var(--forest-800); min-height: 2.75rem; display: flex; align-items: center; }
.contact-edit .field { margin: .5rem 0; }

/* A form already on its way (double-tap protection in app.js) */
button[aria-disabled="true"] { opacity: .75; cursor: progress; }

/* Admin overview tiles: three in a row at normal text sizes (the same as before). With much larger
   text, or wider fallback fonts, the tiles reflow to two or one per row and a status badge wraps,
   so a count or a badge never spills past the edge of the page. Long words in admin headings and
   paragraphs wrap too, rather than widening the page. */
.admin-wrap .tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 5.5rem), 1fr)); }
.tile .badge { max-width: 100%; white-space: normal; }
.admin-wrap :is(.admin-h, p, li, dt, dd, legend, summary, .tile__num) { overflow-wrap: anywhere; }

/* Privacy notice and other short reading pages */
.prose-card .app-title { margin-top: 1.75rem; font-size: clamp(1.45rem, 3vw, 1.75rem); }
.prose-card ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.prose-card li { margin: .35rem 0; }
