/* Faces - design language after ramsa.com: white space, classical serif display,
   small letter-spaced capitals, near-black ink, a single terracotta accent. */

@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/eb-garamond-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/eb-garamond-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/eb-garamond-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }

:root {
  --paper: #ffffff;
  --paper-2: #f7f4ef;
  --paper-3: #ece6dd;
  --ink: #141312;
  --ink-2: #57534d;
  --ink-3: #8c877f;
  --rule: #e6e0d6;
  --accent: #b85a35;
  --accent-soft: #f5e6dd;
  --on-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 19, 18, .06), 0 8px 28px rgba(20, 19, 18, .08);
  --scrim: rgba(20, 19, 18, .42);

  --serif: "EB Garamond", "Iowan Old Style", "Palatino", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --pad: 20px;
  --appbar-h: 50px;
  --tabbar-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121110; --paper-2: #1b1a18; --paper-3: #292623;
  --ink: #f3efe9; --ink-2: #bdb6ad; --ink-3: #8a847b;
  --rule: #2f2c28; --accent: #d9825c; --accent-soft: #3b2619; --on-ink: #121110;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45); --scrim: rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121110; --paper-2: #1b1a18; --paper-3: #292623;
    --ink: #f3efe9; --ink-2: #bdb6ad; --ink-3: #8a847b;
    --rule: #2f2c28; --accent: #d9825c; --accent-soft: #3b2619; --on-ink: #121110;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45); --scrim: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.45 var(--sans);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
img { display: block; }

/* ---------- type ---------- */
.eyebrow { font: 500 11px/1.3 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); margin: 0; }
.eyebrow.accent { color: var(--accent); }
.display { font: 400 44px/1.02 var(--serif); letter-spacing: -.012em; margin: 0; }
.h2 { font: 400 26px/1.1 var(--serif); margin: 0; }
.lede { font: 400 19px/1.4 var(--serif); color: var(--ink-2); margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font: 400 40px/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }

/* ---------- app bar / tab bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--appbar-h) + var(--safe-t)); padding-top: var(--safe-t);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--accent);
}
.wordmark { font: 500 19px/1 var(--serif); letter-spacing: .2em; padding-left: .2em; }
.appbar-sub { font: 500 10px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; }

.view {
  padding: 26px var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 110px);
  max-width: 720px; margin: 0 auto; outline: none;
  animation: fade .28s var(--ease);
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--rule);
}
.tab {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-3); position: relative;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.tab span { font: 500 9.5px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 34%; right: 34%; height: 2px; background: var(--accent); }

/* ---------- sections ---------- */
.page-head { display: grid; gap: 10px; margin-bottom: 26px; }
.section { margin-top: 34px; }
.section > .eyebrow { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: baseline; }
.rule { height: 1px; background: var(--rule); border: 0; margin: 28px 0; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.stat { padding: 16px 0 14px; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--rule); }
.stat .eyebrow { margin-top: 8px; font-size: 10px; }
.meter { height: 2px; background: var(--rule); position: relative; overflow: hidden; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); width: 0; transition: width .6s var(--ease); }

