/* JayXArt Online-Katalog – Oberfläche (Richtung C „Themen immer sichtbar“) */

@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('../fonts/oswald-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Mulish';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/mulish-latin.woff2') format('woff2');
}

:root {
  --navy: #0D1427;
  --black: #000000;
  --grey: #878991;
  --red: #EE2428;
  --white: #FFFFFF;
  --stage: #F6F7FA;
  --line: #D6D8E0;
  --line-soft: #EAECF1;

  --font-head: 'Oswald', 'Arial Narrow', sans-serif;
  --font-text: 'Mulish', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --track: .06em;

  --h-header: 52px;
  --h-chips: 44px;
  --h-thumbs: 64px;
  --h-status: 36px;

  --page-aspect: .7071; /* wird von app.js aus dem Datenvertrag gesetzt */
  --page-shadow: 0 10px 28px rgba(13, 20, 39, .14), 0 2px 6px rgba(13, 20, 39, .08);
  --ease-out: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

/* ---------- Grundlagen ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
  background: var(--white);
  color: var(--navy);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Linien-Icons */
.ico {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  border-radius: 999px;
  color: var(--navy);
  transition: color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--red); }
.icon-btn:active { background: var(--stage); }

/* Oswald-Label in Großbuchstaben */
.label,
.btn-label,
.download {
  font-family: var(--font-head);
  font-weight: 500;
  letter-spacing: var(--track);
  text-transform: uppercase;
}

/* ---------- Gerüst ---------- */

.app {
  display: grid;
  grid-template-rows: var(--h-header) var(--h-chips) minmax(0, 1fr) var(--h-thumbs) var(--h-status);
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  overflow: clip; /* nichts ragt über den Rand: die Seite selbst bleibt unscrollbar */
  background: var(--white);
}

/* ---------- Kopfzeile ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 6px;
}

.menu-toggle {
  justify-self: start;
  gap: 8px;
  padding: 0 10px;
}
.btn-label { display: none; font-size: 13px; }

.brand { margin: 0; line-height: 0; }
.brand img { display: block; width: auto; height: 21px; }

.download {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--navy);
  transition: color .15s, background-color .15s;
}
.download .ico { width: 20px; height: 20px; }
.download:hover { color: var(--red); }
.download:active { background: var(--stage); }

/* ---------- Themen-Chips ---------- */

.chips,
.thumbs {
  position: relative; /* Bezugsrahmen für offsetLeft (chrome.js) */
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar,
.thumbs::-webkit-scrollbar { display: none; }

.chips {
  gap: 6px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  /* weiche Kanten deuten an, dass die Leiste weiterläuft */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 16px), transparent 100%);
}

.chip {
  position: relative;
  flex: none;
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 28px;
  letter-spacing: var(--track);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--navy);
  transition: background-color .2s, border-color .2s, color .2s;
}
/* Trefferfläche auf volle Leistenhöhe vergrößern */
.chip::after { content: ''; position: absolute; inset: -7px -4px; }
.chip:hover { border-color: var(--navy); }
.chip.is-active {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}
/* zentriert, solange alle Chips Platz haben; sonst normal wischbar */
.chip:first-child { margin-left: auto; }
.chip:last-child { margin-right: auto; }

/* ---------- Bühne ---------- */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  padding: 14px 18px;
  background: var(--stage);
}

.book {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  container-type: size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.book:focus { outline: none; }

/* Bogen: so groß wie Seite bzw. Doppelseite im Seitenverhältnis, höchstens in Bildbreite.
   Darin hängt StPageFlip sein Wurzelelement (.book-inner, Breite 100 %); die Höhe ergibt sich daraus. */
.book-sheet {
  --n: 1;
  position: relative;
  width: min(100cqw, calc(100cqh * var(--n) * var(--page-aspect)), calc(var(--n) * var(--page-max-w, 1200px)));
}
.book-sheet[data-layout="spread"] { --n: 2; }

/* StPageFlip setzt touch-action: pan-y – auf der Bühne blättert der Finger, gescrollt wird nichts. */
.book .stf__parent { touch-action: none; }

.book .page {
  overflow: hidden;
  background: var(--white);
}
.book .page.--simple { box-shadow: var(--page-shadow); }

/* Bild erst zeigen, wenn es geladen ist: nie ein kaputtes Bild-Symbol, bis dahin der Platzhalter */
.book .page img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  visibility: hidden;
  pointer-events: none;
}
.book .page img.is-loaded { visibility: visible; }

