/* Tuapapa - demo styles (OPP-015).
   Two boards: blackboard (default) and whiteboard. Chalk lettering comes from
   Chalkboard SE, which ships with macOS and iOS, so there is nothing to
   download. Display type only: body text stays in a clean sans because
   legibility beat theming in the first round of feedback. */

:root {
  --board: #14181a;
  --board-2: #1b2023;
  --board-3: #0f1214;
  --line: #333c41;
  --line-soft: #232b2f;

  --ink: #eef2ee;
  --ink-dim: #a3aeaa;
  --ink-faint: #8b9794; /* WCAG AA against --board at small sizes */

  --green: #8fe0a8;
  --blue: #8cc7f5;
  --amber: #f0c968;
  --rose: #eda28d;

  --hotoke: #9ab5c8;
  --koanga: #8fe0a8;
  --raumati: #f0c968;
  --ngahuru: #e0a07a;

  --ok: #8fe0a8;
  --warn: #f0c968;
  --pending: #9aa8b2;

  --chalk-opacity: 0.05;
  --dust: 0.5;

  --radius: 12px;
  --display: "Chalkboard SE", "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  --board: #f2efe6;
  --board-2: #fbfaf6;
  --board-3: #e8e4d8;
  --line: #c8c1ae;
  --line-soft: #dcd6c6;

  --ink: #23261f;
  --ink-dim: #5b6157;
  --ink-faint: #5b6056; /* WCAG AA against every board surface at small sizes */

  --green: #256640;
  --blue: #235777;
  --amber: #765812;
  --rose: #8c4630;

  --hotoke: #3f5b6f;
  --koanga: #256640;
  --raumati: #765812;
  --ngahuru: #8c5432;

  --ok: #256640;
  --warn: #765812;
  --pending: #6f7a80;

  --chalk-opacity: 0.03;
  --dust: 0.28;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--board);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Chalk dust. Inline SVG noise so the page stays self-contained. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--chalk-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

body {
  max-width: 620px;
  margin: 0 auto;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  position: relative;
}

body > * { position: relative; z-index: 1; }

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 0.7em; }
p:last-child { margin-bottom: 0; }

.chalk { font-family: var(--display); letter-spacing: 0.01em; }

.muted { color: var(--ink-dim); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.76rem; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ink-faint);
}

/* Chalk rule: a hand-drawn looking line rather than a crisp border. */
.rule {
  height: 3px;
  border: 0;
  margin: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='3' preserveAspectRatio='none'%3E%3Cpath d='M0 1.6 Q15 0.5 30 1.7 T60 1.5 T90 1.9 T120 1.4' stroke='%23ffffff' stroke-width='1.3' fill='none' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 120px 3px;
  opacity: var(--dust);
}

/* --- App chrome ----------------------------------------------------------- */

header.app {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 10px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--board);
}

.wordmark { font-family: var(--display); font-size: 1.2rem; font-weight: 600; }
.header-spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink-dim);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--ink); border-color: var(--line); }
.icon-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

main { padding: 2px 18px 26px; }

.screen { display: none; animation: rise 0.2s ease both; }
.screen.active { display: block; }

@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

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

/* --- Bottom nav ----------------------------------------------------------- */

nav.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  max-width: 620px;
  margin: 0 auto;
  background: var(--board-3);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 9px 4px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
nav.tabs button svg { width: 22px; height: 22px; stroke-width: 1.6; }
nav.tabs button[aria-current="page"] { color: var(--green); }

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--board-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
}
.card.flush { padding: 0; overflow: hidden; }

.screen-head { margin: 6px 0 14px; }
.screen-head .t { font-family: var(--display); font-size: 1.45rem; }
.screen-head .s { font-size: 0.85rem; color: var(--ink-dim); margin-top: 2px; }

.section-title {
  font-family: var(--display);
  font-size: 1.02rem;
  color: var(--ink-dim);
  margin: 24px 0 9px;
}

/* --- Kupu gloss ----------------------------------------------------------- */

.kupu {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: help;
  border-bottom: 1px dotted currentColor;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.kupu:hover, .kupu.held { color: var(--green); }
.kupu:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 3px; }

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 7, 0.6);
  z-index: 90; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
