/*
 * Course UI · KARY foundation adapted for a static learning product.
 *
 * The course keeps the kit's visual rules (tokens, dark-first, measured glass,
 * Inter for UI and IBM Plex Serif for display) without requiring a build step yet.
 * This file is intentionally framework-free so the current GitHub Pages deploy
 * remains compatible while the lesson pages are migrated incrementally.
 */
:root {
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: "IBM Plex Serif", Georgia, serif;
  --background: 220 16% 96%;
  --foreground: 220 20% 12%;
  --card: 220 20% 98.5%;
  --card-foreground: 220 20% 12%;
  --popover: 220 18% 98%;
  --primary: 218 78% 46%;
  --primary-foreground: 0 0% 100%;
  --secondary: 220 14% 93%;
  --muted: 220 14% 94%;
  --muted-foreground: 220 11% 39%;
  --accent: 220 14% 93%;
  --border: 220 13% 87%;
  --input: 220 13% 84%;
  --ring: 217 91% 55%;
  --surface: 220 14% 94%;
  --surface-hover: 220 14% 91%;
  --surface-active: 220 14% 88%;
  --accent-brand: 220 11% 39%;
  --accent-green: 152 60% 38%;
  --accent-yellow: 38 92% 50%;
  --accent-red: 0 84% 58%;
  --brand-gradient: hsl(var(--primary));
  --radius: 0.4rem;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0, 0, 0.2, 1);
}

