/* ==========================================================================
   4uKitchen — Flipbook Engine
   A book that opens on a table and turns page by page.
   ========================================================================== */

:root {
  --page-radius: 6px;
  --spine-w: 34px;
  --paper-tile: url("../images/bckg/paper-bg/cream_dust_@2X.png");
}

html, body.book-body {
  height: 100%;
  overflow: hidden;
}

/* ---------- Stage: the table the book rests on ---------- */
.book-stage {
  position: relative;
  min-height: 100svh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #0d0c0a url("../images/site/stage-bg.jpg") center 55% / cover no-repeat;
  overflow: hidden;
  --mx: 50%;
  --my: 50%;
}
.stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -3;
  filter: brightness(0.85) saturate(1.15);
}
/* Static mood gradient, sits over the video for depth + readability */
.book-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 75, 62, 0.12), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(13, 12, 10, 0.15) 0%, rgba(26, 23, 18, 0.3) 100%);
  pointer-events: none;
  z-index: -2;
}
/* Cursor-follow glow, sits on top of the mood gradient */
.book-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 420px at var(--mx) var(--my), rgba(255, 75, 62, 0.16), transparent 70%);
  pointer-events: none;
  z-index: -1;
  transition: opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) { .book-stage::before { display: none; } }
/* ---------- Stage left: back link + contents toggle ---------- */
.stage-left {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-back,
.toc-toggle {
  position: static;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--white);
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}
.stage-back:hover { background: var(--coral); border-color: var(--coral); transform: translateY(-2px); }
.stage-back:active,
.toc-toggle:active { transform: scale(0.94); }
.toc-toggle { animation: menuPulse 2.8s ease-in-out infinite; }
.toc-toggle:hover { animation-play-state: paused; background: var(--coral); border-color: var(--coral); transform: translateY(-2px) scale(1.04); }
@keyframes menuPulse {
  0%, 100% { box-shadow: var(--shadow-md), 0 0 0 4px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(255, 75, 62, 0.5); }
  50% { box-shadow: var(--shadow-md), 0 0 0 4px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(255, 75, 62, 0); }
}

/* ---------- The book ---------- */
.book-perspective {
  width: min(96vw, 1180px);
  height: min(88svh, 760px);
  perspective: 2400px;
}
.book {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  border-radius: var(--page-radius);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.4);
  animation: bookSettle 0.9s var(--ease) both;
  transform-style: preserve-3d;
}
@keyframes bookSettle {
  from { opacity: 0; transform: translateY(26px) rotateX(6deg) scale(0.97); }
  to { opacity: 1; transform: translateY(0) rotateX(0) scale(1); }
}

/* ---------- Left panel: table of contents ---------- */
.book-left {
  position: relative;
  width: 32%;
  min-width: 230px;
  background-image:
    radial-gradient(circle, rgba(255, 75, 62, 0.32), transparent 60%),
    linear-gradient(155deg, var(--ink-soft), var(--ink) 75%);
  background-size: 260% 260%, 100% 100%;
  background-position: 15% 15%, 0 0;
  animation: leftPanelGlow 10s ease-in-out infinite alternate;
  color: var(--cream);
  border-radius: var(--page-radius) 0 0 var(--page-radius);
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 3vw, 36px) clamp(18px, 2.4vw, 28px);
  box-shadow: inset -18px 0 30px -24px rgba(0, 0, 0, 0.7);
  z-index: 5;
  overflow: hidden;
}
@keyframes leftPanelGlow {
  0% { background-position: 10% 10%, 0 0; }
  100% { background-position: 85% 80%, 0 0; }
}
.book-left::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  pointer-events: none;
}
.book-crest { display: flex; align-items: center; gap: 10px; margin-bottom: clamp(18px, 3vw, 34px); }
.book-crest img {
  height: 30px;
  width: auto;
  background: rgba(255, 255, 255, 0.96);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}
