/* Der offene Tag der Tür
   One page, one day. The colours on :root are moved by main.js while you scroll:
   morning at the top, night at the bottom. Everything else derives from them. */

@layer reset, base, layout, parts, motion;

@font-face {
  font-family: 'Jost';
  src: url('fonts/jost-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/geist-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* registered so they can be animated */
@property --sink {
  syntax: '<length>';
  inherits: true;
  initial-value: 40px;
}

@property --glow {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body, h1, h2, h3, p, ol, ul, dl, dd, figure {
    margin: 0;
  }

  ol, ul {
    padding: 0;
    list-style: none;
  }

  svg {
    display: block;
    max-width: 100%;
  }

  button, input {
    font: inherit;
    color: inherit;
  }

  button {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
}

@layer base {
  :root {
    /* the five colours of the day; these are the 06:00 values */
    --bg: oklch(0.968 0.016 65);
    --ink: oklch(0.22 0.03 265);
    --accent: oklch(0.68 0.17 42);
    --sky-a: oklch(0.84 0.07 255);
    --sky-b: oklch(0.91 0.09 55);

    --ink-soft: color-mix(in oklab, var(--ink) 66%, var(--bg));
    --line: color-mix(in oklab, var(--ink) 22%, var(--bg));
    --line-strong: color-mix(in oklab, var(--ink) 62%, var(--bg));

    --sans: 'Jost', 'Futura', 'Century Gothic', 'Avenir Next', system-ui, sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --pad: clamp(1.25rem, 5vw, 4.5rem);
    --gap: clamp(5.5rem, 17vh, 12rem);
    --ease: cubic-bezier(0.2, 0.7, 0.1, 1);

    color-scheme: light;
    scrollbar-color: var(--line-strong) transparent;
    interpolate-size: allow-keywords;
    scroll-padding-top: 4.5rem;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  :root.is-night {
    color-scheme: dark;
  }

  /* Before the morning door has opened it is still dawn: cooler and dimmer.
     main.js warms these four up within a few seconds (same values as DAWN there). */
  :root.js:not(.is-calm) {
    --bg: oklch(0.86 0.028 262);
    --accent: oklch(0.6 0.1 30);
    --sky-a: oklch(0.6 0.06 265);
    --sky-b: oklch(0.8 0.07 25);
  }

  body {
    overflow-x: clip;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: clamp(1.125rem, 1rem + 0.45vw, 1.4rem);
    font-weight: 300;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1, h2, h3 {
    font-weight: 200;
    text-wrap: balance;
  }

  h2 {
    max-width: 17ch;
    font-size: clamp(2.1rem, 1.1rem + 4.3vw, 4.75rem);
    line-height: 1.04;
    letter-spacing: -0.015em;
  }

  p {
    text-wrap: pretty;
  }

  a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.28em;
  }

  /* no italics on this page: emphasis is a thin coloured line */
  em {
    font-style: normal;
    border-bottom: 1px solid var(--accent);
  }

  ::selection {
    background: color-mix(in oklch, var(--accent) 32%, transparent);
  }

  :focus-visible {
    outline: 1px solid var(--ink);
    outline-offset: 4px;
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .skip {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 30;
    padding: 0.6rem 1rem;
    background: var(--ink);
    color: var(--bg);
    font: 400 0.8rem/1 var(--mono);
    translate: 0 -200%;
  }

  .skip:focus {
    translate: 0 0;
  }
}

@layer layout {
  .wrap {
    width: min(100% - 2 * var(--pad), 80rem);
    margin-inline: auto;
  }

  .section {
    padding-block: var(--gap);
  }

  /* every section starts with a hairline; the time sits in the margin */
  .section__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2.5rem 3rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line);
  }

  .section__body > * + * {
    margin-top: clamp(2rem, 5.5vh, 3.75rem);
  }

  .kicker {
    display: flex;
    gap: 1.25ch;
    color: var(--ink-soft);
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .kicker time {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }

  @media (min-width: 60rem) {
    .section__grid {
      grid-template-columns: 9rem minmax(0, 1fr);
    }

    .section__body--solo {
      grid-column: 2;
    }

    .kicker {
      position: sticky;
      top: 4.5rem;
      flex-direction: column;
      gap: 0.2rem;
      align-self: start;
      padding-top: 0.6rem;
    }
  }

  .prose {
    max-width: 33rem;
  }

  .prose p + p {
    margin-top: 1em;
  }

  /* a sentence that gets room */
  .say {
    max-width: 19ch;
    font-size: clamp(1.8rem, 1rem + 3.4vw, 3.6rem);
    font-weight: 200;
    line-height: 1.14;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }
}

@layer parts {
  /* ---------- the sky behind the page (main.js draws sun, stars and moon into it) ---------- */

  .himmel {
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    width: 100%;
    height: 100vh;
    height: 100lvh;
    pointer-events: none;
  }

  /* ---------- bar at the top ---------- */

  .hud {
    position: fixed;
    inset: 0 0 auto;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3rem;
    padding-inline: var(--pad);
    background: color-mix(in oklch, var(--bg) 80%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font: 400 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .hud__left,
  .hud__right {
    display: flex;
    align-items: center;
    gap: clamp(0.9rem, 3vw, 1.75rem);
  }

  .hud__mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 3rem;
    margin-left: -0.3rem;
  }

  .hud__mark svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.2;
  }

  .hud__button {
    height: 3rem;
    letter-spacing: inherit;
    text-transform: inherit;
    text-decoration: underline transparent 1px;
    text-underline-offset: 0.5em;
    transition: text-decoration-color 0.3s;
  }

  .hud__button:hover,
  .hud__button[aria-pressed='true'] {
    text-decoration-color: currentColor;
  }

  .hud__button[data-ton] {
    min-width: 7ch;
    text-align: right;
  }

  .hud__clock {
    font-variant-numeric: tabular-nums;
  }

  /* without scripts these controls could not do anything */
  .no-js [data-ton],
  .no-js [data-ton-hinweis],
  .no-js .winkel__regler {
    display: none;
  }

  /* how much of the day is gone */
  .hud__progress {
    position: absolute;
    inset: auto 0 0;
    height: 1px;
    background: var(--ink);
    transform-origin: 0 50%;
    scale: 0 1;
  }

  @supports (animation-timeline: scroll()) {
    .hud__progress {
      animation: day-passes linear both;
      animation-timeline: scroll(root block);
    }
  }

  @keyframes day-passes {
    to {
      scale: 1 1;
    }
  }

  /* ---------- index (popover) ---------- */

  .toc {
    position: fixed;
    inset: 3.5rem auto auto var(--pad);
    width: min(23rem, 100vw - 2 * var(--pad));
    max-height: calc(100svh - 5rem);
    margin: 0;
    padding: 0.5rem 1.25rem;
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--ink);
    font: 400 0.78rem/1.3 var(--mono);
    opacity: 0;
    translate: 0 -0.5rem;
    transition: opacity 0.3s, translate 0.3s var(--ease), overlay 0.3s allow-discrete, display 0.3s allow-discrete;
  }

  .toc:popover-open {
    opacity: 1;
    translate: 0 0;
  }

  @starting-style {
    .toc:popover-open {
      opacity: 0;
      translate: 0 -0.5rem;
    }
  }

  .toc::backdrop {
    background: color-mix(in oklch, var(--bg) 60%, transparent);
  }

  .toc li + li {
    border-top: 1px solid var(--line);
  }

  .toc a {
    display: grid;
    grid-template-columns: 5ch 1fr;
    gap: 2ch;
    padding-block: 0.8rem;
    text-decoration: none;
  }

  .toc a span {
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
  }

  .toc a:hover {
    text-decoration: underline 1px;
  }

  @supports (anchor-name: --a) {
    .hud__toc-button {
      anchor-name: --toc-button;
    }

    .toc {
      position-anchor: --toc-button;
      inset: anchor(bottom) auto auto anchor(left);
      margin-top: 0.5rem;
    }
  }

  @supports not selector(:popover-open) {
    .toc,
    .hud__toc-button {
      display: none;
    }
  }

  /* ---------- the door (morning and evening) ---------- */

  .door {
    overflow: visible;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1;
  }

  .door * {
    vector-effect: non-scaling-stroke;
  }

  .sky-a {
    stop-color: var(--sky-a);
  }

  .sky-b {
    stop-color: var(--sky-b);
  }

  .beam-a {
    stop-color: var(--sky-b);
    stop-opacity: 0.6;
  }

  .beam-b {
    stop-color: var(--sky-b);
    stop-opacity: 0;
  }

  .door__sky,
  .door__beam {
    stroke: none;
  }

  .door__floor {
    stroke: var(--line-strong);
  }

  .door__leaf {
    fill: var(--bg);
  }

  .door__handle {
    stroke-width: 1.5;
  }

  .door__edge {
    stroke: var(--accent);
    stroke-width: 1.5;
  }

  /* ---------- 06:00 morning ---------- */

  .hero {
    --door-h: min(82svh, 56rem, 58vw);
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    min-height: 100svh;
    padding-inline: max(var(--pad), calc(50% - 40rem));
    overflow: clip;
  }

  /* the floor line of the door is the bottom edge of this row */
  .hero__stage {
    position: relative;
    grid-area: 1 / 1;
    min-height: 50svh;
  }

  .door--hero {
    position: absolute;
    right: 0;
    bottom: calc(var(--door-h) * -0.2);
    width: auto;
    max-width: none;
    height: var(--door-h);
    aspect-ratio: 2 / 3;
    transform: scaleX(-1);
  }

  .hero__head {
    position: relative;
    grid-area: 1 / 1;
    align-self: end;
  }

  .hero__date {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: clamp(1rem, 3vh, 2.25rem);
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .hero__tick {
    width: 2.5rem;
    height: 1px;
    background: var(--accent);
  }

  .hero__title {
    margin-left: -0.045em;
    font-size: clamp(3.3rem, 0.4rem + 10.6vw, 11rem);
    font-weight: 200;
    line-height: 0.94;
    letter-spacing: -0.035em;
    text-wrap: nowrap;
  }

  /* each line of the title rises out of its own slot */
  .rise {
    display: block;
    margin-bottom: -0.16em;
    padding-bottom: 0.16em;
    overflow: clip;
  }

  .rise > span {
    display: block;
  }

  .hero__lead {
    position: relative;
    grid-area: 2 / 1;
    max-width: 26rem;
    padding-block: clamp(2.75rem, 7vh, 4.25rem) clamp(1.75rem, 5svh, 3.5rem);
  }

  .hero__foot {
    position: relative;
    grid-area: 3 / 1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem 3rem;
    padding-bottom: 1.75rem;
    color: var(--ink-soft);
    font: 400 0.72rem/1.6 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  /* only shown when the device asks for less motion */
  .hero__ruhe {
    max-width: 27rem;
  }

  .hero__ruhe button {
    margin-block: -0.7rem;
    padding-block: 0.7rem;
    color: var(--ink);
    letter-spacing: inherit;
    text-transform: inherit;
    text-decoration: underline 1px;
    text-underline-offset: 0.4em;
  }

  .hero__hint {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
  }

  .hero__hint-line {
    width: 1px;
    height: 2.5rem;
    background: var(--ink);
    transform-origin: 50% 0;
  }

  /* Wide screens: the baseline of the title sits exactly on the floor line of the door.
     0.289em is the distance from that baseline to the bottom edge of the title box (Jost, line-height 0.94). */
  @media (min-width: 52rem) and (min-aspect-ratio: 1001/1000) {
    .hero__title {
      margin-bottom: -0.289em;
    }
  }

  @media (min-width: 60rem) {
    .hero__title {
      font-weight: 100;
    }
  }

  /* phones and upright tablets: door on top, words below the floor line */
  @media (max-width: 51.99rem), (max-aspect-ratio: 1/1) {
    .hero {
      --door-h: min(56svh, 34rem);
      grid-template-rows: minmax(0, 1fr) auto auto auto;
    }

    .door--hero {
      right: -2.5rem;
    }

    .hero__head {
      grid-area: 2 / 1;
      align-self: start;
      padding-top: 1.5rem;
    }

    .hero__lead {
      grid-area: 3 / 1;
      padding-top: 1.25rem;
    }

    .hero__foot {
      grid-area: 4 / 1;
      flex-direction: column;
      align-items: flex-start;
    }

    .hero__hint {
      margin-left: 0;
    }
  }

  /* ---------- 07:30 a word has moved ---------- */

  .umzug {
    position: relative;
  }

  .umzug__label {
    color: var(--ink-soft);
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .umzug__line {
    padding-block: 0.6rem;
    font-size: clamp(1.55rem, 0.35rem + 5.6vw, 5rem);
    font-weight: 200;
    line-height: 1.1;
    letter-spacing: -0.015em;
    white-space: nowrap;
  }

  .umzug__line[data-line='b'] {
    margin-top: clamp(6rem, 17vw, 12.5rem);
  }

  .umzug__line[data-line='a'] [data-word='offen'] {
    border-bottom: 1px solid var(--accent);
  }

  .umzug__line[data-line='b'] [data-word='offen'] {
    border-top: 1px solid var(--accent);
  }

  .umzug__neu {
    color: var(--ink-soft);
  }

  /* main.js draws the links between equal words into this */
  .umzug__links {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    fill: none;
    stroke: var(--line-strong);
    stroke-width: 1;
    pointer-events: none;
  }

  .umzug__links [data-link='offen'] {
    stroke: var(--accent);
    stroke-width: 1.5;
  }

  .vergleich {
    display: grid;
    gap: 2rem 3rem;
    max-width: 58rem;
  }

  .vergleich > div {
    padding-top: 1rem;
    border-top: 1px solid var(--line);
  }

  .vergleich dt {
    margin-bottom: 0.6rem;
    font-weight: 400;
  }

  .vergleich dd {
    color: var(--ink-soft);
  }

  @media (min-width: 44rem) {
    .vergleich {
      grid-template-columns: 1fr 1fr;
    }
  }

  /* ---------- 09:00 open, shut, open, shut ---------- */

  .takt {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: clamp(0.75rem, 2.4vw, 1.75rem);
  }

  .takt svg {
    width: clamp(2.5rem, 6.5vw, 4.25rem);
    overflow: visible;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1;
  }

  .takt svg * {
    vector-effect: non-scaling-stroke;
  }

  .takt__arc {
    stroke: var(--line-strong);
    stroke-dasharray: 2 3;
  }

  .takt__leaf {
    animation: auf-zu 3.6s cubic-bezier(0.6, 0, 0.3, 1) infinite;
    animation-delay: calc(var(--i) * 0.42s - 6s);
  }

  @keyframes auf-zu {
    0%, 10% {
      rotate: 0deg;
    }

    46%, 60% {
      rotate: -90deg;
    }

    96%, 100% {
      rotate: 0deg;
    }
  }

  /* today the door does not work: it just leans */
  .takt__heute {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    font: 400 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .takt__heute .takt__leaf {
    stroke: var(--accent);
    stroke-width: 1.5;
    rotate: -26deg;
    animation: none;
  }

  /* ---------- 09:00 the log of an ordinary day ---------- */

  .protokoll {
    max-width: 46rem;
  }

  .protokoll__name {
    margin-bottom: 0.9rem;
    color: var(--ink-soft);
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .protokoll__liste {
    border-bottom: 1px solid var(--line);
  }

  .protokoll__liste li {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr);
    column-gap: 1.5rem;
    align-items: baseline;
    padding-block: 0.7rem 0.8rem;
    border-top: 1px solid var(--line);
  }

  .protokoll__liste time,
  .protokoll__weg {
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .protokoll__liste time {
    font-variant-numeric: tabular-nums;
  }

  /* which way it went through the door */
  .protokoll__weg {
    grid-column: 2;
    color: var(--ink-soft);
  }

  .protokoll__liste li:last-child .protokoll__weg {
    color: var(--ink);
  }

  @media (min-width: 44rem) {
    .protokoll__liste li {
      grid-template-columns: 3.5rem minmax(0, 1fr) auto;
    }

    .protokoll__weg {
      grid-column: 3;
      text-align: right;
    }
  }

  /* ---------- 11:00 the parts ---------- */

  .teile {
    display: grid;
    gap: clamp(2rem, 6vw, 5.5rem);
  }

  .teile__bild svg {
    width: 100%;
    max-width: 25rem;
    margin-inline: auto;
    overflow: visible;
    fill: none;
    stroke-width: 1;
  }

  .teile__bild path {
    stroke: var(--teil, var(--ink));
    transition: stroke 0.3s;
  }

  .teile__bild text {
    fill: var(--teil, var(--ink-soft));
    font: 400 12px var(--mono);
    letter-spacing: 0.04em;
    transition: fill 0.3s;
  }

  .teile__mass path {
    stroke: var(--line-strong);
  }

  .teile__nr text {
    fill: var(--teil, var(--ink));
  }

  .teile__liste {
    counter-reset: teil;
    border-bottom: 1px solid var(--line);
  }

  .teile__liste li {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr);
    padding-block: 1.3rem 1.5rem;
    border-top: 1px solid var(--teil, var(--line));
    counter-increment: teil;
    transition: border-color 0.3s;
  }

  .teile__liste li::before {
    content: counter(teil);
    padding-top: 0.55em;
    color: var(--teil, var(--ink-soft));
    font: 400 0.72rem/1.4 var(--mono);
    transition: color 0.3s;
  }

  .teile__liste h3 {
    font-size: 1.3em;
    font-weight: 300;
    line-height: 1.25;
  }

  .teile__liste p {
    grid-column: 2;
    max-width: 29rem;
    margin-top: 0.35rem;
    color: var(--ink-soft);
  }

  /* point at an entry or at the drawing: the same part lights up in both */
  .teile:has([data-teil='blatt']:hover) [data-teil='blatt'],
  .teile:has([data-teil='rahmen']:hover) [data-teil='rahmen'],
  .teile:has([data-teil='angel']:hover) [data-teil='angel'],
  .teile:has([data-teil='klinke']:hover) [data-teil='klinke'],
  .teile:has([data-teil='loch']:hover) [data-teil='loch'],
  .teile:has([data-teil='schwelle']:hover) [data-teil='schwelle'] {
    --teil: var(--accent);
  }

  @media (min-width: 52rem) {
    .teile {
      grid-template-columns: minmax(15rem, 25rem) minmax(0, 1fr);
      align-items: start;
    }

    .teile__bild {
      position: sticky;
      top: 5.5rem;
    }
  }

  /* ---------- 12:00 through the keyhole ---------- */

  /* Three states.
     No scripts: a plain section with a wide window in it.
     Calm mode: the window is cut to one big keyhole (main.js draws the shape).
     Otherwise: the section is pinned, and scrolling makes the keyhole grow until you are through. */
  .loch__fest {
    display: grid;
    gap: clamp(2rem, 6vh, 4rem);
    padding-block: var(--gap);
  }

  .loch__blick {
    position: relative;
    order: 2;
    height: clamp(18rem, 62svh, 36rem);
  }

  .loch__draussen,
  .loch__draussen svg,
  .loch__rand {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .loch__draussen svg,
  .loch__rand {
    fill: none;
    stroke: var(--ink);
    stroke-width: 1;
  }

  .loch__rand {
    overflow: visible;
  }

  .loch__luft,
  .loch__boden {
    stroke: none;
    opacity: calc(1 - var(--durch, 0));
  }

  .loch__boden {
    fill: color-mix(in oklab, var(--sky-b) 45%, var(--bg));
  }

  .loch__wolken,
  .loch__weg {
    stroke: var(--line-strong);
  }

  .loch__ferne--blatt {
    fill: var(--bg);
  }

  .loch__vorher p {
    max-width: 33rem;
    margin-top: clamp(1.5rem, 4vh, 2.5rem);
  }

  .js:not(.is-calm) .loch {
    height: 260svh;
  }

  .js:not(.is-calm) .loch__fest {
    position: sticky;
    top: 0;
    display: block;
    height: 100svh;
    padding-block: clamp(5rem, 15svh, 9rem) 0;
    overflow: clip;
  }

  .js:not(.is-calm) .loch__blick {
    position: absolute;
    inset: 0;
    height: auto;
  }

  .js:not(.is-calm) .loch__schrift {
    position: relative;
  }

  /* the words on this side and the words on the other side share one place */
  .js:not(.is-calm) .loch__texte {
    display: grid;
  }

  .js:not(.is-calm) .loch__texte > * {
    grid-area: 1 / 1;
    margin-top: 0;
  }

  /* --auf runs from 0 (a small hole) to 1 (the hole is the whole screen) */
  .js:not(.is-calm) .loch__vorher {
    opacity: calc(1 - var(--auf, 0) * 3.5);
  }

  .js:not(.is-calm) .loch__nachher {
    opacity: calc((var(--auf, 0) - 0.72) * 4);
  }

  /* the road from the keyhole runs on into the next section and ends on its hairline */
  .loch__weiter {
    display: none;
  }

  .js:not(.is-calm) .loch + .section {
    position: relative;
  }

  .js:not(.is-calm) .loch__weiter {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--gap);
    overflow: visible;
    pointer-events: none;
    fill: none;
    stroke: var(--line-strong);
    stroke-width: 1;
  }

  /* ---------- 13:00 the angle ---------- */

  .winkel {
    display: grid;
    gap: 1.75rem;
    max-width: 46rem;
  }

  .winkel__plan {
    width: 100%;
    overflow: visible;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
  }

  .winkel__plan:active {
    cursor: grabbing;
  }

  .winkel__ticks,
  .winkel__hatch {
    stroke: var(--line-strong);
  }

  .winkel__grad {
    fill: var(--ink-soft);
    stroke: none;
    font: 400 11px var(--mono);
  }

  .winkel__wall {
    fill: url('#schraffur');
  }

  /* the drawing shrinks on a phone; its lettering should not */
  @media (max-width: 40rem) {
    .winkel__grad {
      font-size: 16px;
    }
  }

  .winkel__sill {
    stroke: var(--line-strong);
    stroke-dasharray: 3 4;
  }

  .winkel__sweep {
    stroke: var(--accent);
  }

  .winkel__leaf {
    stroke-width: 1.5;
  }

  .winkel__hinge {
    fill: var(--ink);
    stroke: none;
  }

  .winkel__grip {
    fill: var(--bg);
    stroke: var(--accent);
    stroke-width: 1.5;
  }

  .winkel__lesen {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem 3rem;
    align-items: start;
  }

  .winkel__zahl {
    min-width: 3.2ch;
    font-size: clamp(4rem, 11vw, 7.5rem);
    font-weight: 100;
    line-height: 0.9;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
  }

  .winkel__wort {
    font-size: clamp(1.5rem, 1rem + 2.2vw, 2.5rem);
    font-weight: 300;
    line-height: 1.15;
  }

  .winkel__satz {
    min-height: 3.2em;
    margin-top: 0.4rem;
    color: var(--ink-soft);
  }

  @media (min-width: 40rem) {
    .winkel__lesen {
      grid-template-columns: auto minmax(0, 1fr);
    }
  }

  .winkel__regler {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    color: var(--ink-soft);
    font: 400 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .winkel__regler input {
    width: 100%;
    height: 2.75rem;
    margin: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
  }

  .winkel__regler input::-webkit-slider-runnable-track {
    height: 1px;
    background: var(--ink);
  }

  .winkel__regler input::-moz-range-track {
    height: 1px;
    background: var(--ink);
  }

  .winkel__regler input::-webkit-slider-thumb {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: calc(-0.575rem + 0.5px);
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    background: var(--bg);
    -webkit-appearance: none;
    appearance: none;
  }

  .winkel__regler input::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    background: var(--bg);
  }

  /* ---------- 15:00 the threshold ---------- */

  .schwelle {
    position: relative;
  }

  /* "you": a dot that stays in the middle of the screen while the line passes under it */
  .schwelle__du {
    position: sticky;
    top: 50svh;
    z-index: 2;
    height: 0;
    pointer-events: none;
  }

  .schwelle__punkt {
    position: absolute;
    top: -4px;
    left: calc(var(--pad) / 2 - 4px);
    width: 8px;
    height: 8px;
    border: 1px solid var(--ink);
    border-radius: 50%;
    background: var(--bg);
    transition: background 0.3s, border-color 0.3s, scale 0.4s var(--ease);
  }

  .schwelle__wo {
    position: absolute;
    top: 1rem;
    left: calc(var(--pad) / 2);
    color: var(--ink-soft);
    font: 400 0.68rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    writing-mode: vertical-rl;
    translate: -50% 0;
    opacity: 0;
    transition: opacity 0.4s;
  }

  .schwelle[data-state='vor'] [data-wo='vor'],
  .schwelle[data-state='auf'] [data-wo='auf'],
  .schwelle[data-state='hinter'] [data-wo='hinter'] {
    opacity: 1;
  }

  .schwelle[data-state='auf'] .schwelle__punkt {
    border-color: var(--accent);
    background: var(--accent);
    scale: 1.6;
  }

  .schwelle[data-state='auf'] [data-wo='auf'] {
    color: var(--ink);
  }

  .schwelle .section__grid:has(.section__body--solo) {
    padding-top: 0;
    border-top: 0;
  }

  .schwelle__strich {
    position: relative;
    height: 1px;
    margin-block: clamp(7rem, 24vh, 15rem);
    background: var(--ink);
    transition: background 0.3s;
  }

  .schwelle[data-state='auf'] .schwelle__strich {
    background: var(--accent);
  }

  .schwelle__strich span {
    position: absolute;
    right: var(--pad);
    color: var(--ink-soft);
    font: 400 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 0.3s;
  }

  .schwelle__strich span:first-child {
    bottom: 0.9rem;
  }

  .schwelle__strich span:last-child {
    top: 0.9rem;
  }

  .schwelle[data-state='vor'] .schwelle__strich span:first-child,
  .schwelle[data-state='hinter'] .schwelle__strich span:last-child {
    color: var(--ink);
  }

  @media (min-width: 60rem) {
    .schwelle__wo {
      top: -1.7rem;
      left: calc(var(--pad) / 2 + 0.9rem);
      writing-mode: horizontal-tb;
      translate: 0 0;
    }
  }

  /* ---------- 16:30 a shut day and an open day ---------- */

  .tage {
    display: grid;
    gap: clamp(3rem, 8vh, 5rem);
    max-width: 58rem;
  }

  .tage__name {
    margin-bottom: 0.9rem;
    color: var(--ink-soft);
    font: 400 0.72rem/1.4 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .tage__linie {
    position: relative;
    height: 6rem;
    border-bottom: 1px solid var(--ink);
    overflow: clip;
    container-type: inline-size;
  }

  /* shut: every hour already has something standing in it */
  .tage__linie--zu span {
    position: absolute;
    bottom: 0;
    left: calc(var(--von) * 1%);
    display: grid;
    place-items: center;
    width: calc((var(--bis) - var(--von)) * 1%);
    height: 100%;
    border: 1px solid var(--ink);
    border-width: 1px 0 0 1px;
    background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line) 6px 7px);
  }

  .tage__linie--zu span:last-child {
    border-right-width: 1px;
  }

  .tage__linie--zu b {
    padding: 0.5rem 0.15rem;
    background: var(--bg);
    font: 400 0.66rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    writing-mode: vertical-rl;
  }

  /* open: a door at each end, and whatever comes drifts through */
  .tage__linie--offen::before,
  .tage__linie--offen::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--ink);
  }

  .tage__linie--offen::before {
    left: 0;
    border-width: 1px 1px 0 1px;
    border-radius: 0 100% 0 0;
    border-top-style: dashed;
    border-right-style: dashed;
  }

  .tage__linie--offen::after {
    right: 0;
    border-width: 1px 1px 0 1px;
    border-radius: 100% 0 0 0;
    border-top-style: dashed;
    border-left-style: dashed;
  }

  .tage__linie--offen i {
    position: absolute;
    bottom: 0.9rem;
    left: 0;
    color: var(--ink-soft);
    font: normal 400 0.7rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    translate: calc(var(--x) * 1cqi) var(--hoch);
    animation: herein var(--dauer) linear var(--start) infinite;
  }

  @keyframes herein {
    from {
      translate: -9rem var(--hoch);
    }

    to {
      translate: 100cqi var(--hoch);
    }
  }

  /* ---------- 18:00 the rules ---------- */

  .regeln {
    max-width: 58rem;
    border-bottom: 1px solid var(--line);
    counter-reset: regel;
  }

  .regeln li {
    display: grid;
    grid-template-columns: clamp(3.25rem, 10vw, 8rem) minmax(0, 1fr);
    align-items: baseline;
    padding-block: clamp(1.4rem, 4vh, 2.4rem);
    border-top: 1px solid var(--line);
    counter-increment: regel;
  }

  .regeln li::before {
    content: counter(regel);
    font-size: clamp(2.6rem, 1.5rem + 4.2vw, 5rem);
    font-weight: 100;
    line-height: 0.9;
  }

  .regeln h3 {
    font-size: clamp(1.45rem, 1.1rem + 1.5vw, 2.2rem);
    font-weight: 300;
    line-height: 1.15;
  }

  .regeln p {
    grid-column: 2;
    margin-top: 0.4rem;
    color: var(--ink-soft);
  }

  /* ---------- 19:30 when ---------- */

  .heute {
    margin-left: -0.06em;
    font-size: clamp(5.5rem, 1rem + 22vw, 21rem);
    font-weight: 100;
    line-height: 0.86;
    letter-spacing: -0.045em;
  }

  .jetzt {
    max-width: 46rem;
  }

  /* the real day on this device, from midnight to midnight */
  .jetzt__linie {
    position: relative;
    height: 2.75rem;
    border-bottom: 1px solid var(--ink);
    font: 400 0.72rem/1 var(--mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .jetzt__null,
  .jetzt__ende {
    position: absolute;
    top: 0;
    color: var(--ink-soft);
  }

  .jetzt__ende {
    right: 0;
  }

  .jetzt__punkt {
    position: absolute;
    bottom: -5px;
    left: calc(var(--now, 0.5) * 100%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    translate: -50% 0;
  }

  .jetzt__punkt::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 4px;
    width: 1px;
    height: 1.4rem;
    background: var(--accent);
  }

  .jetzt__satz {
    max-width: 33rem;
    margin-top: 1.4rem;
  }

  /* ---------- dusk: the page tips from light to dark ---------- */

  .dusk {
    height: clamp(24rem, 85svh, 48rem);
    overflow: clip;
  }

  .dusk svg {
    width: 100%;
    max-width: none;
    height: 100%;
    overflow: visible;
    fill: none;
    stroke: var(--ink);
    stroke-width: 1;
  }

  .dusk svg * {
    vector-effect: non-scaling-stroke;
  }

  .dusk__sun {
    fill: color-mix(in oklch, var(--accent) 16%, transparent);
    stroke: var(--accent);
    stroke-width: 1.25;
    transform: translateY(var(--sink));
  }

  .dusk__water {
    stroke: var(--accent);
  }

  @supports (animation-timeline: view()) {
    .dusk {
      animation: sinken linear both;
      animation-timeline: view();
      animation-range: cover 28% cover 72%;
    }
  }

  @keyframes sinken {
    from {
      --sink: -84px;
    }

    to {
      --sink: 96px;
    }
  }

  /* ---------- 21:00 questions ---------- */

  .fragen {
    max-width: 50rem;
    border-bottom: 1px solid var(--line);
  }

  .fragen details {
    border-top: 1px solid var(--line);
  }

  .fragen summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1rem;
    align-items: center;
    gap: 1.5rem;
    padding-block: 1.3rem;
    list-style: none;
    cursor: pointer;
  }

  .fragen summary::-webkit-details-marker {
    display: none;
  }

  /* a plus made of two hairlines; it turns into a minus when open */
  .fragen summary::after {
    content: '';
    width: 1rem;
    height: 1rem;
    background:
      linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat,
      linear-gradient(currentColor, currentColor) center / 1px 100% no-repeat;
    transition: rotate 0.5s var(--ease), background-size 0.5s var(--ease);
  }

  .fragen details[open] summary::after {
    background-size: 100% 1px, 1px 0;
    rotate: 180deg;
  }

  .fragen h3 {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem);
    font-weight: 300;
    line-height: 1.25;
  }

  .fragen details p {
    max-width: 36rem;
    padding-bottom: 1.6rem;
    color: var(--ink-soft);
  }

  .fragen details::details-content {
    block-size: 0;
    overflow: clip;
    transition: block-size 0.5s var(--ease), content-visibility 0.5s allow-discrete;
  }

  .fragen details[open]::details-content {
    block-size: auto;
  }

  /* ---------- 22:00 a star chart ---------- */

  .sternkarte {
    max-width: 40rem;
  }

  .sternkarte svg {
    width: 100%;
    fill: none;
    stroke-width: 1;
  }

  .sternkarte__netz {
    stroke: var(--line);
  }

  .sternkarte__feld {
    fill: var(--ink-soft);
  }

  .sternkarte__sterne {
    fill: var(--ink);
  }

  .sternkarte__linie {
    stroke: var(--line-strong);
  }

  /* the leaf is the part that stands open */
  .sternkarte__linie--blatt {
    stroke: var(--accent);
  }

  .sternkarte__namen {
    fill: var(--ink-soft);
    font: 400 11px var(--mono);
    letter-spacing: 0.04em;
  }

  /* the chart shrinks on a phone; its lettering should not */
  @media (max-width: 40rem) {
    .sternkarte__namen {
      font-size: 16px;
    }
  }

  .sternkarte figcaption {
    max-width: 33rem;
    margin-top: 1.5rem;
    color: var(--ink-soft);
  }

  /* ---------- 23:00 evening, 24:00 end ---------- */

  .abend {
    padding-bottom: clamp(4rem, 10vh, 7rem);
  }

  .ende {
    --door-h: min(72svh, 46rem);
    position: relative;
    display: grid;
    justify-items: center;
    padding-bottom: clamp(1.5rem, 4svh, 2.5rem);
    overflow: clip;
  }

  /* the last line of the page, below the door */
  .ende__kolophon {
    margin-top: clamp(4.5rem, 11svh, 7rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem 3rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font: 400 0.72rem/1.6 var(--mono);
    letter-spacing: 0.04em;
  }

  .ende__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.75rem;
  }

  .ende__links a,
  .ende__links button {
    display: inline-block;
    padding-block: 0.6rem;
    margin-block: -0.6rem;
  }

  .ende__links button {
    letter-spacing: inherit;
    text-decoration: underline 1px;
    text-underline-offset: 0.28em;
  }

  .ende__links [hidden] {
    display: none;
  }

  .door--abend {
    width: auto;
    max-width: none;
    height: var(--door-h);
    margin-top: clamp(5rem, 14vh, 9rem);
    aspect-ratio: 2 / 3;
    animation: atmen 7s ease-in-out infinite alternate;
  }

  /* the light from the hallway: a soft copy under a sharp one */
  .door--abend .door__sky {
    filter: drop-shadow(0 0 14px var(--sky-b));
  }

  .door--abend .door__beam {
    opacity: var(--glow);
  }

  .door--abend .door__beam--glow {
    filter: blur(16px);
  }

  .door--abend .beam-a {
    stop-opacity: 0.85;
  }

  @keyframes atmen {
    from {
      --glow: 0.78;
    }

    to {
      --glow: 1;
    }
  }

  /* Placed in door units, so it stays in the light at every screen size:
     the beam ends up 0.75% of the door height left of the middle. */
  .widmung {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: calc(var(--door-h) * 0.024 + 0.6em);
    width: 100%;
    margin-top: calc(var(--door-h) * 0.05);
    color: var(--accent);
    font-size: clamp(1.2rem, 1rem + 0.9vw, 1.7rem);
    font-weight: 200;
    letter-spacing: 0.04em;
    translate: calc(var(--door-h) * -0.0075) 0;
  }

  .widmung span:first-child {
    justify-self: end;
  }

  /* The two words wait until the reader has arrived (main.js sets .is-da on the footer),
     then they come slowly. By then the bar at the top has gone: main.js counts --angekommen
     from 0 to 1 over the last stretch of the page. Nothing else is left on the screen. */
  .js:not(.is-calm) .widmung {
    opacity: 0;
    transition: opacity 0.8s;
  }

  .js:not(.is-calm) .is-da .widmung {
    opacity: 1;
    transition: opacity 3.2s ease 0.6s;
  }

  .js:not(.is-calm) .hud {
    opacity: calc((0.97 - var(--angekommen, 0)) * 6);
  }

  .js:not(.is-calm) .hud:hover,
  .js:not(.is-calm) .hud:focus-within {
    opacity: 1;
  }
}

@layer motion {
  /* things arrive when you get to them; only if scripts run, so nothing stays hidden without them */
  .js [data-reveal] {
    opacity: 0;
    translate: 0 1.4rem;
    transition: opacity 1.1s var(--ease), translate 1.3s var(--ease);
  }

  .js [data-reveal].is-in {
    opacity: 1;
    translate: 0 0;
  }

  /* drawings draw themselves (every path carries pathLength="1") */
  .js .draw path,
  .js .umzug__links path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 1.8s var(--ease), stroke 0.3s;
  }

  .js .draw.is-in path,
  .js .umzug.is-in .umzug__links path {
    stroke-dashoffset: 0;
  }

  .js .umzug__links path {
    transition-delay: 0.4s;
  }

  .js .umzug__links [data-link='offen'] {
    transition-delay: 1.3s;
  }

  /* the log of the ordinary day is written line by line
     (sibling-index() is new; where it is missing, all lines come at once) */
  .js .protokoll li {
    opacity: 0;
    transition: opacity 0.7s var(--ease);
    transition-delay: calc(sibling-index() * 0.11s);
  }

  .js .protokoll.is-in li {
    opacity: 1;
  }

  /* the stars are there first, then the frame is found, then the open leaf */
  .js .sternkarte path.sternkarte__linie {
    transition-duration: 2.4s;
    transition-delay: 0.6s;
  }

  .js .sternkarte path.sternkarte__linie--blatt {
    transition-delay: 2.2s;
  }

  .js .draw text {
    opacity: 0;
    transition: opacity 0.8s 1s, fill 0.3s;
  }

  .js .draw.is-in text {
    opacity: 1;
  }

  .rise > span {
    animation: rise 1.5s var(--ease) both;
  }

  .rise:nth-child(2) > span {
    animation-delay: 0.14s;
  }

  .hero__date,
  .hero__lead,
  .hero__hint,
  .door--hero {
    animation: appear 1.8s ease 0.5s both;
  }

  .door--hero {
    animation-delay: 0.1s;
  }

  .hero__hint-line {
    animation: drip 2.8s var(--ease) infinite;
  }

  @keyframes rise {
    from {
      translate: 0 105%;
    }
  }

  @keyframes appear {
    from {
      opacity: 0;
    }
  }

  @keyframes drip {
    0% {
      scale: 1 0;
    }

    60% {
      scale: 1 1;
      opacity: 1;
    }

    100% {
      scale: 1 1;
      opacity: 0;
    }
  }

  /* Calm mode. The device asked for less motion, so nothing travels across the screen:
     things fade in where they are, and the loops stand still.
     main.js sets .is-calm (the reader may switch it off); without scripts the media query decides. */
  .is-calm {
    scroll-behavior: auto;
  }

  .is-calm [data-reveal] {
    translate: 0 0;
  }

  .is-calm .rise > span {
    animation-name: appear;
  }

  .is-calm .takt__leaf,
  .is-calm .tage__linie--offen i,
  .is-calm .hero__hint-line,
  .is-calm .dusk {
    animation: none;
  }

  /* every second door stays open, so the row still reads open, shut, open, shut */
  .is-calm .takt > svg:nth-child(even) .takt__leaf {
    rotate: -90deg;
  }

  @media (prefers-reduced-motion: reduce) {
    .no-js {
      scroll-behavior: auto;
    }

    .no-js .rise > span {
      animation-name: appear;
    }

    .no-js .takt__leaf,
    .no-js .tage__linie--offen i,
    .no-js .hero__hint-line,
    .no-js .dusk {
      animation: none;
    }

    .no-js .takt > svg:nth-child(even) .takt__leaf {
      rotate: -90deg;
    }
  }

  @media print {
    .hud,
    .toc,
    .himmel,
    .hero__hint,
    .schwelle__du {
      display: none;
    }

    .js [data-reveal] {
      opacity: 1;
      translate: 0 0;
    }
  }
}
