@charset "utf-8";

/* ==========================================================================
   Moritz Mader — moritzmader.ch
   Eine Schrift (EB Garamond), Eierschale statt Weiss, viel Ruhe.
   ========================================================================== */

@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-latin.woff2") format("woff2");
  font-weight: 400 700;          /* variabel */
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("../fonts/ebgaramond-latin-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --papier:  #f7f5ef;            /* Eierschale, kein reines Weiss */
  --tinte:   #1b1917;
  --grau:    #7a736a;
  --linie:   rgba(27, 25, 23, .14);

  --rand:      clamp(1.5rem, 4vw, 3.5rem);
  --spalte:    17rem;
  --gitter-x:  clamp(1.5rem, 3vw, 3rem);
  --gitter-y:  clamp(2.75rem, 5vw, 4.5rem);
  --regalhoehe: clamp(10.5rem, 19vw, 18rem);

  --nav-breite: 11rem;
  --weich: cubic-bezier(.4, 0, .2, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font-family: "EB Garamond", Garamond, "Times New Roman", serif;
  font-size: 100%;
  line-height: 1.5;
  font-kerning: normal;
  font-variant-numeric: oldstyle-num;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

img { display: block; max-width: 100%; height: auto; }

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

.sprungmarke {
  position: absolute; left: -100vw; top: 0; z-index: 200;
  padding: .6rem 1rem; background: var(--tinte); color: var(--papier);
}
.sprungmarke:focus { left: 0; }

:focus-visible { outline: 1px solid var(--tinte); outline-offset: 3px; }

/* --------------------------------------------------------------------------
   Ladeschirm — einmal pro Tag, rein per CSS animiert.
   Die Materialien liegen zuerst grau da und nehmen von links nach rechts
   Farbe an: ein Moment zum Ankommen, bevor die Seite erscheint.
   Das Bild hat weissen Grund; multiply legt ihn nahtlos auf die Eierschale.
   -------------------------------------------------------------------------- */

#ladeschirm {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: var(--rand);
  background: var(--papier);
  animation: ladeschirm-weg 3.6s var(--weich) forwards;
}
.ohne-ladeschirm #ladeschirm { display: none; }

/*
 * Der Papierton steckt fest in beiden Bilddateien, nicht in einem Blendmodus.
 * mix-blend-mode scheiterte hier: die Transformation auf dem Vorfahren macht
 * einen eigenen Stacking-Context auf, womit nichts mehr zu multiplizieren war
 * und das Foto als hellweisser Block auf der Eierschale lag.
 */
.ladebild { position: relative; }
.ladebild picture { display: block; }
.ladebild img { max-height: 74vh; width: auto; }

/* Graue Fassung unten, farbige deckungsgleich darueber und maskiert.
   Beide haben denselben Hintergrund, darum ist an der Kante nichts zu sehen. */
.ladebild picture + picture { position: absolute; inset: 0; }
.ladebild picture + picture img { width: 100%; height: 100%; max-height: none; }

.ladebild .farbe {
  /* Weiche Kante, die von links nach rechts ueber das Bild wandert.
     Die Maske ist dreimal so breit wie das Bild und wandert von Position
     100% (nur der durchsichtige Teil liegt darueber, nichts ist farbig)
     nach 0% (nur der deckende Teil, alles ist farbig). Der Verlauf muss
     vor 66,6% durchsichtig sein, sonst liegt anfangs schon Farbe am
     linken Rand. */
  -webkit-mask-image: linear-gradient(90deg, #000 0 45%, rgba(0,0,0,0) 62% 100%);
          mask-image: linear-gradient(90deg, #000 0 45%, rgba(0,0,0,0) 62% 100%);
  -webkit-mask-size: 300% 100%;  mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;  mask-position: 100% 0;
  animation: farbe-einlaufen 2.5s var(--weich) .4s forwards;
}

@keyframes farbe-einlaufen {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  to   { -webkit-mask-position: 0% 0;   mask-position: 0% 0; }
}
@keyframes ladeschirm-weg {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  86%  { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* --------------------------------------------------------------------------
   Kopf und Navigation — links, als Liste
   -------------------------------------------------------------------------- */

.kopf {
  position: fixed; top: 0; left: 0; z-index: 20;
  width: var(--nav-breite);
  padding: var(--rand) 0 var(--rand) var(--rand);
}

.monogramm { display: block; width: 2.6rem; margin-bottom: 2.25rem; }
.monogramm img { width: 100%; height: auto; }

.kopf nav ul { margin: 0; padding: 0; list-style: none; }
.kopf nav li + li { margin-top: .35rem; }

.kopf nav a {
  display: inline-block;
  font-size: 1.0625rem;
  letter-spacing: .012em;
  color: var(--grau);
  transition: color .35s var(--weich);
}
.kopf nav a:hover { color: var(--tinte); }
.kopf nav a[aria-current="page"] { color: var(--tinte); font-style: italic; }

/* --------------------------------------------------------------------------
   Inhalt
   -------------------------------------------------------------------------- */

main {
  margin-left: calc(var(--nav-breite) + var(--rand));
  padding: var(--rand) var(--rand) clamp(4rem, 12vh, 9rem);
  min-height: 100vh;
}

.hinweis { color: var(--grau); }
.hinweis code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; }

/* --------------------------------------------------------------------------
   Regal — Cover behalten ihr Seitenverhaeltnis und stehen auf einer Grundlinie
   -------------------------------------------------------------------------- */

.regal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--spalte), 1fr));
  gap: var(--gitter-y) var(--gitter-x);
  align-items: start;
  margin: 0; padding: 0; list-style: none;
  max-width: 82rem;
}

