/* Layout, header, nav, footer: owned by UI/UX. Mobile first.
   Colours come from the designer's tokens; fallbacks keep it readable until they land. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
img, svg { max-width: 100%; height: auto; }
main { flex: 1 0 auto; width: 100%; max-width: var(--content-width, 64rem); margin: 0 auto; padding: var(--space-5, 1.5rem) var(--space, 1rem) var(--space-6, 3rem); }
main p, main li { max-width: var(--measure, 65ch); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--color-deep, #1f2937); color: var(--color-on-deep, #fff); box-shadow: 0 2px 10px color-mix(in srgb, var(--color-primary) 14%, transparent); }
.brand { display: inline-flex; align-items: center; gap: .75rem; min-height: 44px; padding: .5rem var(--space, 1rem); font-size: 1.25rem; font-weight: 700; color: inherit; text-decoration: none; }
.brand img { display: block; flex: none; }
.site-header a:focus-visible, .nav-toggle:focus-visible { outline: 3px solid var(--color-focus, #ffd166); outline-offset: 2px; }
.site-header nav { border-top: 1px solid rgba(255,255,255,.2); }
.site-header nav ul { list-style: none; margin: 0; padding: 0; }
.site-header nav a { display: flex; align-items: center; min-height: 48px; padding: .5rem var(--space, 1rem); color: inherit; text-decoration: none; font-weight: 600; border-left: 4px solid transparent; }
.site-header nav a:hover { background: rgba(255,255,255,.1); }
.site-header nav a[aria-current="page"] { color: var(--color-gold, #ffd166); border-left-color: var(--color-gold, #ffd166); background: rgba(255,255,255,.08); }

/* Menu button (nav.js adds it) */
.nav-toggle { display: none; align-items: center; gap: .5rem; min-height: 44px; padding: .5rem 1rem; font: inherit; font-weight: 600; color: inherit; background: transparent; border: 2px solid currentColor; border-radius: 6px; cursor: pointer; }
.nav-toggle .bars { width: 18px; height: 12px; background: linear-gradient(currentColor 0 0) 0 0/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 50%/100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 100%/100% 2px no-repeat; }
.js .nav-toggle { display: inline-flex; }
.js .site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-right: var(--space, 1rem); }
.js .site-header nav { flex-basis: 100%; margin-right: calc(-1 * var(--space, 1rem)); }
.js .site-header nav[data-collapsed="true"] { display: none; }

/* Footer */
.site-footer { background: var(--color-deep, #1f2937); border-top: 1px solid var(--color-line, #f0dcc0); color: var(--color-on-deep, #fff); font-size: .925rem; }
.site-footer p { max-width: var(--content-width, 64rem); margin: 0 auto; padding: 1.5rem var(--space, 1rem); }
.site-footer a { color: var(--color-primary-light, #cbd5e1); text-decoration: underline; text-underline-offset: .2em; }

main h1 { font-family: var(--font-display); font-weight: var(--weight-display, 700); font-size: var(--text-2xl, 2rem); line-height: var(--leading-tight, 1.1); margin: 1rem 0 .75rem; }
main h1::after { content: ""; display: block; width: 4rem; height: 6px; margin-top: .75rem; background: var(--gradient-spark, currentColor); border-radius: 3px; }
main h2 { font-family: var(--font-display); font-weight: var(--weight-display, 700); line-height: 1.2; }
main .hero { display: block; width: 100%; border-radius: var(--radius-lg, 24px); box-shadow: var(--shadow-card); margin: 0 0 var(--space-5, 1.75rem); }
main section { margin-top: var(--space-6, 3rem); }
main .card-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 1rem; }
main .card-list li { max-width: none; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: 1.25rem; background: var(--color-mist, #fff1dc); border: 1px solid var(--color-line, #f0dcc0); border-radius: var(--radius-md, 14px); transition: transform .15s ease, box-shadow .15s ease; }
main .card-list img { width: 48px; height: 48px; flex: none; }
main .card-list a { font-family: var(--font-display); font-weight: var(--weight-display, 700); font-size: var(--text-lg, 1.25rem); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) { main .card-list li:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); } }
main a:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; border-radius: 2px; }

@media (min-width: 48rem) {
  .site-header, .js .site-header { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; padding: 0 max(1.5rem, calc((100vw - var(--content-width, 64rem)) / 2 + 1.5rem)); }
  .brand { padding-left: 0; }
  .site-header nav, .js .site-header nav { border-top: 0; flex-basis: auto; margin: 0; }
  .site-header nav ul { display: flex; gap: .25rem; }
  .site-header nav a { min-height: 44px; padding: .5rem .75rem; border-left: 0; border-bottom: 4px solid transparent; border-radius: 6px 6px 0 0; }
  .site-header nav a[aria-current="page"] { border-bottom-color: var(--color-gold, #ffd166); }
  .js .nav-toggle { display: none; }
  .js .site-header nav[data-collapsed="true"] { display: block; }
  main { padding-left: 1.5rem; padding-right: 1.5rem; }
  main .card-list { grid-template-columns: repeat(3, 1fr); }
  main .card-list li { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Tables and code scroll inside themselves, never the page */
main pre, main code { font-family: var(--font-mono, ui-monospace, Menlo, Consolas, monospace); font-size: .92em; }
main pre { max-width: 100%; overflow-x: auto; padding: 1rem; background: var(--color-mist, #f3f4f6); border: 1px solid var(--color-line, #d1d5db); border-radius: var(--radius-sm, 6px); }
.table-scroll { max-width: 100%; margin: 1.25rem 0; overflow-x: auto; }
main table { width: 100%; border-collapse: collapse; font-size: .95rem; }
main th, main td { padding: .6rem .75rem; text-align: left; vertical-align: top; border: 1px solid var(--color-line, #d1d5db); }
main thead th { background: var(--color-mist, #f3f4f6); white-space: nowrap; }
main pre:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 2px; }
