/* ==========================================================================
   BASE: reset, typography, buttons, reveal system, accessibility
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }
* { min-width: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html:not(.js) { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body) / 1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

img, video, canvas, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

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

:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 3px;
  border-radius: 8px;
}
:root[data-scheme="light"] :focus-visible { outline-color: var(--accent); }
section[tabindex="-1"]:focus { outline: none; }

.skip {
  position: fixed;
  left: 16px;
  top: -64px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  transition: top 0.2s;
}
.skip:focus { top: 16px; }

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

.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;
}

/* ---------- Atmosphere ---------- */
.bg-particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
main, .footer { position: relative; z-index: 1; }

@media (min-width: 900px) {
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: var(--r-pill);
  font: 600 0.9375rem / 1 var(--font-body);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition:
    transform 0.45s var(--ease-out),
    box-shadow 0.45s var(--ease-out),
    background-color 0.3s,
    border-color 0.3s,
    color 0.3s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 12px 32px -12px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px -14px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn--glass {
  color: var(--ink);
  background: rgba(var(--glass-tint), 0.35);
  border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.btn--glass:hover { transform: translateY(-2px); border-color: var(--lavender); }
.btn:active { transform: translateY(0) scale(0.98); }

/* ---------- Placeholder content (clearly labelled, editable later) ---------- */
[data-empty] { color: var(--ink-3); }
[data-empty]::before {
  content: "Placeholder";
  display: inline-block;
  margin-right: 10px;
  padding: 2px 9px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-pill);
  font: 600 0.75rem / 1.5 var(--font-body);
  color: var(--ink-3);
  vertical-align: 2px;
}

/* ---------- Reveal system ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.9s var(--ease-out) calc(var(--i, 0) * 90ms),
    transform 1.05s var(--ease-out) calc(var(--i, 0) * 90ms);
}
.js [data-reveal][data-from="above"] { transform: translateY(-26px); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

.js [data-enter] { opacity: 0; transform: translateY(18px); }
.is-ready [data-enter] {
  opacity: 1;
  transform: none;
  transition:
    opacity 1s var(--ease-out) var(--d, 0s),
    transform 1.15s var(--ease-out) var(--d, 0s);
}

/* ---------- Theme switching ---------- */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 1; }

.theme-anim,
.theme-anim *,
.theme-anim *::before,
.theme-anim *::after {
  transition: background-color 0.55s var(--ease-io), color 0.55s var(--ease-io),
    border-color 0.55s var(--ease-io), fill 0.55s var(--ease-io) !important;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .js [data-reveal], .js [data-enter] { opacity: 1; transform: none; }
}
