/* clar.tax · Der Stapel: Kartendeck und Platten
 * Abgeleitet aus lavern.ai (site/index.html, Zeilen 1617–2021), Apache-2.0,
 * Copyright (c) 2025-2026 Antti Innanen. Für clar.tax angepasst, siehe NOTICE. */

/* ═══════════════════════════════════════════════════════════════════
   THE STACK — interactive deck of cards (Apple-grade)
   Real slab photographs as the drawn card faces. 3D mouse parallax
   on the stack. Auto-cycling demo when idle. Cinematic weighted
   physics on the card-from-deck animation. Ambient warm glow that
   breathes behind the whole composition.
   ═══════════════════════════════════════════════════════════════════ */
.codex-head{margin:0 auto clamp(56px,7vw,96px);max-width:840px;text-align:center}
.codex-deck-line{
  font-family:var(--sans);font-size:clamp(16px,1.5vw,20px);
  font-weight:400;color:var(--muted);
  max-width:560px;line-height:1.55;margin:24px auto 0
}

.codex-stage{
  display:grid;
  grid-template-columns:300px 1fr;
  gap:64px;
  max-width:1320px;
  margin:0 auto;
  padding:0 32px;
  align-items:center;
  position:relative;
  /* Scroll-choreographed — same vocabulary as .feature and .hero-imac.
     JS rAF handler writes --so, --ss, --sy so the whole Stack scales
     in/out and floats as it approaches the viewport centre. */
  opacity:var(--so, 1);
  transform:scale(var(--ss, .9)) translateY(var(--sy, 30px));
  transition:opacity .55s var(--ease)
}
@media(max-width:1080px){
  .codex-stage{grid-template-columns:240px 1fr;gap:40px}
}
@media(max-width:860px){
  .codex-stage{grid-template-columns:1fr;gap:40px;padding:0 20px}
}

/* — DECK — seven cards stacked vertically, Apple-class elevation */
.codex-deck{display:flex;flex-direction:column;gap:10px;position:relative}
.codex-deck-card{
  position:relative;display:flex;align-items:center;gap:14px;
  width:100%;padding:16px 22px;
  background:var(--surface-2);border:1px solid var(--hair);
  border-radius:16px;cursor:pointer;text-align:left;
  font-family:var(--sans);color:var(--text);
  box-shadow:
    0 1px 2px rgba(20,19,16,0.04),
    0 2px 6px rgba(20,19,16,0.06),
    0 6px 18px rgba(20,19,16,0.05);
  transition:
    transform .5s cubic-bezier(0.2,0.9,0.3,1.15),
    box-shadow .45s var(--ease),
    background .3s var(--ease),
    border-color .3s var(--ease),
    color .3s var(--ease);
  transform-origin:left center;
  overflow:hidden
}
/* Top edge highlight — gives the card real "edge" depth */
.codex-deck-card::before{
  content:'';position:absolute;top:0;left:8px;right:8px;height:1px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,0.85) 50%,transparent);
  pointer-events:none
}
.codex-deck-card:hover{
  transform:translateX(10px) translateY(-2px) rotateZ(-0.3deg);
  border-color:var(--hair-strong);
  box-shadow:
    0 3px 6px rgba(20,19,16,0.08),
    0 10px 24px rgba(20,19,16,0.12),
    0 24px 48px rgba(20,19,16,0.10)
}
/* Card .label gets a tiny horizontal slide on hover so the text feels live */
.codex-deck-card .label{transition:transform .35s var(--ease)}
.codex-deck-card:hover .label{transform:translateX(2px)}
.codex-deck-card.active .label{transform:translateX(0)}
.codex-deck-card.active{
  background:var(--text);color:var(--bg);
  border-color:var(--text);
  transform:translateX(18px) translateY(-3px) scale(1.025);
  box-shadow:
    0 6px 12px rgba(20,19,16,0.18),
    0 18px 36px rgba(20,19,16,0.22),
    0 36px 72px rgba(20,19,16,0.16);
  /* Subtle continuous breath on the active deck card too */
  animation:deckCardBreath 3.6s ease-in-out infinite
}
@keyframes deckCardBreath{
  0%,100%{box-shadow:
    0 6px 12px rgba(20,19,16,0.18),
    0 18px 36px rgba(20,19,16,0.22),
    0 36px 72px rgba(20,19,16,0.16),
    0 0 0 0 rgba(20,19,16,0.18)}
  50%{box-shadow:
    0 6px 12px rgba(20,19,16,0.18),
    0 22px 44px rgba(20,19,16,0.26),
    0 44px 88px rgba(20,19,16,0.18),
    0 0 0 8px rgba(20,19,16,0)}
}
/* Click pop — a quick 1.04 scale spike then settle */
.codex-deck-card.clicked{
  animation:deckCardPop .35s var(--ease)
}
@keyframes deckCardPop{
  0%   {transform:translateX(18px) translateY(-3px) scale(1.025)}
  40%  {transform:translateX(22px) translateY(-5px) scale(1.05)}
  100% {transform:translateX(18px) translateY(-3px) scale(1.025)}
}
/* Active card — a thin glowing accent on the right edge,
   like a deck-card edition stamp */
