/* Porte 2D — même gabarit que le carnet ouvert · Lexend */

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

:root {
  --parchment: #f4e8c1;
  --parchment-dark: #e6d7b8;
  --leather: #3d2914;
  --leather-light: #5c3d1e;
  --leather-dark: #2a1c0e;
  --ink: #2c1810;
  --ink-muted: #5a4030;
  --brass: #8b6914;
  --discord: #5865f2;
  --font: 'Lexend', sans-serif;
}

html { font-size: 15px; }

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--parchment);
  background:
    radial-gradient(ellipse at 20% 30%, rgba(61, 41, 20, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(61, 41, 20, 0.1) 0%, transparent 50%),
    linear-gradient(160deg, #1a1208 0%, #2a1c0e 40%, #1a1208 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
}

.gate-stage {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.ledger-gate {
  width: 100%;
}

/* Même enveloppe cuir que .ledger du site */
.book-2d {
  position: relative;
  width: 100%;
  background: var(--leather);
  border-radius: 4px 8px 8px 4px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 0 0 2px var(--leather-light),
    inset 0 0 60px rgba(0, 0, 0, 0.3);
  padding: 14px 10px;
  overflow: hidden;
}

/* Pages ouvertes — grille identique au carnet */
.ledger-spread {
  display: grid;
  grid-template-columns: 1fr 12px 1fr;
  width: 100%;
  min-height: 720px;
  gap: 0;
  opacity: 0.35;
  filter: brightness(0.92);
  transition: opacity 0.55s ease 0.2s, filter 0.55s ease 0.2s;
}

.book-2d.is-opening .ledger-spread {
  opacity: 1;
  filter: none;
}

.spine {
  background: linear-gradient(90deg, var(--leather-dark), var(--leather-light) 40%, var(--leather-dark));
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
}

.page {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(44, 24, 16, 0.04) 27px,
      rgba(44, 24, 16, 0.04) 28px
    ),
    radial-gradient(circle at 15% 85%, rgba(139, 105, 20, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(44, 24, 16, 0.05) 0%, transparent 35%),
    var(--parchment);
  padding: 1.25rem 1.5rem;
  min-height: 692px;
  color: var(--ink);
}

.page-left {
  border-radius: 2px 0 0 2px;
  box-shadow: inset -12px 0 20px rgba(44, 24, 16, 0.05);
}

.page-right {
  border-radius: 0 2px 2px 0;
  box-shadow: inset 12px 0 20px rgba(44, 24, 16, 0.05);
}

.page-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.65rem;
}

.page-heading {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.page-line {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.page-line.muted,
.page-body {
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.page-rule {
  height: 1px;
  background: rgba(44, 24, 16, 0.18);
  margin: 1.25rem 0;
}

/* Couverture 2D : même surface que le carnet, s’ouvre vers la gauche */
.cover {
  position: absolute;
  inset: 14px 10px;
  z-index: 4;
  transform-origin: left center;
  transition: transform 1.05s cubic-bezier(0.33, 0.1, 0.25, 1), opacity 0.35s ease 0.55s;
}

.book-2d.is-opening .cover {
  transform: translateX(-102%);
  opacity: 0;
  pointer-events: none;
}

.cover-pages-edge {
  position: absolute;
  top: 8px;
  right: -7px;
  bottom: 8px;
  width: 9px;
  border-radius: 0 2px 2px 0;
  background: repeating-linear-gradient(
    to right,
    #f4e8c1 0 2px,
    #e6d7b8 2px 3px
  );
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
  z-index: 1;
  transition: opacity 0.25s ease;
}

.book-2d.is-opening .cover-pages-edge {
  opacity: 0;
}

.cover-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.6rem;
  width: 100%;
  height: 100%;
  min-height: 692px;
  padding: 2rem 1.75rem;
  border-radius: 2px 4px 4px 2px;
  background:
    radial-gradient(ellipse at 30% 18%, rgba(196, 163, 90, 0.1) 0%, transparent 45%),
    linear-gradient(155deg, #4a3218 0%, #2a1c0e 48%, #3d2914 100%);
  border: 1px solid rgba(139, 105, 20, 0.35);
  box-shadow:
    inset 0 0 0 8px rgba(139, 105, 20, 0.12),
    inset 0 0 70px rgba(0, 0, 0, 0.32);
}

.book-2d.is-ready .cover-panel {
  border-color: rgba(196, 163, 90, 0.55);
}

.cover-brand {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244, 232, 193, 0.55);
}

.cover-star {
  font-size: 2rem;
  color: var(--brass);
  line-height: 1;
}

.cover-title {
  display: block;
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--parchment);
}

.cover-year {
  font-size: 0.95rem;
  letter-spacing: 0.28em;
  color: rgba(244, 232, 193, 0.55);
  margin-bottom: 0.35rem;
}

.cover-audience {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(244, 232, 193, 0.72);
  margin-bottom: 0.85rem;
  max-width: 26rem;
}

.cover-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1rem;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: rgba(244, 232, 193, 0.35);
  pointer-events: none;
}

.cover-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.cover-hint {
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(244, 232, 193, 0.78);
  max-width: 28rem;
}

.cover-hint-ok {
  color: rgba(210, 230, 190, 0.9);
}

.cover-cta {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 230px;
  padding: 0.75rem 1.15rem;
  border-radius: 4px;
  background: var(--discord);
  color: #fff;
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(88, 101, 242, 0.35);
}

.cover-cta:hover {
  filter: brightness(1.06);
}

.cover-cta::before {
  content: '';
  width: 16px;
  height: 16px;
  background: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 127.14 96.36'%3E%3Cpath fill='%23fff' d='M107.7 8.07A105.15 105.15 0 0 0 81.47 0a72.06 72.06 0 0 0-3.36 6.83 97.68 97.68 0 0 0-29.11 0A72.37 72.37 0 0 0 45.64 0 105.89 105.89 0 0 0 19.39 8.09C2.79 32.65-1.71 56.6.54 80.21a105.73 105.73 0 0 0 32.17 16.15 77.7 77.7 0 0 0 6.89-11.11 68.42 68.42 0 0 1-10.85-5.18c.91-.66 1.8-1.34 2.66-2a75.57 75.57 0 0 0 64.32 0c.87.71 1.76 1.39 2.66 2a68.68 68.68 0 0 1-10.87 5.19 77 77 0 0 0 6.89 11.1 105.25 105.25 0 0 0 32.19-16.14c2.64-27.38-4.51-51.11-18.87-72.15ZM42.45 65.69C36.18 65.69 31 60 31 53s5-12.74 11.45-12.74S54 46 53.89 53s-5.05 12.69-11.44 12.69Zm42.24 0C78.41 65.69 73.25 60 73.25 53s5-12.74 11.44-12.74S96.23 46 96.12 53s-5.04 12.69-11.43 12.69Z'/%3E%3C/svg%3E");
}

/* Cadenas — visible seulement après Discord */
.padlock-btn {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  color: var(--parchment);
  font-family: var(--font);
  transition: transform 0.2s ease;
}

.padlock-btn:hover {
  transform: translateY(-3px);
}

.padlock-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 6px;
  border-radius: 4px;
}