.toc { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.toc-tab {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: none;
  border: none;
  text-align: left;
  color: rgba(255, 255, 255, 0.62);
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 11px 10px 11px 16px;
  border-radius: 10px;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
  opacity: 0;
  animation: tabIn 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}
@keyframes tabIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.toc-tab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 2px;
  background: var(--coral);
  transform: translateY(-50%);
  transition: height 0.25s ease;
}
.toc-tab .num { font-family: var(--font-display); font-size: 0.72rem; font-weight: 700; color: var(--coral); opacity: 0.85; transition: transform 0.25s ease; }
.toc-tab:hover { background: rgba(255, 255, 255, 0.06); color: var(--white); transform: translateX(3px); }
.toc-tab:hover .num { transform: scale(1.15); }
.toc-tab:active { transform: translateX(3px) scale(0.97); }
.toc-tab.active { background: rgba(255, 75, 62, 0.16); color: var(--white); font-weight: 600; }
.toc-tab.active::before { height: 60%; }
.book-left-foot {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  display: none;
}
.ribbon {
  position: absolute;
  top: 0;
  right: 22px;
  width: 22px;
  height: 70px;
  background: var(--coral);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* ---------- Right panel: the flipping page ---------- */
.book-right {
  position: relative;
  flex: 1;
  border-radius: 0 var(--page-radius) var(--page-radius) 0;
  overflow: hidden;
  box-shadow:
    8px 0 0 -4px #f2ead9,
    12px 0 0 -6px #ecdfc4,
    16px 0 0 -8px #e4d3ac;
}
.page-slot {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.page-base {
  position: absolute;
  inset: 0;
  background: var(--cream);
  background-image: var(--paper-tile);
  background-size: 60px;
}
.book-page { width: 100%; height: 100%; }

/* Spine shadow crease */
.book::after {
  content: "";
  position: absolute;
  left: 32%;
  top: 0;
  bottom: 0;
  width: var(--spine-w);
  margin-left: calc(var(--spine-w) / -2);
  background: linear-gradient(90deg, rgba(0,0,0,0.28), rgba(0,0,0,0) 40%, rgba(0,0,0,0) 60%, rgba(0,0,0,0.16));
  pointer-events: none;
  z-index: 30;
}

/* ---------- Flip leaf ---------- */
.flip-leaf {
  position: absolute;
  inset: 0;
  transform-origin: 0% 50%;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  z-index: 20;
  pointer-events: none;
}
.flip-leaf.is-turning.dir-next,
.flip-leaf.is-turning.dir-prev {
  animation: pageTurnArc 0.8s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
}
@keyframes pageTurnArc {
  0% { transform: rotateY(0deg) translateZ(0) scale(1); box-shadow: none; }
  48% { transform: rotateY(-92deg) translateZ(90px) scale(1.015); box-shadow: 0 40px 70px rgba(0,0,0,0.35); }
  100% { transform: rotateY(-180deg) translateZ(0) scale(1); box-shadow: none; }
}
.flip-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  background: var(--cream);
  background-image: var(--paper-tile);
  background-size: 60px;
}
.flip-face.flip-back { transform: rotateY(180deg); }
.flip-leaf::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.16), transparent 18%, transparent 82%, rgba(0,0,0,0.12));
  opacity: 0;
  transition: opacity 0.75s ease;
  z-index: 5;
  pointer-events: none;
}
.flip-leaf.is-turning::before { opacity: 1; }