.codex-deck-card.active::after{
  content:'';position:absolute;right:-1px;top:22%;bottom:22%;
  width:3px;background:var(--bg);border-radius:2px;
  box-shadow:0 0 14px rgba(250,248,240,0.5)
}
.codex-deck-card .num{
  font-family:var(--mono);font-size:10px;font-weight:500;
  letter-spacing:1.8px;color:var(--muted);
  flex:none;width:24px;transition:color .25s var(--ease)
}
.codex-deck-card.active .num{color:rgba(250,248,240,0.7)}
.codex-deck-card .label{
  font-family:var(--sans);font-size:16px;font-weight:500;
  letter-spacing:-0.012em;line-height:1.1
}

/* Deck "auto-cycle" progress strip — sits below the deck, hairline,
   fills 0→100% over the auto-cycle interval to telegraph that the
   carousel is alive */
.codex-deck-progress{
  margin-top:14px;height:2px;width:100%;
  background:var(--hair);border-radius:1px;overflow:hidden;
  opacity:0;transition:opacity .35s var(--ease)
}
.codex-stage.auto-cycling .codex-deck-progress{opacity:1}
.codex-deck-progress-bar{
  display:block;height:100%;width:0;background:var(--text);
  border-radius:1px;transform-origin:left
}
.codex-stage.auto-cycling .codex-deck-progress-bar{
  animation:deckProgress 4.6s linear infinite
}
@keyframes deckProgress{
  0%{width:0}
  96%{width:100%}
  100%{width:100%;opacity:0}
}

/* — STACK WRAP — 3D perspective container with ambient warm halo */
.codex-stack-wrap{
  position:relative;width:100%;
  aspect-ratio:1500/1000;
  perspective:1600px;
  perspective-origin:50% 38%;
  isolation:isolate
}
/* Ambient warm halo behind everything — continuously breathing */
.codex-stack-wrap::before{
  content:'';position:absolute;inset:-12%;
  background:radial-gradient(
    ellipse 65% 50% at 50% 58%,
    rgba(255,232,195,0.45) 0%,
    rgba(255,220,170,0.22) 38%,
    rgba(250,248,240,0) 78%);
  filter:blur(48px);
  z-index:-1;pointer-events:none;
  animation:stackHalo 7.5s ease-in-out infinite alternate
}
@keyframes stackHalo{
  0%,100%{opacity:.7;transform:scale(1)}
  50%{opacity:1;transform:scale(1.06)}
}
.codex-stack-img{
  width:100%;height:auto;display:block;
  transform-style:preserve-3d;
  transform:rotateY(0) rotateX(0);
  transition:
    transform .9s cubic-bezier(0.2,0.8,0.3,1),
    filter .45s var(--ease),
    opacity .45s var(--ease);
  will-change:transform;
  animation:stackIdleBreath 9s ease-in-out infinite alternate
}
@keyframes stackIdleBreath{
  0%,100%{filter:brightness(1) saturate(1)}
  50%{filter:brightness(1.04) saturate(1.06)}
}
/* Pause the idle breath while the user is parallaxing or a slab is drawn */
.codex-stack-wrap.parallax .codex-stack-img,
.codex-stack-wrap.has-active .codex-stack-img{animation:none}
/* Tracking mouse — JS writes inline rotateY/X for parallax */
.codex-stack-wrap.parallax .codex-stack-img{
  transition:transform .12s linear, filter .45s var(--ease)
}
/* When a slab is drawn, dim the underlying stack so the card pops */
.codex-stack-wrap.has-active .codex-stack-img{
  filter:brightness(.88) saturate(.88);
  opacity:.78
}
/* Floor reflection beneath the stack — grounds the 3D-perspective stack
   on the page. Subtle by design so it sits behind the warm halo. */
