/* ============================================================
   POLSTER-KLINIK — Design Tokens & Styles
   Leitkonzept: "Die Naht als Rückgrat / Operationssaal für Möbel"
   ============================================================ */

:root {
  /* ---- Light (Standard) ---- */
  --bg:        #F4EFE7;
  --bg-2:      #EBE3D6;
  --surface:   #FBF8F2;
  --ink:       #1A1614;
  --ink-2:     #6B635B;
  --rot:       #E2231A;
  --orange:    #F26B1D;
  --hair:      rgba(26,22,20,0.14);
  --hair-2:    rgba(26,22,20,0.08);
  --shadow:    rgba(40,28,20,0.16);
  --grain:     rgba(26,22,20,0.035);

  /* ---- Type ---- */
  --display: "Clash Display", "Hanken Grotesk", system-ui, sans-serif;
  --body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --mono:    "Space Mono", ui-monospace, monospace;

  /* ---- Scale ---- */
  --step--1: clamp(0.78rem, 0.74rem + 0.15vw, 0.86rem);
  --step-0:  clamp(1rem, 0.95rem + 0.28vw, 1.16rem);
  --step-1:  clamp(1.2rem, 1.05rem + 0.7vw, 1.6rem);
  --step-2:  clamp(1.5rem, 1.2rem + 1.5vw, 2.4rem);
  --step-3:  clamp(2rem, 1.4rem + 3vw, 3.4rem);
  --hero:    clamp(2.6rem, 5vw + 0.8rem, 5.1rem);

  /* ---- Space ---- */
  --s-1: 0.5rem; --s-2: 1rem; --s-3: 1.5rem; --s-4: 2.5rem;
  --s-5: 4rem;   --s-6: 6rem; --s-7: 9rem;

  /* ---- Motion ---- */
  --e-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --e-out:  cubic-bezier(0.22, 0.61, 0.36, 1);
  --e-soft: cubic-bezier(0.4, 0, 0.1, 1);
  --maxw: 1280px;
}

[data-theme="dark"] {
  --bg:        #16110F;
  --bg-2:      #1C1512;
  --surface:   #211A16;
  --ink:       #F4EFE7;
  --ink-2:     #B3A89D;
  --rot:       #FF4438;
  --orange:    #FF8A3D;
  --hair:      rgba(244,239,231,0.16);
  --hair-2:    rgba(244,239,231,0.08);
  --shadow:    rgba(0,0,0,0.5);
  --grain:     rgba(244,239,231,0.03);
}

/* ============================================================ Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.62;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.6s var(--e-soft), color 0.6s var(--e-soft);
  position: relative;
}
body::before {
  /* subtle leather grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    radial-gradient(var(--grain) 1px, transparent 1px),
    radial-gradient(var(--grain) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 4px;
  opacity: 0.9; mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { mix-blend-mode: screen; }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

h1,h2,h3 { font-family: var(--display); font-weight: 600; line-height: 1.02; letter-spacing: -0.02em; }

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

.skip {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--ink); color: var(--bg); padding: .8rem 1.2rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2.5px solid var(--orange); outline-offset: 3px; border-radius: 3px; }

.wrap { width: min(100% - 2.4rem, var(--maxw)); margin-inline: auto; }
.mono { font-family: var(--mono); font-size: var(--step--1); letter-spacing: 0.04em; text-transform: uppercase; }

/* ============================================================ Seam spine (signature) */
#seam-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: visible;
}
#seam-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.seam-thread { fill: none; stroke: var(--orange); stroke-width: 2; opacity: 0.55; }
.seam-stitch {
  fill: none; stroke: var(--rot); stroke-width: 4.5; stroke-linecap: round;
  stroke-dasharray: 13 12;
}
.seam-needle { transition: opacity .3s; }
.seam-needle .nbody { fill: var(--ink); }
.seam-needle .neye  { fill: none; stroke: var(--bg); stroke-width: 1.4; }
.seam-glow { filter: drop-shadow(0 0 10px color-mix(in oklab, var(--orange) 70%, transparent)); }

