/* ==========================================================================
   Madame Süsette — Vintage Fashion Walk Málaga
   Prototype: 01-prototyp-template-exact
   --------------------------------------------------------------------------
   Every measurement below was taken directly from the five-page design
   template (pixel-measured: sidebar width, heading positions, divider
   widths, photo crop, text-column margins). Ornament images are NOT
   redrawn — they are cropped directly from the template file itself
   (assets/ornaments/*.png) and the photo is cropped from the template's
   own Vorwort page. Nothing here is invented.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap');

:root {
  /* Exact palette as specified: Bordeaux for ALL text, warm neutrals for
     backgrounds. Gold is reserved strictly for fine ornament graphics
     (sidebar vine, star, divider flourish, map pin) — never for text. */
  --color-paper: #f2e7d2;       /* Creme — slightly lighter & warmer, per feedback */
  --color-beige: #e8ded2;       /* warmes Beige */
  --color-sand:  #d8c9b6;       /* Sand */
  --color-bordeaux: #632530;    /* all typography, no exceptions — slightly darker for readability */
  --color-spine: #5c4130;       /* lighter dark brown book spine — ornaments on it stay gold */
  --color-gold: #b8935c;        /* ornament graphics only */

  --font-heading: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  /* Page geometry — ratio 700:997 = 0.7020, matching the template's
     measured 924:1316 = 0.7022 ratio (NOT 3:4). */
  --page-w: 700px;
  --page-h: 997px;
  --sidebar-w: 94px; /* 13.4% of page width, measured on all 5 template pages */
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  background: #2a1410;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; overscroll-behavior: none; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }

a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ==========================================================================
   App shell
   ========================================================================== */

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #3a1c14 0%, #221009 78%);
}

/* ==========================================================================
   "Handyansicht prüfen" — desktop-only control tool that previews the book
   inside a phone-sized, framed box. NOT part of the book pages, NEVER
   printed (see @media print), and does not replace real mobile responsive
   behavior — it reuses the exact same layout logic, just inside a
   constrained container, so what you see here is genuinely representative.
   ========================================================================== */
body.mobile-preview-active {
  overflow: hidden;
}
body.mobile-preview-active #app {
  position: fixed;
  inset: auto;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 390px;
  height: 844px;
  border: 10px solid #1a0d08;
  border-radius: 32px;
  box-shadow: 0 0 0 2px rgba(184,147,92,0.5), 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  z-index: 500;
}
/* Mirror the real small-screen chrome rules here too: the browser's own
   viewport is still desktop-sized in this preview (only #app itself is
   shrunk), so the real `@media (max-width: 860px)` query never fires on
   its own — without this, the toolbar would overflow the 390px frame. */
body.mobile-preview-active #top-bar,
body.mobile-preview-active #bottom-bar { padding: 8px 10px; }
body.mobile-preview-active .book-title-chrome { display: none; }
body.mobile-preview-active .chrome-btn.wide span.label { display: none; }
body.mobile-preview-active .chrome-group { gap: 4px; }
body.mobile-preview-active .chrome-btn { min-width: 40px; min-height: 40px; }
body.mobile-preview-active #stage { padding-top: 8px; padding-bottom: 8px; }
body.mobile-preview-active::before {
  /* dim the rest of the desktop UI behind the phone-preview frame */
  content: "";
  position: fixed; inset: 0;
  background: rgba(10, 5, 3, 0.72);
  z-index: 400;
}
#mobile-preview-btn.is-active { background: var(--color-gold); color: #241109; border-color: var(--color-gold); }

#stage {
  position: relative; flex: 1 1 auto; width: 100%;
  min-height: 0; perspective: 2600px;
  padding-top: 24px; padding-bottom: 24px; /* desktop breathing room from the toolbars */
  overflow: hidden;
}

#book-scaler {
  position: absolute;
  transform-origin: top left; /* fixed for both desktop and mobile — see
    script.js updateScale(): position (top/left) and size are now always
    computed explicitly in pixels for the CURRENT mode (desktop: centered
    both axes; mobile: horizontally centered, anchored near the top), so
    there is no more reliance on flexbox to center a not-yet-scaled box.
    That old center-via-flexbox-then-scale-with-an-origin approach is
    exactly what caused the earlier bugs (desktop pushed up, then mobile
    pushed further up still) — this removes the interaction entirely. */
  flex-shrink: 0;
}

/* ==========================================================================
   Page base — no footer, no page number: the template shows none on the
   cover, none on the contents page, and this prototype intentionally
   omits the small "04"-style folio the template shows on interior pages
   (see README for the specific note on this).
   ========================================================================== */

.page {
  position: relative;
  width: var(--page-w);
  height: var(--page-h);
  background-color: var(--color-paper);
  background-image:
    radial-gradient(ellipse at 15% 8%, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 45%);
  overflow: hidden;
  color: var(--color-bordeaux);
}