.codex-stack-wrap::after{
  content:'';position:absolute;left:14%;right:14%;bottom:-18px;height:54px;
  background:radial-gradient(ellipse at 50% 0%,
    rgba(20,19,16,0.32) 0%,
    rgba(20,19,16,0.16) 30%,
    rgba(20,19,16,0.06) 55%,
    rgba(20,19,16,0) 78%);
  filter:blur(10px);
  pointer-events:none;z-index:-1;
  opacity:.78
}

/* — SLAB — uses the actual photographed slab as background, then
   overlays the principle's content on top. Weighted physics on
   the draw: starts tucked, tilted, blurred. Lands flat with a
   soft heavy shadow that suggests real mass. */
.codex-slab{
  position:absolute;
  top:50%;left:50%;
  width:80%;
  aspect-ratio:1.6/1;
  background-image:url('/img/stack-slab-a.png');
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  /* Initial state: tucked deep inside the stack */
  transform:
    translate(-50%,-12%)
    scale(.36)
    rotateZ(-15deg)
    rotateX(38deg);
  opacity:0;pointer-events:none;
  transition:
    transform 1.0s cubic-bezier(0.32,0.94,0.28,1.05),
    opacity .65s var(--ease),
    filter .65s var(--ease),
    box-shadow .65s var(--ease);
  filter:brightness(.72) blur(2px);
  transform-style:preserve-3d;
  border-radius:22px;
  z-index:1;
  display:flex;flex-direction:column;justify-content:center;
  align-items:flex-start;
  padding:8% 10% 9% 10%;
  gap:14px
}
/* Alternate slab photo on every other card for visual variety */
.codex-slab[data-i="1"],
.codex-slab[data-i="3"],
.codex-slab[data-i="5"]{
  background-image:url('/img/stack-slab-b.png')
}
/* Subtle white wash UNDER the text content so it stays legible
   against the translucent slab photo */
.codex-slab::before{
  content:'';position:absolute;inset:3.5% 4.5%;border-radius:18px;
  background:linear-gradient(180deg,
    rgba(252,250,244,0.62) 0%,
    rgba(252,250,244,0.82) 40%,
    rgba(252,250,244,0.88) 100%);
  backdrop-filter:blur(5px) saturate(1.06);
  -webkit-backdrop-filter:blur(5px) saturate(1.06);
  z-index:0;pointer-events:none
}
/* Shimmer-wipe — a diagonal highlight sweeps across the slab once,
   as the card draws out. Apple-page glint. */
