/*
 * Lecture website — hand-written CSS, no frameworks.
 * Token VALUES are taken from the Lecture app's design system
 * (src/Lecture.Client/wwwroot/css/tokens.css): neutral greys, one indigo
 * accent, subtle borders, small radii, system fonts. Theme follows the
 * system (prefers-color-scheme) with a manual override via data-theme
 * (set before first paint by an inline script + js/site.js).
 */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #ffffff; --bg-sidebar: #f7f7f8; --surface: #ffffff; --surface-hover: #ececef;
  --border: #e6e6ea; --border-strong: #b7b9c1;

  /* Text */
  --text: #1f2023; --text-muted: #666971; --text-faint: #6b6e76;

  /* Accent */
  --accent: #4f5ed5; --accent-hover: #404fc5; --accent-soft: #eef0fe; --on-accent: #ffffff;

  /* Status */
  --danger: #b32630; --danger-soft: #fcebed;
  --warning: #805b0b; --warning-soft: #fff5d6;
  --success: #17753e; --success-soft: #e6f6ec;
  --focus-ring: #5b6cf0;

  /* Callouts (left edge + tinted background) */
  --callout-info: #1f62b8; --callout-info-bg: #e8f1fd;
  --callout-success: #17753e; --callout-success-bg: #e6f6ec;
  --callout-warning: #805b0b; --callout-warning-bg: #fff5d6;
  --callout-danger: #b32630; --callout-danger-bg: #fcebed;

  /* Spacing / radius / type */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 6px; --radius: 8px; --radius-lg: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --text-xs: 12px; --text-sm: 13px; --text-base: 15px; --text-lg: 18px;
  --text-xl: 22px; --text-2xl: 28px;

  /* Controls / elevation */
  --control-sm: 28px;
  --shadow-sm: 0 2px 8px #1f202314; --shadow-lg: 0 16px 48px #1f202326;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #18191c; --bg-sidebar: #1f2024; --surface: #232428; --surface-hover: #2b2c31;
    --border: #2f3036; --border-strong: #555861;
    --text: #ececef; --text-muted: #a1a3aa; --text-faint: #9699a2;
    --accent: #8b97ff; --accent-hover: #a4adff; --accent-soft: #2a2d4a; --on-accent: #18191c;
    --danger: #ff929e; --danger-soft: #3f252b;
    --warning: #efca70; --warning-soft: #393020;
    --success: #4ade80; --success-soft: #1d3326;
    --focus-ring: #8b97ff;
    --callout-info: #7ab4ff; --callout-info-bg: #1d2a3d;
    --callout-success: #4ade80; --callout-success-bg: #1d3326;
    --callout-warning: #efca70; --callout-warning-bg: #393020;
    --callout-danger: #ff929e; --callout-danger-bg: #3f252b;
    --shadow-sm: 0 2px 8px #00000033; --shadow-lg: 0 16px 48px #00000066;
  }
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18191c; --bg-sidebar: #1f2024; --surface: #232428; --surface-hover: #2b2c31;
  --border: #2f3036; --border-strong: #555861;
  --text: #ececef; --text-muted: #a1a3aa; --text-faint: #9699a2;
  --accent: #8b97ff; --accent-hover: #a4adff; --accent-soft: #2a2d4a; --on-accent: #18191c;
  --danger: #ff929e; --danger-soft: #3f252b;
  --warning: #efca70; --warning-soft: #393020;
  --success: #4ade80; --success-soft: #1d3326;
  --focus-ring: #8b97ff;
  --callout-info: #7ab4ff; --callout-info-bg: #1d2a3d;
  --callout-success: #4ade80; --callout-success-bg: #1d3326;
  --callout-warning: #efca70; --callout-warning-bg: #393020;
  --callout-danger: #ff929e; --callout-danger-bg: #3f252b;
  --shadow-sm: 0 2px 8px #00000033; --shadow-lg: 0 16px 48px #00000066;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--space-3); font-weight: 650; }
