/* ==========================================================================
   Soupir d'Amour — Digital Brand Book
   Black / Gold / Silence. A single book placed in an empty room.
   ========================================================================== */

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-garamond-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/cormorant-garamond-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/cormorant-garamond-400italic.woff2') format('woff2');
}

:root {
  --black: #050505;
  --black-deep: #000000;
  --gold: #c4a45a;
  --gold-soft: rgba(196, 164, 90, 0.55);
  --gold-dim: rgba(196, 164, 90, 0.18);
  --ivory: #f2ede2;
  --page-ratio: 0.71277;         /* 2566 / 3600 (new 8-page artwork) */
  --flip-duration: 1300ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--black);
  color: var(--ivory);
  overflow: hidden;               /* スクロール禁止 */
  overscroll-behavior: none;
  touch-action: none;
  font-family: 'Cormorant Garamond', 'Hiragino Mincho ProN', serif;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background: radial-gradient(ellipse at 50% 38%, #0d0c0a 0%, #050505 55%, #000000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------------- */
/* Particles                                                               */
/* ---------------------------------------------------------------------- */
#particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.8;
}

/* ---------------------------------------------------------------------- */
/* Spotlight glow                                                          */
/* ---------------------------------------------------------------------- */
#spotlight {
  position: absolute;
  top: -10%;
  left: 50%;
  width: 70vw;
  max-width: 900px;
  height: 120vh;
  transform: translateX(-50%) scale(0.85);
  background: radial-gradient(ellipse 50% 40% at 50% 0%, rgba(210, 178, 110, 0.16) 0%, rgba(190, 156, 92, 0.06) 35%, rgba(0,0,0,0) 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 2.6s ease, transform 2.6s ease;
}
#stage.lit #spotlight {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ---------------------------------------------------------------------- */
/* Book stand — a single book resting in the room, not a shelf             */
/* ---------------------------------------------------------------------- */
#book-stand {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  opacity: 0;
  transform: translateY(26px) scale(0.975);
  filter: blur(6px);
  transition: opacity 2.2s cubic-bezier(.22,.61,.36,1), transform 2.2s cubic-bezier(.22,.61,.36,1), filter 2.2s ease;

  /* explicit box so StPageFlip's "stretch" mode has a real parent size
     to read — width drives height via aspect-ratio, never the reverse.
     min() keeps the book inside both the width AND height budget of the
     room at once, so it never overflows a short or narrow viewport. */
  width: min(86vw, calc(78dvh * var(--page-ratio)), 480px);
  aspect-ratio: var(--page-ratio);
}
#stage.revealed #book-stand {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

#book {
  position: relative;
  width: 100%;
  height: 100%;
}

/* subtle contact shadow grounding the book like an object on a surface */
#book-stand::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 70%;
  height: 34px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 72%);
  z-index: -1;
}

/* ---------------------------------------------------------------------- */
/* Pages                                                                   */
/* ---------------------------------------------------------------------- */
.page {
  background: #0a0a0a;
  overflow: hidden;
}
.page-surface {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
}
.page-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
  background: #0a0a0a;
}
.page-img.is-loaded { opacity: 1; }

/* faint inner edge shading so pages read as paper, not flat screenshots */
.page-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------------------- */
/* Hint text                                                               */
/* ---------------------------------------------------------------------- */
#hint {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(242, 237, 226, 0.38);
  opacity: 0;
  transition: opacity 1.4s ease 2.6s;
  pointer-events: none;
  animation: hint-breathe 3.6s ease-in-out infinite;
}
#stage.revealed #hint { opacity: 1; }
#stage.opened #hint { opacity: 0 !important; transition: opacity 0.8s ease; }

@keyframes hint-breathe {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 0.62; }
}

/* ---------------------------------------------------------------------- */
/* Sound toggle — the only control on screen                               */
/* ---------------------------------------------------------------------- */
#sound-toggle {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 10;
  width: 40px;
  height: 40px;
  border: 1px solid var(--gold-dim);
  border-radius: 50%;
  background: rgba(5, 5, 5, 0.4);
  color: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 1.2s ease 1.6s, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
#stage.revealed #sound-toggle { opacity: 0.55; }
#sound-toggle:hover,
#sound-toggle:focus-visible {
  opacity: 1 !important;
  border-color: var(--gold-soft);
  color: var(--gold);
}
#sound-toggle svg {
  width: 17px;
  height: 17px;
}
#sound-toggle .icon-off { display: none; }
#sound-toggle[aria-pressed="false"] .icon-on { display: none; }
#sound-toggle[aria-pressed="false"] .icon-off { display: block; }

/* ---------------------------------------------------------------------- */
/* Intro veil                                                              */
/* ---------------------------------------------------------------------- */
#intro-veil {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000000;
  opacity: 1;
  transition: opacity 2.4s ease;
  pointer-events: none;
}
#stage.lit #intro-veil { opacity: 0; }

/* ---------------------------------------------------------------------- */
/* StPageFlip internal element polish                                     */
/* ---------------------------------------------------------------------- */
.stf__parent { touch-action: none; }
.stf__wrapper { margin: 0 auto; }

/* ---------------------------------------------------------------------- */
/* Responsive                                                             */
/* ---------------------------------------------------------------------- */
@media (min-width: 1024px) {
  #book-stand { width: min(40vw, calc(78dvh * var(--page-ratio)), 480px); }
}

@media (max-width: 420px) {
  #book-stand { width: min(88vw, calc(74dvh * var(--page-ratio))); }
}

@media (prefers-reduced-motion: reduce) {
  #book-stand, #spotlight, #intro-veil, .page-img { transition-duration: 0.2s !important; }
  #hint { animation: none; }
}
