/* Trova. Mobile first. Clean dictionary look: white page, ink, one red. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #5b5b5b;
  --line: #e2e2e2;
  --line-strong: #a0a0a0;
  --accent: #b3401a;
  --accent-soft: #fbe9e1;
  --region: #ffffff;
  --region-hover: #fbefe9;
  --halo: #f4f4f4;
  --hand-fill: #ffffff;
  --focus: #1f5fbf;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 6px;
  --ease: 150ms ease-out;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--sans);
  font-kerning: normal;
}

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.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;
}

.skip { position: absolute; left: 12px; top: -60px; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: var(--radius); z-index: 20; }
.skip:focus { top: 12px; }

.noscript { margin: 16px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); }

/* Masthead */

.top { max-width: 1280px; margin: 0 auto; padding: 20px 16px 0; }
.masthead { padding-bottom: 14px; border-bottom: 3px double var(--ink); }
.top h1 { margin: 0; line-height: 0; }
.home { display: inline-block; line-height: 0; border-radius: 4px; }
.logo { display: block; width: auto; height: 56px; }
.tagline { margin: 8px 0 0; max-width: 34em; color: var(--muted); font-size: 1rem; line-height: 1.4; }
.tagline b { color: var(--ink); font-weight: 700; }

.layout { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* Question blocks: ruled sections, not boxes */

.q { padding: 18px 0 22px; border-bottom: 1px solid var(--line); }
.q-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 36px; }
.q h2 {
  display: flex; align-items: baseline; gap: 10px; margin: 0;
  font-family: var(--serif); font-weight: 600; font-size: 1.4rem; line-height: 1.2; letter-spacing: -0.01em;
}
.q-num {
  flex: none; min-width: 0.9em;
  font-family: var(--serif); font-weight: 600; font-size: 1em; color: var(--accent);
  font-variant-numeric: lining-nums;
}
.q-num::after { content: "."; }
.q-help { margin: 2px 0 12px; color: var(--muted); font-size: 0.95rem; }
.clear {
  flex: none; min-height: 44px; padding: 0 4px; border: 0; background: none;
  color: var(--accent); font-size: 0.95rem; font-weight: 700;
  text-decoration: underline; text-underline-offset: 0.18em; cursor: pointer;
}

.count { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Shared tile look: plain tile, hairline border, ink on hover, red when chosen */

.group-tile, .hs-tile, .opt, .more, .back, .chip {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  transition: border-color var(--ease), background-color var(--ease);
}
@media (hover: hover) {
  .group-tile:hover, .hs-tile:hover, .opt:hover, .more:hover, .back:hover, .chip:hover { border-color: var(--ink); }
}
.group-tile:active, .hs-tile:active, .opt:active, .more:active, .chip:active { background: var(--halo); }

.is-selected { border-color: var(--accent) !important; background: var(--accent-soft) !important; box-shadow: inset 0 0 0 1px var(--accent); }
.is-selected .count { color: var(--ink); }
.is-empty { opacity: 0.45; }
.is-empty.is-selected { opacity: 1; }

/* Describe box */

.describe label { cursor: pointer; }
.describe-row { display: grid; gap: 8px; }
.describe textarea {
  display: block; width: 100%; min-height: 76px; margin: 0; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--ink); font: 17px/1.4 var(--sans); resize: vertical;
}
.describe textarea::placeholder { color: var(--muted); opacity: 1; }
.describe textarea:focus-visible { border-color: var(--ink); outline-offset: 1px; }
.describe-go {
  min-height: 48px; padding: 0 18px; border: 0; border-radius: var(--radius);
  background: var(--ink); color: var(--bg); font-weight: 700; cursor: pointer;
}
.describe-go:active { background: var(--accent); }
.describe form[aria-busy="true"] .describe-go { opacity: 0.6; }
.describe-status { margin: 10px 0 0; font-size: 0.95rem; line-height: 1.4; color: var(--muted); }
.describe-status:empty { display: none; }
.describe-status[data-tone="done"] { color: var(--ink); }
.describe-status[data-tone="problem"] { padding-left: 10px; border-left: 2px solid var(--accent); color: var(--ink); }

/* Handshape: finger groups */