.buch a { display: block; }

.buch .cover {
  display: flex;
  align-items: flex-end;          /* Buecher stehen auf einer Linie */
  height: var(--regalhoehe);
}

.buch .cover img {
  width: auto; height: auto;
  max-width: 100%; max-height: 100%;
  transition: opacity .4s var(--weich);
}

.buch a:hover .cover img { opacity: .84; }

.beschriftung { display: block; margin-top: .85rem; }

.buchtitel {
  display: block;
  font-size: .9375rem;
  line-height: 1.32;
  padding-bottom: .1em;
  border-bottom: 1px solid transparent;
  transition: border-color .35s var(--weich);
}
.buch a:hover .buchtitel { border-bottom-color: var(--linie); }

.buchunter {
  display: block;
  margin-top: .2rem;
  font-size: .8125rem;
  line-height: 1.36;
  font-style: italic;
  color: var(--grau);
  max-width: 26em;
}

/* --------------------------------------------------------------------------
   Einzelne Projektseite
   -------------------------------------------------------------------------- */

.projekt { max-width: 34rem; }

.brotkrume {
  margin-bottom: 2.25rem;
  font-size: .8125rem; color: var(--grau);
}
.brotkrume a { border-bottom: 1px solid transparent; }
.brotkrume a:hover { border-bottom-color: var(--linie); }

.projekt h1 {
  margin: 0 0 .3rem;
  font-size: 1.5rem; font-weight: 400; line-height: 1.25;
}
.projekt-unter {
  margin: 0 0 2.25rem;
  font-size: 1.0625rem; font-style: italic; color: var(--grau);
}

.projekt-cover { display: block; width: fit-content; margin-bottom: 2.25rem; }
.projekt-cover img { max-width: min(22rem, 60vw); height: auto; }
.projekt-cover:hover img { opacity: .84; }

.projekt-text p { margin: 0 0 1.15rem; font-size: 1.0625rem; line-height: 1.64; }

.projekt-daten {
  display: grid; grid-template-columns: 7rem 1fr;
  gap: .3rem 1rem;
  margin: 2.25rem 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--linie);
  font-size: .875rem;
}
.projekt-daten dt { color: var(--grau); font-style: italic; }
.projekt-daten dd { margin: 0; }

.projekt-aktionen {
  display: flex; flex-wrap: wrap; gap: 1.5rem;
  margin: 0; font-size: .9375rem;
}
.projekt-aktionen a { border-bottom: 1px solid var(--linie); }
.projekt-aktionen a:hover { border-bottom-color: var(--tinte); }

/* --------------------------------------------------------------------------
   Fliesstext (Impressum)
   -------------------------------------------------------------------------- */

.text { max-width: 34rem; }
.text h1 { margin: 0 0 1.6rem; font-size: 1.5rem; font-weight: 400; }
.text h2 {
  margin: 3.75rem 0 1.4rem; padding-top: 1.4rem;
  border-top: 1px solid var(--linie);
  font-size: 1.5rem; font-weight: 400;
}
.text h3 {
  margin: 2rem 0 .4rem;
  font-size: .9375rem; font-weight: 400; font-style: italic; color: var(--grau);
}
.text p { margin: 0 0 1.15rem; font-size: 1.0625rem; line-height: 1.64; }
.text a { border-bottom: 1px solid var(--linie); }
.text a:hover { border-bottom-color: var(--tinte); }
.anschrift { font-variant-numeric: oldstyle-num; }

/* ==========================================================================
   Buch-Viewer
   ========================================================================== */

#viewer {
  position: fixed; inset: 0; z-index: 60;
  background: var(--papier);
  opacity: 0; visibility: hidden;
  transition: opacity .5s var(--weich), visibility .5s;
  touch-action: none;             /* Zoomen und Schieben macht das Skript */
}
#viewer.offen { opacity: 1; visibility: visible; }
body.liest { overflow: hidden; }

/* Buehne: haelt die Doppelseite mittig, Raum oben fuer die Bedienung */
.buehne {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(3.5rem, 7vh, 5rem) clamp(1rem, 4vw, 3.5rem) clamp(3rem, 6vh, 4rem);
}

.spread {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;      /* definite Masse, damit max-% der Bilder greift */
  opacity: 0;
  transition: opacity .32s var(--weich);
  transform-origin: 50% 50%;
  will-change: transform;
}
.spread.da { opacity: 1; }
/* Beim Zoomen weich nachziehen, beim Schieben mit dem Finger nicht */
.spread.federt { transition: opacity .32s var(--weich), transform .28s var(--weich); }