:root[data-theme="light"] .sheet-backdrop { background: rgba(35, 38, 31, 0.4); }
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 100;
  max-width: 620px; margin: 0 auto;
  background: var(--board-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateY(102%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 82vh; overflow-y: auto;
}
.sheet.open { transform: none; }
.sheet .grab { width: 36px; height: 4px; background: var(--line); border-radius: 4px; margin: 0 auto 14px; }

.gloss-word { font-family: var(--display); font-size: 1.6rem; color: var(--green); }
.gloss-en { font-size: 1rem; margin-bottom: 9px; }
.gloss-note {
  font-size: 0.85rem; color: var(--ink-dim);
  border-left: 2px solid var(--line); padding-left: 10px; margin-bottom: 13px;
}
.audio-slot {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.77rem; color: var(--ink-faint);
  background: var(--board-3); border: 1px dashed var(--line);
  border-radius: 9px; padding: 9px 11px; margin-bottom: 13px;
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 0.92rem;
  border-radius: 10px; padding: 12px 17px;
  border: 1px solid var(--line);
  background: var(--board-3); color: var(--ink);
  cursor: pointer; min-height: 46px;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--board); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn.sm { padding: 8px 12px; font-size: 0.82rem; min-height: 38px; }

/* --- Chips ---------------------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 3px 9px;
  border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-dim); white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.pending { color: var(--pending); border-color: var(--pending); }
.chip.sealed { color: var(--blue); border-color: var(--blue); }

.draft-flag {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 0.78rem; color: var(--warn);
  border: 1px dashed var(--warn);
  border-radius: 9px; padding: 10px 11px; margin-bottom: 12px; line-height: 1.45;
}
.draft-flag svg { flex: none; width: 15px; height: 15px; margin-top: 2px; }

/* --- Home tiles ----------------------------------------------------------- */

.board-hero {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  text-align: center;
  background: var(--board-2);
}
.board-hero .season { font-family: var(--display); font-size: 1.9rem; }
.board-hero .sub { font-size: 0.84rem; color: var(--ink-dim); margin-top: 1px; }

.streak-row {
  display: flex; justify-content: center; gap: 26px;
  margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line-soft);
}
.stat { text-align: center; }
.stat .n { font-family: var(--display); font-size: 1.5rem; line-height: 1; }
.stat .n.fire { color: var(--amber); }
.stat .n.seed { color: var(--green); }
.stat .l { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); margin-top: 5px; font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 7px;
  text-align: left; font: inherit; color: var(--ink);
  background: var(--board-2);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 14px;
  cursor: pointer;
  min-height: 104px;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.tile:hover { border-color: var(--line); }
.tile:active { transform: scale(0.99); }
.tile:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.tile .ic { width: 24px; height: 24px; color: var(--green); }
.tile .t { font-family: var(--display); font-size: 1.02rem; line-height: 1.2; }
.tile .d { font-size: 0.75rem; color: var(--ink-faint); margin-top: auto; }
.tile.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 12px; }
.tile.wide .d { margin: 0; }

/* --- Initiative rows ------------------------------------------------------ */

.init { display: flex; gap: 11px; align-items: flex-start; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.init:last-child { border-bottom: 0; }
.init .body { flex: 1; min-width: 0; }
.init .reo { font-weight: 600; }
.init .en { font-size: 0.82rem; color: var(--ink-dim); margin-top: 1px; }
.init .meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; align-items: center; }

.tick {
  flex: none; width: 27px; height: 27px;
  border-radius: 8px; border: 1.5px solid var(--line);
  background: transparent;
  display: grid; place-items: center;
  cursor: pointer; padding: 0; margin-top: 1px;
  transition: all 0.15s ease;
}
.tick svg { width: 15px; height: 15px; opacity: 0; }
.tick[aria-pressed="true"] { background: var(--green); border-color: var(--green); }
.tick[aria-pressed="true"] svg { opacity: 1; stroke: var(--board); }
.tick:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.bar { height: 5px; background: var(--board-3); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 4px; transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1); }

.pou-head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 15px 10px; border-bottom: 1px solid var(--line-soft);
  background: var(--board-3);
}
.pou-head i { width: 7px; height: 20px; border-radius: 3px; flex: none; }
.pou-head .n { font-family: var(--display); font-size: 1rem; }
.pou-head .e { font-size: 0.73rem; color: var(--ink-faint); }
.pou-head .count { margin-left: auto; font-size: 0.76rem; color: var(--ink-faint); font-weight: 600; }

/* --- Wheel ---------------------------------------------------------------- */

.wheel-wrap { display: flex; justify-content: center; padding: 2px 0 8px; }
.wheel { width: 100%; max-width: 320px; height: auto; overflow: visible; }
.wheel .arc { fill: none; stroke-width: 14; opacity: 0.25; }
.wheel .arc.now { opacity: 0.65; }
.wheel .lbl { font-family: var(--display); font-size: 13px; fill: var(--ink-faint); text-anchor: middle; }
.wheel .lbl.now { fill: var(--ink); }
.wheel .mid-n { font-family: var(--display); font-size: 32px; fill: var(--ink); text-anchor: middle; }
.wheel .mid-l { font-size: 9px; font-weight: 700; letter-spacing: 0.13em; fill: var(--ink-faint); text-anchor: middle; }

.legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 4px; }
.legend div { display: flex; align-items: center; gap: 7px; font-size: 0.79rem; color: var(--ink-dim); }
.legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* --- Tohu ----------------------------------------------------------------- */

