/* Typografie und Farbwerte aus dem H2Org-Theme: https://h2org.de/angebot/wissenswerkstatt/ */
@font-face { font-family: Barlow; font-weight: 300; src: url("./assets/barlow-light.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: Barlow; font-weight: 400; src: url("./assets/barlow-regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Sofia Pro"; font-weight: 400; src: url("./assets/sofia-regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Sofia Pro"; font-weight: 600; src: url("./assets/sofia-semibold.woff2") format("woff2"); font-display: swap; }

:root {
  --paper: #ffffff;
  --ink: #022e41;
  --muted: #3d5562;
  --line: #a8bcc8;
  --accent: #165c74;
  --gutter: clamp(18px, 5vw, 88px);
  --inset: clamp(20px, 5.5vw, 240px);
  --header-top: clamp(12px, 2.8svh, 68px);
  --header-height: clamp(44px, 2.5vw, 80px);
  --body: "Sofia Pro", sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color: var(--ink);
  background: var(--paper);
  font: 17px/1.5 var(--body);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; display: grid; grid-template-rows: auto 1fr; min-height: 100vh; min-height: 100svh; }
h1, h2, p { margin: 0; }
a { color: inherit; text-underline-offset: .24em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.credit {
  display: inline-flex; align-items: center; gap: 1em; width: fit-content;
  text-decoration: none; color: var(--muted); font-size: clamp(14px, 1.15vw, 36px);
}
.credit img { width: clamp(76px, 6.9vw, 215px); height: auto; }
.credit span { border-left: 1px solid var(--line); padding-left: .8em; }

h1 { font: 300 clamp(46px, 6vw, 100px)/1.08 Barlow, sans-serif; color: var(--muted); letter-spacing: -.025em; }
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--header-top) + var(--header-height));
  padding: var(--header-top) var(--inset) 0; gap: 12px;
}
button.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: .75em;
  min-height: 44px; padding: .65em .95em;
  background: var(--paper); color: var(--muted); border: 1px solid #d5e0e6;
  border-radius: 999px; font: 400 clamp(15px, 1.05vw, 28px)/1 var(--body);
}
.menu-toggle i {
  display: block; width: .42em; height: .42em; margin-top: -.2em;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
button.menu-toggle:hover, .site-header:has(#workshop:popover-open) .menu-toggle {
  background: #f5f8fa; color: var(--accent); border-color: #9cb7c5;
}
.site-header:has(#workshop:popover-open) .menu-toggle i { transform: rotate(225deg); margin-top: .2em; }
#workshop {
  inset: calc(var(--header-top) + var(--header-height) + 10px) var(--inset) auto auto;
  margin: 0; width: min(16rem, calc(100vw - 2 * var(--inset)));
  padding: 6px; background: var(--paper); color: var(--ink);
  border-radius: 14px; border: 1px solid #d5e0e6; box-shadow: 0 8px 28px #022e4114;
}
#workshop nav { display: grid; }
#workshop a { padding: .7em .9em; border-radius: 8px; text-decoration: none; font-size: 1rem; }
#workshop a:hover { background: #f5f8fa; }
#workshop a[aria-current] { color: var(--accent); background: #e4ebf5; }
#clock-settings { width: min(28rem, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
#clock-settings::backdrop { background: #022e4140; }
#clock-settings h2 { font: 400 1.6rem/1.2 Barlow, sans-serif; }
#clock-settings form > button { display: block; margin: 20px 0 0 auto; }
.clock {
  display: grid; grid-template-rows: 1fr clamp(76px, 17svh, 380px); min-width: 0;
}
.reading {
  min-width: 0; align-self: center; text-align: center;
  padding: clamp(16px, 3svh, 54px) var(--inset);
}
.clock h1 { font-size: clamp(36px, min(4.5vw, 7.6svh), 160px); }
.weight {
  display: flex; justify-content: center; align-items: baseline; gap: .1em; margin: .10em 0 .11em;
  font: 400 clamp(44px, min(15vw, 26svh), 650px)/1 Barlow, sans-serif;
  font-variant-numeric: tabular-nums; letter-spacing: -.045em; color: #165c74;
}
#weight, #reels { overflow-wrap: anywhere; min-width: 0; }
#weight.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.digit-window {
  --roll: 0;
  --fade: calc(var(--roll) * var(--roll) * (3 - 2 * var(--roll)));
  display: inline-grid; vertical-align: top; width: .94ch; text-align: center;
}
.digit-strip, .digit-window::after { grid-area: 1 / 1; }
.digit-strip {
  opacity: calc(1 - var(--fade));
  transform: translateY(calc(-.52em * var(--roll))) rotateX(calc(85deg * var(--roll)));
}
.digit-window::after {
  content: attr(data-next); opacity: var(--fade);
  transform: translateY(calc(.52em * (1 - var(--roll)))) rotateX(calc(-85deg * (1 - var(--roll))));
}
.unit { font: 300 .44em/1 Barlow, sans-serif; letter-spacing: -.035em; }
.caption { color: var(--muted); font: 400 clamp(22px, min(2.6vw, 4.8svh), 108px)/1.2 var(--body); }
.estimate { margin-top: .8em; color: var(--muted); font: 400 clamp(16px, 1.35vw, 54px)/1.4 var(--body); }
.estimate button { padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; }
.estimate button:hover { background: transparent; color: var(--accent); text-decoration: underline; }
.water { display: block; width: 100%; height: 100%; pointer-events: none; }
.settings {
  margin: 16px 0 0; padding: 12px 0 0; border: 0; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.settings label { color: var(--muted); font: .85rem/1.6 var(--body); }
input { font: inherit; color: var(--ink); }
.settings input, .free-answer { width: 100%; padding: 8px; background: #f5f8fa; border: 1px solid var(--line); border-radius: 0; }

.quiz, .results { width: 100%; max-width: 820px; margin: clamp(32px, 7vw, 100px) auto; padding: 0 var(--gutter) 32px; }
.quiz h1, .results h1 { margin-bottom: .35em; }
.quiz h2 { font: 400 clamp(27px, 3vw, 44px)/1.1 Barlow, sans-serif; margin: .9em 0 .5em; }
.quiz p, .results p { max-width: 55ch; margin-block: .8em; }
.quiz ul, .results ul { padding-left: 1.2em; }
.quiz li, .results li { margin-block: .5em; }
.results li { overflow-wrap: anywhere; }
button {
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: 8px;
  padding: 10px 19px; font: 600 1.1rem/1.2 var(--body); cursor: pointer;
}
button:enabled:hover { background: #2a5363; color: white; }
.options { display: grid; gap: 8px; margin-top: 22px; }
.option { text-align: left; background: transparent; color: var(--ink); border: 2px solid var(--line); }
.option[aria-pressed="true"] { background: var(--ink); color: white; }
.option:disabled { cursor: default; opacity: 1; }
.option.correct { color: #173d2e; background: #d3e2d4; }
.option.wrong { color: #742e21; background: #f1d8ce; }
.option.missing { border: 2px dashed #396447; }
.option::after { content: ""; display: block; min-height: 1.5em; font: .75rem/1.5 var(--mono); margin-top: 4px; }
.option.correct::after { content: "Richtig"; }
.option.wrong::after { content: "Falsch"; }
.option.missing::after { content: "Richtige Antwort fehlt"; }
.footer { display: grid; grid-template-columns: 1fr 3ch auto; gap: 12px; align-items: center; border-top: 1px solid var(--line); margin-top: 22px; padding-top: 16px; }
.footer button { min-width: 10rem; }
.footer button:disabled { opacity: .45; cursor: default; }
.footer button:disabled:hover { background: var(--ink); color: var(--paper); }
.quiz #question { min-height: var(--question-height, 3.3em); }
.quiz .options .option { min-height: var(--option-height, 5em); }
.quiz-measure { position: fixed; left: -10000px; top: 0; visibility: hidden; margin: 0; padding: 0; max-width: none; }
.quiz-measure .option { display: block; width: 100%; }
.points { font: 600 1.5rem/1 Barlow, sans-serif; }
.free-answer { margin: 4px 0; }
@media (max-width: 600px) {
  .reading { padding-inline: 16px; }
  .weight { font-size: 15.5vw; margin-block: .24em; }
  .caption br { display: none; }
  .footer { grid-template-columns: 1fr auto; }
  .footer button { grid-column: 1 / -1; width: 100%; }
  .footer .points { min-height: 1em; }
}
@media (max-width: 380px) {
  .credit span { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .clock { grid-template-rows: 1fr 13svh; }
  .reading { padding-block: 8px; }
  .clock h1 { font-size: 8svh; }
  .weight { font-size: min(15vw, 23svh); }
}
@media (prefers-reduced-motion: no-preference) {
  .water path:nth-child(1) { animation: swell-back 23s ease-in-out infinite alternate; }
  .water path:nth-child(2) { animation: swell-middle 17s ease-in-out -7s infinite alternate; }
  .water path:nth-child(3) { animation: swell-front 29s ease-in-out -11s infinite alternate; }
  @keyframes swell-back {
    50% { d: path("M0 56 C170 87 335 78 540 39 S935 12 1200 42 V120 H0Z"); }
    100% { d: path("M0 24 C170 43 335 79 540 58 S935 31 1200 60 V120 H0Z"); }
  }
  @keyframes swell-middle {
    50% { d: path("M0 50 C235 25 380 36 620 69 S965 87 1200 57 V120 H0Z"); }
    100% { d: path("M0 76 C235 51 380 32 620 43 S965 90 1200 79 V120 H0Z"); }
  }
  @keyframes swell-front {
    50% { d: path("M0 77 C180 94 346 104 550 86 S960 55 1200 82 V120 H0Z"); }
    100% { d: path("M0 88 C180 62 346 80 550 99 S960 76 1200 91 V120 H0Z"); }
  }
  .reading { animation: surface .45s ease-out both; }
  @keyframes surface { from { opacity: 0; transform: translateY(6px); } }
}
