@font-face { font-family: 'Rye'; src: url('../fonts/Rye-Regular.ttf'); font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/EBGaramond.ttf'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/EBGaramond-Italic.ttf'); font-style: italic; font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk.ttf'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('../fonts/SpaceMono-Bold.ttf'); font-weight: 700; font-display: swap; }

:root {
  --paper: #f2eadb;
  --card: #fbf8f1;
  --dark: #1d1a17;
  --muted: #6f6a61;
  --ink: #cf432b;
  --line: rgba(29, 26, 23, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper);
  background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1.2px);
  background-size: 5px 5px;
  color: var(--dark);
  font: 400 17px/1.5 'Space Grotesk', system-ui, sans-serif;
}
main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 8px 16px 48px; }
body.wide main { max-width: 1180px; }
a { color: inherit; text-decoration-color: var(--ink); text-underline-offset: 3px; }
h1 { font: 400 clamp(30px, 6vw, 46px)/1.08 'Rye', serif; margin: 0 0 14px; letter-spacing: -.01em; }
i { font-family: 'EB Garamond', serif; font-size: 1.08em; }

.masthead {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  max-width: 1180px; width: 100%; margin: 0 auto; padding: 22px 16px 18px;
}
.wordmark { font: 700 13px 'Space Mono', monospace; letter-spacing: .28em; text-transform: uppercase; text-decoration: none; }
.tag { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); font-weight: 600; }
.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px 32px; }

.intro p { font-size: 18px; max-width: 34em; margin: 0 0 28px; }

/* form */
.step { border: 0; padding: 0; margin: 0 0 30px; min-width: 0; }
.q { display: flex; align-items: center; gap: 10px; font: 700 15px 'Space Grotesk', sans-serif;
     letter-spacing: .12em; text-transform: uppercase; margin-bottom: 12px; padding: 0; }
.n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
     background: var(--dark); color: var(--card); font: 700 13px 'Space Mono', monospace; letter-spacing: 0; }
.quiz-note { margin: 0 0 22px; padding-top: 18px; border-top: 1.5px dashed var(--line); color: var(--muted); }
.quiz-note b { color: var(--dark); font-weight: 600; }

.handle-field {
  display: flex; align-items: center; background: var(--card); border: 2px solid var(--dark);
  box-shadow: 4px 4px 0 var(--ink); max-width: 420px;
}
.handle-field span { padding: 0 4px 0 14px; font: 700 22px 'Space Mono', monospace; color: var(--muted); }
.handle-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 12px 12px 0;
  font: 700 22px 'Space Mono', monospace; color: var(--dark); outline: none;
}
.handle-field:focus-within { outline: 3px solid var(--ink); outline-offset: 3px; }
.hint { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.hint.error { color: #a3271a; font-weight: 600; }

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px 12px; background: var(--card); border: 1.5px solid var(--line); cursor: pointer;
  text-align: center; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card input { position: absolute; opacity: 0; pointer-events: none; }
.card:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.card:has(input:checked) { border: 2px solid var(--dark); box-shadow: 4px 4px 0 var(--ink); transform: rotate(-1deg); }
.card:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.card .name { font-size: 14px; font-weight: 500; }
.card.surprise .name { color: var(--muted); font-style: italic; }
.glyph { font-size: 34px; line-height: 1.1; height: 40px; }
.surprise .glyph { font: 400 30px/40px 'Rye', serif; color: var(--muted); }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--dark); }
.swatch.mixed { background: conic-gradient(#cf432b 0 25%, #2b40a3 0 50%, #1e6b4b 0 75%, #6c2b5d 0); }

.go, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; font: 700 15px 'Space Grotesk', sans-serif; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; border: 2px solid var(--dark);
}
.go { background: var(--dark); color: var(--card); box-shadow: 4px 4px 0 var(--ink); }
.go:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.go:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn { background: var(--card); color: var(--dark); }
.btn:hover { background: #fff; }
button.go { font-size: 17px; padding: 16px 30px; }

/* making */
.making { padding-top: 12px; }
/* the slot machine: library pictures flicker past and land on the one chosen */
.slot { position: relative; width: 190px; margin: 26px 0 8px; }
.slot .frame { display: block; width: 190px; height: 230px; padding: 10px; background: #fff; transform: rotate(-2deg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .2); }
.slot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.slot .tape { position: absolute; width: 74px; height: 22px; background: var(--ink); opacity: .55; transform: rotate(-38deg); }
.slot .tape.a { left: -22px; top: 4px; }
.slot .tape.b { right: -22px; top: 206px; }
.slot figcaption { margin-top: 14px; font: 700 11px 'Space Mono', monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.slot.landed .frame { animation: thunk .4s ease-out; }
.slot.landed figcaption { color: var(--ink); }
@keyframes thunk { 0% { transform: rotate(-2deg) scale(1.07); } 60% { transform: rotate(-2deg) scale(.98); } 100% { transform: rotate(-2deg) scale(1); } }
@media (prefers-reduced-motion: reduce) { .slot.landed .frame { animation: none; } }
.stages { list-style: none; padding: 0; margin: 26px 0; counter-reset: s; }
.stages li { position: relative; padding: 10px 0 10px 40px; color: var(--muted); font-size: 18px; }
.stages li::before {
  content: ''; position: absolute; left: 6px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border: 2px solid var(--line); border-radius: 50%;
}
.stages li.done { color: var(--dark); }
.stages li.done::before { background: var(--dark); border-color: var(--dark); }
.stages li.now { color: var(--dark); font-weight: 600; }
.stages li.now::before { border-color: var(--ink); border-top-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .stages li.now::before { animation: none; background: var(--ink); } }

/* result */
.result h1 { margin-bottom: 18px; }
.spread { display: block; box-shadow: 0 6px 24px rgba(0, 0, 0, .22); background: var(--card); }
.spread img { display: block; width: 100%; height: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 6px; }
.notice p { font-size: 18px; max-width: 34em; }
.side { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 4px 10px 3px;
        font: 700 13px 'Space Mono', monospace; letter-spacing: .14em; text-transform: uppercase;
        background: var(--dark); color: var(--card); transform: rotate(-2deg); }
.flip { margin: 24px 0 6px; }
form.flip { margin-top: 34px; }
.another {
  display: inline-flex; align-items: center; gap: 10px; padding: 16px 28px; cursor: pointer;
  font: 700 17px 'Space Grotesk', sans-serif; letter-spacing: .08em; text-transform: uppercase;
  background: var(--spread-ink, var(--ink)); color: var(--card); border: 2px solid var(--dark);
  box-shadow: 5px 5px 0 var(--dark); transform: rotate(-1.2deg);
  transition: transform .12s, box-shadow .12s;
}
.another span { font: 400 26px/1 'Rye', serif; margin-top: -3px; }
.another:hover { transform: rotate(-1.2deg) translate(-1px, -1px); box-shadow: 6px 6px 0 var(--dark); }
.another:active { transform: rotate(-1.2deg) translate(3px, 3px); box-shadow: 2px 2px 0 var(--dark); }
.another:focus-visible { outline: 3px solid var(--dark); outline-offset: 4px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .choices { grid-template-columns: repeat(2, 1fr); }
  .actions > * { flex: 1 1 100%; }
  .another { width: 100%; justify-content: center; padding: 15px 14px; font-size: 15px; letter-spacing: .04em; }
  button.go { width: 100%; }
}
