/* SantaSlips. Visual idea: names on folded paper slips drawn from a hat, results on a kraft gift tag.
   Cream paper, ink, one cranberry accent for the primary action and state. Serif headings, sans body. */

:root {
  --bg: #f5f0e6;
  --paper: #fffdf8;
  --ink: #221f1b;
  --muted: #5b544a;
  --rule: #d6cbb7;
  --rule-strong: #a89c86;
  --accent: #8f1d3a;
  --accent-ink: #ffffff;
  --accent-soft: #f3e3e3;
  --kraft: #d9c19a;
  --kraft-ink: #2a2016;
  --kraft-line: #8a6f4a;
  --focus: #8f1d3a;
  --serif: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191715; --paper: #23201c; --ink: #efe8dc; --muted: #b8ae9e; --rule: #3e3831; --rule-strong: #6b6255;
    --accent: #e8899f; --accent-ink: #1c1013; --accent-soft: #3a2228;
    --kraft: #4a3a27; --kraft-ink: #f4e8d4; --kraft-line: #b89b70; --focus: #e8899f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191715; --paper: #23201c; --ink: #efe8dc; --muted: #b8ae9e; --rule: #3e3831; --rule-strong: #6b6255;
  --accent: #e8899f; --accent-ink: #1c1013; --accent-soft: #3a2228;
  --kraft: #4a3a27; --kraft-ink: #f4e8d4; --kraft-line: #b89b70; --focus: #e8899f;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; scroll-padding-bottom: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.55 var(--sans);
  overflow-wrap: break-word;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(1.75rem, 5.5vw, 2.5rem); margin-top: .4em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 3.8vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--paper); color: var(--ink); padding: 12px 16px; z-index: 10; border: 2px solid var(--accent); }
