/* ==========================================================================
   Wedding intake form
   Mobile-first. Everything sized so it is comfortable one-handed on a phone,
   because that is where most of these get filled in.
   ========================================================================== */

:root {
  --bg:            #faf8f5;
  --surface:       #ffffff;
  --surface-sunk:  #f4f1ec;
  --ink:           #1f1d1a;
  --ink-soft:      #5c574f;
  --ink-faint:     #8a837a;
  --line:          #e2ddd4;
  --line-strong:   #c9c2b6;
  --accent:        #7a5c3e;
  --accent-ink:    #ffffff;
  --accent-wash:   #f0e7dc;
  --danger:        #a33227;
  --danger-wash:   #fbecea;
  --ok:            #3d6b4a;

  --radius:      12px;
  --radius-lg:   18px;
  --tap:         48px;          /* minimum comfortable touch target */
  --measure:     40rem;         /* readable line length */
  --shadow:      0 1px 2px rgba(31, 29, 26, .05), 0 6px 20px rgba(31, 29, 26, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #171614;
    --surface:       #201e1b;
    --surface-sunk:  #2a2724;
    --ink:           #f2efe9;
    --ink-soft:      #b8b1a6;
    --ink-faint:     #8b847a;
    --line:          #37332e;
    --line-strong:   #4c463f;
    --accent:        #c9a882;
    --accent-ink:    #1a1815;
    --accent-wash:   #2e2822;
    --danger:        #e8897c;
    --danger-wash:   #33211f;
    --ok:            #8fc7a0;
    --shadow:        0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, legend { line-height: 1.25; letter-spacing: -0.011em; }

/* ------------------------------------------------------------------ utilities */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 20;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; }

:where(a):focus-visible,
:where(button, input, textarea, select):focus-visible,
.option:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------- masthead */

.masthead {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  max-width: var(--measure); margin: 0 auto;
  padding: 12px 20px 8px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}

.brand {
  margin: 0; font-size: .95rem; font-weight: 650;
  letter-spacing: .01em; color: var(--ink);
}

.save-state {
  margin: 0; font-size: .8rem; color: var(--ink-faint);
  white-space: nowrap;
}
.save-state[data-state="saved"] { color: var(--ok); }

/* Progress: numbered dots on wide screens, a bar everywhere. */
.progress { max-width: var(--measure); margin: 0 auto; padding: 0 20px 12px; }

.progress-steps {
  display: none;
  list-style: none; margin: 0 0 10px; padding: 0;
  gap: 4px; font-size: .72rem;
}
@media (min-width: 40rem) { .progress-steps { display: flex; } }

.progress-steps li {
  flex: 1; text-align: center; color: var(--ink-faint);
  padding-bottom: 2px; border-bottom: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-steps li[data-state="done"]    { color: var(--ink-soft); }
.progress-steps li[data-state="current"] { color: var(--accent); font-weight: 650; border-bottom-color: var(--accent); }

.progress-track {
  height: 4px; border-radius: 99px; background: var(--surface-sunk); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 99px; background: var(--accent);
  transition: width .3s ease;
}

/* ------------------------------------------------------------------------ main */

main { max-width: var(--measure); margin: 0 auto; padding: 24px 20px 40px; }

.step-title  { margin: 8px 0 6px; font-size: 1.65rem; font-weight: 680; }
.step-title:focus { outline: none; }
.step-blurb  { margin: 0 0 26px; color: var(--ink-soft); }

.resume-banner {
  background: var(--accent-wash); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 22px;
}
.resume-banner p { margin: 0 0 8px; font-size: .92rem; }

/* --------------------------------------------------------------------- groups */

.group {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
  margin: 0 0 18px; padding: 20px;
  min-width: 0;                       /* let long content shrink rather than overflow */
}

.group > legend {
  font-weight: 650; font-size: 1.02rem;
  padding: 0 8px; margin-left: -8px;
}

.group-hint {
  margin: 4px 0 16px; color: var(--ink-soft); font-size: .88rem;
}
.group > legend + .group-hint { margin-top: 10px; }

.note {
  background: var(--surface-sunk); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 14px; margin: 0 0 16px;
  font-size: .88rem; color: var(--ink-soft);
}

/* --------------------------------------------------------------------- fields */

.field-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 34rem) {
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-full { grid-column: 1 / -1; }
}
.field-grid > .field { min-width: 0; }

.field > label,
.field > .field-label {
  display: block; font-weight: 560; font-size: .92rem; margin-bottom: 6px;
}

.req { color: var(--danger); margin-left: 2px; }

.hint {
  display: block; color: var(--ink-soft); font-size: .82rem;
  margin: -2px 0 7px; font-weight: 400;
}

input[type="text"], input[type="email"], input[type="tel"], input[type="url"],
input[type="date"], input[type="time"], textarea {
  width: 100%; min-width: 0; max-width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  font: inherit; font-size: 1rem;         /* 16px+ stops iOS zooming on focus */
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { min-height: auto; resize: vertical; line-height: 1.5; }

input:hover, textarea:hover { border-color: var(--ink-faint); }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
  outline: none;
}

::placeholder { color: var(--ink-faint); opacity: 1; }

/* Date and time inputs carry a chunky intrinsic width from their picker UI, which is what
   pushed them past the fieldset edge. Deliberately NOT using `appearance: none` here -
   some Chrome versions drop the calendar button entirely with it, which trades a layout
   bug for a worse usability one. Constraining the inner edit region is enough. */
input[type="date"], input[type="time"] { display: block; }
input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit { padding: 0; overflow: hidden; }
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  margin-inline-start: auto; padding-inline-start: 8px; flex: none; cursor: pointer;
}