.dept-rows { display: grid; gap: 12px; }
.dept-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; font-size: 14px; }
.dept-row .meter { grid-column: 1 / -1; }
.dept-row b { font-weight: 500; }
.dept-row span { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--pad)); padding: 2px var(--pad) 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--rule); background: var(--paper); border-radius: 2px;
  padding: 9px 12px 8px; font: 500 11px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s;
}
.chip small { font: 400 11px/1 var(--sans); letter-spacing: 0; color: var(--ink-3); margin-left: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip[aria-pressed="true"] small { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }

/* segmented */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 11px 6px 10px; font: 500 11px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.field { display: grid; gap: 10px; margin-top: 18px; }
.field > label, .field > .eyebrow { font: 500 10px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.switch-row:first-child { border-top: 1px solid var(--rule); }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--paper-3); position: relative; flex: none; transition: background .2s; border: 0; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(18px); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: 2px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--on-ink);
  font: 500 12px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.line-accent { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.linkbtn { border: 0; background: none; padding: 0; font: 500 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }

.dock {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  padding: 14px var(--pad) 14px;
  background: linear-gradient(to top, var(--paper) 62%, color-mix(in srgb, var(--paper) 0%, transparent));
}
.dock .inner { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.dock .hint { text-align: center; font-size: 12px; color: var(--ink-3); }

/* list rows (settings) */
.rows { border-top: 1px solid var(--ink); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--rule); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font-size: 15px; }
.row .sub { display: block; color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.row .chev { color: var(--ink-3); font-size: 18px; }
.row.danger { color: var(--accent); }

/* ---------- people grid ---------- */
.search {
  width: 100%; border: 0; border-bottom: 1px solid var(--ink); background: transparent; border-radius: 0;
  padding: 10px 0 10px 28px; font: 400 20px/1.2 var(--serif); outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c877f' stroke-width='1.6'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 0 50%; background-size: 18px;
}
.search::placeholder { color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px 14px; margin-top: 18px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.person { border: 0; background: none; padding: 0; text-align: left; display: grid; gap: 9px; }
.person .ph { aspect-ratio: 1; }
.person .nm { font: 500 14px/1.25 var(--sans); }
.person .tl { font: 500 9.5px/1.35 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.ph { position: relative; width: 100%; background: var(--paper-3); overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.ph img.in { opacity: 1; }
.ph .ini { position: absolute; inset: 0; display: grid; place-items: center; font: 400 clamp(28px, 9vw, 64px)/1 var(--serif); color: var(--ink-3); letter-spacing: .04em; }
.ph .badge { position: absolute; right: 8px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--paper); }
.count-line { font: italic 400 17px/1.3 var(--serif); color: var(--ink-2); margin-top: 16px; }
.empty { padding: 40px 0; text-align: center; color: var(--ink-3); font: italic 400 18px/1.4 var(--serif); }

/* ---------- welcome ---------- */
.welcome { min-height: calc(100dvh - var(--appbar-h) - var(--safe-t) - var(--tabbar-h) - var(--safe-b) - 40px); display: grid; align-content: center; gap: 22px; padding-bottom: 40px; }
.welcome .display { font-size: 58px; }
.steps { counter-reset: s; display: grid; gap: 0; border-top: 1px solid var(--ink); }
.step { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.step::before { content: counter(s, decimal-leading-zero); font: 500 11px/1.9 var(--sans); letter-spacing: .12em; color: var(--accent); }
.step.done { color: var(--ink-3); }
.step.done::before { content: "\2713"; }
.fine { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }

/* ---------- session (study overlay) ---------- */
.session {
  position: fixed; inset: 0; z-index: 50; background: var(--paper);
  display: grid; grid-template-rows: auto auto 1fr auto;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
  animation: rise .32s var(--ease);
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.s-top { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 6px; }
.iconbtn { width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; color: var(--ink); }
.iconbtn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.s-count { font: 500 11px/1 var(--sans); letter-spacing: .16em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.s-progress { height: 2px; background: var(--rule); }
.s-progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .35s var(--ease); }
.s-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px var(--pad) 8px; overflow: hidden; min-height: 0; container-type: size; }
.card {
  width: min(100cqw, 440px, 100cqh - 140px); flex: none;
  background: var(--paper); position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  will-change: transform; transition: transform .35s var(--ease), opacity .35s;
}
.card.dragging { transition: none; }
.card .ph { aspect-ratio: 1; box-shadow: var(--shadow); }
.card .ph img { -webkit-user-drag: none; pointer-events: none; }
.card .stamp { position: absolute; top: 18px; padding: 8px 12px 7px; font: 600 12px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; opacity: 0; border: 2px solid; background: color-mix(in srgb, var(--paper) 86%, transparent); }
.card .stamp.got { left: 16px; color: var(--ink); border-color: var(--ink); transform: rotate(-8deg); }
.card .stamp.again { right: 16px; color: var(--accent); border-color: var(--accent); transform: rotate(8deg); }
.answer { text-align: center; min-height: 116px; padding-top: 18px; display: grid; align-content: start; gap: 8px; }
.answer .who { font: 400 34px/1.05 var(--serif); letter-spacing: -.01em; }
.answer .q { font: italic 400 22px/1.2 var(--serif); color: var(--ink-2); }
.answer .meta { display: grid; gap: 6px; }
.reveal-in > * { animation: fade .3s var(--ease) both; }
.reveal-in > *:nth-child(2) { animation-delay: .05s; }
.reveal-in > *:nth-child(3) { animation-delay: .1s; }
.name-card { width: min(100%, 440px); min-height: 220px; display: grid; align-content: center; justify-items: center; gap: 12px; text-align: center; padding: 28px 18px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.name-card .who { font: 400 40px/1.05 var(--serif); }
.s-actions { padding: 10px var(--pad) 16px; display: grid; gap: 10px; max-width: 520px; width: 100%; margin: 0 auto; }
.s-actions .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.s-actions .hint { text-align: center; font-size: 12px; color: var(--ink-3); min-height: 16px; }
.choices { display: grid; gap: 8px; }
.choice { min-height: 54px; border: 1px solid var(--rule); background: var(--paper); border-radius: 2px; text-align: left; padding: 10px 16px; font: 400 18px/1.2 var(--serif); display: flex; align-items: center; justify-content: space-between; transition: background .15s, border-color .15s, color .15s; }
.choice small { font: 500 9.5px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.choice.right { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.choice.right small { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.choice.wrong { border-color: var(--accent); color: var(--accent); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-ph { border: 0; padding: 0; background: none; position: relative; }
.choice-ph .ph { aspect-ratio: 1; }
.choice-ph::after { content: ""; position: absolute; inset: 0; border: 3px solid transparent; transition: border-color .15s; }
.choice-ph.right::after { border-color: var(--ink); }
.choice-ph.wrong::after { border-color: var(--accent); }
.choice-ph.dim { opacity: .35; }

.session[data-style="choice"] .card { width: min(100cqw, 420px, 100cqh); }
.session[data-style="choice"] .s-actions { gap: 8px; }
.session[data-style="choice"] .answer { min-height: 70px; padding-top: 12px; }
.session[data-style="choice"] .answer .who { font-size: 28px; }
.choice-grid { width: min(100cqw, 400px, 100cqh - 160px); flex: none; margin-top: 10px; }
.s-actions .hint .linkbtn { margin-left: 10px; font-size: 11px; vertical-align: 2px; }

/* end of session */
.done { padding: 24px var(--pad) 18px; overflow-y: auto; max-width: 620px; margin: 0 auto; width: 100%; }
.done .display { font-size: 50px; }
.score { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; }
.score .num { font-size: 72px; }
.missed { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.missed .person .nm { font-size: 12px; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: grid; align-items: end; background: var(--scrim); animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet-body { background: var(--paper); max-height: 92dvh; overflow-y: auto; padding: 10px var(--pad) calc(24px + var(--safe-b)); border-radius: 10px 10px 0 0; animation: rise .3s var(--ease); max-width: 720px; width: 100%; margin: 0 auto; }
.grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--paper-3); margin: 2px auto 14px; }
.sheet .ph { aspect-ratio: 1; max-width: 420px; margin: 0 auto; }
.sheet .who { font: 400 34px/1.05 var(--serif); margin: 18px 0 8px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); margin: 20px 0; }
.facts div { padding: 12px 0; }
.facts div + div { padding-left: 12px; border-left: 1px solid var(--rule); }
.facts b { display: block; font: 400 26px/1 var(--serif); }
.facts span { font: 500 9.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- busy / toast ---------- */
.busy { position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: grid; place-items: center; padding: 30px; }
.busy-box { background: var(--paper); padding: 26px 24px; width: min(100%, 360px); display: grid; gap: 16px; box-shadow: var(--shadow); }
.bar { height: 2px; background: var(--rule); }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.toast {
  position: fixed; left: 50%; z-index: 90; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 92px);
  background: var(--ink); color: var(--on-ink); padding: 13px 16px; border-radius: 2px; max-width: calc(100% - 32px);
  font: 500 13px/1.35 var(--sans); box-shadow: var(--shadow); display: flex; gap: 16px; align-items: center;
  animation: toast .3s var(--ease);
}
.toast button { border: 0; background: none; color: var(--on-ink); font: 600 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