/* ---------- Page content ---------- */
.page-content {
  height: 100%;
  overflow-y: auto;
  padding: clamp(28px, 4.5vw, 60px);
  scrollbar-width: thin;
  animation: pageContentIn 0.5s var(--ease) both;
}
.page-content.no-pad { padding: 0; }
@keyframes pageContentIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-kicker { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-title { font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin-bottom: 6px; }
.page-sub { color: var(--ink-soft); max-width: 56ch; }

/* Cover page */
.book-page.is-cover .page-content {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  color: var(--white);
  background:
    radial-gradient(ellipse at 78% 32%, rgba(255, 75, 62, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(13, 12, 10, 0.35) 0%, rgba(13, 12, 10, 0.55) 55%, rgba(9, 8, 7, 0.92) 100%),
    url("../images/site/cover-page-bg.jpg") center 30% / cover no-repeat;
  padding: clamp(24px, 4vw, 48px);
  overflow: hidden;
}
.book-page.is-cover .page-content > a.btn-primary {
  animation: coverCtaMove 2.4s ease-in-out infinite;
}
.book-page.is-cover .page-content > a.btn-primary:hover { animation-play-state: paused; }
@keyframes coverCtaMove {
  0%, 100% { transform: translateY(0); box-shadow: var(--shadow-md), 0 0 0 0 rgba(255, 75, 62, 0.5); }
  50% { transform: translateY(-7px); box-shadow: var(--shadow-md), 0 0 0 14px rgba(255, 75, 62, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .book-page.is-cover .page-content > a.btn-primary { animation: none; }
}

/* ---------- Cover 3D scene: the logo, orbited by dishes ---------- */
.cover-scene {
  position: absolute;
  top: 50%;
  right: 6%;
  width: min(48vw, 340px);
  height: min(48vw, 340px);
  transform: translateY(-56%);
  perspective: 1000px;
  transform-style: preserve-3d;
  z-index: -1;
}
.logo-pedestal {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 70%;
  height: 34px;
  background: radial-gradient(ellipse at center, rgba(255, 75, 62, 0.55), transparent 72%);
  transform: translateX(-50%);
  animation: pedestalPulse 5s ease-in-out infinite;
  filter: blur(2px);
}
@keyframes pedestalPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(0.94); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

.logo-float {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: logoFloat 4.5s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}
.logo-3d-card {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  animation: logoTiltAuto 7s ease-in-out infinite;
  cursor: default;
}
@keyframes logoTiltAuto {
  0%, 100% { transform: rotateY(-16deg) rotateX(6deg); }
  50% { transform: rotateY(16deg) rotateX(-6deg); }
}
.logo-3d-card img {
  width: 54%;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 30px rgba(255, 75, 62, 0.35));
  transform: translateZ(60px);
}
.cover-steam { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.steam {
  position: absolute;
  bottom: 10%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
  filter: blur(4px);
  animation: steamRise 6s ease-in infinite;
}
.steam.s1 { left: 58%; animation-delay: 0s; }
.steam.s2 { left: 68%; width: 34px; height: 34px; animation-delay: 2s; }
.steam.s3 { left: 78%; width: 28px; height: 28px; animation-delay: 4s; }
@keyframes steamRise {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  20% { opacity: 0.55; }
  100% { transform: translateY(-160px) scale(1.6); opacity: 0; }
}
@media (max-width: 860px) {
  .cover-scene { right: 50%; top: 20%; transform: translate(50%, 0); width: 70vw; height: 70vw; max-width: 300px; max-height: 300px; opacity: 0.9; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-float, .logo-3d-card, .logo-pedestal, .steam { animation: none; }
}
.cover-mark { display: flex; align-items: center; gap: 10px; margin-bottom: auto; }
.cover-mark img {
  height: 34px;
  background: rgba(255, 255, 255, 0.96);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
}
.cover-title { font-size: clamp(1.8rem, 4vw, 3rem); max-width: 12ch; margin-bottom: 10px; }
.cover-sub { color: rgba(255,255,255,0.82); max-width: 40ch; margin-bottom: 22px; }

/* Back cover */
.book-page.is-back .page-content {
  height: 100%;
  background: linear-gradient(155deg, var(--navy), var(--ink));
  color: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.book-page.is-back .page-content img {
  height: 38px;
  background: rgba(255, 255, 255, 0.96);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
}

/* ---------- Nav controls ---------- */
.page-nav {
  position: absolute;
  bottom: 18px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 35;
}
.page-arrow {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border: none;
  color: var(--ink);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.page-arrow:hover:not(:disabled) { background: var(--coral); color: var(--white); transform: translateY(-2px) scale(1.06); }
.page-arrow:active:not(:disabled) { transform: scale(0.9); }
.page-arrow:disabled { opacity: 0.35; cursor: default; }
.page-indicator {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* The cover page has its own "Open the Menu" CTA — the nav arrows aren't needed there */
.page-nav.is-cover-nav { display: none; }

/* Attention-grabbing pulse on the next-page arrow, invites the click */
.page-arrow[data-next]:not(:disabled) { animation: arrowPulse 2.6s ease-in-out infinite; }
.page-arrow[data-next]:hover { animation-play-state: paused; }
@keyframes arrowPulse {
  0%, 100% { box-shadow: var(--shadow-md), 0 0 0 0 rgba(255, 75, 62, 0.55); }
  50% { box-shadow: var(--shadow-md), 0 0 0 12px rgba(255, 75, 62, 0); }
}

/* ---------- Mobile drawer toggle for TOC ---------- */
.toc-toggle { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .book-perspective { width: 100vw; height: 100svh; }
  .book { border-radius: 0; box-shadow: none; }
  .book::after { display: none; }
  .book-left {
    position: fixed;
    inset: 0 20% 0 0;
    width: auto;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.4s var(--ease);
    z-index: 50;
  }
  .book-left.is-open { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,0.4); }
  .book-right { border-radius: 0; box-shadow: none; }
  .toc-toggle { display: inline-flex; align-items: center; gap: 8px; }
  .page-content { padding: 80px 22px 90px; }
  .book-page.is-cover .page-content { padding-top: 90px; }
  .stage-left { top: 14px; left: 14px; }
}
@media (min-width: 861px) {
  .book-left-foot { display: block; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .flip-leaf.is-turning.dir-next,
  .flip-leaf.is-turning.dir-prev { animation: none; transform: rotateY(-180deg); }
  .book { animation: none; }
  .page-content { animation: none !important; }
  .book-left { animation: none; }
  .toc-tab { animation: none; opacity: 1; }
}