.page-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--white);
}
/* Ladekreis erst nach einer kurzen Weile – schnelle Seiten sollen nicht flackern */
.page-placeholder::after {
  content: '';
  width: 26px;
  height: 26px;
  border: 2px solid var(--line-soft);
  border-top-color: var(--grey);
  border-radius: 50%;
  opacity: 0;
  animation: page-spin .9s linear infinite, page-appear .2s .4s forwards;
}
.book .page img.is-loaded + .page-placeholder { display: none; }
@keyframes page-spin { to { transform: rotate(360deg); } }
@keyframes page-appear { to { opacity: 1; } }

/* Bild nach mehreren Versuchen nicht geladen (book.js): Neuladen-Fläche statt des Ladekreises.
   Ein echter Button – StPageFlip übergeht Tipps auf <button>; Wischen daneben blättert wie immer. */
.book .page.is-failed .page-placeholder::after { display: none; }
.page-reload {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(13, 20, 39, .08);
  color: var(--navy);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: var(--track);
  text-transform: uppercase;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  transition: color .15s, border-color .15s;
}
.page-reload > * { pointer-events: none; } /* Ziel jedes Tipps ist der Button selbst, nie Icon oder Text */
.page-reload:hover { border-color: var(--red); color: var(--red); }
.page-reload .ico { width: 20px; height: 20px; }

/* Bundschatten in der Doppelseite */
.book-sheet[data-layout="spread"] .page::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6%;
  pointer-events: none;
}
.book-sheet[data-layout="spread"] .page.--left::after {
  right: 0;
  background: linear-gradient(to left, rgba(13, 20, 39, .13), rgba(13, 20, 39, .04) 40%, transparent);
}
.book-sheet[data-layout="spread"] .page.--right::after {
  left: 0;
  background: linear-gradient(to right, rgba(13, 20, 39, .11), rgba(13, 20, 39, .03) 40%, transparent);
}

/* umgeknickte Ecke (Entwurf C) als kurzer Blätter-Hinweis, einmal pro Sitzung (hint.js): hebt sich an,
   legt sich, blendet aus. Sonst unsichtbar – unten rechts stehen auf Produktseiten die Preise.
   Nur in der Einzelseite und solange es weitergeht; nie beim Blättern und nie im Zoom. */
.page-peel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 34px;
  height: 34px;
  background: linear-gradient(-45deg, var(--stage) 50%, #D9DBE1 50%, #FFFFFF 72%, #E6E7EC 100%);
  box-shadow: -3px -3px 7px rgba(13, 20, 39, .13);
  pointer-events: none;
  transform-origin: 100% 100%;
  visibility: hidden;
  opacity: 0;
}
.page-peel.is-hint {
  visibility: visible;
  animation: peel-hint 2s var(--ease-out) forwards; /* Dauer = HINT_MS in hint.js */
}
.page-peel.is-hint-static { /* Bewegung reduzieren: still stehen, dann weg (STATIC_MS) */
  visibility: visible;
  opacity: 1;
}
@keyframes peel-hint {
  0% { opacity: 0; transform: scale(.5); }
  16% { opacity: 1; transform: scale(1.35); } /* anheben */
  32% { opacity: 1; transform: scale(1); } /* setzen */
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
.book-sheet[data-layout="spread"] .page-peel,
.book-sheet.is-last .page-peel { display: none; }
html[data-flipping] .page-peel,
html[data-zoom] .page-peel { visibility: hidden; }

.nav-arrow { display: none; }

/* ---------- Mini-Vorschau ---------- */

.thumbs {
  padding: 0 8px;
  border-top: 1px solid var(--line-soft);
}

.thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 100%;
}
.thumb img {
  display: block;
  width: auto;
  height: 46px;
  border-radius: 2px;
  background: var(--line-soft);
  box-shadow: 0 0 0 1px var(--line);
  opacity: .78;
  transition: opacity .2s, box-shadow .2s;
}
.thumb:hover img { opacity: 1; }
.thumb img.is-current {
  opacity: 1;
  box-shadow: none;
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* ---------- Statuszeile ---------- */

.statusbar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  padding: 0 4px;
}
.statusbar .icon-btn {
  height: var(--h-status);
  color: var(--grey);
}
.statusbar .icon-btn:hover { color: var(--navy); }
/* Trefferfläche ≥ 44 px trotz niedrigerer Zeile (36 px, quer 32 px) */
.statusbar .icon-btn::after { content: ''; position: absolute; inset: calc((var(--h-status) - 44px) / 2) 0; }
.statusbar .ico { width: 20px; height: 20px; }