.page::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background-color: var(--color-spine);
  background-image: url('assets/ornaments/vine-overlay.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  z-index: 1;
}

.page-content {
  position: relative; z-index: 2;
  margin-left: var(--sidebar-w);
  height: 100%;
  padding: 64px 52px 34px 52px; /* top right bottom left — symmetric left/right so centering is true */
  display: flex; flex-direction: column;
}

/* ==========================================================================
   Heading system (star / heading / divider) — shared by pages 2–5
   ========================================================================== */

.heading-block { flex: 0 0 auto; text-align: center; }

.eyebrow {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 17px;
  color: var(--color-bordeaux);
  margin: 0 0 2px;
}

.chapter-star {
  width: 15px; height: 15px;
  margin: 0 auto 9px;
  display: block;
}

.chapter-heading {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-bordeaux);
  font-size: 46px;
  line-height: 1.1;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  margin: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.chapter-subheading {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 21px;
  color: var(--color-bordeaux);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin: 3px 0 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.heading-divider {
  display: block;
  width: 205px;
  height: auto;
  margin: 11px auto 15px;
}

/* bottom divider (present on Vorwort / Hinweise / Start, per the template —
   but NOT paired with a page number here, see README) */
.bottom-divider {
  display: block;
  width: 205px;
  height: auto;
  margin: auto auto 0;
  padding-top: 6px;
}

/* ==========================================================================
   Body copy
   ========================================================================== */

.page-body {
  flex: 1 1 auto;
  min-height: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.46;
  color: var(--color-bordeaux);
}

.page-body p { margin: 0 0 9px; }
.page-body p:last-child { margin-bottom: 0; }
.page-body em { font-style: italic; }

/* Vorwort / Der Start: left-aligned running text (as in the template) */
.page-body.align-left p { text-align: center; }

/* Shop-name subheadings within a left-aligned running page (e.g. the
   combined PARD-A / Oysters / Flamingos page) — .body-subhead previously
   only had styling under the centered Hinweise-page context. */
.page-body.align-left .body-subhead {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 19px;
  color: var(--color-bordeaux);
  text-align: center;
  margin: 16px 0 6px;
}
.page-body.align-left .body-subhead:first-child { margin-top: 0; }

/* Wichtige Hinweise: fully centered layout (as in the template) */
.page-body.align-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.page-body.align-center p,
.page-body.align-center .body-subhead {
  text-align: center;
  max-width: 470px;
}
.page-body.align-center .body-subhead {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  color: var(--color-bordeaux);
  margin: 20px 0 10px;
}
.page-body.align-center .body-subhead:first-child { margin-top: 6px; }

/* ==========================================================================
   Photo — plain image, no frame, no border, no shadow (template shows none)
   ========================================================================== */

.plain-photo {
  width: 87%;
  margin: 0 auto 8px;
}
.plain-photo img { width: 100%; height: auto; display: block; }

.wide-photo {
  width: 100%;
  margin: 4px 0 12px;
}
.wide-photo img { width: 100%; height: auto; display: block; }

/* Portrait-oriented shop photos (much taller than wide) — sized by
   height rather than width so they don't dominate the page. */
.portrait-photo {
  margin: 0 auto 10px;
  text-align: center;
}
.portrait-photo img {
  height: 400px;
  width: auto;
  max-width: 100%;
  display: inline-block;
}
/* Joan Charity Shop has noticeably more running text than Mosaico/Mapas,
   so its photo is sized a little more conservatively to keep the page
   balanced and avoid overflow. */
[data-key="joan"] .portrait-photo img {
  height: 340px;
}
[data-key="colorhueso"] .portrait-photo img {
  height: 300px;
}
[data-key="flamingos"] .portrait-photo img {
  height: 370px;
}
[data-key="epoca"] .portrait-photo img {
  height: 350px;
}

[data-key="peninsula"] .portrait-photo img {
  height: 310px;
}
[data-key="anitaberber"] .portrait-photo img {
  height: 300px;
}
[data-key="quasipercaso"] .portrait-photo img {
  height: 380px;
}

/* ==========================================================================
   Google Maps feature block (Der Start page)
   ========================================================================== */

/* ==========================================================================
   Audio-Bereich — einheitliches Design, nie automatische Wiedergabe.
   Schmaler Bordeaux-Rahmen, cremefarbener Hintergrund, liegt vollständig
   innerhalb der hellen Inhaltsfläche (kein Überlappen der Ornamente).
   ========================================================================== */

.audio-section {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1.5px solid var(--color-bordeaux);
  background: var(--color-paper);
  border-radius: 3px;
  text-align: center;
}
.audio-section .audio-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--color-bordeaux);
  text-transform: uppercase;
  margin: 0 0 4px;
}
.audio-section .audio-description {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 14px;
  color: var(--color-bordeaux);
  margin: 0 0 10px;
}
.audio-section audio {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 36px;
  margin: 0 auto;
}

