/* Traueranzeige Dr.-Ing. Alfred Weber
   Vorlage: Entwurf "Fassung B". Das Blatt ist ein goldenes Rechteck (706 x 1142 px im Originalmaß, 1 : φ).
   Alle Größen und Abstände folgen einem System aus goldenem Schnitt und Fibonacci-Zahlen:
     Schriftgrade 17 / 21 / 55 px (21 · √φ ≈ 27 für Zeilen, 34 = 21 · φ als Zeilenabstand des Fließtextes)
     Abstände 8 / 13 / 21 / 34 / 55 px (innerhalb einer Gruppe 8 oder 13, zwischen Gruppen 21, zwischen
     Abschnitten 34, Rand 55)
     Foto: Außenhöhe = Höhe des Inhaltsbereichs / φ³ (1035 → 244,3 px), Seitenverhältnis 4 : 5
     Kerze: Höhe = Fotohöhe / φ, Körper Breite : Höhe = 1 : φ, Flammenzone = Körperbreite, Abstand zum Foto = Breite / φ
   Bildschirm: weiße Schrift und Rahmen auf schwarzem Grund, lebende Flamme.
   Druck: schwarz auf weiß, Blatt auf A4 verkleinert (siehe @media print), ruhige Strichkerze.
   Ab 794 px Fensterbreite entspricht die Seite dem Originalmaß. Darunter passen sich Abstände und
   Schriftgrade an, ohne unter gut lesbare Mindestwerte zu fallen. */

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/eb-garamond-roman.woff2") format("woff2");
}

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 800;
  font-display: swap;
  src: url("/eb-garamond-italic.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --ink: #ffffff;
  --paper: #000000;
  /* Eine Einheit = 1 % der Innenbreite des Blattes (688 px im Originalmaß).
     Unter 726 px Fensterbreite ist das Blatt so breit wie das Fenster minus 38 px Rand und Rahmen. */
  --u: min(6.88px, calc((100vw - 38px) / 100));
  /* Fibonacci-Abstände, auf schmalen Bildschirmen anteilig kleiner */
  --s8: 8px;
  --s13: clamp(8px, calc(var(--u) * 1.89), 13px);
  --s21: clamp(14px, calc(var(--u) * 3.05), 21px);
  --s34: clamp(20px, calc(var(--u) * 4.94), 34px);
  --s55: clamp(24px, calc(var(--u) * 8), 55px);
  /* Schriftgrade */
  --t17: clamp(16px, calc(var(--u) * 2.4709), 17px);
  --t21: clamp(18px, calc(var(--u) * 3.0523), 21px);
  --t55: clamp(18px, calc(var(--u) * 7.9942), 55px);
  --leading: 1.618;
  /* Fußpunkt der Flamme in Viewbox-Koordinaten der Kerze (siehe tools/kerze.py) */
  --flame-origin: 28.84px 56.48px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "EB Garamond", Garamond, "Times New Roman", Times, serif;
  font-weight: 500;
  overflow-wrap: break-word;
}

p,
h1 {
  margin: 0;
}

/* Nur für Vorleseprogramme: Die sichtbaren Zeichen * und † werden dort als
   "geboren am" und "gestorben am" gesprochen. Unsichtbar und ohne Einfluss auf das Layout. */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

/* Rand um das Blatt: 55 px im Originalmaß, auf kleinen Bildschirmen mindestens 10 px. */
.page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(10px, calc(50vw - 353px), 55px);
}

/* Äußerer Rahmen (3 / 5 / 1 px: Linie, Zwischenraum, Linie). Mindesthöhe im goldenen Schnitt zur Breite (706 x 1142 px);
   braucht der Text auf schmalen Bildschirmen mehr Höhe, wächst der Rahmen mit. */
.sheet {
  display: flex;
  width: 100%;
  max-width: 706px;
  min-height: min(1142px, calc((100vw - 20px) * 1142 / 706));
  border: 3px solid var(--ink);
  padding: 5px;
}

/* Innerer Rahmen: Rand oben und seitlich 55, unten 34. */
.inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  row-gap: var(--s34);
  border: 1px solid var(--ink);
  padding: var(--s55) clamp(14px, calc(var(--u) * 8), 55px) var(--s34);
  text-align: center;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s34);
}