.codex-slab .codex-slab-glint{
  position:absolute;inset:3.5% 4.5%;border-radius:18px;
  background:linear-gradient(105deg,
    transparent 38%,
    rgba(255,255,255,0.55) 50%,
    transparent 62%);
  background-size:300% 100%;
  background-position:-150% 0;
  opacity:0;pointer-events:none;z-index:3;
  mix-blend-mode:overlay
}
.codex-slab.active .codex-slab-glint{
  animation:slabGlint 1.4s var(--ease) .55s forwards
}
@keyframes slabGlint{
  0%   {background-position:-150% 0;opacity:0}
  10%  {opacity:1}
  90%  {opacity:1}
  100% {background-position:150% 0;opacity:0}
}
.codex-slab > *{position:relative;z-index:1}

/* Tucked-in start position varies by index — each slab is hiding in the
   y-region of the stack photo where its real slab actually lives. Card 0
   (Architecture, bottom of stack) starts lower; card 6 (Open Source,
   top of stack) starts higher. They all DRAW OUT to the same forward
   position so the focal point is consistent. */
.codex-slab[data-i="0"]{transform:translate(-50%,38%)   scale(.36) rotateZ(-14deg) rotateX(38deg)}
.codex-slab[data-i="1"]{transform:translate(-50%,26%)   scale(.36) rotateZ(-12deg) rotateX(35deg)}
.codex-slab[data-i="2"]{transform:translate(-50%,14%)   scale(.36) rotateZ(-15deg) rotateX(34deg)}
.codex-slab[data-i="3"]{transform:translate(-50%,2%)    scale(.36) rotateZ(-13deg) rotateX(33deg)}
.codex-slab[data-i="4"]{transform:translate(-50%,-10%)  scale(.36) rotateZ(-16deg) rotateX(32deg)}
.codex-slab[data-i="5"]{transform:translate(-50%,-22%)  scale(.36) rotateZ(-14deg) rotateX(31deg)}
.codex-slab[data-i="6"]{transform:translate(-50%,-34%)  scale(.36) rotateZ(-15deg) rotateX(30deg)}

.codex-slab.active{
  transform:
    translate(-50%,-52%)
    scale(1)
    rotateZ(-2.5deg)
    rotateX(0);
  opacity:1;pointer-events:auto;
  filter:brightness(1) blur(0);
  z-index:10;
  box-shadow:
    0 4px 8px rgba(20,19,16,0.10),
    0 28px 64px rgba(20,19,16,0.24),
    0 72px 160px rgba(20,19,16,0.18),
    0 0 140px rgba(255,210,150,0.42);
  /* Subtle continuous "alive" breathing layers on top of the draw transition */
  animation:slabAlive 5.2s ease-in-out 1.1s infinite alternate
}
@keyframes slabAlive{
  0%{transform:translate(-50%,-52%) scale(1) rotateZ(-2.5deg) rotateX(0)}
  100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(-2.2deg) rotateX(0.4deg)}
}
/* Per-slab rotation variety on active — slab N gets its own resting tilt
   (and its own alive-breath keyframes derived from it). */
.codex-slab[data-i="0"].active{animation:slabAlive0 5.2s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(-2.5deg)}
.codex-slab[data-i="1"].active{animation:slabAlive1 5.4s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(2deg)}
.codex-slab[data-i="2"].active{animation:slabAlive2 5.0s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(-1.5deg)}
.codex-slab[data-i="3"].active{animation:slabAlive3 5.6s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(3deg)}
.codex-slab[data-i="4"].active{animation:slabAlive4 4.9s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(-3deg)}
.codex-slab[data-i="5"].active{animation:slabAlive5 5.3s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(1.5deg)}
.codex-slab[data-i="6"].active{animation:slabAlive6 5.1s ease-in-out 1.1s infinite alternate;transform:translate(-50%,-52%) scale(1) rotateZ(-2deg)}
@keyframes slabAlive0{0%{transform:translate(-50%,-52%) scale(1) rotateZ(-2.5deg) rotateX(0)}100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(-2.1deg) rotateX(0.4deg)}}
@keyframes slabAlive1{0%{transform:translate(-50%,-52%) scale(1) rotateZ(2deg) rotateX(0)}   100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(2.4deg) rotateX(0.5deg)}}
@keyframes slabAlive2{0%{transform:translate(-50%,-52%) scale(1) rotateZ(-1.5deg) rotateX(0)}100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(-1.1deg) rotateX(0.4deg)}}
@keyframes slabAlive3{0%{transform:translate(-50%,-52%) scale(1) rotateZ(3deg) rotateX(0)}   100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(3.4deg) rotateX(0.6deg)}}
@keyframes slabAlive4{0%{transform:translate(-50%,-52%) scale(1) rotateZ(-3deg) rotateX(0)}  100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(-2.6deg) rotateX(0.4deg)}}
@keyframes slabAlive5{0%{transform:translate(-50%,-52%) scale(1) rotateZ(1.5deg) rotateX(0)} 100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(1.9deg) rotateX(0.5deg)}}
@keyframes slabAlive6{0%{transform:translate(-50%,-52%) scale(1) rotateZ(-2deg) rotateX(0)}  100%{transform:translate(-50%,-54%) scale(1.006) rotateZ(-1.6deg) rotateX(0.4deg)}}

