/* ---------- Fonts (self-hosted, OFL — see /fonts/LICENSE-*.txt) ---------- */
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Caveat"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/caveat-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Caveat"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/caveat-latin-ext-600-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ----------
   Concept: names drawn from a hat. The page is the hat's felt; content sits on
   sheets of notebook paper; people's names are handwritten in ballpoint.
   Roles: ballpoint = actions + names, red = destructive/errors only,
   margin pink + rules = decoration only. */
:root {
  --felt: #1e2740;
  --felt-muted: #aab3cc;
  --felt-line: rgb(251 249 244 / .22);
  --paper: #fbf9f4;
  --paper-back: #f0ece2;
  --field-bg: #ffffff;
  --rule: #c7d3e8;
  --rule-tint: #e8eef8;
  --margin: #efb3a8;
  --ink: #2b2d31;
  --muted: #5d6170;
  --field: #7d8aa6;
  --ballpoint: #2346a0;
  --ballpoint-dark: #1a3579;
  --red: #c8432f;
  --red-dark: #9e2f1f;
  --red-tint: #fbe9e5;
  --red-on-felt: #ff8a73;

  --line-h: 28px;
  --control-h: 44px; /* shared by inputs, selects and buttons so they line up in a row */
  --ui: "Atkinson Hyperlegible", system-ui, sans-serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--felt); color: var(--paper);
  font: 16px/1.55 var(--ui);
  --text-muted: var(--felt-muted);
}
header.site, main { max-width: 640px; margin: 0 auto; padding-inline: 20px; }
header.site { padding-top: 22px; }
main { padding-top: 4px; padding-bottom: 96px; }
/* Logo: the name handwritten on a torn slip, like every other name in the app. */
.brand { display: inline-block; text-decoration: none; border-radius: 2px; }
.brand-slip {
  display: inline-block; padding: 0 12px 5px;
  font: 600 1.8rem/1.15 var(--hand); color: var(--ballpoint); background: var(--paper);
  transform: rotate(-2deg);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 2px), 91% 100%, 83% calc(100% - 3px), 74% calc(100% - 1px), 65% calc(100% - 3px), 56% 100%, 47% calc(100% - 2px), 38% calc(100% - 4px), 29% calc(100% - 1px), 20% calc(100% - 3px), 11% 100%, 0 calc(100% - 2px));
}

h1 { font-size: clamp(2rem, 6vw, 2.6rem); line-height: 1.1; font-weight: 700; letter-spacing: -.015em; margin: 20px 0 10px; text-wrap: balance; }
h2 { font-size: 1.25rem; line-height: 1.3; font-weight: 700; margin: 0 0 10px; }
h2 label { font: inherit; margin: 0; }
p { margin: 0 0 12px; max-width: 65ch; }
.lede { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 28px; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.context { color: var(--text-muted); margin: 20px 0 0; }
.context + h1 { margin-top: 2px; }
.hint { color: var(--text-muted); font-size: .875rem; text-align: center; margin: 10px auto 0; }
a { color: inherit; text-underline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Two-tone ring: paper halo shows on felt, ballpoint ring shows on paper. */
:focus-visible { outline: 2px solid var(--ballpoint); outline-offset: 2px; box-shadow: 0 0 0 2px var(--paper); }

.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; color: var(--text-muted); }
.chip { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; background: rgb(251 249 244 / .14); color: var(--paper); }

/* ---------- Paper sheets ---------- */
.sheet {
  position: relative; margin: 18px 0; padding: 24px 24px 24px 56px;
  background: var(--paper); color: var(--ink); border-radius: 3px;
  box-shadow: 0 1px 0 rgb(0 0 0 / .25), 0 14px 28px -16px rgb(0 0 0 / .6);
  --text-muted: var(--muted);
  color-scheme: light; /* native pickers and menus render light, like the paper */
}
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 38px; border-left: 1px solid var(--margin); }
.sheet > :last-child { margin-bottom: 0; }
.sheet a { color: var(--ballpoint); }
.sheet .chip { background: var(--rule-tint); color: var(--ballpoint); vertical-align: middle; }

/* Sections that sit directly on the felt */
.section { margin: 28px 0; }
.section.manage { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--felt-line); }

.error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 4px;
  background: var(--red-tint); color: var(--red-dark); font-size: .925rem;
}

/* ---------- Forms ---------- */
label { display: block; font-weight: 700; font-size: .9rem; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 180px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--field-bg);
  border: 1px solid var(--field); border-radius: 4px; padding: 0 12px;
}
input, select { height: var(--control-h); }
/* Custom chevron: the native arrow ignores padding and hugs the edge. */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 40px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235d6170' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px;
}
textarea { padding-block: 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ballpoint); outline-offset: 0; border-color: var(--ballpoint); box-shadow: none; }
textarea { min-height: 120px; resize: vertical; }

/* Notebook rules that line up with the text */
.ruled {
  line-height: var(--line-h);
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--line-h) - 1px), var(--rule) calc(var(--line-h) - 1px) var(--line-h));
  background-attachment: local;
}
textarea.ruled { padding: 0 12px; min-height: calc(var(--line-h) * 5 + 2px); }
.wishlist { white-space: pre-wrap; overflow-wrap: anywhere; min-height: var(--line-h); padding: 0 4px; }

