/* =========================================================================
   VIRTUAL-FICTION — core.css
   Design-Tokens · Reset · Typografie · Layout · Utilities
   Mobile first. Alle Größen fluid (clamp), alle Farben über Custom Properties.
   ========================================================================= */

/* ------------------------------------------------------------------ 01 · Tokens */
:root {
  /* Farbwelt — Dark (Default) */
  --bg:            #08080A;
  --bg-2:          #0C0C10;
  --surface:       #131318;
  --surface-2:     #1A1A21;
  --surface-3:     #222229;

  --text:          #EFECE6;
  --text-dim:      #A6A19A;
  --text-faint:    #6C6862;

  --accent:        #E23E2E;
  --accent-hi:     #FF5A47;
  --accent-ink:    #0A0A0C;
  --sand:          #C9BCA6;

  --line:          rgb(255 255 255 / .10);
  --line-strong:   rgb(255 255 255 / .20);
  --glass:         rgb(16 16 20 / .62);
  --shadow-1:      0 1px 2px rgb(0 0 0 / .4);
  --shadow-2:      0 18px 50px -22px rgb(0 0 0 / .85);
  --shadow-3:      0 40px 90px -40px rgb(0 0 0 / .95);
  --img-bg:        #0C0C0F;

  color-scheme: dark;

  /* Typografie */
  --f-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --f-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --t-xs:   clamp(.69rem, .66rem + .12vw, .75rem);
  --t-sm:   clamp(.8rem,  .77rem + .14vw, .875rem);
  --t-base: clamp(.95rem, .91rem + .2vw,  1.06rem);
  --t-md:   clamp(1.06rem, 1rem + .3vw,   1.25rem);
  --t-lg:   clamp(1.25rem, 1.12rem + .62vw, 1.65rem);
  --t-xl:   clamp(1.65rem, 1.4rem + 1.2vw,  2.5rem);
  --t-2xl:  clamp(2.2rem,  1.7rem + 2.4vw,  4rem);
  --t-3xl:  clamp(2.9rem,  1.9rem + 4.6vw,  6.5rem);
  --t-4xl:  clamp(3.4rem,  1.6rem + 8.2vw,  11rem);

  /* Raster & Abstände */
  --gutter:  clamp(1.15rem, .6rem + 2.6vw, 4rem);
  --maxw:    1560px;
  --measure: 62ch;
  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem;   --sp-7: 3rem;   --sp-8: 4rem;
  --section: clamp(4.5rem, 2.6rem + 8vw, 11rem);

  /* Radien */
  --r-xs: 6px;  --r-sm: 10px; --r-md: 16px;
  --r-lg: 24px; --r-xl: 34px; --r-pill: 999px;

  /* Bewegung */
  --e-out:   cubic-bezier(.22, 1, .36, 1);
  --e-inout: cubic-bezier(.76, 0, .24, 1);
  --e-back:  cubic-bezier(.34, 1.56, .64, 1);
  --d-fast: .18s; --d-med: .38s; --d-slow: .7s;

  /* Layout-Variablen (per JS aktualisiert) */
  --header-h: 68px;
  --scroll: 0;
  --vh: 1vh;
}

@media (min-width: 900px) { :root { --header-h: 84px; } }

/* ------------------------------------------------------- Light Theme */
:root[data-theme="light"] {
  --bg:          #F4F1EC;
  --bg-2:        #EDE9E2;
  --surface:     #FFFFFF;
  --surface-2:   #F6F3EE;
  --surface-3:   #E9E4DB;

  --text:        #14131A;
  --text-dim:    #57534C;
  --text-faint:  #8A857D;

  --accent:      #C62D1E;
  --accent-hi:   #E23E2E;
  --accent-ink:  #FFFFFF;
  --sand:        #8A7A5F;

  --line:        rgb(20 19 26 / .12);
  --line-strong: rgb(20 19 26 / .26);
  --glass:       rgb(244 241 236 / .72);
  --shadow-2:    0 18px 50px -26px rgb(30 25 20 / .35);
  --shadow-3:    0 40px 90px -44px rgb(30 25 20 / .45);
  --img-bg:      #E4DFD6;

  color-scheme: light;
}

/* Animierbare Winkel-Property für Conic-Verläufe */
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@property --beam  { syntax: '<percentage>'; initial-value: 0%; inherits: false; }

