/* ============================================================================
   FLASH — component styles (Hedge v2)
   References tokens.css only. No raw colors here.
   ============================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--body-ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip-link {
  position: absolute; left: var(--sp-2); top: -48px;
  background: var(--card); color: var(--ink);
  border: var(--bw) solid var(--line-hard); border-radius: var(--r);
  padding: var(--sp-2) var(--sp-3); font-family: var(--mono);
  font-size: var(--fs-chip); z-index: 100; transition: top var(--t-base);
}
.skip-link:focus { top: var(--sp-2); }

/* Visible focus everywhere — never remove without replacing. */
:focus-visible {
  outline: 2.5px solid var(--teal);
  outline-offset: 2px;
}

/* ── Shared atoms ──────────────────────────────────────────────────────── */
.key-badge {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--ink); background: var(--well);
  border: 1px solid var(--line); border-radius: var(--r-chip);
  padding: 3px 8px;
}
.stat-badge {
  font-family: var(--mono); font-size: var(--fs-chip); color: var(--body-ink);
  background: var(--card); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 7px 12px;
}
.stat-badge b { color: var(--ink); font-weight: 600; }
.stat-badge.streak { background: var(--marker); color: var(--ink); }
.stat-badge.streak b { color: var(--ink); }

/* Solid color-blocked button base. */
.btn {
  font-family: var(--sans); font-weight: 700; font-size: var(--fs-ui);
  color: var(--on-accent); background: var(--orange);
  border: var(--bw) solid var(--line-hard); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: 10px 18px; cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-base);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow); filter: saturate(1.15); }
.btn:active { transform: translate(1px, 1px); box-shadow: var(--shadow-press); }
.btn.teal { background: var(--teal); }
.btn.green { background: var(--green); }
.btn.ghost {
  color: var(--body-ink); background: var(--card);
  font-family: var(--mono); font-size: var(--fs-chip); font-weight: 600;
}
.btn.ghost:hover { background: var(--orange); color: var(--on-accent); filter: none; }

/* ── Dashboard shell ───────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  border-right: var(--bw) solid var(--line-hard); background: var(--canvas);
  display: flex; flex-direction: column; gap: var(--sp-5); padding: var(--sp-4);
}
.brand { display: flex; align-items: center; gap: var(--sp-2); }
.brand .logo { font-size: 22px; }
.brand .name { font-weight: 800; font-size: 17px; color: var(--ink); letter-spacing: -.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-family: var(--mono); font-size: var(--fs-kbd); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  padding: 0 var(--sp-2) var(--sp-1);
}
.nav a {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-ui); font-weight: 500; color: var(--body-ink);
  text-decoration: none; padding: var(--sp-2); border-radius: var(--r);
  border: var(--bw) solid transparent; transition: background var(--t-base), border-color var(--t-base);
}
.nav a:hover { background: var(--well); }
.nav a.active {
  background: var(--card); border-color: var(--line-hard);
  box-shadow: var(--shadow-sm); color: var(--ink); font-weight: 600;
}
.sidebar .spacer { flex: 1; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-h); display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5); border-bottom: var(--bw) solid var(--line-hard); background: var(--canvas);
}
.topbar h1 { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.topbar .grow { flex: 1; }

.content { padding: var(--sp-5); max-width: var(--content-max); width: 100%; }

/* ── Deck-library grid ─────────────────────────────────────────────────── */
.deck-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}
.deck-card {
  background: var(--card); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3);
  text-decoration: none; transition: transform var(--t-base), box-shadow var(--t-base);
}
.deck-card:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-hover); }
.deck-card .row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.deck-card .title { font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -.01em; }
.deck-card .desc { font-size: var(--fs-ui); color: var(--body-ink); line-height: 1.5; }
.deck-card .foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: auto; }
.due-badge {
  font-family: var(--mono); font-size: var(--fs-chip); color: var(--on-accent);
  background: var(--orange); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r-chip); padding: 3px 9px; box-shadow: var(--shadow-sm);
}
.due-badge.clear { background: var(--green); }

/* State stripe (left accent) for list/board contexts. */
.state-stripe { border-left: 4px solid var(--muted); }
.state-stripe.new { border-left-color: var(--teal); }
.state-stripe.learning { border-left-color: var(--marker); }
.state-stripe.young { border-left-color: var(--teal); }
.state-stripe.mature { border-left-color: var(--green); }
.state-stripe.lapsed { border-left-color: var(--red); }
.state-stripe.suspended { border-left-color: var(--muted); }

