/* Dokimasia — a classical "examination" aesthetic.
   Parchment + ink, inscriptional Roman caps over a Garamond body,
   hard offset rules instead of soft shadows, numbered ledger options. */

/* ---- Self-hosted fonts (variable weight; subsets load on demand) ---- */
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/cinzel-latin.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: "EB Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/ebgaramond-latin.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: "EB Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/ebgaramond-latin-ext.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: "EB Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/ebgaramond-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ebgaramond-italic-latin.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;
}

:root {
  --paper:     #efe6d0;   /* parchment */
  --paper-2:   #e7dbbe;   /* inset / hover */
  --ink:       #241c11;   /* warm near-black */
  --ink-2:     #6c5e44;   /* secondary text */
  --rule:      #c9ba96;   /* hairline rules */
  --oxblood:   #8c2c1d;   /* primary accent */
  --verdigris: #2f6a55;   /* correct */
  --wrong:     #9e3320;   /* incorrect */
  --gold:      #7a611f;   /* badges / flourishes (4.5:1 on parchment) */
  --display: "Cinzel", "Georgia", "Times New Roman", serif;
  --body: "EB Garamond", "Georgia", "Times New Roman", serif;
  --grain-blend: multiply;
  --grain-opacity: .06;
  --glow-1: #f5ecd7;
  --glow-2: #e6d9ba;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #201a12;   /* midnight ink */
    --paper-2:   #2a2218;
    --ink:       #e9dfc7;
    --ink-2:     #b3a486;
    --rule:      #4a3f2c;
    --oxblood:   #d4715a;
    --verdigris: #6fae92;
    --wrong:     #d4715a;
    --gold:      #c9a857;
    --grain-blend: screen;
    --grain-opacity: .04;
    --glow-1: #2a2317;
    --glow-2: #17120c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background: radial-gradient(125% 120% at 50% -10%, var(--glow-1) 0%, var(--paper) 42%, var(--glow-2) 100%) fixed;
}

/* Paper grain (subtle, desaturated noise blended over everything) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Accessibility helpers ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--oxblood); outline-offset: 2px; }
h2[tabindex="-1"], p[tabindex="-1"] { outline: none; }

/* ---- Masthead ---- */
.site-header { text-align: center; padding: 2.6rem 1rem 0; }
.eyebrow {
  font-family: var(--body); font-weight: 600;
  letter-spacing: .5em; text-indent: .5em; font-size: .72rem;
  color: var(--oxblood); margin: 0 0 .55rem;
}
.site-header h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.1rem); letter-spacing: .14em; text-indent: .14em;
  margin: 0; color: var(--ink);
}
.site-header h1 a { color: inherit; text-decoration: none; }
.tagline { font-style: italic; color: var(--ink-2); margin: .55rem 0 0; font-size: 1.02rem; }
.site-header::after {
  content: ""; display: block; width: min(440px, 78%); height: 0;
  margin: 1.4rem auto 0; border-top: 1px solid var(--rule);
  box-shadow: 0 3px 0 -2px var(--rule);   /* a second hairline = double rule */
}

.app { max-width: 660px; margin: 0 auto; padding: 1.8rem 1.25rem 4rem; }

/* ---- Entrance motion ---- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.setup, .progress, .question, .result-score, .result-verdict, .recap, .btn-row, .error {
  animation: rise .4s cubic-bezier(.2, .7, .2, 1) both;
}
.card { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; }
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---- Buttons ---- */
.btn {
  font-family: var(--display); font-weight: 600; font-size: .82rem;
  letter-spacing: .14em; text-transform: uppercase;
  display: inline-block; margin-top: 1.4rem; padding: .8rem 1.6rem;
  border: 1px solid var(--ink); border-radius: 1px;
  background: var(--ink); color: var(--paper); cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--oxblood); border-color: var(--oxblood); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--ink); border-color: var(--ink); }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: .8rem; }

