/* Tutor site styles. Structure and tokens follow the reference site (dossier 07, claims 07-C8 to 07-C17).
   Light and dark token sets, system fonts only, no network requests. Layer order: reset, tokens, base, layout, components, utilities, print. */
@layer reset, tokens, base, layout, components, utilities, print;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, figure, dl, dd, ol, ul, pre, blockquote { margin: 0; }
  img, svg, video { display: block; max-width: 100%; }
  button, input, select { font: inherit; color: inherit; }
  table { border-collapse: collapse; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --border: #e1e5ec;
    --border-strong: #8a94a6;
    --text: #141a26;
    --text-muted: #556074;
    --chrome-accent: #334155;
    --on-chrome: #ffffff;
    --link: #1d4ed8;
    --green: #059669;
    --green-text: #047857;
    --green-strong: #047857;
    --green-soft: #e6f6ef;
    --indigo: #4338ca;
    --indigo-text: #4338ca;
    --indigo-strong: #3730a3;
    --indigo-soft: #eceafd;
    --amber: #b45309;
    --amber-text: #92400e;
    --amber-strong: #92400e;
    --amber-soft: #fdf3e3;
    --on-strong: #ffffff;
    --info: #0369a1;
    --info-soft: #e8f4fb;
    --caution: #b91c1c;
    --caution-soft: #fdeeee;
    --ok: #15803d;
    --ok-soft: #e9f7ee;
    --code-bg: #f3f5f9;
    --code-inline-bg: #eef1f6;
    --code-border: #dde2ea;
    --focus-ring: #2563eb;
    --shadow-1: 0 1px 2px rgb(16 24 40 / .06);
    --shadow-2: 0 8px 24px rgb(16 24 40 / .08);

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --fs-xs: .75rem;
    --fs-sm: .875rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.75rem;
    --fs-3xl: 2.5rem;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
    --space-6: 24px; --space-7: 32px; --space-8: 40px; --space-9: 48px; --space-10: 64px;
    --sidebar-w: 260px;
    --topbar-h: 52px;
    --content-pad: clamp(16px, 3vw, 48px);
  }
  :root[data-theme-effective="dark"] {
    color-scheme: dark;
    --bg: #0b0e14;
    --surface: #12161f;
    --surface-2: #1a202b;
    --border: #263040;
    --border-strong: #6b778c;
    --text: #e7eaf1;
    --text-muted: #9aa4b8;
    --chrome-accent: #cbd5e1;
    --on-chrome: #0b0e14;
    --link: #93b4ff;
    --green: #34d399;
    --green-text: #34d399;
    --green-strong: #6ee7b7;
    --green-soft: #0f2a22;
    --indigo: #a5a0ff;
    --indigo-text: #a5a0ff;
    --indigo-strong: #c4c1ff;
    --indigo-soft: #1d1b3d;
    --amber: #fbbf24;
    --amber-text: #fbbf24;
    --amber-strong: #fcd34d;
    --amber-soft: #2d220c;
    --on-strong: #0b0e14;
    --info: #7dd3fc;
    --info-soft: #0c2533;
    --caution: #fca5a5;
    --caution-soft: #2e1414;
    --ok: #86efac;
    --ok-soft: #0d2617;
    --code-bg: #0e121a;
    --code-inline-bg: #1c2230;
    --code-border: #263040;
    --focus-ring: #93b4ff;
    --shadow-1: none;
    --shadow-2: 0 8px 24px rgb(0 0 0 / .4);
  }
  /* With scripting off the theme script never runs, so follow the system setting directly. */
  @media (prefers-color-scheme: dark) {
    :root:not(.js) {
      color-scheme: dark;
      --bg: #0b0e14;
      --surface: #12161f;
      --surface-2: #1a202b;
      --border: #263040;
      --border-strong: #6b778c;
      --text: #e7eaf1;
      --text-muted: #9aa4b8;
      --chrome-accent: #cbd5e1;
      --on-chrome: #0b0e14;
      --link: #93b4ff;
      --green: #34d399;
      --green-text: #34d399;
      --green-strong: #6ee7b7;
      --green-soft: #0f2a22;
      --indigo: #a5a0ff;
      --indigo-text: #a5a0ff;
      --indigo-strong: #c4c1ff;
      --indigo-soft: #1d1b3d;
      --amber: #fbbf24;
      --amber-text: #fbbf24;
      --amber-strong: #fcd34d;
      --amber-soft: #2d220c;
      --on-strong: #0b0e14;
      --info: #7dd3fc;
      --info-soft: #0c2533;
      --caution: #fca5a5;
      --caution-soft: #2e1414;
      --ok: #86efac;
      --ok-soft: #0d2617;
      --code-bg: #0e121a;
      --code-inline-bg: #1c2230;
      --code-border: #263040;
      --focus-ring: #93b4ff;
      --shadow-1: none;
      --shadow-2: 0 8px 24px rgb(0 0 0 / .4);
    }
  }
}