.maps-block {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.maps-block img { width: 26px; height: 26px; flex: none; }
.maps-block .maps-name {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 16px;
  color: var(--color-bordeaux);
}
.maps-block a.maps-link {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-bordeaux);
  text-decoration: underline;
}

/* ==========================================================================
   Table of contents — flush-left, no indentation differences, no
   "Die Läden:" subheading (confirmed absent in the template)
   ========================================================================== */

.toc-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 9px;
  font-family: var(--font-heading);
}
.toc-list .toc-link {
  display: block;
  text-decoration: none;
  color: var(--color-bordeaux);
  font-size: 17px;
  padding: 1px 0;
}
.toc-list .toc-link:hover, .toc-list .toc-link:focus-visible {
  color: var(--color-gold);
}
.toc-list span.toc-link { cursor: default; }

/* ==========================================================================
   Cover page — exact template wording, no footer, no page number
   ========================================================================== */

.cover-page .page-content {
  align-items: center; justify-content: center; text-align: center;
  padding-top: 0; padding-bottom: 0;
}
.cover-title-eyebrow {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 33px;
  letter-spacing: 0.42em;
  color: var(--color-bordeaux);
  margin: 0 0 6px;
}
.cover-title-main {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 84px;
  letter-spacing: 0.05em;
  color: var(--color-bordeaux);
  margin: 0 0 16px;
  line-height: 1;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cover-rule { width: 230px; height: auto; margin: 0 auto 18px; }
.cover-sub1 {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 29px;
  letter-spacing: 0.09em;
  color: var(--color-bordeaux);
  margin: 0 0 3px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cover-sub2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 48px;
  letter-spacing: 0.05em;
  color: var(--color-bordeaux);
  margin: 3px 0 22px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cover-tagline {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 17px;
  line-height: 1.5;
  color: var(--color-bordeaux);
  max-width: 360px;
  margin: 0 auto 30px;
}
.cover-hr { width: 120px; height: 1px; background: var(--color-bordeaux); margin: 0 auto 22px; opacity: 0.8; }
.cover-keywords {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.13em;
  color: var(--color-bordeaux);
}

/* ==========================================================================
   Spreads / layers (navigation + animation) — identical mechanics to the
   original engine, unrelated to the visual-fidelity fixes above.
   ========================================================================== */

.layer {
  position: absolute; inset: 0;
  transform-origin: center center;
  transition: transform 460ms cubic-bezier(.42,.06,.18,1), opacity 460ms ease;
  backface-visibility: hidden;
  z-index: 10;
}
.layer.leaving-next { transform: translateX(-3%) rotateY(-10deg) scale(.985); opacity: 0; }
.layer.leaving-prev { transform: translateX(3%) rotateY(10deg) scale(.985); opacity: 0; }
.layer.entering-from-next { transform: translateX(3%) rotateY(10deg) scale(.985); opacity: 0; }
.layer.entering-from-prev { transform: translateX(-3%) rotateY(-10deg) scale(.985); opacity: 0; }
.layer.settled { transform: translateX(0) rotateY(0) scale(1); opacity: 1; }

.spread {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.spread.is-double::after {
  content: "";
  position: absolute; left: 50%; top: 0; bottom: 0; width: 22px; margin-left: -11px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(122,46,58,0.10), rgba(122,46,58,0) 50%, rgba(122,46,58,0) 50%, rgba(122,46,58,0.10));
  z-index: 5;
}
.slot { position: relative; width: var(--page-w); height: var(--page-h); overflow: hidden; }
.slot .page { position: absolute; inset: 0; }

/* ==========================================================================
   Controls / chrome
   ========================================================================== */

#top-bar, #bottom-bar {
  position: relative; z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  color: #e9d7b8; font-family: var(--font-heading); flex: 0 0 auto;
}
#top-bar { justify-content: space-between; }
#bottom-bar { justify-content: center; }
.book-title-chrome { font-size: 14px; letter-spacing: 0.06em; opacity: 0.8; white-space: nowrap; }
.chrome-btn {
  background: rgba(241,229,207,0.08); border: 1px solid rgba(184,147,92,0.4);
  color: #e9d7b8; border-radius: 3px; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.chrome-btn:hover { background: rgba(184,147,92,0.18); border-color: var(--color-gold); }
.chrome-btn:disabled { opacity: 0.35; cursor: default; }
.chrome-btn.wide { width: auto; padding: 0 14px; font-size: 13px; letter-spacing: 0.05em; gap: 8px; }
.chrome-group { display: flex; align-items: center; gap: 8px; }
#page-indicator { font-size: 13px; min-width: 92px; text-align: center; opacity: 0.85; }

.side-hit { position: absolute; top: 0; bottom: 0; width: 18%; z-index: 30; background: transparent; border: none; }
.side-hit.left { left: 0; }
.side-hit.right { right: 0; }

#stage.is-zoomed #book-scaler { cursor: zoom-out; }
#stage.is-zoomed { overflow: auto; }

/* ==========================================================================
   TRUE MOBILE — real responsive reflow, NOT a scaled-down miniature of
   the desktop page. Applied via the "true-mobile-reflow" class that
   script.js toggles on <body> whenever EITHER the real viewport is
   ≤600px OR the desktop "Handyansicht prüfen" preview frame is active —
   a plain class (rather than only a @media query) is used specifically
   so the exact same real responsive layout also runs correctly inside
   that simulated phone frame, as required, instead of just being a
   miniature preview of the desktop layout.

   Content reorders into normal document flow here: fixed page
   width/height, the scale-to-fit transform, and the 3D flip transforms
   are all switched off. Only ONE page is ever shown (isMobile() in
   script.js already forces single-page mode at this width), but that
   page can now be taller than the screen and scroll normally — exactly
   like reading any responsive web page.

   The desktop scaled/paginated system elsewhere in this file is
   completely untouched: none of these rules apply unless the JS-driven
   class is present, and the PDF (druckversion.html, a separate static
   file that never loads script.js or this class) cannot be affected.
   ========================================================================== */
body.true-mobile-reflow {
  --sidebar-w: 40px; /* much narrower than the 94px desktop sidebar — the
    light content area gets the large majority of the width, per the
    requirement. Ornaments scale down with it automatically since the
    vine background uses background-size: 100% 100%. */
}

html:has(body.true-mobile-reflow),
body.true-mobile-reflow { height: auto; overflow-y: auto; overflow-x: hidden; }

body.true-mobile-reflow:not(.mobile-preview-active) #app { position: fixed; inset: 0; } /* top/bottom bars stay reachable; only #stage scrolls. Scoped away from the preview frame, which positions #app itself (centered, fixed 390×844 box) — this must not override that. */

body.true-mobile-reflow #stage {
  perspective: none;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: block;
}
body.true-mobile-reflow .side-hit { display: none; } /* edge-tap zones would fight normal scrolling/tapping links here — swipe + the prev/next buttons remain */

body.true-mobile-reflow #book-scaler {
  position: static !important;
  transform: none !important;
  width: 100% !important;
  height: auto !important;
  left: auto !important; top: auto !important;
}

