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

body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #3d1a6e 0%, #1a0a35 60%, #0d0620 100%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  padding-bottom: 3rem;
}

/* ===== HEADER ===== */
header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 1.2rem 2rem;
  position: relative;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.terug {
  position: absolute;
  left: 1.5rem;
  color: #ffb3d9;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: color 0.2s;
}
.terug:hover { color: #fff; }

header h1 {
  font-size: 1.5rem;
  background: linear-gradient(90deg, #ffd700, #ffb3d9, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

/* ===== SCENE ===== */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem 1rem;
  width: 100%;
}

.scene {
  perspective: 2000px;
  position: relative;
  margin-bottom: 1.5rem;
}

/* ===== BOEK ===== */
.boek {
  width: 420px;
  height: 590px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

/* ===== PAGINA (kaart die flipt) ===== */
.pagina {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 0.7s cubic-bezier(0.645, 0.045, 0.355, 1.000);
  border-radius: 4px 12px 12px 4px;
  cursor: default;
  /* Verberg alle pagina's behalve de actieve */
  display: none;
}

.pagina.actief {
  display: block;
}

/* Klap-animatie */
.pagina.flipping {
  animation: pageFlip 0.7s cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards;
}

.pagina.flipping-terug {
  animation: pageFlipTerug 0.7s cubic-bezier(0.645, 0.045, 0.355, 1.000) forwards;
}

@keyframes pageFlip {
  0%   { transform: rotateY(0deg); z-index: 10; }
  40%  { transform: rotateY(-90deg); z-index: 10; }
  41%  { transform: rotateY(90deg); z-index: 10; }
  100% { transform: rotateY(0deg); z-index: 1; }
}

@keyframes pageFlipTerug {
  0%   { transform: rotateY(0deg); z-index: 10; }
  40%  { transform: rotateY(90deg); z-index: 10; }
  41%  { transform: rotateY(-90deg); z-index: 10; }
  100% { transform: rotateY(0deg); z-index: 1; }
}

/* ===== VOOR- EN ACHTERKANT ===== */
.pagina-voor,
.pagina-achterkant {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 4px 12px 12px 4px;
  overflow: hidden;
  box-shadow:
    -6px 0 20px rgba(0,0,0,0.4),
    0 4px 30px rgba(0,0,0,0.5),
    inset -3px 0 8px rgba(0,0,0,0.2);
}

.pagina-achterkant {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #f5e6d3, #ede0c8);
}

.pagina-voor img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Boekrug effect */
.pagina-voor::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 12px;
  background: linear-gradient(to right, rgba(0,0,0,0.3), rgba(0,0,0,0.05), transparent);
  z-index: 1;
  pointer-events: none;
}

/* Glans effect */
.pagina-voor::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(to left, rgba(255,255,255,0.08), transparent);
  pointer-events: none;
}

/* Ontbrekende afbeelding placeholder */
.pagina-voor {
  background: linear-gradient(135deg, #2d1b5e, #1a0a35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ontbreekt-tekst {
  display: none;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  line-height: 1.8;
  padding: 2rem;
}

.pagina-voor.ontbreekt .ontbreekt-tekst { display: block; }

.ontbreekt-tekst code {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  font-family: monospace;
}

/* Lege pagina achterkant */
.lege-pagina {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #8b6a4a;
}
.lege-pagina span { font-size: 3rem; }
.lege-pagina p { font-size: 1rem; font-style: italic; }

/* ===== SCHADUW ===== */
.boek-schaduw {
  width: 380px;
  height: 30px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.5) 0%, transparent 70%);
  margin-top: -10px;
  filter: blur(8px);
}

/* ===== NAVIGATIE ===== */
.navigatie {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.navigatie button {
  background: linear-gradient(135deg, #9b59b6, #ff6eb4);
  color: white;
  border: none;
  padding: 0.7rem 2rem;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 15px rgba(155,89,182,0.4);
  font-family: inherit;
}

.navigatie button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(155,89,182,0.6);
}

.navigatie button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.pagina-teller {
  min-width: 120px;
  text-align: center;
}

#pagina-label {
  font-size: 1rem;
  color: #ffb3d9;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.tip {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  .boek { width: 300px; height: 422px; }
  .boek-schaduw { width: 260px; }
  header { flex-direction: column; gap: 0.5rem; padding-top: 2.5rem; }
  .terug { top: 0.7rem; }
  .navigatie { gap: 1rem; }
  .navigatie button { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
}