/* Foto → Einleitung 34 (= 21 + 13), Einleitung → Name 21 */
.head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s21);
}

/* Porträt mit Kerze: Die Figur ist genau so breit wie das Porträt und bleibt dadurch auf der Mittelachse.
   Die Kerze steht absolut daneben und beeinflusst den Textfluss nicht. */
.figure {
  position: relative;
  margin-bottom: var(--s13);
}

/* Foto 193.9 x 242.3 px (außen 195.9 x 244.3 = Inhaltshöhe 1035 / φ³) */
.portrait {
  display: block;
  box-sizing: content-box;
  width: clamp(128px, calc(var(--u) * 28.18), 193.86px);
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--ink);
}

/* Kerze 57.68 x 151.00 px, Unterkante bündig mit der Unterkante des Fotos, skaliert mit dem Foto.
   Auf schmalen Bildschirmen schrumpft nur der Abstand, damit rechts Luft zum inneren Rahmen bleibt. */
.candle {
  position: absolute;
  left: 100%;
  bottom: 0;
  width: clamp(38.08px, calc(var(--u) * 8.384), 57.68px);
  aspect-ratio: 57.68 / 151;
  height: auto;
  margin-left: clamp(14px, calc(var(--u) * 5.181), 35.65px);
  color: var(--ink);
  overflow: visible;
}

/* ---- Die Kerze auf dem Bildschirm ----
   Geschichtet im SVG: Lichthöfe, Wachskörper mit Lichtverlauf und Innenglühen, Schmelzpool, blaue Basis,
   äußere Hülle, innere Flamme mit fraktalen Lichtfäden, weißglühender Kern, Flackerschicht, Docht mit Glut.
   Hülle und innere Flamme werden von fraktalem Rauschen verzerrt (SVG-Filter). Alle Bewegung steht hier;
   sie hat acht verschiedene Zyklen (2,3 bis 11 s), sodass sich das Bild erst nach vielen Minuten wiederholt.
   Druck: ruhige Strichkerze (.print-only). */
.print-only {
  display: none;
}

/* Innere Flamme, Lichtfäden, Kern und Flackerschicht hellen die Hülle auf, statt sie zu überdecken. */
.flame-field-inner,
.flame-veins,
.flame-core,
.flame-flare,
.wax-glow {
  mix-blend-mode: screen;
}

.flame-veins {
  opacity: 0.7;
}

/* Das Rauschen steigt auf: Das Feld wandert nach oben, die Formen darin nach unten, auf dem Bildschirm
   stehen sie still. Weglänge 120 = Kachelhöhe des Rauschens im SVG, daher nahtlos. */
.flame-field {
  animation: field-up 5s linear infinite;
}

.flame-body {
  animation: body-down 5s linear infinite;
}

.flame-field-soft,
.flame-field-soft > .flame-body {
  animation-duration: 7s;
}

@keyframes field-up {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-120px);
  }
}

@keyframes body-down {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(120px);
  }
}

/* Die ganze Flamme neigt sich, atmet und streckt sich gelegentlich, um ihren Fußpunkt
   (Koordinaten der SVG-Viewbox, siehe kerze.py). */
.flame {
  transform-box: view-box;
  transform-origin: var(--flame-origin);
  animation: flame-sway 11s ease-in-out infinite;
}

@keyframes flame-sway {
  0%,
  100% {
    transform: rotate(0deg) scale(1, 1);
  }

  14% {
    transform: rotate(2deg) scale(0.985, 0.96);
  }

  27% {
    transform: rotate(-1deg) scale(1.01, 1.03);
  }

  41% {
    transform: rotate(-2.4deg) scale(0.98, 0.965);
  }

  52% {
    transform: rotate(0.6deg) scale(1.015, 1.1);
  }

  60% {
    transform: rotate(1.4deg) scale(1, 1.02);
  }

  74% {
    transform: rotate(-1.6deg) scale(0.99, 0.975);
  }

  88% {
    transform: rotate(1deg) scale(1.005, 1.015);
  }
}