body.true-mobile-reflow .spread {
  position: static; width: 100%; height: auto; display: block;
}
body.true-mobile-reflow .spread.is-double::after { display: none; } /* no two-page spreads on true mobile */

body.true-mobile-reflow .slot { position: static; width: 100%; height: auto; overflow: visible; }

body.true-mobile-reflow .layer {
  position: static; inset: auto;
  transform: none !important;
  transition: opacity 260ms ease;
}
body.true-mobile-reflow .layer.leaving-next,
body.true-mobile-reflow .layer.leaving-prev,
body.true-mobile-reflow .layer.entering-from-next,
body.true-mobile-reflow .layer.entering-from-prev,
body.true-mobile-reflow .layer.settled {
  transform: none !important; /* only opacity animates on true mobile */
}

body.true-mobile-reflow .page {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: calc(100svh - 116px);
  overflow: visible !important;
}

body.true-mobile-reflow .page-content {
  width: calc(100% - var(--sidebar-w));
  max-width: calc(100% - var(--sidebar-w));
  margin-left: var(--sidebar-w);
  height: auto;
  min-height: calc(100svh - 116px);
  padding: 22px 14px 26px;
  overflow: visible;
}

/* Photos: natural, fluid width instead of fixed pixel sizes. */
body.true-mobile-reflow .wide-photo,
body.true-mobile-reflow .portrait-photo { width: 100%; margin-left: 0; margin-right: 0; }
body.true-mobile-reflow .wide-photo img { width: 100%; height: auto; }
body.true-mobile-reflow .portrait-photo { text-align: center; }
body.true-mobile-reflow .portrait-photo img {
  height: auto; width: 78%; max-width: 320px;
}
body.true-mobile-reflow .plain-photo { width: 100%; }

body.true-mobile-reflow .audio-section,
body.true-mobile-reflow .audio-section audio {
  width: 100%; max-width: 100%; box-sizing: border-box;
}
body.true-mobile-reflow .maps-block { width: 100%; }

/* Larger, genuinely readable type — safe now that page height is no
   longer fixed/clipped, so bigger text simply makes the page taller and
   scrollable rather than risking clipped content. */