@layer base {
  @media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
  }
  html { scroll-padding-top: var(--space-6); }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: 1.65;
    overflow-wrap: break-word;
  }
  h1, h2, h3, h4 { color: var(--text); scroll-margin-top: var(--space-6); }
  h1 { font-size: var(--fs-3xl); line-height: 1.1; font-weight: 750; letter-spacing: -.02em; }
  h2 { font-size: var(--fs-xl); line-height: 1.3; font-weight: 650; margin-bottom: var(--space-4); }
  h3 { font-size: var(--fs-lg); line-height: 1.4; font-weight: 600; margin: var(--space-6) 0 var(--space-3); }
  h4 { font-size: var(--fs-md); font-weight: 600; margin: var(--space-4) 0 var(--space-2); }
  p, ul, ol, dl, pre, .table-wrap, figure, .callout, .cards { margin-bottom: var(--space-4); }
  ul, ol { padding-left: 1.4em; }
  li + li { margin-top: var(--space-1); }
  a { color: var(--link); text-underline-offset: 2px; }
  a:hover { text-decoration-thickness: 2px; }
  strong { font-weight: 650; }
  code, kbd, samp, pre { font-family: var(--font-mono); font-size: .9em; }
  :not(pre) > code {
    background: var(--code-inline-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--radius-sm);
    padding: .05em .35em;
    overflow-wrap: anywhere;
  }
  pre {
    background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius-md);
    padding: var(--space-4); overflow-x: auto; line-height: 1.55; font-size: var(--fs-sm); tab-size: 2;
  }
  hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-7) 0; }
  :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
  main:focus, section:focus { outline: none; }
  ::selection { background: color-mix(in srgb, var(--focus-ring) 30%, transparent); }
}