/* ============================================================ Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.85rem clamp(1.2rem, 4vw, 3rem);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid transparent;
  transition: border-color .4s, background-color .4s, padding .4s var(--e-out);
}
.nav.scrolled { border-bottom-color: var(--hair); padding-top: .6rem; padding-bottom: .6rem; }
.brand { display: flex; align-items: center; gap: .7rem; font-family: var(--display); font-weight: 600; }
.brand img { width: 38px; height: auto; filter: drop-shadow(0 2px 4px var(--shadow)); transition: transform .5s var(--e-expo); }
.brand:hover img { transform: rotate(-6deg) scale(1.06); }
.brand b { font-size: 1.05rem; letter-spacing: -0.01em; }
.brand b span { color: var(--rot); }
.nav-links { display: flex; align-items: center; gap: clamp(1rem, 2.4vw, 2rem); }
.nav-links a.nlink { font-size: var(--step--1); letter-spacing: .02em; font-weight: 500; position: relative; padding: .3rem 0; }
.nav-links a.nlink::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px;
  background: var(--rot); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--e-expo);
}
.nav-links a.nlink:hover::after { transform: scaleX(1); }
@media (max-width: 760px) { .nav-links a.nlink { display: none; } }

.theme-toggle {
  width: 52px; height: 30px; border-radius: 30px; background: var(--bg-2);
  border: 1px solid var(--hair); position: relative; flex: none; transition: background .4s;
}
.theme-toggle .knob {
  position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--rot); display: grid; place-items: center; color: #fff;
  transition: transform .5s var(--e-expo), background .4s;
}
[data-theme="dark"] .theme-toggle .knob { transform: translateX(22px); background: var(--orange); }
.theme-toggle svg { width: 14px; height: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: .55rem; font-weight: 600;
  font-size: var(--step--1); letter-spacing: .01em; padding: .72rem 1.3rem; border-radius: 999px;
  background: var(--ink); color: var(--bg); position: relative; overflow: hidden;
  transition: transform .4s var(--e-expo), box-shadow .4s; min-height: 44px;
}
.btn::before {
  content: ""; position: absolute; inset: 0; background: var(--rot);
  transform: translateY(101%); transition: transform .45s var(--e-expo); z-index: 0;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px var(--shadow); }
.btn:hover::before { transform: translateY(0); }
.btn > * { position: relative; z-index: 1; }
.btn:hover { color: #fff; }
.btn.alt { background: var(--rot); color: #fff; }
.btn.alt::before { background: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--hair); }
.btn.ghost::before { background: var(--ink); }
.btn.ghost:hover { color: var(--bg); border-color: var(--ink); }

/* ============================================================ Hero */
.hero { position: relative; padding: clamp(7rem, 16vh, 11rem) 0 clamp(3rem, 7vh, 6rem); z-index: 2; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(1.5rem, 4vw, 4rem); align-items: center; }
@media (max-width: 920px) { .hero-grid { grid-template-columns: 1fr; } }

.eyebrow { display: inline-flex; align-items: center; gap: .6rem; color: var(--rot); margin-bottom: 1.4rem; }
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rot); box-shadow: 0 0 0 4px color-mix(in oklab, var(--rot) 22%, transparent); }
.hero h1 { font-size: var(--hero); max-width: 14ch; }
.hero h1 .stitched { position: relative; color: var(--rot); white-space: nowrap; }
.hero h1 .stitched::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0.06em; height: 3px;
  background-image: repeating-linear-gradient(90deg, var(--orange) 0 10px, transparent 10px 18px);
  transform: scaleX(0); transform-origin: left; transition: transform 1.1s .5s var(--e-expo);
}
.hero.in h1 .stitched::after { transform: scaleX(1); }
.hero p.lead { font-size: var(--step-1); color: var(--ink-2); max-width: 46ch; margin-top: 1.5rem; line-height: 1.5; text-wrap: pretty; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2.2rem; }
.hero-stats { display: flex; gap: clamp(1.4rem,4vw,2.6rem); margin-top: 2.6rem; flex-wrap: wrap; }
.hero-stats .stat b { font-family: var(--display); font-size: var(--step-2); display: block; line-height: 1; }
.hero-stats .stat span { color: var(--ink-2); font-size: var(--step--1); }
.hero-stats .stat { padding-left: 1rem; border-left: 2px solid var(--rot); }

.hero-media { position: relative; }
.hero-media .frame { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 4/5; box-shadow: 0 30px 60px -20px var(--shadow); }
.hero-media .frame img { width: 100%; height: 100%; object-fit: cover; }
.hero-media .tag {
  position: absolute; left: -14px; bottom: 26px; background: var(--ink); color: var(--bg);
  padding: .6rem .95rem; border-radius: 9px; display: flex; align-items: center; gap: .55rem;
  box-shadow: 0 14px 30px var(--shadow); z-index: 3;
}
.hero-media .tag .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); position: relative; }
.hero-media .tag .pulse::after { content:""; position:absolute; inset:0; border-radius:50%; background: var(--orange); animation: pulse 2.2s var(--e-out) infinite; }
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(3); opacity: 0; } }

/* hide-shape accent behind media */
.hide-accent { position: absolute; z-index: -1; opacity: .9; }