/* Der Kern pulsiert um seinen Fußpunkt. */
.flame-core {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: core-pulse 6.5s ease-in-out infinite;
}

@keyframes core-pulse {
  0%,
  100% {
    transform: scale(1, 1);
    opacity: 1;
  }

  28% {
    transform: scale(0.92, 0.9);
    opacity: 0.85;
  }

  55% {
    transform: scale(1.05, 1.08);
    opacity: 1;
  }

  80% {
    transform: scale(0.97, 0.95);
    opacity: 0.92;
  }
}

/* Die Flackerschicht blitzt unregelmäßig auf (kurzer Zyklus, kleine Amplitude). */
.flame-flare {
  animation: flare 2.3s ease-in-out infinite;
}

@keyframes flare {
  0%,
  100% {
    opacity: 0.1;
  }

  17% {
    opacity: 0.32;
  }

  31% {
    opacity: 0.06;
  }

  48% {
    opacity: 0.26;
  }

  66% {
    opacity: 0.14;
  }

  83% {
    opacity: 0.36;
  }
}

/* Die Lichthöfe und das Glühen im Wachs atmen, der weite Lichthof gegenläufig zum nahen. */
.halo,
.wax-glow,
.pool-light {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: halo-pulse 5.5s ease-in-out infinite;
}

.halo-far {
  animation-duration: 8.5s;
  animation-direction: alternate-reverse;
}

@keyframes halo-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  35% {
    opacity: 0.72;
    transform: scale(0.97);
  }

  70% {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

/* Die Glut am Docht glimmt. */
.ember {
  animation: ember-glow 3.7s ease-in-out infinite;
}

@keyframes ember-glow {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flame,
  .flame-field,
  .flame-body,
  .flame-core,
  .flame-flare,
  .halo,
  .wax-glow,
  .pool-light,
  .ember {
    animation: none;
  }
}

/* Die vier Zeilen des Entwurfs bleiben als Sinnzeilen erhalten. Auf schmalen Bildschirmen wird die
   Schrift bis 16,5 px verkleinert, damit die längste Zeile nicht umbricht; reicht auch das nicht,
   teilt sich eine Zeile ausgewogen in zwei. */
.intro {
  font-size: min(var(--t21), max(16.5px, calc(var(--u) * 5.2)));
  line-height: var(--leading);
  font-style: italic;
}

.intro span {
  display: block;
  text-wrap: balance;
}

.who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s8);
}

h1 {
  font-size: var(--t55);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.dates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: var(--s34);
  row-gap: 0;
  font-size: var(--t21);
  line-height: 1.3;
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

.dates p {
  position: relative;
}

.rule {
  width: 55px;
  height: 0;
  border-top: 1px solid var(--ink);
}

.words {
  display: flex;
  flex-direction: column;
  gap: var(--s13);
  font-size: var(--t21);
  line-height: var(--leading);
}

.words p {
  text-wrap: balance;
}

.pair {
  display: flex;
  flex-direction: column;
}

.signed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s8);
}

.names {
  display: flex;
  flex-direction: column;
  font-size: var(--t21);
  line-height: var(--leading);
}

.names .second {
  font-size: var(--t17);
}

.when {
  font-size: var(--t17);
  line-height: var(--leading);
}

.closing {
  font-size: var(--t17);
  line-height: var(--leading);
  font-style: italic;
  text-wrap: balance;
}

/* Druck: genau ein A4-Blatt, schwarz auf weiß. Das goldene Blatt wird auf 90 % verkleinert,
   damit es mit 44 px Rand auf die A4-Höhe passt; die Kerze erscheint als ruhige Strichzeichnung. */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  :root {
    color-scheme: light;
    --ink: #111111;
    --paper: #ffffff;
  }

  .page {
    display: block;
    min-height: 0;
    height: 296mm;
    padding: 44px;
    overflow: hidden;
  }

  .sheet {
    min-height: 1142px;
    height: auto;
    margin: 0 auto;
    zoom: 0.9;
  }

  .screen-only {
    display: none;
  }

  .print-only {
    display: block;
  }

  .print-outline {
    fill: var(--paper);
  }
}
