/* LearnDen design system — "a warm den after dark" */
@font-face { font-family: 'Fraunces'; src: url('fonts/fraunces-latin.woff2') format('woff2');
  font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('fonts/outfit-latin.woff2') format('woff2');
  font-weight: 300 800; font-display: swap; }

:root {
  --bg: #12151c; --bg2: #191e27; --card: #1e2430; --card2: #242c3a;
  --ink: #edeef2; --ink-soft: #9aa3b5; --line: #2b3342;
  --ks1: #ff9d5c; --ks2: #3fd0bf; --ks3: #8ba3ff; --ks4: #c497f4;
  --accent: var(--ks2);
  --good: #6fd388; --warn: #ffb35c;
  --glow: 0 0 44px;
  --radius: 18px;
  --spring: cubic-bezier(.34, 1.4, .44, 1);
  --shadow: 0 10px 34px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --bg: #f4f1ea; --bg2: #ece8df; --card: #fffdf8; --card2: #f7f4ec;
  --ink: #232832; --ink-soft: #6b7280; --line: #e0dbd0;
  --ks1: #d96f22; --ks2: #0d9488; --ks3: #4f6ae5; --ks4: #8b5cc9;
  --good: #2e9e52; --warn: #d97c1a;
  --shadow: 0 10px 30px rgba(60,50,30,.12);
}
.ks1 { --accent: var(--ks1); } .ks2 { --accent: var(--ks2); }
.ks3 { --accent: var(--ks3); } .ks4 { --accent: var(--ks4); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: 'Outfit', system-ui, sans-serif; font-size: 17px; line-height: 1.55;
  overflow-x: hidden; }
body.easy-read { font-size: 20px; line-height: 1.8; letter-spacing: .01em; }

#bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .55; }
#app { position: relative; z-index: 1; max-width: 780px; margin: 0 auto;
  padding: 1.2rem 1rem 6rem; }

h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 600; }
a { color: var(--accent); }
.soft { color: var(--ink-soft); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .7rem;
  font-weight: 700; color: var(--accent); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .3rem 0 1.1rem; }
.brand { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.25rem;
  color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .45rem; }
.brand .lamp { width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffd9a0, var(--ks1) 58%, transparent 75%);
  box-shadow: 0 0 18px rgba(255,157,92,.55); }
.topbar .actions { display: flex; gap: .45rem; }
.iconbtn { font: inherit; font-size: 1.05rem; width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: transform .25s var(--spring), background .2s; }
.iconbtn:active { transform: scale(.92); }

/* fluid interactive cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.05rem 1.15rem; box-shadow: var(--shadow);
  transition: transform .35s var(--spring), border-color .25s, box-shadow .35s; }
a.card { display: block; color: var(--ink); text-decoration: none; }
.card.tap { cursor: pointer; }
@media (hover: hover) {
  .card.tap:hover { transform: translateY(-3px) scale(1.008); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
}
.card.tap:active { transform: scale(.977); }
.grid { display: grid; gap: .8rem; margin-top: 1rem; }
.grid.cols2 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* the breathing search */
.search-wrap { position: relative; margin: 1.1rem 0 .4rem; }
.search { width: 100%; font: inherit; font-size: 1.12rem; color: var(--ink);
  background: var(--card); border: 2px solid var(--line); border-radius: 20px;
  padding: 1.05rem 1.2rem 1.05rem 3rem; outline: none;
  transition: border-color .3s, box-shadow .5s; }
.search::placeholder { color: var(--ink-soft); }
.search:focus { border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search-wrap::before { content: '🔍'; position: absolute; left: 1.05rem; top: 50%;
  transform: translateY(-50%); font-size: 1.05rem; opacity: .75; }
@keyframes breathe { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 24%, transparent); }
  50% { box-shadow: 0 0 0 9px transparent; } }
.search.breathe:not(:focus) { animation: breathe 3.6s ease-in-out infinite; }

/* chips, pills, ribbons */
.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--card2); color: var(--ink);
  border-radius: 99px; padding: .32rem .8rem; }