/* ---- Home: a ledger of subjects ---- */
.card-list { display: grid; gap: 1.1rem; }
.card {
  position: relative; width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; gap: .2rem 1.1rem; align-items: center;
  font-family: var(--body); font-size: inherit; line-height: inherit;
  background: var(--paper); color: inherit;
  border: 1px solid var(--rule); border-radius: 2px; padding: 1.15rem 1.3rem;
  transition: border-color .15s ease, background .15s ease;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--oxblood); transform: scaleY(0); transform-origin: top;
  transition: transform .18s ease;
}
.card:hover { border-color: var(--ink); background: var(--paper-2); }
.card:hover::before { transform: scaleY(1); }
.card .emoji {
  grid-row: 1 / span 2; align-self: center;
  width: 2.7rem; height: 2.7rem; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--paper-2);
  display: grid; place-items: center; font-size: 1.4rem;
  filter: sepia(.12) contrast(.98);
}
.card-title {
  display: block; font-family: var(--display); font-weight: 600; font-size: 1.18rem;
  letter-spacing: .04em; align-self: end;
}
.card-desc { display: block; grid-column: 2; color: var(--ink-2); font-style: italic; font-size: .98rem; align-self: start; }
.badge {
  grid-column: 2; justify-self: start; margin-top: .5rem;
  font-family: var(--display); font-weight: 600; font-size: .75rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--gold);
}

/* Two ledger columns once there is room for them */
@media (min-width: 880px) {
  .app.wide { max-width: 1000px; }
  .app.wide .card-list { grid-template-columns: 1fr 1fr; }
}

/* ---- The daily examination: a sealed notice above the ledger ---- */
.daily-card { border-color: var(--oxblood); margin-bottom: 1.1rem; }
.daily-card::before { transform: scaleY(1); }
.daily-card .emoji {
  font-family: var(--display); font-weight: 700; font-size: 1.5rem;
  background: var(--oxblood); color: var(--paper); border-color: var(--oxblood);
  filter: none;
}
.daily-card .badge { color: var(--oxblood); }
.daily-grid {
  text-align: center; font-size: 1.5rem; letter-spacing: .25em; text-indent: .25em;
  margin: .4rem 0 1rem;
}
.daily-next { text-align: center; font-style: italic; font-size: .95rem; }

/* ---- Panels (setup + question) ---- */
.setup, .question {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 2px;
  padding: 1.7rem 1.6rem; box-shadow: 7px 7px 0 -3px var(--rule);   /* hard offset, not blur */
}
.setup h2 {
  font-family: var(--display); font-weight: 600; letter-spacing: .03em;
  margin: 0 0 1.4rem; font-size: 1.4rem;
}

/* ---- Setup controls ---- */
.setup-group { margin-bottom: 1.3rem; }
.setup-label {
  display: block; font-family: var(--display); font-weight: 600;
  font-size: .75rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--oxblood); margin-bottom: .6rem;
}
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font-family: var(--body); font-size: .98rem; padding: .45rem 1rem; min-height: 44px;
  border: 1px solid var(--rule); border-radius: 2px;
  background: var(--paper); color: var(--ink); cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.match-count { margin: .2rem 0 0; font-style: italic; font-size: .95rem; color: var(--ink-2); }

/* ---- Question ---- */
.progress {
  font-family: var(--display); font-weight: 600; font-size: .72rem;
  letter-spacing: .22em; text-transform: uppercase; color: var(--ink-2);
  margin: 0 0 1rem; display: flex; align-items: center; gap: .9rem;
}
.progress::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.question h2 { font-family: var(--body); font-weight: 600; font-size: 1.5rem; line-height: 1.3; margin: 0; }

