/* =====================================================================
   360 AI OCR — document chrome
   The only project-local stylesheet. Everything here is expressed in
   design-system tokens (var(--c-*), var(--sp-*), var(--r*), var(--fs-*))
   so the 360 flavour drives the whole page: swap the theme class on
   <html> and this restyles itself. No raw hex, no raw px scale values.
   Ships in @layer ds.utilities so it sits above the system's own layers
   without specificity fights.
   ===================================================================== */

@layer ds.utilities {

  body {
    background: var(--c-bg);
    color: var(--c-txt);
    font-family: var(--font);
    line-height: var(--lh-prose);
    margin: 0;
  }

  .wrap {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--sp-16) var(--sp-6) var(--sp-16);
  }

  /* ---------------- fixed side chrome ---------------- */

  .side-title {
    position: fixed;
    top: var(--sp-6);
    left: var(--sp-6);
    width: 210px;
    text-decoration: none;
    color: inherit;
    z-index: 10;
  }

  .side-logo {
    display: block;
    width: 88px;
    height: auto;
    margin-bottom: var(--sp-3);
  }

  .side-eyebrow {
    font-size: var(--fs-11);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: var(--fw-semi);
    color: var(--c-accent);
    margin-bottom: var(--sp-1);
  }

  .side-doc-title {
    font-family: var(--font-display);
    font-size: var(--fs-15);
    font-weight: var(--fw-semi);
    letter-spacing: var(--tracking-display);
    color: var(--c-txt);
  }

  .side-nav {
    position: fixed;
    top: 190px;
    left: var(--sp-6);
    width: 210px;
    max-height: 62vh;
    overflow-y: auto;
    z-index: 10;
  }

  .side-nav ul { list-style: none; margin: 0; padding: 0; }

  .side-nav a {
    display: flex;
    gap: var(--sp-2);
    align-items: baseline;
    padding: 6px var(--sp-2);
    border-radius: var(--r-sm);
    border-left: 2px solid transparent;
    color: var(--c-muted);
    font-size: var(--fs-13);
    text-decoration: none;
    transition: var(--t);
  }

  .side-nav a:hover { color: var(--c-txt); background: var(--c-surface-2); }

  .side-nav a.active {
    color: var(--c-txt);
    border-left-color: var(--c-accent);
    background: var(--c-surface-2);
    font-weight: var(--fw-medium);
  }

  .side-nav .num {
    font-family: var(--font-mono);
    font-size: var(--fs-11);
    color: var(--c-accent);
    min-width: 1.1em;
  }

  /* ---------------- header ---------------- */

  header .eyebrow {
    display: inline-block;
    font-size: var(--fs-12);
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: var(--fw-semi);
    color: var(--c-accent);
    margin-bottom: var(--sp-3);
  }

  header h1 {
    font-family: var(--font-display);
    font-size: var(--fs-44);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-display);
    margin: 0 0 var(--sp-4);
    color: var(--c-txt);
  }

  .subtitle {
    font-size: var(--fs-20);
    line-height: 1.5;
    color: var(--c-txt-2);
    margin: 0 0 var(--sp-8);
    max-width: 62ch;
  }

  header::after {
    content: "";
    display: block;
    height: 3px;
    width: 96px;
    border-radius: var(--r-pill);
    background: var(--grad-signature);
    margin-bottom: var(--sp-12);
  }

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

  h2 {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-family: var(--font-display);
    font-size: var(--fs-24);
    letter-spacing: -.01em;
    margin: var(--sp-16) 0 var(--sp-4);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--c-line);
    scroll-margin-top: var(--sp-8);
  }

  h2 .num {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--r-pill);
    background: var(--grad-signature);
    color: var(--c-on-accent);
    font-family: var(--font);
    font-size: var(--fs-13);
    font-weight: var(--fw-semi);
    letter-spacing: 0;
  }

  h3 {
    font-family: var(--font-display);
    font-size: var(--fs-18);
    font-weight: var(--fw-semi);
    margin: var(--sp-8) 0 var(--sp-2);
    color: var(--c-txt);
  }

  p { margin: 0 0 var(--sp-4); }
  strong { font-weight: var(--fw-semi); color: var(--c-txt); }
  a { color: var(--c-accent); text-underline-offset: 2px; }

  ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.35em; }
  li { margin: .35em 0; }

  /* ---------------- tables ---------------- */

  table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 var(--sp-6);
    font-size: var(--fs-14);
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r);
    overflow: hidden;
  }

  th, td {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--c-line);
    vertical-align: top;
  }

  th {
    font-size: var(--fs-12);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: var(--fw-semi);
    color: var(--c-muted);
    background: var(--c-surface-2);
  }

  tbody tr:last-child td { border-bottom: none; }
  td:first-child { font-weight: var(--fw-medium); }

  /* ---------------- code + diagram ---------------- */

  code {
    font-family: var(--font-mono);
    font-size: .89em;
    background: var(--c-surface-2);
    border: 1px solid var(--c-line);
    border-radius: 6px;
    padding: 1px 6px;
  }

  pre {
    font-family: var(--font-mono);
    font-size: var(--fs-13);
    background: var(--c-surface-2);
    border: 1px solid var(--c-line);
    border-radius: var(--r);
    padding: var(--sp-4);
    overflow-x: auto;
    margin: 0 0 var(--sp-6);
  }

  pre code { background: none; border: none; padding: 0; }

  .diagram {
    font-family: var(--font-mono);
    font-size: var(--fs-12);
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
    background: var(--c-surface-2);
    border: 1px solid var(--c-line);
    border-radius: var(--r);
    padding: var(--sp-5);
    margin: 0 0 var(--sp-6);
    color: var(--c-txt-2);
  }

  /* ---------------- GFM alerts ---------------- */

  .alert {
    border: 1px solid var(--c-line);
    border-left: 3px solid var(--tone, var(--c-accent));
    background: var(--c-surface);
    border-radius: var(--r);
    padding: var(--sp-4) var(--sp-5);
    margin: 0 0 var(--sp-6);
    box-shadow: var(--sh-1);
  }

  .alert > :last-child { margin-bottom: 0; }

  .alert-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: var(--fw-semi);
    font-size: var(--fs-14);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--tone, var(--c-accent));
    margin: 0 0 var(--sp-2);
  }

  .alert-icon { flex: none; }
  .alert h3 { margin-top: var(--sp-2); font-size: var(--fs-16); }

  .alert-note      { --tone: var(--c-info); }
  .alert-tip       { --tone: var(--c-good); }
  .alert-important { --tone: var(--c-accent); }
  .alert-warning   { --tone: var(--c-warn); }
  .alert-caution   { --tone: var(--c-danger); }

  /* ---------------- footnote ---------------- */

  .footnote {
    margin-top: var(--sp-16);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--c-line);
    color: var(--c-muted);
    font-size: var(--fs-13);
  }

  /* ---------------- responsive ---------------- */

  @media (max-width: 1220px) {
    .side-nav, .side-title { display: none; }
    .wrap { padding-top: var(--sp-10); }
  }

  @media (max-width: 640px) {
    header h1 { font-size: var(--fs-30); }
    .subtitle { font-size: var(--fs-18); }
    .wrap { padding-inline: var(--sp-4); }
    th, td { padding: var(--sp-2) var(--sp-3); }
  }
}