html.dark {
  --background: 220 7% 9%;
  --foreground: 0 0% 98%;
  --card: 220 6% 12%;
  --card-foreground: 0 0% 98%;
  --popover: 222 7% 15%;
  --primary: 217 91% 62%;
  --primary-foreground: 220 8% 10%;
  --secondary: 220 6% 15%;
  --muted: 220 6% 14%;
  --muted-foreground: 220 6% 64%;
  --accent: 220 6% 16%;
  --border: 220 6% 20%;
  --input: 220 6% 24%;
  --ring: 217 91% 62%;
  --surface: 220 6% 12%;
  --surface-hover: 220 6% 16%;
  --surface-active: 220 6% 20%;
  --accent-brand: 220 6% 64%;
  --accent-green: 152 65% 45%;
  --accent-yellow: 38 92% 58%;
  --accent-red: 0 84% 62%;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 180ms var(--ease-standard), color 180ms var(--ease-standard);
}
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 3px solid hsl(var(--ring)); outline-offset: 3px; }
.skip-link {
  position: fixed; left: 1rem; top: -5rem; z-index: 100;
  padding: .65rem .9rem; border-radius: .4rem;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.app-shell { min-height: 100vh; }
.course-sidebar {
  position: fixed; inset: 1rem auto 1rem 1rem; z-index: 20;
  display: flex; flex-direction: column; width: 16.5rem;
  padding: 1.1rem .85rem; border: 1px solid hsl(var(--border));
  border-radius: .5rem; background: hsl(var(--card)); box-shadow: var(--shadow-lg);
}
.brand-lockup { display: flex; align-items: center; gap: .65rem; padding: .25rem .55rem 1.1rem; text-decoration: none; }
.brand-lockup img { width: 2rem; height: 2rem; }
.brand-lockup strong { font-size: .78rem; letter-spacing: .16em; }
.course-name { padding: .85rem .65rem 1.15rem; border-top: 1px solid hsl(var(--border)); }
.course-name small { display: block; color: hsl(var(--muted-foreground)); font-size: .72rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.course-name span { display: block; margin-top: .25rem; font-family: var(--font-display); font-size: 1.12rem; font-weight: 700; line-height: 1.15; }
.side-nav { display: grid; gap: .2rem; }
.side-nav::-webkit-scrollbar { display: none; }
.side-nav { scrollbar-width: none; }
.nav-link { display: flex; align-items: center; gap: .65rem; min-height: 2.55rem; padding: .5rem .65rem; border-radius: .4rem; color: hsl(var(--muted-foreground)); font-size: .86rem; font-weight: 600; text-decoration: none; transition: background-color 120ms var(--ease-standard), color 120ms var(--ease-standard), transform 120ms var(--ease-standard); }
.nav-link:hover { background: hsl(var(--surface-hover)); color: hsl(var(--foreground)); transform: translateX(2px); }
.nav-link[aria-current="page"] { background: hsl(var(--surface-active)); color: hsl(var(--foreground)); }
.nav-link[aria-current="page"]::before { content: ""; width: .2rem; height: 1.25rem; margin-left: -.65rem; border-radius: 6px; background: hsl(var(--accent-brand)); box-shadow: 0 0 12px hsl(var(--accent-brand) / .5); }
.nav-link .nav-mark { width: 1.1rem; height: 1.1rem; flex: none; text-align: center; color: hsl(var(--accent-brand)); }
.session-status[data-state="next"] { color: hsl(var(--accent-brand)); }
.session-card[data-next="true"] { border-color: hsl(var(--accent-brand) / .55); box-shadow: 0 0 0 3px hsl(var(--accent-brand) / .12); }
.sidebar-progress { margin-top: auto; padding: .9rem .65rem .2rem; border-top: 1px solid hsl(var(--border)); }
.sidebar-progress .eyebrow { margin-bottom: .45rem; }
.eyebrow { color: hsl(var(--accent-brand)); font-size: .69rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.side-percent { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .4rem; }
.side-percent strong { font-size: 1.6rem; letter-spacing: -.02em; }
.side-percent span { color: hsl(var(--muted-foreground)); font-size: .75rem; }
.progress-track { height: .42rem; overflow: hidden; border-radius: 6px; background: hsl(var(--surface-active)); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand-gradient); transition: width 260ms var(--ease-standard); }

.app-main { min-height: 100vh; margin-left: 18.75rem; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.7rem; padding: .65rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid hsl(var(--border) / .7); background: hsl(var(--background) / .9); backdrop-filter: blur(16px) saturate(140%); }
.crumb { color: hsl(var(--muted-foreground)); font-size: .84rem; text-decoration: none; }
.crumb:hover { color: hsl(var(--foreground)); }
.top-actions { display: flex; align-items: center; gap: .5rem; }
.topbar .help-link { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.4rem; padding: 0 .75rem; border: 1px solid hsl(var(--border)); border-radius: .4rem; background: hsl(var(--card)); color: hsl(var(--primary)); font-size: .78rem; font-weight: 750; text-decoration: none; white-space: nowrap; transition: border-color 120ms var(--ease-standard); }
.topbar .help-link::before { content: "?"; display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: .7rem; line-height: 1; }
.topbar .help-link:hover { border-color: hsl(var(--primary)); }
.icon-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 1px solid hsl(var(--border)); border-radius: .4rem; background: hsl(var(--card)); cursor: pointer; transition: background-color 120ms var(--ease-standard), border-color 120ms var(--ease-standard), transform 120ms var(--ease-standard); }
.icon-btn:hover { background: hsl(var(--surface-hover)); border-color: hsl(var(--primary)); transform: translateY(-1px); }
.main-content { width: min(100%, 74rem); margin: 0 auto; padding: clamp(2rem, 5vw, 4.8rem) clamp(1rem, 4vw, 3rem) 5rem; }

.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(19rem, .75fr); gap: 2.5rem; align-items: end; }
.hero h1 { max-width: 12ch; margin: .55rem 0 1rem; font-family: var(--font-display); font-size: clamp(2.4rem, 4.6vw, 3.9rem); line-height: 1.08; letter-spacing: -.02em; }
.hero h1 em { color: inherit; font-style: normal; }
.lede { max-width: 62ch; margin: 0; color: hsl(var(--muted-foreground)); font-size: 1.08rem; }
.online-note { display: flex; align-items: flex-start; gap: .55rem; max-width: 62ch; margin: 1rem 0 0; padding: .72rem .85rem; border: 1px solid hsl(var(--primary) / .22); border-radius: .4rem; background: hsl(var(--primary) / .06); color: hsl(var(--foreground)); font-size: .82rem; line-height: 1.5; }
.online-note span { color: hsl(var(--accent-green)); font-size: .7rem; line-height: 1.7; }
.hero-card { padding: 1.35rem; border: 1px solid hsl(var(--border)); border-radius: .5rem; background: hsl(var(--card)); }
.hero-card-label { color: hsl(var(--accent-brand)); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero-card h2 { margin: .45rem 0 .25rem; font-size: 1.22rem; letter-spacing: -.01em; }
.hero-card p { margin: 0 0 1rem; color: hsl(var(--muted-foreground)); font-size: .9rem; }
.primary-btn, .secondary-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; gap: .5rem; padding: .65rem 1rem; border-radius: .4rem; font-weight: 750; text-decoration: none; cursor: pointer; transition: background-color 120ms var(--ease-standard), border-color 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard), transform 120ms var(--ease-standard); }
.primary-btn { border: 1px solid transparent; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: 0 6px 18px hsl(var(--primary) / .2); }
.primary-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 8px 24px hsl(var(--primary) / .3); }
.secondary-btn { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--foreground)); }
.secondary-btn:hover { border-color: hsl(var(--primary)); background: hsl(var(--surface-hover)); transform: translateY(-1px); }
.primary-btn:active, .secondary-btn:active { transform: translateY(1px); }