body.true-mobile-reflow .page-body { font-size: 17px; line-height: 1.62; }
body.true-mobile-reflow .page-body .body-subhead { font-size: 20px; }
body.true-mobile-reflow .chapter-heading { font-size: 32px; }
body.true-mobile-reflow .chapter-heading.tight { font-size: 28px; }
body.true-mobile-reflow .chapter-subheading { font-size: 17px; }
body.true-mobile-reflow .eyebrow { font-size: 15px; }
body.true-mobile-reflow .cover-title-eyebrow { font-size: clamp(18px, 5.5vw, 22px); letter-spacing: 0.28em; }
body.true-mobile-reflow .cover-title-main {
  font-size: clamp(36px, 11vw, 46px);
  letter-spacing: 0.025em;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}
body.true-mobile-reflow .cover-sub1 { font-size: clamp(15px, 4.8vw, 19px); letter-spacing: 0.055em; }
body.true-mobile-reflow .cover-sub2 { font-size: clamp(27px, 8vw, 32px); }
body.true-mobile-reflow .cover-tagline { font-size: 15px; }
body.true-mobile-reflow .toc-list .toc-link { font-size: 18px; }
body.true-mobile-reflow .audio-section .audio-title { font-size: 15px; }
body.true-mobile-reflow .audio-section .audio-description { font-size: 14px; }
body.true-mobile-reflow .maps-block .maps-name { font-size: 16px; }
body.true-mobile-reflow .maps-block a.maps-link { font-size: 15px; }



@media (max-width: 860px), (max-aspect-ratio: 4/5) {
  #top-bar, #bottom-bar { padding: 8px 10px; }
  .book-title-chrome { display: none; }
  .chrome-btn.wide span.label { display: none; }

  /* Mobile-only: anchor scaling from the top so the single visible page
     lines up cleanly under the compact mobile toolbar, using the small
     dedicated mobile padding computed in script.js (isMobile() ? 8 : 24).
     This must stay scoped to mobile — applying it on desktop breaks
     vertical centering there (flexbox centers the pre-scale box, and a
     top-anchored scale then keeps that top edge fixed instead of
     shrinking symmetrically, pushing the book upward). */
  #stage { padding-top: 8px; padding-bottom: 8px; }

  /* "Handyansicht prüfen" is a desktop-only simulation tool for previewing
     the phone layout from a desktop browser. On a real phone the mobile
     layout is already active, so the button is redundant there and is
     hidden — this uses the same real viewport media query that already
     drives the rest of the mobile layout, so it activates automatically. */
  #mobile-preview-btn { display: none !important; }

  /* Forward/back buttons at least 44×44 px, per mobile usability
     requirements — comfortably tappable with a thumb. */
  #prev-btn, #next-btn, #zoom-btn, #fullscreen-btn, #toc-btn {
    min-width: 44px;
    min-height: 44px;
  }
  #page-indicator { font-size: 14px; }

  /* Never allow horizontal scrolling on small screens. */
  html, body { overflow-x: hidden; }

  /* Audio player spans almost the full available width on phones. */
  .audio-section audio { height: 40px; }
  .audio-section .audio-title { font-size: 14px; }
  .audio-section .audio-description { font-size: 13px; }
}

/* Mobile interaction hardening: native audio controls must stay above all
   decorative/animation layers and must never trigger page-swipe handling. */
body.true-mobile-reflow .page-content,
body.true-mobile-reflow .page-body,
body.true-mobile-reflow .audio-section,
body.true-mobile-reflow .audio-section audio {
  position: relative;
  pointer-events: auto !important;
}
body.true-mobile-reflow .audio-section {
  z-index: 60;
  padding: 10px 12px;
  overflow: visible;
}
body.true-mobile-reflow .audio-section audio {
  z-index: 61;
  display: block;
  width: 100% !important;
  min-width: 0 !important;
  height: 46px;
  touch-action: manipulation;
}
body.true-mobile-reflow .shade,
body.true-mobile-reflow .spread::after,
body.true-mobile-reflow .page::before {
  pointer-events: none !important;
}

@media screen and (max-width: 600px) {
  body.true-mobile-reflow #top-bar { min-height: 56px; }
  body.true-mobile-reflow #bottom-bar { min-height: 60px; }
  body.true-mobile-reflow .cover-page .page-content {
    justify-content: flex-start;
    padding-top: clamp(48px, 15vh, 100px);
  }
  body.true-mobile-reflow .cover-rule { width: min(190px, 70%); }
  body.true-mobile-reflow .cover-keywords {
    font-size: 11px;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }
}

#page-bank { display: none; }

/* ==========================================================================
   Editor toolbar — TEXT_BEARBEITEN.html only. Never part of the book
   pages, never printed/exported to PDF (see @media print below).
   ========================================================================== */

