/**
 * base.css — reset, document surface, typography primitives, helpers.
 */

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

  * {
    margin: 0;
  }

  [hidden] {
    display: none !important;
  }

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    background-color: var(--paper);
  }

  html.is-locked {
    overflow: hidden;
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--paper);
    background-image:
      radial-gradient(130% 55% at 50% -12%, #fffdf7 0%, transparent 62%),
      radial-gradient(70% 42% at 108% 18%, rgb(238 125 31 / 5%) 0%, transparent 70%),
      radial-gradient(62% 38% at -8% 62%, rgb(238 125 31 / 4%) 0%, transparent 72%);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--fs-body);
    font-weight: 400;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* Warm paper grain, above artwork but never interactive. */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
  }

  img,
  svg {
    display: block;
    max-width: 100%;
  }

  img {
    height: auto;
  }

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

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  button {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  h1,
  h2,
  h3 {
    font-weight: 400;
    line-height: 1.2;
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }

  ::selection {
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

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

  main:focus {
    outline: none;
  }

  /* ── Layout primitives ─────────────────────────────────────────── */

  .wrap {
    width: min(var(--content), calc(100% - var(--gutter) * 2));
    margin-inline: auto;
  }

  .sec {
    position: relative;
    overflow: hidden;
    padding-block: var(--section-y);
  }

  .sec + .sec {
    padding-top: calc(var(--section-y) * 0.7);
  }

  /* ── Type primitives ───────────────────────────────────────────── */

  .eyebrow {
    font-family: var(--font-body);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.26em;
    line-height: 1.4;
    text-transform: uppercase;
    color: var(--accent-deep);
  }

  .eyebrow--center {
    text-align: center;
  }

  .icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .dots {
    width: min(18rem, 80%);
    margin: 1.7rem auto;
    border: 0;
    border-top: 1.5px dotted var(--line-strong);
  }

  .sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
  }

  /* ── Accessibility helpers ─────────────────────────────────────── */

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: fixed;
    top: 0.75rem;
    left: 50%;
    z-index: 200;
    translate: -50% -160%;
    padding: 0.65rem 1.1rem;
    border-radius: var(--pill);
    background: var(--ink);
    color: var(--paper);
    font-size: var(--fs-sm);
    text-decoration: none;
    transition: translate var(--dur-fast) var(--ease-out);
  }

  .skip-link:focus-visible {
    translate: -50% 0;
  }

  .noscript {
    position: fixed;
    inset: auto 1rem 1rem;
    z-index: 300;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    font-size: var(--fs-sm);
    text-align: center;
  }

  /* Shown only when index.html is opened over file:// (modules are blocked). */
  .protocol-note {
    display: none;
    width: min(30rem, calc(100vw - 2.5rem));
    margin: 18vh auto;
    padding: clamp(1.2rem, 5vw, 1.6rem);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    text-align: center;
    overflow-wrap: anywhere;
  }

  .protocol-note strong {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 0.04em;
  }

  .protocol-note p {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--ink-soft);
  }

  .protocol-note code {
    padding: 0.1em 0.35em;
    border-radius: 4px;
    background: var(--paper-warm);
    font-size: 0.85em;
  }

  .is-file .cover,
  .is-file .dock,
  .is-file .progress,
  .is-file .petals,
  .is-file .toast {
    display: none;
  }

  .is-file .protocol-note {
    display: block;
  }

  .is-file .invitation {
    display: none;
  }

  .no-js .cover,
  .no-js .dock {
    display: none;
  }

  .no-js main {
    padding-top: 1rem;
  }
}
