/* css/base.css — Reset + Typography + Global Styles */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-base);
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

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

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

a {
  color: var(--accent-green);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--text-primary); }

ul, ol { list-style: none; }

/* Restore list markers inside content areas */
.article-body ul, .article-breakdown ul { list-style: disc; padding-left: 1.5em; }
.article-body ol, .article-breakdown ol { list-style: decimal; padding-left: 1.5em; }
.card ul { list-style: disc; padding-left: 1.5em; }
.card ol { list-style: decimal; padding-left: 1.5em; }

/* Typography */
h1, h2, h3 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-3xl); font-weight: var(--weight-semibold); }
h3 { font-size: var(--text-2xl); font-weight: var(--weight-medium); }
h4 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }

p { max-width: 65ch; }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

::selection {
  background-color: var(--accent-green);
  color: var(--bg-primary);
}

:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* Scroll-reveal */
.reveal,
.reveal--scale,
.reveal--blur {
  opacity: 1;
  transform: none;
  filter: none;
}

html.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
html.js .reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal — scale variant */
html.js .reveal--scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
html.js .reveal--scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* Reveal — blur variant */
html.js .reveal--blur {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(20px);
  transition: opacity var(--duration-slow) var(--ease-out),
              filter var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
html.js .reveal--blur.visible {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

/* Stagger delays for children */
.reveal-stagger > .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger > .reveal:nth-child(2) { transition-delay: 80ms; }
.reveal-stagger > .reveal:nth-child(3) { transition-delay: 160ms; }
.reveal-stagger > .reveal:nth-child(4) { transition-delay: 240ms; }
.reveal-stagger > .reveal:nth-child(5) { transition-delay: 320ms; }
.reveal-stagger > .reveal:nth-child(6) { transition-delay: 400ms; }

/* Fallback: ensure content is visible for crawlers and noscript */
@media print {
  .reveal, .reveal--scale, .reveal--blur {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}

/* Cookie consent banner */
.cookie-banner {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: clamp(12px, 2vw, 20px);
  width: min(720px, calc(100vw - (2 * var(--gutter))));
  z-index: var(--z-overlay);
  background: rgba(14, 14, 18, 0.94);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, calc(100% + 24px));
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}
.cookie-banner--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.cookie-banner__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: none;
  line-height: 1.5;
  margin: 0;
}
.cookie-banner__text a {
  color: var(--accent-green);
  text-decoration: underline;
}
.cookie-banner__actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .cookie-banner {
    width: calc(100vw - 20px);
    flex-direction: column;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    text-align: left;
    padding: var(--space-md);
    transform: translateY(calc(100% + 24px));
  }

  .cookie-banner--visible {
    transform: translateY(0);
  }
}

/* Skip to content */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  background: var(--accent-green);
  color: var(--bg-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  z-index: var(--z-modal);
  font-weight: var(--weight-semibold);
  transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-md);
  color: var(--bg-primary);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
}