.tohu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.tohu-card { background: var(--board-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 12px; text-align: center; }
.tohu-card.earned { border-color: var(--amber); }
.tohu-card .medal {
  width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center; border: 1.5px solid var(--line); font-size: 1.1rem;
}
.tohu-card.earned .medal { border-color: var(--amber); color: var(--amber); }
.tohu-card .t { font-family: var(--display); font-size: 0.94rem; }
.tohu-card .d { font-size: 0.72rem; color: var(--ink-faint); margin-top: 3px; line-height: 1.35; }

.maunga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.maunga-cell { border: 1px solid var(--line-soft); border-radius: 9px; padding: 8px 9px; font-size: 0.74rem; color: var(--ink-faint); }
.maunga-cell.found { color: var(--ink); border-color: var(--blue); }
.maunga-cell .en { font-size: 0.65rem; color: var(--ink-faint); margin-top: 2px; }

.kete-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kete-list .k { border: 1px solid var(--green); color: var(--green); border-radius: 999px; padding: 4px 11px; font-size: 0.82rem; }

/* --- Rewards -------------------------------------------------------------- */

.reward { border: 1px solid var(--line-soft); background: var(--board-2); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.reward.featured { border-color: var(--green); }
.reward .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; }
.reward .reo { font-family: var(--display); font-size: 1.08rem; }
.reward .en { font-size: 0.85rem; color: var(--ink-dim); }
.reward .detail { font-size: 0.84rem; color: var(--ink-dim); margin-top: 8px; line-height: 1.5; }
.reward .foot { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line-soft); }
.reward .cost { font-size: 0.73rem; color: var(--ink-faint); }

.want {
  border: 1px solid var(--line); background: transparent; color: var(--ink-dim);
  border-radius: 9px; padding: 8px 12px; font: inherit; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; min-height: 38px; white-space: nowrap; flex: none;
}
.want[aria-pressed="true"] { border-color: var(--green); color: var(--green); }

/* --- Collective ----------------------------------------------------------- */

.team-row { padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.team-row:last-child { border-bottom: 0; }
.team-row .t { display: flex; justify-content: space-between; gap: 9px; align-items: baseline; }
.team-row .name { font-weight: 600; font-size: 0.9rem; }
.team-row .pct { font-size: 0.83rem; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.team-row .sub { font-size: 0.73rem; color: var(--ink-faint); margin-top: 3px; }

.shift { display: grid; grid-template-columns: 1fr auto 1fr; gap: 11px; align-items: center; }
.shift-col .lbl { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); font-weight: 700; margin-bottom: 8px; }
.shift-bar { display: flex; height: 25px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-soft); }
.shift-bar span { display: block; }
.shift-bar .u { background: var(--pending); opacity: 0.55; }
.shift-bar .c { background: var(--blue); opacity: 0.7; }
.shift-bar .f { background: var(--green); opacity: 0.8; }
.shift .arrow { color: var(--ink-faint); }

.priv-note {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 0.78rem; color: var(--ink-dim);
  border: 1px solid var(--line-soft); border-radius: 9px; padding: 10px 11px; line-height: 1.5;
}
.priv-note svg { flex: none; width: 15px; height: 15px; margin-top: 2px; color: var(--blue); }

/* --- Wizard --------------------------------------------------------------- */

.wiz { padding: 20px 20px 40px; max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
/* display:flex above would otherwise beat the hidden attribute */
[hidden] { display: none !important; }
.wiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.dots { display: flex; gap: 5px; flex: 1; }
.dots i { height: 3px; flex: 1; border-radius: 2px; background: var(--line); }
.dots i.on { background: var(--green); }

.wiz-step { animation: rise 0.22s ease both; flex: 1; }
.wiz h2 { font-family: var(--display); font-size: 1.75rem; line-height: 1.2; margin-bottom: 8px; }
.wiz .lead { color: var(--ink-dim); margin-bottom: 22px; font-size: 0.95rem; }
.wiz-foot { display: flex; gap: 9px; margin-top: 26px; }
.wiz-foot .btn { flex: 1; }

.field { margin-bottom: 17px; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; }
.field .hint { font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 8px; line-height: 1.45; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 0.95rem;
  background: var(--board-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; color: var(--ink); resize: vertical;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }

.pick-list { display: grid; gap: 8px; }
.pick {
  display: flex; gap: 11px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--board-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 13px; font: inherit; color: var(--ink); cursor: pointer;
}
.pick[aria-pressed="true"] { border-color: var(--green); }
.pick .dot { flex: none; width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--line); margin-top: 2px; }
.pick[aria-pressed="true"] .dot { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px var(--board-2); }
.pick .t { display: block; font-weight: 600; font-size: 0.93rem; }
.pick .t .chalk { font-size: 1.02rem; }
.pick .d { display: block; font-size: 0.79rem; color: var(--ink-dim); margin-top: 2px; line-height: 1.4; }

/* --- Kakano pop ----------------------------------------------------------- */

.kakano-pop {
  position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%);
  z-index: 120; background: var(--green); color: var(--board);
  font-family: var(--display); font-weight: 700; font-size: 0.92rem;
  padding: 9px 17px; border-radius: 999px; pointer-events: none;
  animation: pop 1.5s ease forwards;
}
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.9); }
  16%, 76% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(0.97); }
}

.demo-bar {
  font-size: 0.68rem; text-align: center; color: var(--ink-faint);
  border-bottom: 1px solid var(--line-soft); padding: 5px 14px;
}

@media (min-width: 560px) {
  .tohu-grid { grid-template-columns: repeat(3, 1fr); }
  .legend { grid-template-columns: repeat(4, 1fr); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