/* ============================================================ Sections */
section { position: relative; z-index: 2; }
.sec { padding: clamp(4rem, 11vh, 8rem) 0; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: clamp(2rem,5vh,3.5rem); }
.sec-head .label { color: var(--rot); display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.sec-head .label::before { content: ""; width: 26px; height: 2px; background: var(--rot); }
.sec-head h2 { font-size: var(--step-3); max-width: 16ch; }
.sec-head p { color: var(--ink-2); max-width: 38ch; }

/* ---- Services ---- */
.services { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--hair); border: 1px solid var(--hair); border-radius: 16px; overflow: hidden; }
.svc {
  background: var(--surface); padding: clamp(1.4rem,2.5vw,2rem); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: .8rem; min-height: 230px;
  transition: background .4s var(--e-out);
}
.svc:nth-child(1), .svc:nth-child(2), .svc:nth-child(3) { grid-column: span 2; }
.svc:nth-child(4) { grid-column: span 3; }
.svc:nth-child(5) { grid-column: span 3; }
@media (max-width: 860px) { .services { grid-template-columns: 1fr 1fr; } .svc, .svc:nth-child(n) { grid-column: span 1 !important; } }
@media (max-width: 520px) { .services { grid-template-columns: 1fr; } }
.svc .num { font-family: var(--mono); font-size: var(--step--1); color: var(--ink-2); }
.svc h3 { font-size: var(--step-1); }
.svc p { color: var(--ink-2); font-size: var(--step--1); margin-top: auto; }
.svc .ico { width: 34px; height: 34px; color: var(--rot); }
.svc::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background-image: repeating-linear-gradient(90deg, var(--orange) 0 9px, transparent 9px 16px);
  transform: scaleX(0); transform-origin: left; transition: transform .55s var(--e-expo);
}
.svc:hover { background: var(--bg-2); }
.svc:hover::after { transform: scaleX(1); }
.svc:hover .ico { transform: rotate(-8deg) scale(1.08); transition: transform .5s var(--e-expo); }

/* ---- Process (clinic metaphor) ---- */
.process { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1.2rem,3vw,2.4rem); }
@media (max-width: 820px) { .process { grid-template-columns: 1fr; } }
.step { position: relative; padding-top: 2rem; }
.step .idx { font-family: var(--display); font-size: clamp(3rem,7vw,5rem); color: transparent; -webkit-text-stroke: 1.5px var(--rot); line-height: .8; opacity: .55; }
.step h3 { font-size: var(--step-1); margin: .8rem 0 .5rem; }
.step .diag { font-family: var(--mono); font-size: var(--step--1); color: var(--orange); display: block; margin-bottom: .9rem; letter-spacing: .04em; }
.step p { color: var(--ink-2); font-size: var(--step--1); }
.step::before { content: ""; position: absolute; top: 0; left: 0; width: 46px; height: 3px; background: var(--rot); }

/* ---- Before/After ---- */
.ba-wrap { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(1.5rem,4vw,3.5rem); align-items: center; }
@media (max-width: 860px) { .ba-wrap { grid-template-columns: 1fr; } }
.ba {
  position: relative; aspect-ratio: 16/11; border-radius: 14px; overflow: hidden; user-select: none;
  box-shadow: 0 24px 50px -22px var(--shadow); cursor: ew-resize; touch-action: none;
}
.ba img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ba .before { filter: grayscale(0.45) brightness(0.82) contrast(0.9) saturate(0.7) sepia(0.12); }
.ba .before-wear {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(140px 110px at 26% 70%, rgba(40,28,16,0.28), transparent 72%),
    radial-gradient(180px 130px at 78% 44%, rgba(30,22,14,0.22), transparent 74%),
    repeating-linear-gradient(98deg, rgba(0,0,0,0.04) 0 3px, transparent 3px 14px),
    linear-gradient(180deg, rgba(0,0,0,0.10), rgba(0,0,0,0.20));
  clip-path: inset(0 0 0 0);
}
.ba .after { clip-path: inset(0 0 0 50%); }
.ba .divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--bg); transform: translateX(-1px); z-index: 4; }
.ba .handle {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 5;
  width: 46px; height: 46px; border-radius: 50%; background: var(--rot); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 18px var(--shadow);
}
.ba .lbl { position: absolute; bottom: 12px; z-index: 4; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; background: color-mix(in oklab, var(--ink) 80%, transparent); color: var(--bg); padding: .3rem .6rem; border-radius: 6px; }
.ba .lbl.l { left: 12px; } .ba .lbl.r { right: 12px; }

/* ---- About strip ---- */
.about { background: var(--surface); border-radius: 18px; border: 1px solid var(--hair); padding: clamp(2rem,5vw,4rem); position: relative; overflow: hidden; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.5rem,4vw,3.5rem); align-items: center; }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }
.about h2 { font-size: var(--step-2); margin-bottom: 1rem; }
.about p { color: var(--ink-2); margin-bottom: 1rem; }
.about .sig { font-family: var(--display); font-size: var(--step-1); color: var(--rot); }
.about .sig small { display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-2); letter-spacing: .05em; }
.material { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.4rem; }
.material span { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: .4rem .7rem; border: 1px solid var(--hair); border-radius: 999px; color: var(--ink-2); }