.field[data-invalid] input,
.field[data-invalid] textarea { border-color: var(--danger); }

.field-error {
  display: block; color: var(--danger); font-size: .82rem; margin-top: 5px; font-weight: 500;
}

/* ------------------------------------------------- radios and checkbox chips */

.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
}

.option {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 10px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  font-size: .93rem;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: var(--ink-faint); }
.option:has(:checked) {
  border-color: var(--accent); background: var(--accent-wash);
  font-weight: 560;
}
.option input { accent-color: var(--accent); width: 19px; height: 19px; flex: none; margin: 0; }

/* --------------------------------------------------------- running-order list */

.events-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.event-row {
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.event-row[data-on="true"] { border-color: var(--accent); }
.event-row[data-dragging="true"] { opacity: .45; }
.event-row[data-dropbefore="true"] { box-shadow: 0 -3px 0 var(--accent); }

.event-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; }

.event-pos {
  font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--ink-faint);
  min-width: 1.5rem; flex: none;
}

.event-check {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 auto; min-width: 0; cursor: pointer; min-height: 40px;
}
.event-check input { accent-color: var(--accent); width: 20px; height: 20px; flex: none; margin: 0; }
.event-name { font-weight: 560; font-size: .96rem; }
.event-note { display: block; font-size: .79rem; color: var(--ink-faint); font-weight: 400; }

.event-move { display: flex; gap: 4px; flex: none; }
.move-btn {
  width: 40px; height: 40px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink-soft);
  font-size: 1rem; cursor: pointer; line-height: 1;
}
.move-btn:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); }
.move-btn:disabled { opacity: .3; cursor: default; }

.drag-handle { cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }

.event-detail {
  padding: 4px 14px 16px 14px;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
  display: grid; gap: 14px;
}

/* --------------------------------------------------------------------- review */

.review-section { margin-bottom: 22px; }
.review-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px;
}
.review-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; }

.edit-link {
  background: none; border: 0; padding: 4px 6px; cursor: pointer;
  color: var(--accent); font: inherit; font-size: .85rem; font-weight: 560;
  text-decoration: underline; text-underline-offset: 2px;
}