.padlock {
  position: relative;
  width: 64px;
  height: 78px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}

.padlock-shackle {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  border: 6px solid #9aa0a6;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  transition: transform 0.35s ease;
}

.padlock-btn:hover .padlock-shackle {
  transform: translateX(-50%) translateY(-3px);
}

.padlock-btn.is-opening .padlock-shackle {
  transform: translateX(-42%) translateY(-8px) rotate(-22deg);
  transform-origin: left bottom;
}

.padlock-body {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 52px;
  height: 44px;
  border-radius: 6px;
  background: linear-gradient(180deg, #d4af37 0%, #a88420 55%, #7a6118 100%);
  border: 1px solid rgba(255, 230, 150, 0.35);
  display: grid;
  place-items: center;
}

.padlock-keyhole {
  width: 9px;
  height: 14px;
  border-radius: 50% 50% 2px 2px;
  background: #2a1c0e;
  position: relative;
}

.padlock-keyhole::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  width: 3px;
  height: 8px;
  background: #2a1c0e;
  border-radius: 1px;
}

.padlock-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(244, 232, 193, 0.85);
}

.gate-msg {
  width: min(520px, 100%);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  background: rgba(179, 58, 26, 0.15);
  border: 1px solid rgba(179, 58, 26, 0.4);
  color: #f0c4b8;
}

.gate-msg.info {
  background: rgba(61, 92, 58, 0.18);
  border-color: rgba(90, 140, 90, 0.4);
  color: #d5e8d0;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .ledger-spread {
    grid-template-columns: 1fr;
    grid-template-rows: auto 10px auto;
    min-height: 0;
  }

  .spine {
    height: 10px;
    width: 100%;
    background: linear-gradient(180deg, var(--leather-dark), var(--leather-light) 40%, var(--leather-dark));
  }

  .page,
  .cover-panel {
    min-height: 320px;
  }

  .book-2d.is-opening .cover {
    transform: translateY(-105%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cover,
  .ledger-spread,
  .padlock-shackle {
    transition: none !important;
  }
}