.skip:focus { top: 8px; }
[hidden] { display: none !important; }

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--bg); }
.header-row { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; min-height: 44px; }
.logo-tag { fill: var(--kraft); stroke: var(--kraft-line); stroke-width: 1.5; }
.logo-hole { fill: var(--bg); stroke: var(--kraft-line); stroke-width: 1.2; }
.logo-string { stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; }
.wordmark { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.wordmark em { color: var(--accent); }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 4px; order: 3; width: 100%; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav li:first-child a { padding-left: 0; }
.theme-toggle { margin-left: auto; }
@media (min-width: 640px) {
  .nav { order: 0; width: auto; margin-left: auto; }
  .nav li:first-child a { padding-left: 8px; }
  .theme-toggle { margin-left: 0; }
}

/* ---------- buttons and fields ---------- */
.btn, .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 8px 14px;
  font: inherit; font-size: .95rem; line-height: 1.2; text-align: center;
  color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 2px;
  cursor: pointer; text-decoration: none;
}
.btn:hover, .theme-toggle:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(.94); }
.btn.quiet { background: transparent; }
.btn.danger { color: var(--accent); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { margin: 0 0 18px; min-width: 0; }
label, legend { font-weight: 600; }
.field > label { display: block; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="date"], textarea, select {
  width: 100%; min-height: 44px; padding: 9px 10px;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: 2px;
}
textarea { resize: vertical; line-height: 1.5; font-family: var(--sans); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--accent); border-width: 2px; }
.help { color: var(--muted); font-size: .92rem; margin: 6px 0 0; }
.count { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .9rem; margin: 6px 0 0; color: var(--muted); }
.error { color: var(--accent); font-weight: 600; font-size: .95rem; margin: 6px 0 0; }
.error:empty, .count:empty { display: none; }
.note { color: var(--muted); font-size: .92rem; }
.warn-line { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; color: var(--ink); }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain:disabled { opacity: .62; }
.row-2 { display: grid; gap: 0 16px; }
@media (min-width: 560px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.money { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 8.5rem); gap: 8px; }
.money input { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.seg-group { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.seg-group legend { margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 0; border-top: 1px solid var(--rule); min-height: 44px; cursor: pointer; }
.choice:last-child { border-bottom: 1px solid var(--rule); }
.choice input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

details.fold { border-top: 1px solid var(--rule); margin: 0; }
details.fold:last-of-type { border-bottom: 1px solid var(--rule); }
details.fold > summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: 6px; font-weight: 600; list-style: none; padding: 4px 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "+"; font-family: var(--mono); width: 1.2em; color: var(--accent); }
details.fold[open] > summary::before { content: "\2212"; }
details.fold[open] { padding-bottom: 14px; }

.ex-list, .hint-list { list-style: none; margin: 12px 0; padding: 0; }
.ex-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--rule); }
.ex-row .ex-msg { color: var(--accent); font-size: .92rem; margin: 0; font-weight: 600; }
@media (min-width: 600px) {
  .ex-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: center; }
  .ex-row .ex-msg { grid-column: 1 / -1; }
}
.hint-row { padding: 8px 0; border-top: 1px dashed var(--rule); }
.hint-row label { display: block; margin-bottom: 4px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.setup { margin-top: 8px; }
.event-bar { margin: 12px 0 0; }
.event-bar:has(> [hidden]) { display: none; }
.setup-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.setup-head h2 { margin-top: 1em; }

.draw-error { border: 2px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; margin: 16px 0 0; border-radius: 2px; }
.draw-error p { margin: 0 0 .5em; }
.draw-error p:last-child, .draw-error ul:last-child { margin-bottom: 0; }

/* ---------- saved events ---------- */
.saved { margin: 8px 0 0; }
.saved h2 { font-size: 1.15rem; margin-top: 1em; }
.saved-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.saved-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.saved-list .ev-meta { color: var(--muted); font-size: .92rem; display: block; }
.saved-list .current { font-weight: 600; }

/* ---------- result: the tag head and the slips ---------- */
.result { margin: 28px 0 8px; outline: none; }
.tag-head {
  position: relative; background: var(--kraft); color: var(--kraft-ink);
  padding: 18px 18px 16px 52px;
  clip-path: polygon(30px 0, 100% 0, 100% 100%, 30px 100%, 0 calc(100% - 26px), 0 26px);
}
.tag-head::before { /* the string hole */
  content: ""; position: absolute; left: 16px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--kraft-line);
}
.tag-head h2 { margin: 0 0 4px; }
.result-sub { margin: 0; font-variant-numeric: tabular-nums; }
.privacy-line { margin: 16px 0 8px; border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.count-line { color: var(--muted); font-size: .95rem; }
.count-line strong { color: var(--ink); }

.link-list { list-style: none; margin: 12px 0 20px; padding: 0; counter-reset: slip; }
.slip-row {
  counter-increment: slip; position: relative;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 2px;
  padding: 12px 12px 12px 14px; margin: 0 0 10px;
}
.slip-row::after { /* the fold line of a paper slip */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0; border-top: 3px double var(--rule);
}
.slip-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.slip-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 700; margin: 0; }
.slip-name::before { content: counter(slip) ". "; font-family: var(--mono); font-size: .85rem; font-weight: 400; color: var(--muted); }
.sent { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 400; cursor: pointer; }
.sent input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.slip-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.slip-actions .btn { padding: 8px 6px; font-size: .9rem; }
@media (min-width: 640px) { .slip-actions { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.slip-done .slip-name { color: var(--muted); }
.copy-fallback { margin: 8px 0 0; }
.copy-fallback input { font-family: var(--mono); font-size: .85rem; }

.announce-text { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--rule); padding: 10px 12px; }
.manage { margin-top: 18px; }
.manage h3 { margin-top: .5em; }
.manage-row { display: flex; flex-wrap: wrap; gap: 8px; }
.confirm { border: 2px solid var(--accent); background: var(--paper); padding: 12px 14px; margin-top: 12px; }
.confirm p { margin: 0 0 .5em; }
.status { min-height: 1.5em; margin-top: 10px; font-weight: 600; }
.import-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 22px 0 8px; }
.file-btn { font-weight: 400; }
.import-row input:focus-visible + .import-status, .file-btn:focus-within { outline: 3px solid var(--focus); }
.import-status { font-size: .95rem; }