.options { display: grid; gap: .55rem; counter-reset: opt; margin-top: 1.3rem; }
.option {
  counter-increment: opt; position: relative; text-align: left;
  font-family: var(--body); font-size: 1.05rem;
  padding: .8rem 1rem .8rem 3rem; min-height: 44px; cursor: pointer; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 2px;
  transition: border-color .12s ease, background .12s ease;
}
.option::before {
  content: counter(opt); position: absolute; left: 0; top: 0; bottom: 0; width: 2.3rem;
  display: grid; place-items: center;
  font-family: var(--display); font-size: .8rem; color: var(--ink-2);
  background: var(--paper-2); border-right: 1px solid var(--rule);
}
.option:hover:not(:disabled) { border-color: var(--ink); }
.option:disabled { cursor: default; }
/* Resolution is marked with glyphs as well as colour (colour-blind safe). */
.option.correct { border-color: var(--verdigris); background: color-mix(in srgb, var(--verdigris) 12%, var(--paper)); }
.option.correct::before { content: "✓"; font-size: 1rem; background: var(--verdigris); color: var(--paper); border-color: var(--verdigris); }
.option.wrong { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 12%, var(--paper)); }
.option.wrong::before { content: "✗"; font-size: 1rem; background: var(--wrong); color: var(--paper); border-color: var(--wrong); }

.kbd-hint { display: none; margin: 1rem 0 0; font-size: .88rem; font-style: italic; color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; } }

.explanation {
  margin-top: 1.2rem; padding: .6rem 0 .6rem 1.1rem;
  border-left: 3px solid var(--oxblood); color: var(--ink-2);
  font-style: italic; font-size: 1rem;
}

/* ---- Results ---- */
.result-score {
  font-family: var(--display); font-weight: 700; letter-spacing: .02em;
  font-size: clamp(3.5rem, 16vw, 5.5rem); text-align: center; color: var(--ink); margin: .6rem 0 0;
}
.result-verdict { text-align: center; font-style: italic; font-size: 1.25rem; color: var(--oxblood); margin: .2rem 0 .4rem; }
.new-best {
  display: block; text-align: center; margin: 0 0 1.8rem;
  font-family: var(--display); font-weight: 600; font-size: .78rem;
  letter-spacing: .18em; text-transform: uppercase; color: var(--gold);
}
.recap { list-style: none; padding: 0; margin: 1.6rem 0; }
.recap li {
  display: flex; gap: .7rem; align-items: baseline; padding: .7rem .2rem;
  font-size: 1rem; border-bottom: 1px solid var(--rule);
}
.recap li:first-child { border-top: 1px solid var(--rule); }
.recap li::before { font-family: var(--display); font-weight: 700; flex-shrink: 0; }
.recap li.ok::before { content: "✓"; color: var(--verdigris); }
.recap li.miss::before { content: "✗"; color: var(--wrong); }

/* Clipboard fallback: a selectable field */
.share-url {
  display: block; width: 100%; margin-top: .8rem; padding: .6rem .8rem;
  font-family: var(--body); font-size: .92rem; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px;
  resize: none;
}

.error { color: var(--oxblood); font-style: italic; font-size: 1.15rem; }
.muted { color: var(--ink-2); }

/* ---- Footer ---- */
.site-footer { text-align: center; padding: 0 1rem 2.2rem; }
.site-footer a {
  font-family: var(--display); font-weight: 600; font-size: .72rem;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.site-footer a:hover { color: var(--oxblood); border-color: var(--oxblood); }

/* ---- Static pages (privacy, 404) ---- */
.prose { background: var(--paper); border: 1px solid var(--rule); border-radius: 2px; padding: 1.7rem 1.6rem; box-shadow: 7px 7px 0 -3px var(--rule); }
.prose h2 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; letter-spacing: .03em; margin: 0 0 1rem; }
.prose h3 { font-family: var(--display); font-weight: 600; font-size: 1.02rem; letter-spacing: .05em; margin: 1.6rem 0 .4rem; }
.prose p, .prose li { font-size: 1.02rem; }
.prose a { color: var(--oxblood); }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .app { padding: 1.2rem 1rem 3rem; }
  .setup, .question { padding: 1.3rem 1.2rem; box-shadow: 5px 5px 0 -3px var(--rule); }
}