h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.01em; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.4em; }
li { margin: 0 0 var(--space-2); }
img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
strong { font-weight: 650; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent-soft); }

code, pre, kbd { font-family: var(--font-mono); font-size: 0.9em; }
code {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  overflow-wrap: break-word;
}
pre { margin: 0; overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }

kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: 0 5px;
  background: var(--surface);
}

table { border-collapse: collapse; width: 100%; }

/* ---------- Utilities ---------- */

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 var(--space-5); }
.narrow { max-width: 780px; margin: 0 auto; padding: 0 var(--space-5); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--text-sm); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--space-4); top: -64px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); color: var(--on-accent); }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: var(--space-4);
  min-height: 60px; flex-wrap: wrap;
  padding-top: var(--space-2); padding-bottom: var(--space-2);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none;
  margin-right: auto;
}
.brand:hover { color: var(--text); }
.brand svg { display: block; border-radius: 6px; }

.site-nav { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.site-nav a {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-base);
}
.site-nav a:hover { background: var(--surface-hover); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-sm); height: var(--control-sm);
  padding: 0;
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.theme-toggle svg { display: none; }
.theme-toggle[data-state="light"] .i-sun,
.theme-toggle[data-state="dark"] .i-moon,
.theme-toggle[data-state="system"] .i-auto { display: block; }
.theme-toggle:not([data-state]) .i-auto { display: block; }

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

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit; font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-width: var(--control-sm); height: var(--control-sm);
  padding: 0 var(--space-2);
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font: inherit; font-size: var(--text-sm);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-hover); color: var(--text); }

/* ---------- Page sections ---------- */

.hero { padding: var(--space-8) 0 var(--space-7); }
.hero h1 { max-width: 22ch; }
.hero .lead {
  font-size: var(--text-lg); color: var(--text-muted);
  max-width: 62ch; margin-bottom: var(--space-5);
}
.status-pill {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px;
  padding: 3px var(--space-3);
  font-size: var(--text-sm); font-weight: 550;
  margin-bottom: var(--space-4);
}
.cta-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

section { padding: var(--space-7) 0; }
.section-head { max-width: 68ch; margin-bottom: var(--space-6); }
.section-head h2 { margin-bottom: var(--space-2); }
.section-head p { color: var(--text-muted); margin: 0; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

.feature-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.card p { margin: 0; color: var(--text-muted); }
.card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: var(--space-3);
}
.card-title-link { color: var(--text); text-decoration: none; }
.card-title-link:hover { color: var(--accent); }

/* How it works diagram */
.diagram {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  overflow-x: auto;
}
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram svg.diagram-tall { display: none; }
@media (max-width: 719.98px) {
  .diagram svg.diagram-wide { display: none; }
  .diagram svg.diagram-tall { display: block; width: 300px; max-width: 100%; }
}
.diagram-note { color: var(--text-muted); font-size: var(--text-sm); margin: var(--space-4) 0 0; }

/* Screenshots — wrapping flex so both mockups always stay fully inside the
   content column from 360px up; they only ever shrink, never overflow. */
.shot-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-5);
}
.shot-grid > figure.shot { flex: 1 1 320px; min-width: 0; max-width: 100%; }
.shot-grid > figure.shot-phone { flex: 0 1 240px; }

figure.shot { margin: 0; min-width: 0; }
figure.shot figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm); color: var(--text-muted);
}

