/* Shared tokens, reset and typography for every page. */

@layer reset, tokens, base;

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

  body,
  h1,
  h2,
  h3,
  p,
  figure,
  pre {
    margin: 0;
  }
}

@layer tokens {
  :root {
    color-scheme: light dark;

    /* Each room sets its own hue; every accent derives from it. */
    --hue: 285;

    --bg: light-dark(oklch(98.5% 0.006 90), oklch(17% 0.012 260));
    --surface: light-dark(oklch(100% 0 0), oklch(22% 0.014 260));
    --surface-2: light-dark(oklch(96% 0.008 260), oklch(26% 0.016 260));
    --text: light-dark(oklch(23% 0.02 260), oklch(93% 0.01 90));
    --muted: light-dark(oklch(47% 0.02 260), oklch(72% 0.015 260));
    --line: light-dark(oklch(89% 0.01 260), oklch(33% 0.016 260));
    --accent: light-dark(oklch(52% 0.2 var(--hue)), oklch(78% 0.14 var(--hue)));
    --accent-soft: oklch(from var(--accent) l c h / 0.12);
    --good: light-dark(oklch(50% 0.14 150), oklch(78% 0.14 150));
    --warn: light-dark(oklch(55% 0.14 70), oklch(82% 0.13 80));
    --bad: light-dark(oklch(52% 0.18 25), oklch(75% 0.14 25));

    --font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --radius: 0.75rem;
    --space: 1rem;
    --page: 72rem;
    --measure: 65ch;
  }
}

@layer base {
  html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    interpolate-size: allow-keywords;
  }

  body {
    min-block-size: 100dvh;
    background: var(--bg);
  }

  h1,
  h2,
  h3 {
    line-height: 1.15;
    text-wrap: balance;
  }

  p,
  li {
    text-wrap: pretty;
  }

  a {
    color: var(--accent);
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;

    &:hover {
      text-decoration-thickness: 2px;
    }
  }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  code,
  pre,
  kbd,
  textarea {
    font-family: var(--font-mono);
    font-size: 0.875em;
  }

  :not(pre) > code {
    padding: 0.1em 0.35em;
    border-radius: 0.3em;
    background: var(--surface-2);
    overflow-wrap: anywhere;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
  }

  pre {
    overflow-x: auto;
    padding: 1rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    line-height: 1.5;
    tab-size: 2;
  }

  .wrap {
    inline-size: min(100% - 2rem, var(--page));
    margin-inline: auto;
  }

  .site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1.25rem;
    font-size: 0.9375rem;

    & .logo {
      color: var(--text);
      font-weight: 700;
      text-decoration: none;
      letter-spacing: -0.01em;

      & span {
        color: var(--accent);
      }
    }
  }

  .site-footer {
    margin-block-start: 6rem;
    padding-block: 2rem 3rem;
    border-block-start: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.875rem;
  }

  .visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Page-to-page crossfade: a cross-document view transition, no JS. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}