/* ---- Contact ---- */
.contact { background: var(--ink); color: var(--bg); border-radius: 22px; padding: clamp(2.2rem,5vw,4.5rem); position: relative; overflow: hidden; }
.contact h2 { font-size: var(--step-3); max-width: 16ch; }
.contact p { color: color-mix(in oklab, var(--bg) 72%, transparent); max-width: 40ch; margin-top: 1rem; }
.contact-rows { display: flex; flex-direction: column; gap: 1px; margin-top: 2.4rem; border-top: 1px solid color-mix(in oklab, var(--bg) 18%, transparent); }
.crow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem .2rem; border-bottom: 1px solid color-mix(in oklab, var(--bg) 18%, transparent); transition: padding-left .4s var(--e-expo); }
.crow:hover { padding-left: 1rem; }
.crow .k { font-family: var(--mono); font-size: var(--step--1); color: color-mix(in oklab, var(--bg) 60%, transparent); }
.crow .v { font-family: var(--display); font-size: var(--step-1); display: flex; align-items: center; gap: .6rem; }
.crow .v .arr { color: var(--orange); transition: transform .4s var(--e-expo); }
.crow:hover .v .arr { transform: translateX(5px); }
.contact .glow { position: absolute; width: 480px; height: 480px; border-radius: 50%; background: radial-gradient(circle, color-mix(in oklab, var(--rot) 55%, transparent), transparent 70%); right: -120px; top: -120px; filter: blur(20px); pointer-events: none; }

/* ---- Footer ---- */
.foot { padding: 3.5rem 0 2.5rem; border-top: 1px solid var(--hair); margin-top: 4rem; }
.foot-grid { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.foot .brand img { width: 34px; }
.foot small { color: var(--ink-2); font-size: var(--step--1); }
.foot .speclist { display: flex; gap: .5rem 1.2rem; flex-wrap: wrap; color: var(--ink-2); font-size: var(--step--1); max-width: 520px; }

/* ---- Reveal ---- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s var(--e-expo), transform .9s var(--e-expo); transition-delay: calc(var(--i, 0) * 90ms); }
.reveal.in { opacity: 1; transform: none; }

/* ---- Image fallback (designed, never broken) ---- */
.imgfb {
  width: 100%; height: 100%; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg, var(--grain) 0 2px, transparent 2px 9px),
    linear-gradient(150deg, var(--rot) 0%, color-mix(in oklab, var(--rot) 60%, #000) 55%, var(--ink) 100%);
  display: grid; place-items: center; color: #fff;
}
.imgfb::after { content: ""; position: absolute; inset: 12px; border: 2px dashed rgba(255,255,255,.45); border-radius: 8px; }
.imgfb .fbl { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; text-align: center; padding: 0 1rem; opacity: .92; position: relative; z-index: 2; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .hero h1 .stitched::after, .svc::after { transition: none !important; opacity: 1 !important; transform: none !important; }
  .reveal { transform: none !important; }
  .seam-stitch { stroke-dashoffset: 0 !important; }
  .pulse::after { animation: none !important; }
}

/* ---- Stitch scene (award animation) ---- */
.stitch-scene {
  position: relative; margin: 0; border-radius: 14px; overflow: hidden;
  aspect-ratio: 4/3; box-shadow: 0 28px 56px -22px var(--shadow), inset 0 0 0 1px rgba(0,0,0,0.25);
  background: #3a0f0b;
}
.stitch-scene .ss-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stitch-scene .ss-tag {
  position: absolute; left: 14px; top: 14px; z-index: 4; display: flex; align-items: center; gap: .5rem;
  background: color-mix(in oklab, #1A1614 72%, transparent); color: #F4EFE7;
  padding: .4rem .7rem; border-radius: 7px; font-size: 11px; letter-spacing: .06em; backdrop-filter: blur(4px);
}
.stitch-scene .ss-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 0 color-mix(in oklab, var(--orange) 60%, transparent); animation: ssdot 1.8s var(--e-out) infinite; }
@keyframes ssdot { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--orange) 55%, transparent); } 70%,100% { box-shadow: 0 0 0 9px transparent; } }
.stitch-scene .ss-svg { transition: opacity .55s var(--e-soft); }
.stitch-scene.ss-fade .ss-svg { opacity: 0; }
.stitch-scene #ss-needle { filter: drop-shadow(0 6px 6px rgba(0,0,0,0.45)); }
@media (prefers-reduced-motion: reduce) {
  .stitch-scene .ss-dot { animation: none !important; }
  .stitch-scene.ss-fade .ss-svg { opacity: 1 !important; }
}
