@layer reset, tokens, base, layout, components;

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  img { display: block; max-width: 100%; }
}

@layer tokens {
  :root {
    --color-parchment: #dacbc2;
    --color-moonstone: #ebe7e4;
    --color-terracotta: #844f3b;
    --color-terracotta-light: #b86b52;
    --color-sunkissed: #e1b06e;
    --color-sage: #a3a473;
    --bg-deep: #0d1116;
    --bg-canvas: #161d27;
    --panel: #212730;
    --line: #495059;
    --text: #ebe7e4;
    --muted: #9fa4ab;
    --pass: #5db87a;
    --fail: #e8704f;
    --serif: "Plantin MT Pro", Plantin, Georgia, "Times New Roman", serif;
    --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  :root[data-theme="light"] {
    --bg-deep: #f3f2f0;
    --bg-canvas: #ebe7e4;
    --panel: #e2ddd8;
    --line: #b9b2aa;
    --text: #25211e;
    --muted: #5c5752;
  }
}

@layer base {
  html { color-scheme: dark; }
  html[data-theme="light"] { color-scheme: light; }
  body {
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--sans);
    font-size: 1.02rem;
    line-height: 1.65;
    transition: background-color 0.35s var(--ease-out), color 0.35s var(--ease-out);
  }
  ::selection { background: var(--color-terracotta-light); color: #13110f; }
  a { color: var(--color-terracotta-light); transition: color 0.2s var(--ease-out); }
  :focus-visible { outline: 2px solid var(--color-sunkissed); outline-offset: 2px; }
  code, pre { font-family: var(--mono); }
  pre {
    background: var(--bg-canvas);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
  }
  p code, li code, td code {
    background: var(--bg-canvas);
    border: 1px solid var(--line);
    border-radius: 0.3rem;
    padding: 0.05rem 0.35rem;
    font-size: 0.85em;
  }
  h1, h2, h3 { line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
  table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }
  th, td { border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; }
  th { background: var(--panel); }
  tbody tr { transition: background-color 0.2s var(--ease-out); }
  tbody tr:hover { background: var(--bg-canvas); }
  header.site, footer.site, pre, .card, th, td, .demo {
    transition: background-color 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
  }
}

@layer layout {
  .wrap { max-width: 54rem; margin: 0 auto; padding: 0 1.2rem 4rem; }
  header.site {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line);
    margin-bottom: 2.5rem;
  }
  header.site nav { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.95rem; }
  header.site nav a { color: var(--muted); text-decoration: none; position: relative; padding-bottom: 0.15rem; }
  header.site nav a::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: var(--color-terracotta-light); border-radius: 2px;
    transform: scaleX(0); transform-origin: left;
    transition: transform 0.25s var(--ease-out);
  }
  header.site nav a:hover::after, header.site nav a[aria-current="page"]::after { transform: scaleX(1); }
  header.site nav a:hover, header.site nav a[aria-current="page"] { color: var(--text); }
  .brand { font-size: 1.3rem; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
  .brand b { color: var(--color-terracotta-light); font-weight: 700; }
  main > * + * { margin-top: 1.2rem; }
  main h1 { font-size: 2.1rem; }
  main h2 { font-size: 1.45rem; margin-top: 2.2rem; }
  footer.site {
    margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line);
    color: var(--muted); font-size: 0.9rem;
  }
}

@layer components {
  @keyframes hero-enter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
  .hero { padding: 2.5rem 0 1rem; animation: hero-enter 0.6s var(--ease-out) both; }
  .hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); max-width: 16ch; letter-spacing: -0.02em; }
  .hero h1 em { color: var(--color-sunkissed); font-style: italic; font-family: var(--serif); }
  .hero p.lede { font-size: 1.2rem; color: var(--muted); max-width: 52ch; }
  .cta-row { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.4rem; }
  .button {
    display: inline-block; padding: 0.6rem 1.2rem; border-radius: 0.5rem;
    background: var(--color-terracotta-light); color: #13110f !important;
    text-decoration: none; font-weight: 700;
    transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out),
      color 0.2s var(--ease-out), transform 0.1s var(--ease-out);
  }
  .button:hover { background: var(--color-sunkissed); }
  .button:active { transform: translateY(1px); }
  .button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text) !important; font-weight: 400; }
  .button.ghost:hover { border-color: var(--color-terracotta-light); background: transparent; }
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1rem; }
  .card { background: var(--bg-canvas); border: 1px solid var(--line); border-radius: 0.6rem; padding: 1.1rem 1.2rem; }
  .card:hover { border-color: var(--color-terracotta-light); }
  .card h3 { font-size: 1.05rem; margin-bottom: 0.4rem; font-family: var(--mono); font-weight: 400; }
  .card p { color: var(--muted); font-size: 0.95rem; }
  .theme-toggle {
    background: transparent; border: 1px solid var(--line); border-radius: 0.4rem;
    color: var(--muted); cursor: pointer; padding: 0.3rem 0.7rem; font-family: var(--mono); font-size: 0.8rem;
    transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
  }
  .theme-toggle:hover { border-color: var(--color-terracotta-light); color: var(--text); }
  .verdict-pass { color: var(--pass); font-weight: 700; }
  .verdict-fail { color: var(--fail); font-weight: 700; }
  .kicker { font-family: var(--mono); font-size: 0.85rem; color: var(--color-sunkissed); }
  .demo { margin-top: 1.6rem; border: 1px solid var(--line); border-radius: 0.6rem; overflow: hidden; background: var(--bg-canvas); }
  .demo-bar { display: flex; gap: 0.45rem; align-items: center; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line); }
  .demo-bar i { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--line); }
  .demo-bar i:first-child { background: var(--color-terracotta-light); }
  .demo img { width: 100%; height: auto; }
  .demo figcaption { padding: 0.6rem 0.9rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); font-family: var(--mono); }

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