/* ------------------------------------------------------------------ 02 · Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-tap-highlight-color: transparent;
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-sans);
  font-size: var(--t-base);
  font-weight: 380;
  line-height: 1.62;
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100svh;
  transition: background-color .5s var(--e-out), color .5s var(--e-out);
}
body.is-locked { overflow: hidden; }

img, svg, video, canvas, picture {
  display: block;
  max-width: 100%;
  height: auto;
}
img { background: var(--img-bg); }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

a { color: inherit; text-decoration: none; }

:where(h1, h2, h3, h4, h5, h6) { text-wrap: balance; font-weight: 400; }
:where(p, li) { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 3px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

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

/* Scrollbar */
@supports (scrollbar-width: thin) {
  html { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: content-box; }

/* ------------------------------------------------------------ 03 · Typografie */
.display {
  font-family: var(--f-display);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.035em;
  text-wrap: balance;
}
/* Hervorhebung ohne Kursive — Space Grotesk hat keinen kursiven Schnitt */
.display em {
  font-style: normal;
  font-weight: 300;
  color: var(--sand);
}

.t-4xl { font-size: var(--t-4xl); }
.t-3xl { font-size: var(--t-3xl); }
.t-2xl { font-size: var(--t-2xl); }
.t-xl  { font-size: var(--t-xl); }
.t-lg  { font-size: var(--t-lg); line-height: 1.34; }
.t-md  { font-size: var(--t-md); line-height: 1.5; }
.t-sm  { font-size: var(--t-sm); }
.t-xs  { font-size: var(--t-xs); }

.lead {
  font-size: var(--t-md);
  line-height: 1.58;
  color: var(--text-dim);
  max-width: var(--measure);
  font-weight: 350;
}

.mono {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 500;
}

.dim   { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.accent{ color: var(--accent); }
.sand  { color: var(--sand); }

/* Kapitel-Marke: 01 — Titel */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .7em;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
}
.eyebrow::before {
  content: "";
  inline-size: clamp(1.4rem, 4vw, 3rem);
  block-size: 1px;
  background: currentColor;
  opacity: .6;
}
.eyebrow.is-accent { color: var(--accent); }

/* Fließtext-Bereiche (Rechtstexte, Journal) */
.prose { max-width: 70ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-family: var(--f-display); font-size: var(--t-xl); margin-top: 2.2em; line-height: 1.06; }
.prose h3 { font-size: var(--t-md); margin-top: 1.8em; font-weight: 500; }
.prose p, .prose li { color: var(--text-dim); }
.prose a { color: var(--text); text-decoration: underline; text-underline-offset: .22em; text-decoration-color: var(--accent); }
.prose a:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: .45em; }
.prose strong { color: var(--text); font-weight: 550; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* Unterstrichener Link mit Wisch-Animation */
.link {
  position: relative;
  display: inline-block;
  padding-bottom: 2px;
}
.link::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  block-size: 1px;
  background: currentColor;
  transform-origin: right;
  transform: scaleX(var(--sx, 1));
  transition: transform .45s var(--e-out);
}
.link:hover::after { --sx: 0; transform-origin: left; animation: link-sweep .55s var(--e-out) forwards; }
@keyframes link-sweep { 0% { transform: scaleX(1); transform-origin: right; } 49% { transform: scaleX(0); transform-origin: right; } 51% { transform: scaleX(0); transform-origin: left; } 100% { transform: scaleX(1); transform-origin: left; } }

/* ---------------------------------------------------------------- 04 · Layout */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap-narrow { max-width: 1080px; }
.wrap-tight  { max-width: 820px; }

.section { padding-block: var(--section); position: relative; }
.section-sm { padding-block: calc(var(--section) * .58); }

.stack > * + * { margin-top: var(--flow, 1.4rem); }

.grid { display: grid; gap: var(--gap, clamp(1rem, 2.4vw, 2rem)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.g-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

.row { display: flex; flex-wrap: wrap; gap: var(--gap, 1rem); align-items: center; }
.row-between { justify-content: space-between; }
.push { margin-inline-start: auto; }

/* Zweispaltiges Kapitel: Titel links (sticky), Inhalt rechts */
.split {
  display: grid;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .split-sticky { position: sticky; top: calc(var(--header-h) + 3rem); }
}

/* Trennlinie mit Laufeffekt */
.rule {
  block-size: 1px;
  border: 0;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.rule::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inline-size: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: rule-run 6s var(--e-inout) infinite;
  opacity: .55;
}
@keyframes rule-run { 0% { transform: translateX(-120%); } 55%, 100% { transform: translateX(430%); } }

/* -------------------------------------------------------------- 05 · Utilities */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  top: .6rem; left: .6rem;
  z-index: 999;
  padding: .7rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-sm);
  transform: translateY(-160%);
  transition: transform .3s var(--e-out);
}
.skip-link:focus { transform: none; }