/* ── Study screen (ported from 07-hedge.html) ──────────────────────────── */
.study { display: flex; flex-direction: column; min-height: 100vh; }
.study-header {
  display: flex; align-items: center; gap: 14px; padding: 14px var(--sp-5);
  border-bottom: var(--bw) solid var(--line-hard); background: var(--canvas);
}
.deck-id { display: flex; align-items: baseline; gap: 10px; }
.deck-id .deck-name { font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
.study-header .spacer { flex: 1; }

.progress-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5) 0; }
.track {
  flex: 1; height: 10px; background: var(--card);
  border: var(--bw) solid var(--line-hard); border-radius: 999px; overflow: hidden;
}
.fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(-45deg, var(--orange) 0 8px, var(--orange-deep) 8px 16px);
  transition: width .35s ease;
}
.prog-mono { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.study-main {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 22px; padding: var(--sp-6) 22px;
}
.coach { display: flex; align-items: center; gap: 9px; font-size: var(--fs-ui); color: var(--body-ink); }
.coach .hog { font-size: 21px; }
.coach em { font-style: normal; border-bottom: 2px dashed var(--marker); }

.card-zone { width: var(--study-col); }
.card {
  position: relative; background: var(--card);
  border: var(--bw) solid var(--line-hard); border-radius: var(--r-card);
  box-shadow: var(--shadow); min-height: 310px; cursor: pointer;
  display: flex; flex-direction: column; padding: 30px 34px;
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.card:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-hover); }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.state-tag {
  font-family: var(--mono); font-size: var(--fs-kbd); font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--on-accent);
  background: var(--teal); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r-chip); padding: 4px 10px; box-shadow: var(--shadow-sm);
}
.state-tag.learning { background: var(--marker); color: var(--on-marker); }
.state-tag.new { background: var(--teal); }
.state-tag.review { background: var(--green); }
.idx { font-family: var(--mono); font-size: var(--fs-chip); color: var(--muted); }
.q-text {
  font-weight: 700; font-size: var(--fs-q); line-height: 1.35; letter-spacing: -.015em;
  color: var(--ink); flex: 1; display: flex; align-items: center;
}
.a-block { display: none; border-top: var(--bw) dashed var(--line); margin-top: 18px; padding-top: 18px; }
.card.revealed .a-block { display: block; }
.card.revealed .reveal-row { display: none; }
.a-text { font-size: var(--fs-answer); line-height: 1.6; color: var(--body-ink); }
.a-text b {
  color: var(--ink); font-weight: 700;
  background: linear-gradient(transparent 55%, var(--marker-hi) 55%); padding: 0 2px;
}
[data-theme="dark"] .a-text b,
:root:not([data-theme="light"]) .a-text b { color: var(--ink); }

.fsrs-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }
.f-chip {
  font-family: var(--mono); font-size: var(--fs-kbd); color: var(--muted);
  background: var(--canvas); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 3px 9px;
}
.f-chip b { color: var(--body-ink); font-weight: 600; }
.f-chip.dashed { border-style: dashed; }

.reveal-row { margin-top: 18px; }
.reveal-kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 10px; }

.grades {
  display: flex; gap: 10px; width: var(--study-col);
  opacity: .35; pointer-events: none; transition: opacity .2s;
}
.grades.armed { opacity: 1; pointer-events: auto; }
.grade {
  flex: 1; font-family: var(--sans); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 12px 6px 10px;
  cursor: pointer; text-align: center;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-base);
}
.grade .g-name { font-weight: 800; font-size: 14px; display: block; color: var(--on-accent); }
.grade .g-meta { font-family: var(--mono); font-size: 10px; color: rgba(255,255,255,.8); display: block; margin-top: 4px; }
.grade.again { background: var(--orange); }
.grade.hard { background: var(--marker); }
.grade.hard .g-name { color: var(--on-marker); }
.grade.hard .g-meta { color: rgba(35,37,29,.65); }
.grade.good { background: var(--green); }
.grade.easy { background: var(--teal); }
.grade:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-hover); filter: saturate(1.15); }
.grade:active { transform: translate(1px, 1px); box-shadow: var(--shadow-press); }

.study-footer {
  display: flex; justify-content: center; align-items: center; gap: 22px;
  padding: 14px var(--sp-5); border-top: var(--bw) solid var(--line-hard);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.study-footer b {
  color: var(--body-ink); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-chip); padding: 1px 7px; font-weight: 500;
}
.study-footer .wink { margin-left: 8px; font-style: italic; }

.done { display: none; flex-direction: column; align-items: center; gap: 14px; text-align: center; max-width: 460px; }
.done.show { display: flex; }
.done .hog-big { font-size: 46px; }
.done h2 { font-weight: 800; font-size: var(--fs-done); letter-spacing: -.02em; color: var(--ink); }
.done h2 em { font-style: normal; background: linear-gradient(transparent 55%, var(--marker-hi) 55%); padding: 0 3px; }
.done p { font-size: 14.5px; line-height: 1.6; }
.done .stat-line {
  font-family: var(--mono); font-size: var(--fs-chip); color: var(--body-ink);
  background: var(--card); border: var(--bw) solid var(--line-hard);
  border-radius: var(--r); box-shadow: var(--shadow-sm); padding: 9px 16px;
}
.done .stat-line b { color: var(--green); font-weight: 600; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; gap: var(--sp-4);
    border-right: 0; border-bottom: var(--bw) solid var(--line-hard); padding: var(--sp-3) var(--sp-4);
  }
  .sidebar .nav-label, .sidebar .spacer { display: none; }
  .nav { flex-direction: row; gap: var(--sp-1); }
}
@media (max-width: 560px) {
  .card { padding: 24px 22px; }
  .q-text { font-size: 20px; }
  .deck-id .deck-name { display: none; }
  /* grade buttons stay large + thumb-reachable; min tap target 44px */
  .grade { padding: 16px 6px; }
}

/* ── Reduced motion (PRD NFR-4) ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .fill { transition: none !important; }
}