/* Slab content fade-in after the card lands (~0.4s into the draw) */
.codex-slab > .codex-slab-num,
.codex-slab > .codex-slab-title,
.codex-slab > .codex-slab-body,
.codex-slab > .codex-slab-tag{
  opacity:0;transform:translateY(10px);
  transition:opacity .55s var(--ease), transform .55s var(--ease)
}
.codex-slab.active > .codex-slab-num   {transition-delay:.42s;opacity:1;transform:translateY(0)}
.codex-slab.active > .codex-slab-title {transition-delay:.55s;opacity:1;transform:translateY(0)}
.codex-slab.active > .codex-slab-body  {transition-delay:.70s;opacity:1;transform:translateY(0)}
.codex-slab.active > .codex-slab-tag   {transition-delay:.85s;opacity:1;transform:translateY(0)}

.codex-slab-num{
  font-family:var(--mono);font-size:10px;font-weight:500;
  letter-spacing:1.8px;text-transform:uppercase;color:var(--muted)
}
.codex-slab-title{
  font-family:var(--sans);
  font-size:clamp(22px,2.4vw,32px);font-weight:500;
  line-height:1.08;letter-spacing:-0.025em;color:var(--text);
  max-width:22ch
}
.codex-slab-body{
  font-family:var(--sans);font-size:clamp(13px,1.2vw,16px);
  font-weight:400;line-height:1.5;color:var(--muted);
  max-width:42ch
}
.codex-slab-tag{
  display:inline-flex;align-items:center;
  font-family:var(--mono);font-size:10px;font-weight:500;
  letter-spacing:1.4px;text-transform:uppercase;color:var(--muted);
  padding-top:8px;border-top:1px solid var(--hair-strong);
  max-width:fit-content
}
/* Position indicator pinned to the slab's top-right corner */
.codex-slab-pos{
  position:absolute;top:7%;right:8%;
  font-family:var(--mono);font-size:9px;font-weight:600;
  letter-spacing:2px;color:var(--muted);
  padding:4px 10px;border:1px solid var(--hair-strong);
  border-radius:100px;background:rgba(252,250,244,0.55);
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
  z-index:2
}
.codex-slab-pos strong{color:var(--text);font-weight:600}

@media(max-width:860px){
  .codex-slab{width:88%}
  .codex-slab-title{font-size:18px}
  .codex-slab-body{font-size:12px}
  .codex-slab-tag{font-size:9px}
}

@media(prefers-reduced-motion:reduce){
  .codex-slab,.codex-deck-card,.codex-stack-img,
  .codex-stack-wrap::before,
  .codex-stage.auto-cycling .codex-deck-progress-bar,
  .codex-slab.active,.codex-deck-card.active,
  .codex-slab.active .codex-slab-glint{
    transition:opacity .2s,background .2s,color .2s,border-color .2s;
    animation:none
  }
}