#editor-toolbar {
  position: relative;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #241109;
  border-bottom: 1px solid rgba(184,147,92,0.4);
  font-family: var(--font-heading);
  color: #f1e5cf;
}
#editor-title { font-weight: 600; letter-spacing: 0.03em; margin-right: 8px; }
#editor-toolbar button {
  background: rgba(241,229,207,0.08);
  border: 1px solid rgba(184,147,92,0.5);
  color: #f1e5cf;
  border-radius: 3px;
  padding: 7px 12px;
  font-family: var(--font-heading);
  font-size: 14px;
}
#editor-toolbar button:hover { background: rgba(184,147,92,0.22); border-color: var(--color-gold); }
#editor-toggle[aria-pressed="true"] {
  background: var(--color-gold);
  color: #241109;
  border-color: var(--color-gold);
  font-weight: 600;
}
#editor-warning {
  flex-basis: 100%;
  color: #ffd7d7;
  background: rgba(140,30,30,0.35);
  border: 1px solid rgba(255,120,120,0.5);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-body);
}
#editor-warning[hidden] { display: none; }

/* Subtle highlight so it's obvious which element currently has focus
   while editing — a UI affordance, not a book-design change. */
.is-editing-focus {
  outline: 2px dashed var(--color-gold);
  outline-offset: 3px;
}

@media print {
  #editor-toolbar { display: none !important; }
}