.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.group-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 108px; padding: 10px 12px 12px; text-align: left; cursor: pointer;
}
.group-icons { display: flex; height: 40px; margin-bottom: 4px; color: var(--ink); }
.group-icons svg { width: 40px; height: 40px; margin-right: -6px; }
.group-label { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.group-all {
  grid-column: 1 / -1; min-height: 48px; align-items: center; justify-content: center;
  background: transparent; border-style: dashed; border-color: var(--line-strong);
}
.group-all .group-label { font-weight: 700; }

/* Handshape: tiles */

.hs-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px 0 8px;
  cursor: pointer; font-size: 0.95rem; font-weight: 700;
}
.back svg { width: 16px; height: 16px; }
.hs-group-name { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; text-align: right; }

.tile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hs-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 140px; padding: 10px 4px 8px; cursor: pointer;
}
.hs-visual { width: 64px; height: 64px; display: grid; place-items: center; flex: none; }
.hs-visual svg { width: 64px; height: 64px; }
.hs-visual.is-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg);
}
.glyph { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1; }
.glyph-mod { max-width: 60px; margin-top: 3px; font-size: 0.62rem; line-height: 1.1; color: var(--muted); text-align: center; }
.hs-name {
  font-size: 0.82rem; font-weight: 700; line-height: 1.2; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* Location */

.view-tabs {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px; border-bottom: 1px solid var(--line);
}
.view-tab {
  position: relative; min-height: 46px; margin-bottom: -1px; border: 0; border-bottom: 3px solid transparent;
  background: transparent; font-size: 0.97rem; font-weight: 700; color: var(--muted); cursor: pointer;
  transition: color var(--ease), border-color var(--ease);
}
@media (hover: hover) { .view-tab:hover { color: var(--ink); } }
.view-tab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.view-tab .dot { position: absolute; top: 9px; right: 18%; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.view-note { margin: 10px 0 0; min-height: 1.3em; font-size: 0.87rem; font-style: italic; color: var(--muted); text-align: center; }

.diagram { max-width: 400px; margin: 4px auto 0; }
.diagram svg { display: block; width: 100%; height: auto; touch-action: manipulation; overflow: visible; }

.region { fill: var(--region); stroke: var(--line-strong); stroke-width: 1.5; cursor: pointer; transition: fill var(--ease); }
.region:hover { fill: var(--region-hover); }
.region.halo { fill: var(--halo); stroke-dasharray: 7 6; }
.region.is-selected { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; box-shadow: none; }
.region.is-empty { opacity: 1; fill-opacity: 0.35; }
.region:focus { outline: none; }
.region:focus-visible { stroke: var(--focus); stroke-width: 3.5; }
.nav { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 3 3; cursor: pointer; }
.nav:hover { fill: var(--region-hover); }
.nav:focus { outline: none; }
.nav:focus-visible { stroke: var(--focus); stroke-width: 3; }
.deco { fill: none; stroke: var(--line-strong); stroke-width: 1.5; pointer-events: none; }
.part { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1.5; pointer-events: none; }
.hit { fill: transparent; stroke: none; cursor: pointer; pointer-events: all; }
.svg-label, .svg-cap { font: 700 12.5px var(--sans); fill: var(--muted); text-anchor: middle; pointer-events: none; }
.svg-cap.start { text-anchor: start; }

.loc-status { min-height: 1.5em; margin: 8px 0 12px; font-size: 0.97rem; text-align: center; color: var(--muted); }
.loc-status.is-chosen { color: var(--ink); font-weight: 700; }
.other-btn { width: 100%; }

/* Movement and hands options */

.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.option-list { display: grid; gap: 8px; margin-top: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px;
  text-align: left; cursor: pointer;
}
.opt .move-icon { flex: none; width: 44px; height: 30px; color: var(--accent); }
.opt-text { display: flex; flex-direction: column; min-width: 0; }
.opt-label { font-weight: 700; font-size: 0.98rem; line-height: 1.25; }
.opt-hint { font-size: 0.84rem; line-height: 1.3; color: var(--muted); }

/* Results: dictionary entries */

.results { margin: 24px 0 28px; scroll-margin-top: 8px; }
.results:focus { outline: none; }
.results-head {
  position: sticky; top: 0; z-index: 2; padding: 12px 0;
  background: var(--bg); border-bottom: 3px double var(--ink);
}
.results-head h2 {
  margin: 0; font-family: var(--serif); font-weight: 600;
  font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.015em; font-variant-numeric: lining-nums tabular-nums;
}
.maybe-count { margin: 2px 0 0; font-size: 0.92rem; color: var(--muted); }
.maybe-count:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 36px; padding: 4px 10px;
  border-color: var(--line-strong); font-size: 0.87rem; cursor: pointer;
}
.chip b { font-weight: 700; color: var(--muted); }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { flex: none; width: 10px; height: 10px; color: var(--accent); }
.chip-reset { background: transparent; border-style: dashed; font-weight: 700; }

.result-list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0 15px; border-bottom: 1px solid var(--line); }
.row-text { flex: 1; min-width: 0; }
.row p { margin: 0; }
.word-line { line-height: 1.2; }
.word {
  font-family: var(--serif); font-weight: 600; font-size: 1.5rem; line-height: 1.15;
  letter-spacing: -0.01em; overflow-wrap: anywhere;
}
.variant { margin-left: 8px; font-size: 0.84rem; font-style: italic; color: var(--muted); white-space: nowrap; }
.also { margin-top: 2px !important; font-size: 0.9rem; font-style: italic; color: var(--muted); }
.desc { margin-top: 6px !important; font-size: 1rem; line-height: 1.45; }
.maybe-note { margin-top: 6px !important; font-size: 0.86rem; color: var(--muted); font-style: italic; }