.center { text-align: center; }
.center .lead, .center .measure { margin-inline: auto; }
.measure { max-width: var(--measure); }
.nowrap { white-space: nowrap; }
.relative { position: relative; }
.overflow-clip { overflow: clip; }
.full-bleed { margin-inline: calc(var(--gutter) * -1); }

.hide-sm { display: none; }
@media (min-width: 720px) { .hide-sm { display: revert; } .only-sm { display: none !important; } }
@media (max-width: 899px) { .hide-md { display: none !important; } }
@media (min-width: 900px) { .only-md { display: none !important; } }

/* Kartenraster mit Container-Queries */
.cq { container-type: inline-size; }

/* Bildrahmen mit konstantem Seitenverhältnis */
.frame {
  position: relative;
  overflow: hidden;
  background: var(--img-bg);
  border-radius: var(--r-md);
  aspect-ratio: var(--ar, 4 / 5);
  isolation: isolate;
}
.frame > img,
.frame > canvas,
.frame > video {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}
.frame-sq { --ar: 1; }
.frame-wide { --ar: 16 / 10; }

/* Filmkorn über der ganzen Seite */
.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes grain-shift {
  0%, 100% { transform: translate(0, 0); }
  17% { transform: translate(-2%, 1%); }
  33% { transform: translate(1%, -2%); }
  50% { transform: translate(-1%, -1%); }
  67% { transform: translate(2%, 1%); }
  83% { transform: translate(1%, 2%); }
}

/* Weicher Farbschimmer als Hintergrund-Akzent */
.aura {
  position: absolute;
  inset-block-start: var(--top, 0);
  inset-inline-start: var(--left, 50%);
  inline-size: var(--size, 60vmax);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in oklab, var(--aura-c, var(--accent)) 34%, transparent) 0%, transparent 64%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
  opacity: var(--aura-o, .5);
}

/* ------------------------------------------------- 06 · Scroll-Reveal (GSAP + CSS-Fallback) */
/* Kein will-change: GSAP setzt es selbst und nimmt es danach wieder zurück.
   Dauerhafte Ebenen für Dutzende Elemente kosten unnötig Speicher. */

/* Fallback, falls JS deaktiviert ist: Inhalte sind sichtbar */
.no-js [data-reveal] { opacity: 1 !important; transform: none !important; }

/* CSS Scroll-Driven Animations als progressive Verbesserung */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .sd-fade {
      animation: sd-fade linear both;
      animation-timeline: view();
      animation-range: entry 8% cover 34%;
    }
    .sd-parallax {
      animation: sd-parallax linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
    .sd-scale {
      animation: sd-scale linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 42%;
    }
  }
}
@keyframes sd-fade     { from { opacity: 0; transform: translateY(38px); } to { opacity: 1; transform: none; } }
@keyframes sd-parallax { from { transform: translateY(var(--pf, 6%)); } to { transform: translateY(calc(var(--pf, 6%) * -1)); } }
@keyframes sd-scale    { from { scale: .93; opacity: .3; } to { scale: 1; opacity: 1; } }

/* Fortschrittsbalken oben (rein per CSS scroll-timeline, JS-Fallback in app.js) */
.scroll-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 2px;
  z-index: 90;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi), var(--sand));
  transform-origin: 0 50%;
  transform: scaleX(var(--scroll, 0));
  pointer-events: none;
}
@supports (animation-timeline: scroll()) {
  .scroll-progress {
    transform: scaleX(0);
    animation: sp-grow linear both;
    animation-timeline: scroll(root block);
  }
}
@keyframes sp-grow { to { transform: scaleX(1); } }

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

/* ------------------------------------------------------------ 08 · Druck */
@media print {
  .site-header, .site-footer, .cursor, .grain, .scroll-progress, .age-gate, .preloader { display: none !important; }
  body { background: #fff; color: #000; }
  .section { padding-block: 1.5rem; }
}