.pair { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 10px; align-items: center; }
.pair-sep { color: var(--muted); }
@media (max-width: 560px) {
  .pair { grid-template-columns: 1fr auto 1fr; }
  .pair > button { grid-column: 1 / -1; }
}

.copybox { display: flex; gap: 8px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Buttons ---------- */
button {
  font: 700 .95rem/1.2 var(--ui); border: 1px solid transparent; border-radius: 6px; padding: 0 16px;
  min-height: var(--control-h);
  background: var(--ballpoint); color: var(--paper); cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--ballpoint-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--ballpoint); border-color: var(--field); }
button.secondary:hover { background: var(--rule-tint); }
button.small { min-height: 0; padding: 4px 10px; font-size: .85rem; }
button.ghost { background: transparent; color: var(--paper); border-color: rgb(251 249 244 / .5); }
button.ghost:hover { background: rgb(251 249 244 / .1); }
button.danger { background: transparent; color: var(--red-on-felt); border-color: rgb(255 138 115 / .6); }
button.danger:hover { background: rgb(255 138 115 / .1); }
button.danger.armed { background: var(--red); border-color: var(--red); color: var(--paper); }
/* The draw is a paper slip on the felt */
button.draw {
  width: 100%; padding: 16px; font-size: 1.1rem;
  background: var(--paper); color: var(--ballpoint); border-radius: 3px;
  box-shadow: 0 1px 0 rgb(0 0 0 / .25), 0 14px 28px -16px rgb(0 0 0 / .6);
}
button.draw:hover { background: var(--field-bg); }
button.icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; padding: 0; margin-right: -10px;
  background: transparent; color: var(--muted); font-size: 1.3rem; font-weight: 400;
}
button.icon:hover { color: var(--red); background: transparent; }

/* ---------- Lists: one name per ruled line ---------- */
ul.list { list-style: none; padding: 0; margin: 0 0 16px; border-top: 1px solid var(--rule); }
ul.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--rule); }
.name { font: 600 1.6rem/1 var(--hand); color: var(--ballpoint); }
.joiner { color: var(--muted); font-size: .9rem; margin: 0 8px; }

.groups { border-top: 1px solid var(--rule); }
.groups a { display: block; padding: 12px 0; border-bottom: 1px solid var(--rule); font-weight: 700; text-decoration: none; }
.groups a:hover { text-decoration: underline; }

/* ---------- Manual-copy dialog ---------- */
dialog.sheet { width: min(520px, calc(100% - 32px)); margin: auto; }
dialog.sheet::backdrop { background: rgb(30 39 64 / .75); }
dialog textarea { min-height: 0; margin-bottom: 14px; }

/* ---------- The slip (reveal) ----------
   A folded slip: the top flap is hinged on the fold and covers the name.
   Unfolding swings the flap up and the slip grows to its full height. */
.slip {
  --h: 150px;
  position: relative; max-width: 420px; margin: 32px auto;
  padding-top: 0; perspective: 900px; cursor: pointer;
  transform: rotate(-1.2deg);
  filter: drop-shadow(0 10px 12px rgb(0 0 0 / .4));
  transition: padding-top .7s cubic-bezier(.3, .7, .2, 1);
}
.slip.open { padding-top: var(--h); cursor: default; }
.slip:focus-visible { outline-offset: 6px; }
.slip-bottom {
  height: var(--h); background-color: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 0 20px;
}
.slip-bottom:focus { outline: none; }
.slip-name { font: 600 clamp(3rem, 14vw, 4.5rem)/1 var(--hand); color: var(--ballpoint); transform: rotate(-3deg); text-align: center; overflow-wrap: anywhere; }
.slip-name.long { font-size: 2.6rem; }
.slip-name.longer { font-size: 1.8rem; }
.slip-flap {
  position: absolute; left: 0; right: 0; bottom: var(--h); height: var(--h);
  transform-origin: bottom center; transform-style: preserve-3d;
  transform: rotateX(-180deg);
  transition: transform .7s cubic-bezier(.3, .7, .2, 1);
}
.slip.open .slip-flap { transform: rotateX(0deg); }
.slip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; justify-content: center; padding: 16px;
}
.slip-inside {
  align-items: flex-end; color: var(--muted); background-color: var(--paper);
  background-image:
    linear-gradient(to top, rgb(0 0 0 / .07), transparent 22px),
    repeating-linear-gradient(to top, transparent 0 calc(var(--line-h) - 1px), var(--rule) calc(var(--line-h) - 1px) var(--line-h));
}
.slip-outside {
  align-items: center; transform: rotateX(180deg);
  color: var(--muted); font-weight: 700; background: var(--paper-back);
  background-image: linear-gradient(to bottom, rgb(0 0 0 / .08), transparent 26px);
}

/* ---------- Toast: a small slip ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--paper); color: var(--ink); padding: 10px 18px; border-radius: 3px; font-size: .925rem; font-weight: 700;
  box-shadow: 0 10px 24px -8px rgb(0 0 0 / .5);
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  header.site, main { padding-inline: 14px; }
  .sheet { padding: 20px 18px 20px 42px; }
  .sheet::before { left: 28px; }
  .slip { --h: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  .slip, .slip-flap, #toast { transition: none; }
}