.browser-frame {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.frame-bar {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
}
.frame-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.frame-url {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  margin-left: var(--space-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.browser-frame img { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; }

.phone-frame {
  width: min(220px, 100%);
  margin-inline: auto;
  border: 8px solid var(--border-strong);
  border-radius: 28px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.phone-notch {
  height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar);
}
.phone-notch span {
  width: 64px; height: 5px; border-radius: 999px; background: var(--border-strong);
}
/* contain (not cover): the 16:10 placeholder art must never be cropped into
   the 9:19 screen — nothing gets clipped, whatever image goes in here. */
.phone-frame img { aspect-ratio: 9 / 19; width: 100%; max-width: 100%; object-fit: contain; background: var(--bg-sidebar); }

.split { display: grid; gap: var(--space-4); grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

/* ---------- Callouts ---------- */

.note {
  border-left: 4px solid var(--callout-info);
  background: var(--callout-info-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-5);
}
.note-warning { border-left-color: var(--callout-warning); background: var(--callout-warning-bg); }
.note-success { border-left-color: var(--callout-success); background: var(--callout-success-bg); }
.note-danger { border-left-color: var(--callout-danger); background: var(--callout-danger-bg); }
.note > :last-child { margin-bottom: 0; }
.note-title { font-weight: 650; margin-bottom: var(--space-1); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.table-wrap table { font-size: var(--text-sm); min-width: 640px; }
th, td { text-align: left; padding: var(--space-3) var(--space-4); vertical-align: top; }
thead th {
  background: var(--bg-sidebar);
  font-size: var(--text-xs); font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr + tr td { border-top: 1px solid var(--border); }
td .dl-note { display: block; margin-top: var(--space-1); color: var(--text-faint); font-size: var(--text-xs); }

/* ---------- Code snippets ---------- */

.snippet {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sidebar);
  margin: 0 0 var(--space-4);
  overflow: hidden;
}
.snippet-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--text-muted);
}
.snippet pre { padding: var(--space-3) var(--space-4); background: var(--bg); }
.copy-status { font-size: var(--text-xs); color: var(--success); }

/* ---------- Versions page ---------- */

.current-card {
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.current-card .meta { color: var(--text-muted); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.badge {
  display: inline-block;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 2px var(--space-3);
  font-size: var(--text-xs); font-weight: 650;
  vertical-align: middle;
}
.badge-muted { background: var(--bg-sidebar); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: var(--space-8);
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.footer-inner {
  display: grid; gap: var(--space-6);
  grid-template-columns: 2fr 1fr 1fr;
  padding-top: var(--space-7); padding-bottom: var(--space-7);
}
@media (max-width: 760px) { .footer-inner { grid-template-columns: 1fr; gap: var(--space-5); } }
.footer-brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-weight: 700; color: var(--text); text-decoration: none;
  margin-bottom: var(--space-2);
}
.footer-brand svg { border-radius: 5px; }
.site-footer h4 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: var(--space-3); }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin: 0 0 var(--space-2); }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }
.footer-legal { font-size: var(--text-sm); color: var(--text-muted); margin: var(--space-2) 0 0; }

/* ---------- Docs ---------- */

.docs-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: var(--space-7);
  padding-top: var(--space-6);
}
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; gap: var(--space-5); }
}
.docs-sidebar { min-width: 0; }
@media (min-width: 901px) {
  .docs-sidebar { position: sticky; top: 76px; align-self: start; }
}
.docs-nav { display: grid; gap: 2px; }
.docs-nav-title {
  font-size: var(--text-xs); font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint);
  margin: 0 0 var(--space-2);
}
.docs-nav a {
  display: block;
  padding: 5px var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
}
.docs-nav a:hover { background: var(--surface-hover); color: var(--text); }
.docs-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.docs-content { min-width: 0; max-width: 780px; }
.docs-content h2 { margin-top: var(--space-7); padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-xl); }
.docs-content h3 { font-size: var(--text-lg); margin-top: var(--space-6); }
.docs-content .lead { font-size: var(--text-lg); color: var(--text-muted); }
.docs-content .table-wrap { margin-bottom: var(--space-5); }
.docs-content .table-wrap table { min-width: 0; }
.docs-content .snippet pre { white-space: pre; }

.doc-card-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

/* 404 */

.lost { text-align: center; padding: var(--space-8) 0; }
.lost svg { margin: 0 auto var(--space-5); display: block; }
.lost .cta-row { justify-content: center; }

/* ---------- Motion ---------- */

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