.status {
  margin: 0;
  overflow: hidden;
  font-size: 12.5px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}

.sound-toggle .ico-off,
.sound-toggle[aria-pressed="false"] .ico-on,
#menu-sound .ico-off,
#menu-sound[aria-pressed="false"] .ico-on { display: none; }
.sound-toggle[aria-pressed="false"] .ico-off,
#menu-sound[aria-pressed="false"] .ico-off { display: block; }

/* ---------- Menü (Panel von links) ---------- */

.menu {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.menu[hidden] { display: none; }

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 20, 39, .42);
  animation: menu-fade .2s ease-out;
}

.menu-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(86vw, 360px);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--white);
  box-shadow: 10px 0 36px rgba(13, 20, 39, .2);
  animation: menu-slide .28s var(--ease-out);
}

@keyframes menu-fade { from { opacity: 0; } }
@keyframes menu-slide { from { transform: translateX(-100%); } }

.menu-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--h-header);
  padding: 0 6px 0 20px;
  border-bottom: 1px solid var(--line-soft);
}
.menu-logo { display: block; width: auto; height: 18px; }

.menu-body {
  position: relative; /* Bezugsrahmen für offsetTop (chrome.js) */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 0 12px;
}

.label { margin: 0; font-size: 12px; color: var(--grey); }

.goto {
  margin: 0 20px 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.goto-row {
  display: flex;
  height: 46px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s;
}
.goto-row:focus-within { border-color: var(--navy); }
.goto.is-invalid .goto-row { border-color: var(--red); }
.goto input {
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--navy);
  font-family: var(--font-head);
  font-size: 17px; /* ≥ 16 px: kein Auto-Zoom unter iOS */
  letter-spacing: var(--track);
}
.goto input::placeholder { color: var(--grey); opacity: .75; }
.goto-btn {
  display: grid;
  place-items: center;
  width: 48px;
  background: var(--navy);
  color: var(--white);
  transition: background-color .15s;
}
.goto-btn:hover { background: var(--red); }
.goto-hint { margin: 8px 0 0; font-size: 13px; color: var(--red); }

.menu-label { margin: 0 20px 6px; }

.menu-topics,
.menu-sub {
  margin: 0;
  padding: 0;
  list-style: none;
}
.menu-sub { margin-bottom: 4px; }

.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 44px;
  padding: 6px 20px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  transition: background-color .15s, color .15s;
}
.menu-item:hover { background: var(--stage); }
.menu-item .num {
  flex: none;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: var(--track);
  color: var(--grey);
  font-variant-numeric: tabular-nums;
}
.menu-sub .menu-item {
  padding-left: 38px;
  font-size: 14px;
  font-weight: 400;
}
.menu-sub .menu-item::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 50%;
  width: 6px;
  height: 1px;
  background: var(--line);
}
.menu-item.is-active { color: var(--red); }
.menu-item.is-active .num { color: var(--red); }
.menu-topics > li > .menu-item.is-active::after {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--red);
}