/* Sobald hineingezoomt ist, schiebt der Finger das Bild, statt zu blaettern */
#viewer.gezoomt .blaettern { pointer-events: none; }
#viewer.gezoomt .spread img { box-shadow: none; }

.spread img {
  width: auto; height: auto;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 1px 2px rgba(27,25,23,.07), 0 8px 26px rgba(27,25,23,.06);
}
/* Falz: die beiden Seiten stossen ohne Abstand aneinander */
.spread.zwei img:first-child { max-width: 50%; }
.spread.zwei img:last-child  { max-width: 50%; }
.spread.eins img { max-width: 100%; }

/* Bedienung — tritt bei Ruhe zurueck */
.steuer {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(.9rem, 2.4vh, 1.6rem) clamp(1rem, 4vw, 2.25rem);
  opacity: 1; transition: opacity .5s var(--weich);
  pointer-events: none;
}
#viewer.ruhig .steuer { opacity: 0; }
.steuer > * { pointer-events: auto; }

.steuer button {
  margin: 0; padding: .25rem .5rem;
  border: 0; background: none; cursor: pointer;
  font-family: inherit; font-size: 1.5rem; line-height: 1;
  color: var(--grau);
  transition: color .3s var(--weich), opacity .3s var(--weich);
}
.steuer button:hover { color: var(--tinte); }
.steuer button[disabled] { opacity: .22; cursor: default; }
.rechts { display: flex; align-items: center; gap: clamp(.75rem, 2vw, 1.5rem); }
.schliessen { font-size: 1.25rem !important; }

/* Titelzeile mittig, sehr zurueckhaltend */
.buchkopf {
  flex: 1; text-align: center;
  padding: 0 1rem;
  font-size: .8125rem; line-height: 1.3; color: var(--grau);
}
.buchkopf em { font-style: italic; }
.buchkopf b { font-weight: 400; color: var(--tinte); }

/* Einmaliger Hinweis, wenn das Telefon hochkant gehalten wird.
   Die Doppelseite bleibt bestehen — sie ist nur quer bequemer zu lesen. */
.drehhinweis {
  position: absolute; left: 50%; bottom: 3.25rem; z-index: 3;
  transform: translateX(-50%);
  margin: 0; padding: .5rem .9rem;
  white-space: nowrap;
  font-size: .8125rem; font-style: italic; color: var(--grau);
  background: var(--papier);
  border: 1px solid var(--linie); border-radius: 2px;
  opacity: 0; pointer-events: none;
  animation: hinweis-zeigen 5s var(--weich) forwards;
}
@keyframes hinweis-zeigen {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  72%  { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* Seitenzaehler unten */
.zaehler {
  position: absolute; left: 0; right: 0; bottom: clamp(.9rem, 2.4vh, 1.5rem);
  text-align: center; font-size: .75rem; letter-spacing: .04em; color: var(--grau);
  opacity: 1; transition: opacity .5s var(--weich); pointer-events: none;
}
#viewer.ruhig .zaehler { opacity: 0; }

/* Unsichtbare Klickflaechen zum Blaettern: je eine Haelfte, wie im Buch.
   Die Pfeile oben liegen darueber und bleiben klickbar. */
.blaettern {
  position: absolute; top: 0; bottom: 0; z-index: 1;
  width: 50%; border: 0; background: none; padding: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.blaettern.zurueck { left: 0;  cursor: w-resize; }
.blaettern.vor     { right: 0; cursor: e-resize; }
.blaettern[disabled] { cursor: default; }

/* --------------------------------------------------------------------------
   Mobil
   -------------------------------------------------------------------------- */

@media (max-width: 46rem) {
  :root { --regalhoehe: clamp(8.5rem, 34vw, 13rem); --spalte: 8.5rem; }

  .kopf {
    position: static; width: auto;
    padding: var(--rand) var(--rand) 0;
    display: flex; align-items: center; gap: 1.5rem;
  }
  .monogramm { width: 2rem; margin: 0; }
  .kopf nav ul { display: flex; gap: 1.25rem; }
  .kopf nav li + li { margin-top: 0; }

  main { margin-left: 0; padding-top: 2rem; min-height: 0; }

  .buehne { padding: 3.25rem .5rem 2.5rem; }
  .steuer button { font-size: 1.75rem; padding: .35rem .6rem; }
  .buchkopf { font-size: .75rem; }
}

/* Telefon quer: fast der ganze Schirm gehoert der Doppelseite.
   Das ist die Haltung, in der ein Buch am Telefon Sinn ergibt. */
@media (orientation: landscape) and (max-height: 30rem) {
  .buehne { padding: 2.25rem .5rem 1.5rem; }
  .steuer { padding: .3rem .75rem; }
  .steuer button { font-size: 1.4rem; padding: .2rem .45rem; }
  .buchkopf { display: none; }        /* zu wenig Hoehe fuer den Titel */
  .zaehler { bottom: .3rem; font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  #ladeschirm { animation: ladeschirm-weg .6s linear forwards; }
}
