/* Gewerk-Stile — gemeinsame Grundlage.
   Jede Gewerkseite legt ihre eigene stil.css darüber. Hier nur, was alle brauchen:
   Schriften, Grundreset, Regler-Mechanik, Rollzähler, Drehregler, Stilwechsler. */

/* ---------- Schriften (alle lokal, OFL) ---------- */
@font-face { font-family: "Big Shoulders"; src: url("schriften/big-shoulders.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("schriften/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("schriften/barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("schriften/unbounded.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("schriften/manrope.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("schriften/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("schriften/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("schriften/bricolage.woff2") format("woff2"); font-weight: 200 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("schriften/archivo.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Young Serif"; src: url("schriften/young-serif.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Karla"; src: url("schriften/karla.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Geist"; src: url("schriften/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("schriften/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("schriften/instrument-serif.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("schriften/instrument-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("schriften/inter-tight.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* ---------- Seitenwechsel zwischen den Gewerken ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 420ms cubic-bezier(.6,0,.2,1) both vt-raus; }
::view-transition-new(root) { animation: 620ms cubic-bezier(.2,.7,.1,1) both vt-rein; }
@keyframes vt-raus { to { opacity: 0; scale: .97; } }
@keyframes vt-rein { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }

/* ---------- Grundreset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; overflow-x: clip; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--fokus, #1f5bff); outline-offset: 3px; }
.nur-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprung { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: .6rem 1rem; background: #fff; color: #000; border-radius: 6px; }
.sprung:focus { top: 1rem; }
.zahl { font-variant-numeric: tabular-nums; }

/* ---------- 3D-Bühne ---------- */
.buehne { position: relative; }
.buehne > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.ohne-3d .buehne > canvas { display: none; }
.buehne-ersatz { display: none; }
.ohne-3d .buehne-ersatz { display: block; position: absolute; inset: 0; }

/* ---------- Schieberegler ----------
   Mechanik für alle; Form, Farbe und Knopf setzt jede Gewerkseite über Variablen:
   --spur, --fuell, --knopf, --knopf-rand, --spur-h, --knopf-g, --knopf-form */
input[type="range"] {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: calc(var(--knopf-g, 22px) + 8px);
  background: transparent; margin: 0; cursor: pointer; touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: var(--spur-h, 6px); border-radius: var(--spur-r, 99px);
  background: linear-gradient(to right, var(--fuell, #1f5bff) var(--p), var(--spur, #d0d5dc) var(--p));
}
input[type="range"]::-moz-range-track {
  height: var(--spur-h, 6px); border-radius: var(--spur-r, 99px);
  background: linear-gradient(to right, var(--fuell, #1f5bff) var(--p), var(--spur, #d0d5dc) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: var(--knopf-g, 22px); height: var(--knopf-g, 22px);
  margin-top: calc((var(--spur-h, 6px) - var(--knopf-g, 22px)) / 2);
  border-radius: var(--knopf-r, 50%); background: var(--knopf, #fff);
  border: var(--knopf-rand, 2px solid currentColor);
  box-shadow: var(--knopf-schatten, 0 2px 6px rgb(0 0 0 / .25));
  transition: transform .18s cubic-bezier(.3,1.6,.5,1);
}
input[type="range"]::-moz-range-thumb {
  width: var(--knopf-g, 22px); height: var(--knopf-g, 22px);
  border-radius: var(--knopf-r, 50%); background: var(--knopf, #fff);
  border: var(--knopf-rand, 2px solid currentColor);
  box-shadow: var(--knopf-schatten, 0 2px 6px rgb(0 0 0 / .25));
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--fokus, #1f5bff); outline-offset: 2px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--fokus, #1f5bff); outline-offset: 2px; }

.regler { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: .15rem 1rem; }
.regler > input[type="range"] { grid-column: 1 / -1; }
.regler > output { font-variant-numeric: tabular-nums; }

/* ---------- Segmentschalter (Auswahl aus wenigen Möglichkeiten) ---------- */
.segmente { display: flex; flex-wrap: wrap; gap: .35rem; }
.segmente > button {
  border: 1px solid currentColor; background: transparent; padding: .45rem .8rem;
  border-radius: var(--seg-r, 99px); line-height: 1.1;
  transition: background-color .2s, color .2s, border-color .2s;
}
.segmente > button[aria-checked="true"] { background: var(--seg-an, currentColor); color: var(--seg-an-text, #fff); border-color: var(--seg-an, currentColor); }

/* ---------- Schalter (an/aus) ---------- */
.schalter { display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; user-select: none; }
.schalter input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.schalter .bahn {
  position: relative; width: 2.9rem; height: 1.6rem; border-radius: 99px;
  background: var(--spur, #c8ced6); transition: background-color .25s; flex: none;
}
.schalter .bahn::after {
  content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.2rem; height: 1.2rem; border-radius: 50%;
  background: var(--knopf, #fff); box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: translate .3s cubic-bezier(.3,1.5,.5,1);
}
.schalter input:checked + .bahn { background: var(--fuell, #1f5bff); }
.schalter input:checked + .bahn::after { translate: 1.3rem 0; }
.schalter input:focus-visible + .bahn { outline: 3px solid var(--fokus, #1f5bff); outline-offset: 2px; }

/* ---------- Zähler-Stufen (− Wert +) ---------- */
.stufen { display: inline-flex; align-items: center; border: 1px solid currentColor; border-radius: var(--seg-r, 99px); }
.stufen button { width: 2.4rem; height: 2.4rem; border: 0; background: transparent; font-size: 1.2rem; line-height: 1; }
.stufen output { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Rollzähler (Ziffern rollen wie ein Zählwerk) ---------- */
.rolle { display: inline-flex; overflow: hidden; height: 1.08em; line-height: 1.08; vertical-align: bottom; font-variant-numeric: tabular-nums; }
.rolle .band { display: flex; flex-direction: column; transition: transform var(--rolle-dauer, 1.1s) cubic-bezier(.16,.9,.2,1); }
.rolle .band > span, .rolle .fest { height: 1.08em; display: block; text-align: center; }
.rolle .fest { padding-inline: .02em; }

/* ---------- Drehregler ---------- */
.drehregler { position: relative; touch-action: none; cursor: grab; user-select: none; border-radius: 50%; }
.drehregler:active { cursor: grabbing; }
.drehregler .zeiger { position: absolute; inset: 0; rotate: var(--winkel, 0deg); transition: rotate .08s linear; }

/* ---------- Stilwechsler (Popover) ---------- */
.wechsler-knopf {
  position: fixed; z-index: 60; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: .55rem; padding: .55rem .9rem .55rem .6rem;
  border-radius: 99px; border: 1px solid rgb(255 255 255 / .25);
  background: rgb(20 22 26 / .78); color: #fff; backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4);
  font: 500 .85rem/1 system-ui, sans-serif; box-shadow: 0 8px 30px rgb(0 0 0 / .25);
}
.wechsler-knopf .punkte { display: inline-flex; }
.wechsler-knopf .punkte i { width: .8rem; height: .8rem; border-radius: 50%; margin-left: -.25rem; border: 1.5px solid rgb(20 22 26); }
.wechsler-knopf .wtext { white-space: nowrap; }
@media (max-width: 600px) { .wechsler-knopf { padding: .6rem .6rem .6rem .85rem; } .wechsler-knopf .wtext { display: none; } }
.wechsler-liste {
  position: fixed; inset: auto max(1rem, env(safe-area-inset-right)) 4.2rem auto; margin: 0;
  width: min(22rem, calc(100vw - 2rem)); max-height: min(34rem, calc(100vh - 6rem)); overflow: auto;
  padding: .5rem; border: 1px solid rgb(255 255 255 / .14); border-radius: 18px;
  background: rgb(20 22 26 / .92); color: #fff; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  font: 400 .92rem/1.25 system-ui, sans-serif; box-shadow: 0 20px 60px rgb(0 0 0 / .35);
  opacity: 0; translate: 0 12px; transition: opacity .25s, translate .3s cubic-bezier(.2,.8,.2,1), display .3s allow-discrete, overlay .3s allow-discrete;
}
.wechsler-liste:popover-open { opacity: 1; translate: 0 0; }
@starting-style { .wechsler-liste:popover-open { opacity: 0; translate: 0 12px; } }
.wechsler-liste a { display: grid; grid-template-columns: 2.4rem 1fr; align-items: center; gap: .75rem; padding: .55rem .6rem; border-radius: 12px; text-decoration: none; }
.wechsler-liste a:hover, .wechsler-liste a:focus-visible { background: rgb(255 255 255 / .08); }
.wechsler-liste a[aria-current="page"] { background: rgb(255 255 255 / .14); }
.wechsler-liste .muster { width: 2.4rem; height: 2.4rem; border-radius: 10px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
.wechsler-liste .muster i:first-child { grid-row: span 2; }
.wechsler-liste small { display: block; opacity: .62; font-size: .78rem; margin-top: .15rem; }
.wechsler-liste .zur-uebersicht { grid-template-columns: 1fr; text-align: center; opacity: .8; margin-top: .25rem; border-top: 1px solid rgb(255 255 255 / .1); border-radius: 0 0 12px 12px; }

/* ---------- Musterhinweis ---------- */
.musterhinweis { font-size: .8rem; opacity: .7; }

/* Diagnosezeile (?diag=1) */
.diagzeile { position: fixed; left: .5rem; top: .5rem; z-index: 999; font: 11px/1.3 ui-monospace, monospace; background: rgb(0 0 0 / .7); color: #7f7; padding: .3rem .5rem; border-radius: 4px; pointer-events: none; white-space: pre; }

/* Weniger Bewegung: nicht abschalten, nur beruhigen */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rolle .band { --rolle-dauer: .5s; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .2s; }
}