.menu-foot {
  flex: none;
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
}
.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  transition: background-color .15s, color .15s;
}
.menu-row:hover { background: var(--stage); }
.menu-row .ico { width: 20px; height: 20px; color: var(--grey); }
.menu-row .meta {
  margin-left: auto;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: var(--track);
  color: var(--grey);
}

.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--line);
  transition: background-color .2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(13, 20, 39, .25);
  transition: transform .2s var(--ease-out);
}
#menu-sound[aria-pressed="true"] .switch { background: var(--red); }
#menu-sound[aria-pressed="true"] .switch::after { transform: translateX(16px); }

/* ---------- Zoom-Ansicht ---------- */

/* über allem, ganzflächig; die übrige Oberfläche ist währenddessen ausgeblendet (zoom.js setzt html[data-zoom]) */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--stage);
  overscroll-behavior: none;
}
.zoom[hidden] { display: none; }
html[data-zoom] .app { visibility: hidden; }

/* ganzer Bildschirm als Gestenfläche; der Zoom wird hier abgeschnitten */
.zoom-viewport {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  container-type: size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Rahmen (Panzoom-Eltern): Seite bzw. Doppelseite bei 1×, so groß wie möglich im Seitenverhältnis */
.zoom-frame {
  --n: 1;
  width: min(100cqw, calc(100cqh * var(--n) * var(--page-aspect)));
  height: min(100cqh, calc(100cqw / (var(--n) * var(--page-aspect))));
  touch-action: none;
}
.zoom-frame[data-count="2"] { --n: 2; }

/* Panzoom-Element: die Bilder nebeneinander */
.zoom-pages {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--white);
  box-shadow: var(--page-shadow);
  touch-action: none;
}

/* Bis das große Bild da ist, zeigt der Hintergrund das schon geladene Seitenbild (zoom.js). */
.zoom-img {
  display: block;
  flex: none;
  width: calc(100% / var(--n));
  height: 100%;
  background-color: var(--white);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  -webkit-user-drag: none;
}

.zoom-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 1;
  width: 44px;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(13, 20, 39, .16);
}
.zoom-close:active { background: var(--stage); }
.zoom[data-quiet-focus] .zoom-close:focus-visible { outline: none; }

/* ---------- Ohne JavaScript ---------- */

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px;
  background: var(--white);
  text-align: center;
}
.noscript img { display: block; width: auto; height: 28px; }
.noscript p { margin: 0; max-width: 28ch; }
.noscript a {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 500;
  letter-spacing: var(--track);
  text-transform: uppercase;
}

/* ---------- Breitere Fenster ---------- */

@media (min-width: 700px) {
  .btn-label { display: inline; }
  .brand img { height: 24px; }
  .status { font-size: 13px; }
}

/* ab 1200 px passen alle 13 Chips in eine Zeile */
@media (min-width: 1200px) {
  .chips { gap: 5px; }
  .chip { padding: 0 11px; }
}

/* Doppelseite: Pfeile links und rechts neben dem Heft */
html[data-layout="spread"] .stage {
  grid-template-columns: 76px minmax(0, 1fr) 76px;
  padding: 22px 12px;
}
html[data-layout="spread"] .nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 2px 10px rgba(13, 20, 39, .06);
  transition: color .15s, background-color .15s, border-color .15s;
}
html[data-layout="spread"] .nav-arrow:hover {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}
.nav-arrow .ico { width: 24px; height: 24px; stroke-width: 1.5; }

/* Handy quer (und sehr niedrige Fenster): Chip-Leiste und Mini-Vorschau ausblenden, Kopf- und
   Statuszeile schmaler – sonst bliebe der Seite nur gut 40 % der Höhe. Themen bleiben übers Menü
   erreichbar. Schwelle auch in chrome.js (COMPACT_QUERY): rollt die Leisten beim Zurückdrehen nach. */
@media (max-height: 500px) {
  :root {
    --h-header: 44px;
    --h-status: 32px;
  }
  .app { grid-template-rows: var(--h-header) minmax(0, 1fr) var(--h-status); }
  .chips,
  .thumbs { display: none; }
  .stage,
  html[data-layout="spread"] .stage {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