.watch {
  flex: none; display: inline-flex; flex-direction: column; align-items: flex-end; justify-content: center;
  min-width: 64px; min-height: 48px; padding: 2px 0 2px 8px; margin-top: 0;
  color: var(--accent); text-decoration: none; font-weight: 700; font-size: 0.97rem;
}
.watch-label { display: inline-flex; align-items: center; gap: 4px; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
.watch:hover .watch-label { text-decoration-thickness: 2px; }
.watch .ext { width: 14px; height: 14px; }
.watch .host { font-size: 0.74rem; font-weight: 400; color: var(--muted); }
.watch.is-missing { color: var(--muted); font-weight: 400; font-size: 0.84rem; }

.divider {
  padding: 22px 0 8px; font-size: 0.92rem; font-style: italic; color: var(--muted);
  border-bottom: 1px solid var(--ink);
}

.more {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; margin: 18px 0 0;
  border-color: var(--ink); font-weight: 700; cursor: pointer;
}

.empty { padding: 16px 0 6px; }
.empty p { margin: 0; }
.empty-title { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; }
.empty-help { margin-top: 2px !important; color: var(--muted); font-size: 0.95rem; }
.suggest { display: grid; gap: 8px; margin-top: 12px; }
.suggest-btn { min-height: 52px; }

/* Jump bar, phones only */

.jump {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 8px 8px 16px; border-radius: 10px; background: var(--ink); color: var(--bg);
  font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 10px 30px rgba(29, 27, 24, 0.28);
}
.jump button {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--bg); font-weight: 700; cursor: pointer;
}

/* Footer: colophon */

.foot {
  max-width: 1280px; margin: 12px auto 0; padding: 20px 16px 104px;
  border-top: 3px double var(--ink); font-size: 0.9rem; color: var(--muted);
}
.foot-inner { display: grid; gap: 0 40px; }
.foot p { margin: 0 0 10px; max-width: 68ch; }
.foot strong { color: var(--ink); }
.foot .lead { font-size: 1rem; color: var(--ink); }
.cite { padding-left: 12px; border-left: 2px solid var(--accent); font-size: 0.86rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* Larger phones and small tablets */

@media (min-width: 540px) {
  .logo { height: 64px; }
  .describe-row { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
  .group-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Desktop: filters left, results right */

@media (min-width: 960px) {
  .top { padding-top: 28px; }
  .masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
  .logo { height: 72px; }
  .tagline { margin: 0 0 4px; text-align: right; }
  .layout { display: grid; grid-template-columns: minmax(440px, 520px) minmax(0, 1fr); gap: 48px; align-items: start; }
  .group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; margin: 8px 0 0; padding: 0 8px 28px 0; }
  .results-head h2 { font-size: 2rem; }
  .jump { display: none !important; }
  .foot { padding-bottom: 32px; }
  .foot-inner { grid-template-columns: 1fr 1fr; }
}