.now-ribbon { display: inline-flex; align-items: center; gap: .4rem; font-size: .74rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .09em; color: #171207;
  background: linear-gradient(100deg, #ffd98c, #ffb35c); border-radius: 7px; padding: .18rem .55rem; }
.pill-year { font-weight: 800; font-size: .74rem; letter-spacing: .05em; border-radius: 7px;
  padding: .16rem .55rem; color: var(--bg); background: var(--accent); }

/* subtopic rows */
.sub-row { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.sub-row .name { font-weight: 600; }
.sub-row .meta { font-size: .78rem; color: var(--ink-soft); }
.tick { width: 34px; height: 34px; min-width: 34px; border-radius: 50%; border: 2px solid var(--line);
  background: transparent; color: transparent; font-size: 1rem; cursor: pointer; display: grid;
  place-items: center; transition: all .3s var(--spring); position: relative; }
.tick.on { background: var(--good); border-color: var(--good); color: #0e2413; }
.tick .rip { position: absolute; inset: -2px; border-radius: 50%; pointer-events: none; }
@keyframes ripple { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); }
  to { box-shadow: 0 0 0 26px transparent; } }
.tick.on .rip.go { animation: ripple .7s ease-out; }

/* resource buttons */
.res { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .9rem; }
.res a, .res button { display: inline-flex; align-items: center; gap: .45rem; font: inherit;
  font-size: .92rem; font-weight: 700; text-decoration: none; cursor: pointer;
  border-radius: 13px; padding: .68rem 1rem; min-height: 46px; border: none;
  transition: transform .3s var(--spring), filter .2s; }
.res a:active, .res button:active { transform: scale(.94); }
.res .watch { background: #e2574c22; color: #ff8d80; border: 1.5px solid #e2574c66; }
.res .oak   { background: #4caf7a22; color: #7fd6a4; border: 1.5px solid #4caf7a66; }
.res .bites { background: #4f6ae522; color: #97a8ff; border: 1.5px solid #4f6ae566; }
.res .les   { background: #0d948822; color: #56d0c2; border: 1.5px solid #0d948866; }
.res .cbt   { background: #b7791f22; color: #ffc46b; border: 1.5px solid #b7791f66; }
:root[data-theme="light"] .res .watch { color: #b3362b; }
:root[data-theme="light"] .res .oak   { color: #1d7a4b; }
:root[data-theme="light"] .res .bites { color: #3a52c4; }
:root[data-theme="light"] .res .les   { color: #0b6f66; }
:root[data-theme="light"] .res .cbt   { color: #8f5c12; }

.prereq { margin-top: .8rem; font-size: .9rem; padding: .7rem .9rem; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-left: 3px solid var(--warn); }
.prereq a { color: var(--warn); font-weight: 700; }

/* activity list */
.acts { margin: .6rem 0 0; padding: 0; list-style: none; }
.acts li { padding: .5rem .2rem; border-bottom: 1px solid var(--line); font-size: .95rem; }
.acts li:last-child { border-bottom: none; }

/* term planner */
.term-grid { display: grid; gap: .7rem; margin-top: 1rem; }
.term-cell { border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  padding: .8rem 1rem; }
.term-cell.now { border-color: #ffb35c; background: color-mix(in srgb, #ffb35c 9%, var(--card)); }
.term-cell h3 { display: flex; justify-content: space-between; align-items: baseline; }

/* settings sheet */
.sheet { position: fixed; inset: auto 0 0 0; z-index: 40; background: var(--card);
  border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: none;
  padding: 1.3rem 1.2rem 2rem; max-width: 780px; margin: 0 auto; box-shadow: 0 -18px 60px rgba(0,0,0,.45);
  transform: translateY(105%); transition: transform .45s var(--spring); max-height: 82vh; overflow-y: auto; }
.sheet.open { transform: translateY(0); }
.sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; font-size: .88rem; font-weight: 600; border: none; cursor: pointer;
  background: transparent; color: var(--ink-soft); padding: .5rem .85rem; }
.seg button.on { background: var(--accent); color: var(--bg); }
.overlay { position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.45); opacity: 0;
  pointer-events: none; transition: opacity .3s; }
.overlay.show { opacity: 1; pointer-events: auto; }

/* arcade */
#game-wrap { position: relative; margin-top: 1rem; }
#game { width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
  background: #0d1017; display: block; touch-action: none; }
.score-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-variant-numeric: tabular-nums; }
.score-table td, .score-table th { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; }

.backlink { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-soft);
  text-decoration: none; font-size: .9rem; font-weight: 600; margin-bottom: .8rem; }
.section-label { margin: 1.6rem 0 .6rem; display: flex; align-items: center; gap: .6rem; }
.count-badge { font-size: .72rem; font-weight: 700; color: var(--ink-soft); }

footer { text-align: center; color: var(--ink-soft); font-size: .78rem; margin-top: 3rem; }

/* bottom navigation */
#bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom)); }
#bottomnav a { display: flex; flex-direction: column; align-items: center; gap: .1rem;
  font-size: .68rem; font-weight: 700; color: var(--ink-soft); text-decoration: none;
  padding: .3rem .9rem; border-radius: 12px; min-width: 64px; }
#bottomnav a .ni { font-size: 1.25rem; }
#bottomnav a.on { color: var(--accent); }
#bottomnav a:active { transform: scale(.92); }

/* arcade layout — everything fits one screen */
.arcade-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; flex-wrap: wrap; }
#game { max-height: min(72vh, 820px); width: auto; max-width: 100%; margin: 0 auto; }
#game-wrap { display: flex; justify-content: center; }

/* activity list as tappable links */
.acts li { padding: 0; }
.acts li a { display: flex; gap: .55rem; align-items: baseline; padding: .65rem .4rem;
  color: var(--ink); text-decoration: none; font-size: .95rem; border-radius: 8px; }
.acts li a:active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
@media (hover: hover) { .acts li a:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent); } }

/* view transitions + reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #bg-canvas { display: none; }
}
::view-transition-old(root) { animation: fadeout .18s ease both; }
::view-transition-new(root) { animation: fadein .28s ease both; }
@keyframes fadeout { to { opacity: 0; transform: translateY(-6px); } }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 480px) {
  #app { padding: .9rem .75rem 5rem; }
  .card { padding: .9rem .95rem; }
}
