/* ═══════════════════════════════════════════════
   SHARED.CSS – Rätsel-aktuell.de
   Tokens, Reset, Skip-Link, Focus-Visible, Back-to-Top
   ═══════════════════════════════════════════════ */

/* ── VARIABLE FONTS ────────────────────────────── */
@font-face {
  font-family: 'Merriweather';
  src: url('../fonts/merriweather.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Open Sans';
  src: url('../fonts/open-sans.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* Farb-Tokens – Rätsel-aktuell Rot-Schema */
  --red-dark:     #8B0000;   /* Dunkelrot, Akzente */
  --red-main:     #CC1122;   /* Hauptrot */
  --red-mid:      #E03344;   /* Mittelstufe */
  --red-light:    #E87070;   /* Helles Rot */
  --red-pale:     #FAD5D5;   /* Sehr hell (Hintergründe) */
  --red-tint:     #FEF0F0;   /* Minimales Tint */
  --text:         #666666;   /* Body-Text – 60% Schwarz, sehr sanft */
  --gray:         #666;      /* Meta-Text */
  --white:        #fff;

  /* Typografie */
  font-size: 17px;
}

/* ── RESET ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
img { max-width: 100%; display: block; }

body {
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--white);
  line-height: 1.6;
}

/* ── SKIP LINK (WCAG 2.4.1) ──────────────────── */
.skip-link {
  position: absolute; top: 0; left: 0;
  background: var(--red-dark); color: #fff;
  padding: .75rem 1rem; z-index: 9999;
  text-decoration: none; font-weight: 700;
  transform: translateY(-150%);
  transition: transform .2s;
}
.skip-link:focus { transform: translateY(0); }

/* ── FOCUS VISIBLE (WCAG 2.4.7) ──────────────── */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--red-dark);
  outline-offset: 2px;
}

/* ── BACK TO TOP ─────────────────────────────── */
.back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--red-main); color: #fff;
  border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(25,25,25,0.25);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s, background .15s;
  z-index: 999;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-to-top:hover { background: var(--red-dark); transform: translateY(-2px); }
.back-to-top svg { width: 34px; height: 34px; display: block; }

/* ── SCROLL REVEAL ──────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .6s ease-out, transform .6s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.visible { transition: none; opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity .15s; }
  .back-to-top:hover { transform: none; }
  html { scroll-behavior: auto; }
}

/* ── RESPONSIVE TYPO ─────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.1rem; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  h1 { font-size: 1rem; }
  h2 { font-size: 1rem; }
}

/* ── FLIPBOOK OVERLAY (nach kopf-fit.de Muster) ──────────────────────────────────────── */
#fbOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

#fbOverlay.active {
  display: flex;
}

.fb-inner {
  position: relative;
  background: var(--red-main);
  border-radius: 12px;
  padding: 16px 16px 12px;
  max-width: 94vw;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

#fb-close-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  z-index: 1;
  transition: transform 0.2s ease;
}

#fb-close-btn:hover {
  transform: scale(1.2);
}

#ra-flipbook {
  width: 100%;
  max-width: 800px;
  height: auto;
  touch-action: none;
  overflow: visible;
}

#ra-flipbook .ra-page {
  background: #fff;
  overflow: hidden;
}

#ra-flipbook .ra-page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

.fb-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fb-nav-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 7px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
}

.fb-nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.fb-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

#ra-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  min-width: 120px;
  text-align: center;
}

/* ── FLIPBOOK RESPONSIVE ─────────────────────── */
@media (max-width: 768px) {
  .fb-inner {
    padding: 12px 12px 8px;
    gap: 8px;
    max-width: 90vw;
    max-height: 90vh;
  }
  #ra-flipbook {
    max-width: 500px;
  }
  .fb-nav-btn {
    padding: 6px 16px;
    font-size: 12px;
  }
  #ra-label {
    min-width: 100px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .fb-inner {
    padding: 10px 10px 6px;
    gap: 6px;
    max-width: 95vw;
    max-height: 95vh;
  }
  #ra-flipbook {
    max-width: 100%;
    max-width: min(100vw - 20px, 400px);
  }
  .fb-nav-btn {
    padding: 5px 12px;
    font-size: 11px;
  }
  #ra-label {
    min-width: 80px;
    font-size: 11px;
  }
}