@layer layout {
  .skip-link {
    position: absolute; left: var(--space-3); top: -100px; z-index: 100;
    background: var(--surface); color: var(--text);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
    outline: 2px solid var(--focus-ring); font-weight: 600; text-decoration: none;
  }
  .skip-link:focus { top: var(--space-3); }

  .layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
  .sidebar {
    position: sticky; top: 0; align-self: start;
    height: 100vh; overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 0 var(--space-4) var(--space-6); font-size: var(--fs-sm);
    display: flex; flex-direction: column; gap: var(--space-4);
  }
  main { min-width: 0; padding: var(--space-8) var(--content-pad) var(--space-10); width: 100%; max-width: 1200px; }
  main > section { padding-top: var(--space-6); margin-top: var(--space-6); border-top: 1px solid var(--border); }
  main > section:first-of-type { border-top: 0; margin-top: var(--space-4); }

  .topbar { display: none; }

  @media (max-width: 979.98px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    /* Without scripting the contents stay at the top of the page as a plain list. */
    html:not(.js) .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .js .topbar {
      display: flex; align-items: center; gap: var(--space-3);
      position: sticky; top: 0; z-index: 40;
      height: var(--topbar-h); padding: 0 var(--space-4);
      background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .topbar .topbar-current { color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
    .js .sidebar {
      position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
      width: min(320px, 86vw); height: 100%;
      transform: translateX(-105%); visibility: hidden; box-shadow: var(--shadow-2);
    }
    .js body.nav-open .sidebar { transform: none; visibility: visible; }
    .js body.nav-open { overflow: hidden; }
    .scrim { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); }
    .scrim[hidden] { display: none; }
    html { scroll-padding-top: calc(var(--topbar-h) + var(--space-4)); }
    h1, h2, h3, h4 { scroll-margin-top: calc(var(--topbar-h) + var(--space-4)); }
    main { padding-top: var(--space-6); }
    h1 { font-size: var(--fs-2xl); line-height: 1.2; }
  }
  @media (prefers-reduced-motion: no-preference) {
    .sidebar { transition: transform .2s ease, visibility .2s; }
    body.nav-open .sidebar { transition: transform .2s ease, visibility 0s; }
  }
}

@layer components {
  .brand { display: inline-flex; align-items: center; gap: .45em; font-weight: 750; font-size: var(--fs-lg); letter-spacing: -.01em; text-decoration: none; color: var(--text); }
  .brand::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: var(--green); }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
  .sidebar-head .drawer-close { display: none; }
  /* Same layer as the hide rule above: a rule in an earlier layer would lose to it whatever its specificity. */
  @media (max-width: 979.98px) { .js .sidebar-head .drawer-close { display: inline-flex; } }
  .sidebar-top {
    position: sticky; top: 0; z-index: 3;
    display: flex; flex-direction: column; gap: var(--space-2);
    background: var(--surface); padding: var(--space-5) 0 var(--space-3);
    border-bottom: 1px solid var(--border);
  }
  .course-name { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

  .pill {
    display: inline-flex; align-items: center; gap: .35em;
    padding: 2px 9px; border-radius: var(--radius-pill);
    font-size: var(--fs-xs); font-weight: 650; line-height: 1.5;
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
    white-space: nowrap;
  }
  .pill.green { background: var(--green-strong); border-color: var(--green-strong); color: var(--on-strong); }
  .pill.indigo { background: var(--indigo-strong); border-color: var(--indigo-strong); color: var(--on-strong); }
  .pill.sim { background: var(--amber-strong); border-color: var(--amber-strong); color: var(--on-strong); letter-spacing: .04em; text-transform: uppercase; }

  .toc { list-style: none; padding: 0; margin: 0; }
  .toc li { margin: 0; }
  .toc li + li { margin-top: 2px; }
  .toc a {
    display: flex; align-items: baseline; gap: var(--space-2);
    padding: 5px var(--space-2); border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; border-left: 3px solid transparent;
  }
  .toc a:hover { background: var(--surface-2); }
  .toc .num {
    flex: 0 0 auto; min-width: 1.9em; text-align: center;
    font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
    color: var(--chrome-accent); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 0 4px;
  }
  .toc .tag { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
  .toc a[aria-current="page"] { background: var(--surface-2); border-left-color: var(--chrome-accent); font-weight: 650; }
  .toc a[aria-current="page"] .num { background: var(--chrome-accent); border-color: var(--chrome-accent); color: var(--on-chrome); }

  .theme { display: grid; gap: var(--space-2); margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--border); }
  .theme:empty { display: none; }
  .theme-buttons { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; }
  .theme-buttons button { min-height: 34px; border: 0; background: var(--surface); color: var(--text); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
  .theme-buttons button + button { border-left: 1px solid var(--border-strong); }
  .theme-buttons button:hover { background: var(--surface-2); }
  .theme-buttons button[aria-pressed="true"] { background: var(--chrome-accent); color: var(--on-chrome); }
  .theme-buttons button:focus-visible { outline-offset: -3px; }
  .theme-status { font-size: var(--fs-xs); color: var(--text-muted); margin: 0; }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
    min-height: 36px; padding: 6px 14px; border-radius: var(--radius-md);
    background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
    font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-decoration: none;
  }
  .btn:hover { background: var(--surface-2); }
  .btn.primary { background: var(--chrome-accent); color: var(--on-chrome); border-color: var(--chrome-accent); }
  .btn.primary:hover { filter: brightness(1.1); }
  .btn[disabled] { opacity: .55; cursor: not-allowed; }

  .page-head { margin-bottom: var(--space-6); }
  .eyebrow { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: var(--space-2); }
  .page-head h1 { margin-bottom: var(--space-3); }
  .lede { font-size: var(--fs-lg); color: var(--text-muted); line-height: 1.55; }
  .meta { font-size: var(--fs-sm); color: var(--text-muted); }
  .objectives {
    list-style: none; padding: var(--space-4) var(--space-5); margin-top: var(--space-5);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  }
  .objectives::before { content: "You will learn"; display: block; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: var(--space-2); }
  .objectives li { padding-left: 1.4em; position: relative; }
  .objectives li::before { content: ""; position: absolute; left: .2em; top: .62em; width: .5em; height: .5em; border-radius: 2px; background: var(--chrome-accent); }

  .callout {
    --c: var(--chrome-accent); --c-soft: var(--surface-2);
    background: var(--c-soft); border: 1px solid var(--border); border-left: 4px solid var(--c);
    border-radius: var(--radius-md); padding: var(--space-4) var(--space-5);
  }
  .callout > :last-child { margin-bottom: 0; }
  .callout > .callout-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text); margin-bottom: var(--space-1); }
  .callout.key { --c-soft: var(--surface); box-shadow: var(--shadow-1); }
  .callout.note { --c: var(--info); --c-soft: var(--info-soft); }
  .callout.warn { --c: var(--caution); --c-soft: var(--caution-soft); }
  .callout.lab { --c: var(--green); --c-soft: var(--surface); }
  .callout.voice { --c: var(--amber); --c-soft: var(--amber-soft); }
  .checkpoint { --c: var(--info); background: var(--info-soft); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4); }
  .checkpoint::before { content: "Checkpoint"; display: block; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text); margin-bottom: var(--space-1); }
  .checkpoint > :last-child { margin-bottom: 0; }
  .checkpoint details { margin-top: var(--space-2); }
  .checkpoint details summary { cursor: pointer; font-weight: 600; }

  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: var(--space-4); }
  .card {
    background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--green);
    border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-1); min-width: 0;
    display: flex; flex-direction: column; gap: var(--space-3);
  }
  .card > * { margin: 0; }
  .card h2, .card h3 { margin: 0; font-size: var(--fs-lg); }
  .card .card-foot { margin-top: auto; }

  .table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
  .table-wrap:focus-visible { outline-offset: 2px; }
  table { width: 100%; font-size: var(--fs-sm); line-height: 1.5; }
  caption { caption-side: top; text-align: left; padding: var(--space-3) var(--space-4); font-weight: 650; color: var(--text); border-bottom: 1px solid var(--border); }
  th, td { text-align: left; vertical-align: top; padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); }
  thead th { background: var(--surface-2); font-weight: 650; white-space: nowrap; }
  tbody th[scope="row"] { font-weight: 600; background: var(--surface); }
  tbody tr:last-child > * { border-bottom: 0; }

  dl.terms { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
  dl.terms dt { font-weight: 650; padding: var(--space-3) var(--space-4) 0; }
  dl.terms dd { padding: var(--space-1) var(--space-4) var(--space-3); margin: 0; border-bottom: 1px solid var(--border); }
  dl.terms dd:last-child { border-bottom: 0; }

  .cite { font-size: .72em; line-height: 0; vertical-align: super; margin-left: 1px; }
  .cite a { text-decoration: none; font-weight: 650; padding: 0 1px; }
  .cite a:hover { text-decoration: underline; }
  ol.sources { font-size: var(--fs-sm); }
  ol.sources li { overflow-wrap: anywhere; }

  .video-block { margin: var(--space-5) 0; }
  .video-block video { width: 100%; height: auto; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--border); border-radius: var(--radius-lg); }
  .video-block figcaption { margin-top: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); }
  video::cue { background: rgb(0 0 0 / .78); color: #ffffff; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
  details.transcript { margin-top: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 0 var(--space-4); }
  details.transcript > summary { cursor: pointer; font-weight: 650; padding: var(--space-3) 0; }
  details.transcript[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: var(--space-3); }
  details.transcript ol { list-style: none; padding: 0; margin: 0 0 var(--space-3); }
  details.transcript li { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); gap: var(--space-3); margin: 0; padding: var(--space-2) 0; }
  details.transcript li + li { margin-top: 0; border-top: 1px solid var(--border); }
  details.transcript .seek { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 650; }
  details.transcript li p { margin: 0; }

  .pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-9); padding-top: var(--space-6); border-top: 1px solid var(--border); }
  .pager a {
    display: grid; gap: 2px; padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface);
    color: var(--text); text-decoration: none; min-width: 0;
  }
  .pager a:hover { background: var(--surface-2); }
  .pager .dir { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
  .pager .target { font-weight: 650; color: var(--link); }
  .pager .next { grid-column: 2; text-align: right; }
  @media (max-width: 539.98px) { .pager { grid-template-columns: minmax(0, 1fr); } .pager .next { grid-column: 1; } }

  .site-foot { margin-top: var(--space-7); font-size: var(--fs-xs); color: var(--text-muted); }
}

@layer utilities {
  .sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .muted { color: var(--text-muted); }
  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
  }
}

@layer print {
  @media print {
    :root, :root[data-theme-effective="dark"] {
      color-scheme: light;
      --bg: #ffffff; --surface: #ffffff; --surface-2: #f3f4f6; --border: #cfd4dc; --border-strong: #6b7280;
      --text: #000000; --text-muted: #374151; --chrome-accent: #111827; --on-chrome: #ffffff; --link: #1d4ed8;
    }
    body { font-size: 11pt; }
    .layout { display: block; }
    .sidebar, .topbar, .scrim, .pager, .skip-link { display: none !important; }
    main { padding: 0; max-width: none; }
    .video-block video { display: none; }
    pre, figure, table, .callout, .card, .checkpoint { break-inside: avoid; }
    h2, h3 { break-after: avoid; }
    main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: var(--text-muted); overflow-wrap: anywhere; }
    .cite a::after { content: none !important; }
  }
}