.section { margin-top: clamp(3rem, 7vw, 5.2rem); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.015em; }
.section-heading p { max-width: 42ch; margin: 0; color: hsl(var(--muted-foreground)); font-size: .88rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.stat { padding: 1rem; border: 1px solid hsl(var(--border)); border-radius: .5rem; background: hsl(var(--card)); }
.stat small { display: block; color: hsl(var(--muted-foreground)); font-size: .75rem; }
.stat strong { display: block; margin-top: .2rem; font-size: 1.7rem; letter-spacing: -.02em; }
.stat span { color: hsl(var(--primary)); font-size: .76rem; font-weight: 600; }
.session-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.session-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: .85rem; align-items: start; min-height: 8.4rem; padding: 1.15rem; border: 1px solid hsl(var(--border)); border-radius: .5rem; background: hsl(var(--card)); text-decoration: none; box-shadow: var(--shadow-xs); transition: border-color 180ms var(--ease-standard), background-color 180ms var(--ease-standard), transform 180ms var(--ease-standard), box-shadow 180ms var(--ease-standard); }
.session-card:hover { border-color: hsl(var(--primary) / .7); background: hsl(var(--surface)); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.session-number { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .4rem; background: hsl(var(--surface-active)); color: hsl(var(--accent-brand)); font-size: .8rem; font-weight: 800; }
.session-card h3 { margin: 0 0 .3rem; font-size: 1.05rem; line-height: 1.15; letter-spacing: -.01em; }
.session-card p { margin: 0; color: hsl(var(--muted-foreground)); font-size: .82rem; line-height: 1.45; }
.session-meta { display: inline-flex; margin-top: .65rem; color: hsl(var(--accent-brand)); font-size: .7rem; font-weight: 750; letter-spacing: .01em; }
.session-status { white-space: nowrap; color: hsl(var(--muted-foreground)); font-size: .73rem; font-weight: 700; }
.session-status[data-state="done"] { color: hsl(var(--accent-green)); }
.session-status[data-state="active"] { color: hsl(var(--primary)); }
.session-progress { grid-column: 2 / -1; align-self: end; height: .3rem; overflow: hidden; border-radius: 6px; background: hsl(var(--surface-active)); }
.session-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: hsl(var(--primary)); transition: width 260ms var(--ease-standard); }
.resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.resource-card { display: flex; align-items: flex-start; gap: .65rem; min-height: 5.3rem; padding: .9rem; border: 1px solid hsl(var(--border)); border-radius: .75rem; background: hsl(var(--card)); text-decoration: none; transition: border-color 120ms var(--ease-standard), background-color 120ms var(--ease-standard); }
.resource-card:hover { border-color: hsl(var(--primary)); background: hsl(var(--surface)); }
.resource-card.teacher-resource { border-color: hsl(var(--accent-brand) / .34); background: hsl(var(--accent-brand) / .045); }
.resource-card.teacher-resource:hover { border-color: hsl(var(--accent-brand)); background: hsl(var(--accent-brand) / .1); }
.resource-icon { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; flex: none; border-radius: .5rem; background: hsl(var(--surface-active)); color: hsl(var(--accent-brand)); font-size: .95rem; }
.resource-card strong { display: block; font-size: .86rem; }
.resource-card span { display: block; margin-top: .15rem; color: hsl(var(--muted-foreground)); font-size: .75rem; line-height: 1.35; }
.progress-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.2rem; align-items: center; padding: 1.25rem; border: 1px solid hsl(var(--border)); border-radius: .5rem; background: hsl(var(--card)); box-shadow: var(--shadow-sm); }
.progress-card p { margin: 0; color: hsl(var(--muted-foreground)); font-size: .88rem; }
.progress-card .button-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.progress-card input[type="file"],
.share-panel input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.progress-message { min-height: 1.4em; margin: .45rem 0 0; color: hsl(var(--accent-green)); font-size: .78rem; font-weight: 700; }
.share-panel { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.25rem; align-items: start; margin-top: .85rem; padding: 1.25rem; border: 1px solid hsl(var(--primary) / .35); border-radius: .5rem; background: hsl(var(--card)); box-shadow: var(--shadow-sm); overflow: hidden; }
.share-panel > * { min-width: 0; }
.share-body { overflow-wrap: anywhere; }
.share-qr { width: 12rem; max-width: 100%; aspect-ratio: 1; padding: .5rem; border-radius: .75rem; background: #fff; display: grid; place-items: center; font-size: .78rem; color: #333; text-align: center; }
.share-qr svg { width: 100%; height: 100%; display: block; }
.share-body strong { display: block; font-size: .95rem; }
.share-body p { margin: .35rem 0 .75rem; color: hsl(var(--muted-foreground)); font-size: .84rem; line-height: 1.5; }
.share-field { display: block; margin-bottom: .75rem; color: hsl(var(--muted-foreground)); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.share-field input { display: block; width: 100%; margin-top: .35rem; padding: .6rem .7rem; border: 1px solid hsl(var(--border)); border-radius: .4rem; background: hsl(var(--background)); color: hsl(var(--foreground)); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .76rem; }
@media (max-width: 640px) { .share-panel { grid-template-columns: 1fr; padding: 1rem; } .share-qr { margin: 0 auto; } .share-panel .button-row > * { flex: 1 1 100%; } }
@media print { .share-panel { display: none !important; } }
.teacher-callout { display: flex; gap: .8rem; padding: 1rem 1.1rem; border: 1px solid hsl(var(--accent-brand) / .3); border-radius: .8rem; background: hsl(var(--accent-brand) / .08); }
.teacher-callout strong { display: block; font-size: .9rem; }
.teacher-callout p { margin: .2rem 0 0; color: hsl(var(--muted-foreground)); font-size: .82rem; }
.teacher-callout a { color: hsl(var(--primary)); font-weight: 700; }
footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid hsl(var(--border)); color: hsl(var(--muted-foreground)); font-size: .78rem; text-align: center; }

@media (max-width: 980px) {
  .course-sidebar { position: static; width: auto; margin: .75rem; padding: .7rem; border-radius: .5rem; }
  .brand-lockup { padding-bottom: .7rem; }
  .course-name { display: none; }
  .side-nav { display: flex; overflow-x: auto; padding: .15rem 0; }
  .nav-link { flex: none; min-height: 2.35rem; }
  .sidebar-progress { display: none; }
  .app-main { margin-left: 0; }
  .hero { grid-template-columns: 1fr; gap: 1.35rem; }
  .hero h1 { max-width: 16ch; }
}
@media (max-width: 640px) {
  .topbar { min-height: 3.25rem; padding-inline: 1rem; }
  .main-content { padding-top: 1.8rem; }
  .hero h1 { font-size: clamp(2.7rem, 15vw, 4.2rem); }
  .section-heading { display: block; }
  .section-heading p { margin-top: .35rem; }
  .stats, .session-grid, .resource-grid { grid-template-columns: 1fr; }
  .session-card { min-height: 7.5rem; }
  .progress-card { grid-template-columns: 1fr; }
  .button-row > * { flex: 1 1 12rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
@media print {
  .course-sidebar, .topbar, .progress-card, .teacher-callout { display: none !important; }
  .app-main { margin-left: 0; }
  body { background: #fff; color: #111; }
  .session-card, .resource-card, .stat { break-inside: avoid; box-shadow: none; }
}
