/* ========================================================================
   RSVP — "wedding invitation" theme.
   Ivory paper, ink serif, hairline gold rules. The daintiness lives in the
   surfaces, the type, and the whitespace; the only saturated colour is the
   tiny yes/no/maybe reply bar, whose hues are the validated categorical
   triad (green/orange/blue) so it stays colour-blind legible.
   ======================================================================== */

@font-face {
  font-family: "Cormorant";
  src: url("/static/fonts/cormorant600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant";
  src: url("/static/fonts/cormorant500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Garamond";
  src: url("/static/fonts/ebgaramond400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Garamond";
  src: url("/static/fonts/ebgaramond500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Script";
  src: url("/static/fonts/greatvibes.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light;
  --paper:      #faf6ee;   /* the invitation card */
  --paper-2:    #f3ecdf;   /* insets, table stripes */
  --surface-0:  #f0e9db;   /* page behind the cards */
  --ink:        #34302a;   /* body text */
  --ink-soft:   #6b6459;   /* secondary */
  --ink-faint:  #938b7d;
  --gold:       #b0904f;   /* hairline rules, flourishes */
  --gold-soft:  #cdb583;
  --line:       #e2d7c2;   /* borders */
  --danger:     #9c4a3c;
  --series-yes:   #1baf7a;
  --series-no:    #eb6834;
  --series-maybe: #2a78d6;
  --radius: 3px;           /* invitations are barely rounded */
  --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 6px 24px rgba(80,64,40,.10);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper:      #22201d;
    --paper-2:    #2b2823;
    --surface-0:  #1a1815;
    --ink:        #efe7d7;
    --ink-soft:   #c3b8a3;
    --ink-faint:  #8f8674;
    --gold:       #cdb583;
    --gold-soft:  #9a854f;
    --line:       #3c372f;
    --danger:     #e0a89a;
    --series-yes:   #199e70;
    --series-no:    #d95926;
    --series-maybe: #3987e5;
    --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #22201d; --paper-2: #2b2823; --surface-0: #1a1815;
  --ink: #efe7d7; --ink-soft: #c3b8a3; --ink-faint: #8f8674;
  --gold: #cdb583; --gold-soft: #9a854f; --line: #3c372f; --danger: #e0a89a;
  --series-yes: #199e70; --series-no: #d95926; --series-maybe: #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(176,144,79,.07), transparent 60%),
    var(--surface-0);
  color: var(--ink);
  font: 17px/1.65 "Garamond", "EB Garamond", Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 40px 22px 80px; }
.wrap--narrow { max-width: 540px; }

/* --- headings in the display serif --- */
h1, h2, h3 { font-family: "Cormorant", Garamond, Georgia, serif; font-weight: 600;
             color: var(--ink); letter-spacing: .01em; margin: 0; }
h1 { font-size: clamp(26px, 7vw, 34px); line-height: 1.15; }
h2 { font-size: clamp(20px, 5.2vw, 24px); }
h3 { font-size: 13px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
     color: var(--gold); }
p { margin: 0 0 14px; color: var(--ink-soft); }

.script { font-family: "Script", "Great Vibes", cursive; font-weight: 400; }

/* an ornamental gold rule with a centred diamond — the wedding flourish */
.flourish { display: flex; align-items: center; justify-content: center; gap: 12px;
            color: var(--gold); margin: 14px 0 22px; }
.flourish::before, .flourish::after {
  content: ""; height: 1px; width: 72px;
  background: linear-gradient(to var(--dir, right), transparent, var(--gold-soft)); }
.flourish::before { --dir: left; }
.flourish .diamond { width: 6px; height: 6px; transform: rotate(45deg);
                     border: 1px solid var(--gold); }
.eyebrow { font-family: "Cormorant", serif; font-weight: 500; letter-spacing: .34em;
           text-transform: uppercase; font-size: 13px; color: var(--gold);
           text-align: center; }

.card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
/* a fine gold keyline just inside the border, like engraved stationery */
.card::after {
  content: ""; position: absolute; inset: 5px; border: 1px solid var(--gold-soft);
  border-radius: 1px; opacity: .35; pointer-events: none;
}
.card > * { position: relative; }
.card--plain::after { display: none; }

/* --- forms --- */
label { display: block; font-family: "Cormorant", serif; font-weight: 600;
        letter-spacing: .06em; text-transform: uppercase; font-size: 12.5px;
        color: var(--ink-soft); margin-bottom: 7px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 11px 13px; font: 16px/1.5 "Garamond", Georgia, serif;
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 20px; }
.hint { font-size: 14px; color: var(--ink-faint); margin: 7px 0 0; font-style: italic; }

/* --- buttons: quiet, letter-spaced, gold on press --- */
button {
  font-family: "Cormorant", serif; font-weight: 600; font-size: 15px;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 11px 20px; border-radius: var(--radius);
  border: 1px solid var(--gold-soft); background: transparent; color: var(--ink);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
button:hover { background: var(--paper-2); border-color: var(--gold); }
button.primary { background: var(--gold); border-color: var(--gold); color: #fffdf8; }
button.primary:hover { background: #9c7e42; }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
button.small { padding: 6px 13px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.full { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.mt0 { margin-top: 0; } .mb20 { margin-bottom: 20px; } .mtneg { margin-top: -8px; }
.center { text-align: center; }

/* --- answer picker --- */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice { padding: 20px 10px; text-align: center; background: var(--paper-2);
          border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
          font-family: "Cormorant", serif; font-weight: 600; font-size: 18px;
          letter-spacing: .04em; color: var(--ink); transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--gold-soft); }
.choice[aria-pressed="true"] { border-color: var(--gold); border-width: 2px; padding: 19px 9px;
                               background: color-mix(in srgb, var(--gold) 10%, var(--paper-2)); }
.choice .mark { display: block; font-size: 24px; margin-bottom: 6px; color: var(--gold); }

/* --- KPI tiles --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 16px 18px; text-align: center; }
.kpi .label { font-family: "Cormorant", serif; font-weight: 600; letter-spacing: .12em;
              text-transform: uppercase; font-size: 11.5px; color: var(--gold); margin-bottom: 4px; }
.kpi .value { font-family: "Cormorant", serif; font-weight: 600; font-size: 30px;
              line-height: 1; color: var(--ink); }
.kpi .value.hero { font-size: clamp(38px, 12vw, 52px); }
.kpi.flag { border-color: color-mix(in srgb, var(--series-no) 40%, var(--line)); }

/* --- part-to-whole bar --- */
.bar { display: flex; height: 30px; border-radius: 2px; overflow: hidden;
       background: var(--paper-2); gap: 2px; border: 1px solid var(--line); }
.bar .seg { display: flex; align-items: center; justify-content: center;
            font-family: "Garamond", serif; font-size: 13px; font-weight: 500; color: #fff; min-width: 0; }
.bar .seg[data-k=yes]   { background: var(--series-yes); }
.bar .seg[data-k=no]    { background: var(--series-no); }
.bar .seg[data-k=maybe] { background: var(--series-maybe); }
.legend { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; font-size: 14px;
          color: var(--ink-soft); }
.legend .item { display: flex; align-items: center; gap: 7px; }
.legend .swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.legend .swatch[data-k=yes]   { background: var(--series-yes); }
.legend .swatch[data-k=no]    { background: var(--series-no); }
.legend .swatch[data-k=maybe] { background: var(--series-maybe); }

/* --- tables --- */
table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
th { text-align: left; font-family: "Cormorant", serif; font-size: 12px; font-weight: 600;
     color: var(--gold); text-transform: uppercase; letter-spacing: .14em;
     padding: 9px 11px; border-bottom: 1px solid var(--gold-soft); }
td { padding: 11px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
td.num { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
        padding: 3px 11px; border-radius: 99px; background: var(--paper-2);
        color: var(--ink-soft); border: 1px solid var(--line); }
.pill .dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.pill .dot[data-k=yes]   { background: var(--series-yes); }
.pill .dot[data-k=no]    { background: var(--series-no); }
.pill .dot[data-k=maybe] { background: var(--series-maybe); }
.tag { font-family: "Cormorant", serif; font-size: 12px; font-weight: 600; letter-spacing: .08em;
       text-transform: uppercase; padding: 2px 9px; border-radius: 2px;
       background: var(--paper-2); color: var(--ink-faint); border: 1px solid var(--line); }
.tag.warn { background: color-mix(in srgb, var(--series-no) 14%, transparent);
            color: var(--series-no); border-color: color-mix(in srgb, var(--series-no) 30%, transparent); }

.msg { padding: 13px 16px; border-radius: var(--radius); font-size: 15px; margin-bottom: 18px;
       border: 1px solid var(--line); }
.msg.error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger);
             border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.msg.ok { background: color-mix(in srgb, var(--series-yes) 12%, transparent); color: var(--ink); }

.muted { color: var(--ink-faint); font-size: 14px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all;
        color: var(--ink-soft); }
.hidden { display: none !important; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-faint); font-style: italic; }
.inset { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 18px; }

/* --- guest page specifics --- */
.invite { text-align: center; padding: 40px 30px; }
.invite .eyebrow { margin-bottom: 6px; }
.invite h1 { font-size: clamp(30px, 9vw, 46px); margin: 2px 0 4px; }
.invite .event-name { font-family: "Script", cursive; font-size: clamp(34px, 11vw, 52px); line-height: 1.15;
                      color: var(--gold); margin: 6px 0 2px; font-weight: 400; }
.invite .lede { font-style: italic; color: var(--ink-soft); font-size: 18px; }
.big-check { font-family: "Script", cursive; font-size: clamp(42px, 14vw, 60px); color: var(--gold); line-height: 1;
             margin-bottom: 4px; }

/* a queued reply awaiting your decision -- an inset slip inside the card */
.pending-row { background: var(--paper-2); padding: 16px 18px; margin-bottom: 12px; }
.pending-row:last-child { margin-bottom: 0; }
.pending-row .controls { margin-top: 12px; }
.who-select { max-width: 260px; }

/* --- QR panel --- */
.qr-panel { text-align: center; }
.qr-panel .qr-frame { display: inline-block; padding: 16px; background: #fff;
                      border: 1px solid var(--line); border-radius: var(--radius); }
.qr-panel .qr-frame svg, .qr-panel .qr-frame img { display: block; width: 220px; height: 220px; }

.w80 { width: 80px; }
.mtop { margin-top: 18px; }

/* ========================================================================
   Phones. The layout is designed for a 390px iPhone first and simply gets
   roomier above 640px; nothing here is a patch on a desktop layout.
   ======================================================================== */

/* Comfortable thumb targets everywhere touch is the primary input. Apple's
   own guidance is 44px; the quiet letter-spaced buttons were about 28px. */
@media (hover: none) and (pointer: coarse) {
  button, .choice, select, a.hint { min-height: 44px; }
  button { padding-top: 12px; padding-bottom: 12px; }
  button.small { padding: 11px 14px; font-size: 13px; }
}

@media (max-width: 640px) {
  .wrap {
    padding: 22px 14px calc(56px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }
  .card { padding: 20px 16px; margin-bottom: 16px; }
  .card::after { inset: 4px; }
  .invite { padding: 26px 8px; }
  body { font-size: 16.5px; }

  h3, .eyebrow { letter-spacing: .2em; font-size: 11.5px; }
  .flourish::before, .flourish::after { width: 48px; }

  /* Header rows stop fighting for width and stack. */
  .spread { flex-direction: column; align-items: stretch; gap: 10px; }
  .spread > .row, .spread .row { justify-content: flex-start; }

  /* Stat tiles two-up rather than squeezed to four. */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px 10px; }

  /* The answer picker keeps three across but loses the generous padding. */
  .choices { gap: 8px; }
  .choice { padding: 15px 4px; font-size: 15px; }
  .choice[aria-pressed="true"] { padding: 14px 3px; }
  .choice .mark { font-size: 20px; margin-bottom: 4px; }

  /* Action rows: full-width buttons, one per line, easy to hit. */
  .row > button { flex: 1 1 100%; }
  .row { gap: 8px; }

  .who-select { width: 100%; max-width: none; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls > button { width: 100%; }

  .qr-panel .qr-frame { padding: 12px; }
  .qr-panel .qr-frame img, .qr-panel .qr-frame svg { width: 100%; height: auto; max-width: 240px; }

  /* ---- tables become stacked cards ----
     A five-column table is unreadable at 390px. Each row turns into a small
     labelled block; the data-label written by admin.js supplies the column
     name that the header row used to carry. */
  table, thead, tbody, tr, th, td { display: block; }
  table { border-collapse: separate; }
  .head-row { position: absolute; left: -9999px; }
  tr {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  tr:last-child { margin-bottom: 0; }
  td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    border-bottom: none;
    text-align: right;
  }
  td::before {
    content: attr(data-label);
    font-family: "Cormorant", serif;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: left;
    flex: 0 0 auto;
  }
  /* Cells with no label (the row's action button) go full width. */
  td.actions { justify-content: stretch; padding-top: 9px; }
  td.actions::before { content: none; }
  td.actions button { width: 100%; }
  /* The name is the heading of each little card, not a labelled field. */
  td[data-label="Name"] { display: block; text-align: left; font-size: 17px; }
  td[data-label="Name"]::before { display: block; margin-bottom: 2px; }
  td[data-label="Note"] { text-align: right; }
}

/* Very narrow phones (SE and friends). */
@media (max-width: 360px) {
  .choice { font-size: 13.5px; padding: 13px 2px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .card { padding: 18px 13px; }
}