.review-list { margin: 0; display: grid; gap: 10px; }
@media (min-width: 34rem) {
  .review-list { grid-template-columns: minmax(9rem, 13rem) 1fr; gap: 8px 16px; }
  .review-list dt { grid-column: 1; }
  .review-list dd { grid-column: 2; }
}
.review-list dt { color: var(--ink-soft); font-size: .86rem; }
.review-list dd {
  margin: 0 0 6px; font-size: .93rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
@media (min-width: 34rem) { .review-list dd { margin-bottom: 0; } }

.review-empty { color: var(--ink-faint); font-style: italic; font-size: .9rem; }

.review-order { list-style: none; margin: 0; padding: 0; counter-reset: ord; }
.review-order li {
  counter-increment: ord; padding: 7px 0 7px 2.2rem; position: relative;
  border-bottom: 1px solid var(--line); font-size: .93rem;
}
.review-order li:last-child { border-bottom: 0; }
.review-order li::before {
  content: counter(ord); position: absolute; left: 0; top: 7px;
  font-variant-numeric: tabular-nums; color: var(--ink-faint); font-size: .82rem;
}
.review-order .ord-detail { display: block; color: var(--ink-soft); font-size: .84rem; }

/* ----------------------------------------------------------------------- gate */

.gate {
  max-width: 26rem; margin: 8vh auto 0; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 34px 26px;
}
.gate[hidden] { display: none; }

.gate-title { margin: 0 0 10px; font-size: 1.5rem; font-weight: 680; }
.gate-blurb { margin: 0 0 22px; color: var(--ink-soft); font-size: .93rem; }

.gate-label {
  display: block; font-weight: 560; font-size: .9rem; margin-bottom: 8px;
}

#pin-input {
  width: 100%; min-height: 56px;
  padding: 12px 14px; text-align: center;
  font: inherit; font-size: 1.6rem; font-weight: 600;
  letter-spacing: .5em; text-indent: .5em;      /* indent offsets the trailing gap */
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
}
#pin-input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); outline: none;
}

.gate .field-error { text-align: left; margin-top: 8px; }
.gate-btn { width: 100%; margin-top: 16px; }
.gate-help { margin: 18px 0 0; color: var(--ink-faint); font-size: .82rem; }

/* -------------------------------------------------------------- nav + buttons */

.form-nav {
  display: flex; gap: 10px; justify-content: space-between;
  margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line);
}

.btn {
  min-height: var(--tap); padding: 12px 22px;
  font: inherit; font-size: .97rem; font-weight: 600;
  border-radius: var(--radius); border: 1.5px solid transparent;
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary { background: var(--accent); color: var(--accent-ink); margin-left: auto; }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 85%, black); }

.btn-quiet { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-sunk); color: var(--ink); }
.btn-quiet[hidden] { display: none; }

.errors {
  display: block; background: var(--danger-wash);
  border: 1px solid var(--danger); border-radius: var(--radius);
  padding: 14px 16px; margin-top: 20px; color: var(--danger);
  font-size: .9rem;
}
.errors ul { margin: 8px 0 0; padding-left: 20px; }
.errors li { margin-bottom: 4px; }
.errors[hidden] { display: none; }

.done-panel { text-align: center; padding: 40px 0; }
.done-panel h1 { font-size: 1.7rem; margin-bottom: 12px; }
.done-panel p { color: var(--ink-soft); margin-bottom: 26px; }

.footer {
  max-width: var(--measure); margin: 0 auto; padding: 0 20px 40px;
  color: var(--ink-faint); font-size: .8rem; text-align: center;
}

/* The submitted summary: invisible on screen, the whole point of the printout. */
.print-only { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------------- print */

@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-sunk: #fff;
    --ink: #000; --ink-soft: #333; --ink-faint: #555;
    --line: #bbb; --line-strong: #999; --accent: #000; --accent-wash: #fff;
    --shadow: none;
  }
  .masthead, .form-nav, .footer, .skip-link, .resume-banner,
  .gate, .edit-link, .event-move, .done-panel .btn { display: none !important; }

  body { font-size: 11pt; }
  main { max-width: none; padding: 0; }

  /* Print shows every step at once - app.js unhides them for printing. */
  .group { break-inside: avoid; box-shadow: none; border-color: #bbb; margin-bottom: 12pt; }
  .review-section { break-inside: avoid; }
  .step-blurb, .hint, .group-hint { display: none; }

  .print-only { display: block !important; }
  .done-panel { text-align: left; padding: 0; }
}