@media print {
  #page-bank[hidden], #page-bank { display: block !important; }
  @page { size: 700px 997px; margin: 0; }
  html, body { background: #fff !important; overflow: visible !important; }
  #top-bar, #bottom-bar, .side-hit { display: none !important; }
  body.mobile-preview-active { overflow: visible !important; }
  body.mobile-preview-active #app { position: static !important; width: auto !important; height: auto !important; border: none !important; box-shadow: none !important; transform: none !important; }
  body.mobile-preview-active::before { display: none !important; }
  #app { position: static; display: block; }
  #stage { display: none !important; }
  .spread { position: static !important; display: block; }
  .spread .slot { display: none; }
  .layer { display: none !important; }
  .print-page {
    width: 700px; height: 997px;
    page-break-after: always; break-after: page;
  }
  .print-page:last-child { page-break-after: auto; }

  /* No functional browser audio control makes sense in a static PDF —
     show only the styled title/description text of the audio section,
     never the native <audio> widget itself. */
  .audio-section audio { display: none !important; }

  /* The block below repeats the same rules using the exact class names
     requested for this request (.editor-toolbar / .book-navigation /
     .viewer-controls / .book-page). It's intentionally redundant with the
     ID-based rules above (which already hide the same elements) — kept
     here verbatim so both naming schemes are covered no matter which
     file/markup version is being printed. */
  .editor-toolbar,
  .book-navigation,
  .viewer-controls {
      display: none !important;
  }

  .book-page {
      break-after: page;
      page-break-after: always;
  }
}


/* ======================================================================
   v17 – Android/Samsung mobile audio fallback + cover title fit
   ====================================================================== */
@media screen and (max-width: 600px) {
  body.true-mobile-reflow .cover-title-main {
    font-size: clamp(38px, 12.5vw, 50px) !important;
    line-height: 1 !important;
    letter-spacing: 0.025em !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  body.true-mobile-reflow .audio-section audio {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    min-height: 48px !important;
    margin-top: 8px !important;
    position: relative !important;
    z-index: 100 !important;
    pointer-events: auto !important;
  }

  body.true-mobile-reflow .audio-mobile-play {
    display: flex;
    width: 100%;
    min-height: 48px;
    margin: 10px 0 0;
    padding: 10px 14px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1.5px solid var(--color-bordeaux);
    border-radius: 6px;
    background: #f4ead9;
    color: var(--color-bordeaux);
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    z-index: 101;
    pointer-events: auto !important;
    touch-action: manipulation;
  }
}

.audio-mobile-play { display: none; }

@media print {
  .audio-mobile-play { display: none !important; }
}

/* ==========================================================================
   v20 Android audio fix
   The previous mobile fallback rules were accidentally nested inside
   @media print and therefore never applied on a real phone.
   ========================================================================== */
@media screen and (max-width: 860px), screen and (max-aspect-ratio: 4/5) {
  body.true-mobile-reflow .audio-section {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.true-mobile-reflow .audio-section audio {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 48px !important;
    margin-top: 8px !important;
    position: relative !important;
    z-index: 100 !important;
    pointer-events: auto !important;
  }

  body.true-mobile-reflow .audio-mobile-play {
    display: flex !important;
    width: 100% !important;
    min-height: 50px !important;
    margin: 10px 0 0 !important;
    padding: 10px 14px !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid var(--color-bordeaux) !important;
    border-radius: 6px !important;
    background: #f4ead9 !important;
    color: var(--color-bordeaux) !important;
    font-family: var(--font-heading) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 101 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
}

/* ==========================================================================
   v21 – Audio player deliberately placed below the bordered text box
   ========================================================================== */
.audio-player-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  position: relative;
  z-index: 120;
  overflow: visible;
}

.audio-player-row .audio-player-below {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 48px !important;
  position: relative !important;
  z-index: 121 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

@media screen and (max-width: 860px), screen and (max-aspect-ratio: 4/5) {
  body.true-mobile-reflow .audio-player-row {
    display: block !important;
    width: 100% !important;
    margin: 10px 0 18px !important;
    overflow: visible !important;
  }

  body.true-mobile-reflow .audio-player-row .audio-player-below {
    display: block !important;
    width: 100% !important;
    min-height: 52px !important;
  }

  body.true-mobile-reflow .audio-player-row .audio-mobile-play {
    display: flex !important;
    width: 100% !important;
    min-height: 50px !important;
    margin-top: 8px !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid var(--color-bordeaux) !important;
    border-radius: 6px !important;
    background: #f4ead9 !important;
    color: var(--color-bordeaux) !important;
    font-family: var(--font-heading) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    pointer-events: auto !important;
  }
}

@media print {
  .audio-player-row { display: none !important; }
}


/* ==========================================================================
   v22 - Desktop: native player in the bordered box.
   Real mobile portrait/landscape: direct MP3 link only, no native player.
   PDF/print: clickable direct MP3 link only.
   ========================================================================== */
.audio-direct-link {
  display: none;
}
.audio-close-btn {
  display: none; /* global base — hidden everywhere by default; only the
    mobile "is-revealed" state (further below) shows it, and only on
    mobile. Must live outside any @media block so desktop is covered too. */
}

/* Desktop keeps the original native player inside the cream audio box. */
@media screen and (min-width: 861px) and (min-aspect-ratio: 4/5) {
  .audio-section .audio-player-row {
    display: block !important;
    margin: 10px 0 0 !important;
  }
  .audio-section .audio-player-below {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
  }
  .audio-direct-link {
    display: none !important;
  }
}

/* All true mobile reflow modes use a normal hyperlink instead of browser
   audio controls. This avoids the Android portrait rendering bug. */
body.true-mobile-reflow .audio-section .audio-player-row,
body.true-mobile-reflow .audio-section audio,
body.true-mobile-reflow .audio-section .audio-mobile-play {
  display: none !important;
}

body.true-mobile-reflow .audio-direct-link {
  display: flex !important;
  width: 100% !important;
  min-height: 52px !important;
  margin: 10px 0 18px !important;
  padding: 11px 16px !important;
  box-sizing: border-box !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1.5px solid var(--color-bordeaux) !important;
  border-radius: 6px !important;
  background: #f4ead9 !important;
  color: var(--color-bordeaux) !important;
  font-family: var(--font-heading) !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  position: relative !important;
  z-index: 130 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

@media print {
  .audio-section .audio-player-row,
  .audio-section audio,
  .audio-mobile-play {
    display: none !important;
  }
  .audio-direct-link {
    display: block !important;
    margin: 10px 0 0 !important;
    padding: 9px 14px !important;
    border: 1.5px solid var(--color-bordeaux) !important;
    border-radius: 4px !important;
    background: var(--color-paper) !important;
    color: var(--color-bordeaux) !important;
    font-family: var(--font-heading) !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    text-align: center !important;
    text-decoration: underline !important;
  }
}

/* ========================================================================
   v23 definitive mobile rule
   Do not depend on JavaScript adding body.true-mobile-reflow.
   Every narrow screen gets the direct MP3 link and no native player.
   ======================================================================== */
@media screen and (max-width: 860px) {
  .audio-section .audio-player-row,
  .audio-section audio,
  .audio-section .audio-mobile-play {
    display: none !important;
    visibility: hidden !important;
  }

  .audio-direct-link {
    display: flex !important;
    width: 100% !important;
    min-height: 52px !important;
    margin: 10px 0 18px !important;
    padding: 11px 16px !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid var(--color-bordeaux) !important;
    border-radius: 6px !important;
    background: #f4ead9 !important;
    color: var(--color-bordeaux) !important;
    font-family: var(--font-heading) !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    text-align: center !important;
    text-decoration: none !important;
    position: relative !important;
    z-index: 999 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
  }
}



/* V24 Mobile: Papier und vorhandener Ornamentrand folgen der echten Seitenhöhe */
@media screen and (max-width: 860px) {
    body.true-mobile-reflow .page {
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page-content {
        height: auto !important;
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page::before {
        top: 0 !important;
        bottom: 0 !important;
        height: auto !important;
        background-color: var(--color-spine) !important;
        background-image: url('assets/ornaments/vine-overlay.png') !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
    }
}

/* V24 Mobile: Papier und vorhandener Ornamentrand folgen der echten Seitenhöhe */
@media screen and (max-width: 860px) {
    body.true-mobile-reflow .page {
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page-content {
        height: auto !important;
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page::before {
        top: 0 !important;
        bottom: 0 !important;
        height: auto !important;
        background-color: var(--color-spine) !important;
        background-image: url('assets/ornaments/vine-overlay.png') !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
    }
}

/* V24 Mobile: Papier und vorhandener Ornamentrand folgen der echten Seitenhöhe */
@media screen and (max-width: 860px) {
    body.true-mobile-reflow .page {
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page-content {
        height: auto !important;
        overflow: visible !important;
        background-color: var(--color-paper) !important;
    }

    body.true-mobile-reflow .page::before {
        top: 0 !important;
        bottom: 0 !important;
        height: auto !important;
        background-color: var(--color-spine) !important;
        background-image: url('assets/ornaments/vine-overlay.png') !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
    }
}

/* V25 Mobile: bordeauxroter Ornamentrand und Papierfarbe wie Desktop */
@media screen and (max-width: 860px) {

    /* Helle Papierfläche wie in der Desktopansicht */
    body.true-mobile-reflow .page {
        background-color: var(--color-paper) !important;
        background-image:
            radial-gradient(
                ellipse at 15% 8%,
                rgba(255,255,255,0.10) 0%,
                rgba(255,255,255,0) 45%
            ) !important;
    }

    body.true-mobile-reflow .page-content,
    body.true-mobile-reflow .page-body {
        background-color: transparent !important;
        background-image: none !important;
    }

    /* Bestehender Rand: dunkles Bordeauxrot und originale goldene Ornamente */
    body.true-mobile-reflow .page::before {
        background-color: #3d1119 !important;
        background-image: url('assets/ornaments/vine-overlay.png') !important;
    }
}

/* ==========================================================================
   v-NEXT — Mobile audio: reveal-in-place player with a visible close (X).
   Builds on the existing v19–v23 mobile audio system without replacing it:
   the default state (link only) is completely unchanged; these rules only
   add what happens after the link is tapped. Uses a toggled class
   (".is-revealed") rather than a second layout system, and every selector
   below repeats "!important" to reliably win over the earlier mobile
   audio rules, which are also heavily !important-based.
   ========================================================================== */
@media screen and (max-width: 860px), screen and (max-aspect-ratio: 4/5) {

  /* Closed (default) state: unchanged from v23 — link only, player hidden.
     Revealed state: show the player row (custom play button, not the
     native widget — this deliberately avoids the native-control Android
     rendering bug that v20–v22 already fixed once), hide the trigger link.
     Selectors here are deliberately prefixed with "body.true-mobile-reflow"
     (matching the specificity of the earlier v-anything hiding rules,
     e.g. "body.true-mobile-reflow .audio-section .audio-player-row") —
     without that prefix, the earlier, more specific hiding rule silently
     won regardless of !important or source order. */
  body.true-mobile-reflow .audio-section.is-revealed .audio-player-row,
  .audio-section.is-revealed .audio-player-row {
    display: flex !important;
    visibility: visible !important;
    align-items: center !important;
    gap: 8px !important;
    position: relative !important;
  }
  body.true-mobile-reflow .audio-section.is-revealed .audio-player-row .audio-mobile-play,
  .audio-section.is-revealed .audio-player-row .audio-mobile-play {
    display: flex !important;
    visibility: visible !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }
  /* The native <audio> stays out of view even while "revealed" — only the
     custom button + close control are shown, per the reasoning above. */
  body.true-mobile-reflow .audio-section.is-revealed .audio-player-row audio,
  .audio-section.is-revealed .audio-player-row audio {
    display: none !important;
  }
  body.true-mobile-reflow .audio-section.is-revealed ~ .audio-direct-link,
  .audio-section.is-revealed ~ .audio-direct-link {
    display: none !important;
  }

  body.true-mobile-reflow .audio-section.is-revealed .audio-close-btn,
  .audio-section.is-revealed .audio-close-btn {
    display: flex !important;
    visibility: visible !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    border: 1.5px solid var(--color-bordeaux) !important;
    border-radius: 6px !important;
    background: var(--color-paper) !important;
    color: var(--color-bordeaux) !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer;
    touch-action: manipulation;
    pointer-events: auto !important;
    z-index: 140 !important;
  }
}

@media print {
  /* The reveal/close interaction is a screen-only feature; print always
     shows just the plain, clickable "Audio anhören" link (handled by the
     existing v22/v23 print rules above) and never the close button. */
  .audio-close-btn { display: none !important; }
}