/* ---------- prose ---------- */
.hero { padding-top: 8px; }
.lede { font-size: 1.08rem; }
.noscript { border-left: 3px solid var(--accent); padding-left: 12px; }
.prose { padding-bottom: 24px; }
.prose li { margin-bottom: .4em; }
.steps { padding-left: 1.3em; }
.guide-list { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.guide-list li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.guide-list a { font-family: var(--serif); font-size: 1.1rem; font-weight: 700; display: inline-block; min-height: 44px; padding-top: 10px; }
.guide-list span { display: block; color: var(--muted); }
.table-scroll { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
caption { text-align: left; font-weight: 600; padding-bottom: 6px; }
th, td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { border-bottom: 2px solid var(--rule-strong); }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { font-family: var(--sans); }
.compare th, .compare td { padding-right: 8px; }
@media (max-width: 480px) { .counts, .compare { font-size: .85rem; } .counts th, .counts td, .compare th, .compare td { padding-right: 6px; } }
.crumb { margin: 16px 0 0; font-size: .92rem; color: var(--muted); }
.crumb a { display: inline-block; min-height: 44px; line-height: 44px; }
.meta { color: var(--muted); font-size: .92rem; }
.page { padding-bottom: 32px; }
.article .tool-link { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; }
.sources { font-size: .95rem; }
.sources li { overflow-wrap: anywhere; }
.callout { background: var(--paper); border: 1px solid var(--rule); padding: 12px 14px; }

/* ---------- ads (off by default) ---------- */
.ad-slot { margin: 24px 0; }
.ad-label { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.ad-box { min-height: 280px; border: 1px dashed var(--rule); }
@media (min-width: 600px) { .ad-box { min-height: 120px; } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 24px; padding: 20px 0 28px; font-size: .95rem; color: var(--muted); }
.footer-brand { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--ink); margin-bottom: .4em; }
.footer-brand em { color: var(--accent); }
.footer-nav { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 0 4px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px 0 0; }
.copyright { margin: 0; }

/* ---------- reveal page ---------- */
.reveal-main { padding-top: 12px; padding-bottom: 24px; }
.reveal-main h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); }
.check-line { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.slip {
  position: relative; display: block; width: 100%; max-width: 26rem; margin: 20px auto 12px;
  min-height: 11rem; padding: 0; border: 1px solid var(--rule-strong); border-radius: 2px;
  background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; perspective: 800px;
}
.slip-lower, .slip-flap {
  position: absolute; left: 0; right: 0; height: 50%; display: flex; align-items: center; justify-content: center;
  padding: 10px 16px; text-align: center;
}
.slip-lower { bottom: 0; border-top: 1px dashed var(--rule-strong); }
.slip-flap { top: 0; background: var(--paper); transform-origin: bottom center; transition: transform .4s ease, opacity .4s ease; }
.slip-flap span { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; }
.slip-lower span { color: var(--muted); }
.slip:hover { border-color: var(--ink); }
.slip.unfolding .slip-flap { transform: rotateX(-180deg); opacity: 0; }
@media (prefers-reduced-motion: reduce) { .slip-flap, .gift-tag { transition: none !important; } }

.tag-wrap { max-width: 26rem; margin: 8px auto 16px; }
.string { display: block; width: 100%; height: 44px; }
.string path { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.gift-tag {
  position: relative; background: var(--kraft); color: var(--kraft-ink);
  padding: 58px 22px 22px; text-align: center;
  clip-path: polygon(34px 0, calc(100% - 34px) 0, 100% 34px, 100% 100%, 0 100%, 0 34px);
  transition: opacity .3s ease;
}
.gift-tag::before {
  content: ""; position: absolute; left: 50%; top: 18px; width: 20px; height: 20px; margin-left: -10px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--kraft-line);
}
.gift-tag.fresh { opacity: 0; }
.tag-label { margin: 0; font-size: .95rem; }
.tag-name { font-family: var(--serif); font-size: clamp(2rem, 10vw, 3rem); line-height: 1.1; margin: 6px 0 14px; overflow-wrap: anywhere; }
.tag-hint { margin: 0 0 16px; font-style: italic; }
.tag-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; border-top: 1px solid var(--kraft-line); text-align: left; }
.tag-facts div { padding: 10px 6px 4px 0; min-width: 0; }
.tag-facts div + div { padding-left: 10px; border-left: 1px solid var(--kraft-line); }
.tag-facts dt { font-size: .85rem; }
.tag-facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; }
.tag-facts .days { display: block; font-weight: 400; font-size: .9rem; }
.tag-note { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--kraft-line); text-align: left; }
.drawn-line { font-size: .9rem; color: var(--muted); text-align: center; }
.after { max-width: 26rem; margin: 0 auto; }
.cta-line { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 22px; }
.reveal-error { border: 2px solid var(--accent); padding: 12px 14px; background: var(--paper); }
