/* R10 Photo Book — Vietnamese edition
   ----------------------------------------------------
   Trim size: 10×10 in, spread = 20×10 in (2 pages side-by-side).
   Screen preview scales to viewport; print outputs 10×10 in per page.
*/

:root {
  --orange: #FC7B26;
  --orange-light: #FFA85C;
  --ink: #16171B;
  --ink-2: #222328;
  --paper: #F5F5F0;
  --muted: #999999;
  --rule: #666666;

  --grad-cover: linear-gradient(135deg, #FC7B26 0%, #16171B 78%);
  --grad-divider: linear-gradient(90deg, #FC7B26 0%, #16171B 100%);

  /* type scale anchored at 10in page */
  --pt: calc(1in / 72); /* 1 point */
  --title: calc(72 * var(--pt));
  --cover-title: calc(84 * var(--pt));
  --subtitle: calc(24 * var(--pt));
  --pullquote: calc(28 * var(--pt));
  --bignum: calc(60 * var(--pt));
  --body: calc(14 * var(--pt));
  --caption: calc(10 * var(--pt));
  --kicker: calc(10 * var(--pt));
  --pagenum: calc(9 * var(--pt));

  --margin: 0.5in;
  --bleed: 3mm;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #0a0b0d;
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  /* Soft scroll-snap: snaps near each spread but allows free scroll between */
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(10, 11, 13, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(252, 123, 38, 0.18);
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c9c8c2;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--paper);
}
.topbar .brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 12px var(--orange);
}
.topbar nav {
  display: flex;
  gap: 18px;
  font-size: 10px;
}
.topbar nav a {
  color: #8a8a82;
  text-decoration: none;
  transition: color .15s;
}
.topbar nav a:hover { color: var(--orange); }
.topbar .meta {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.18em;
  color: var(--orange);
  font-size: 14px;
}

/* ---------- sound toggle ---------- */
.sound-toggle {
  appearance: none;
  background: rgba(34,35,40,0.5);
  border: 1px solid rgba(252,123,38,0.25);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-left: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #8a8a82;
  transition: color .15s, background .15s, border-color .15s, box-shadow .15s;
  padding: 0;
}
.sound-toggle:hover { color: var(--paper); }
.sound-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .on-wave { display: none; }
.sound-toggle .off-x  { display: block; }
.sound-toggle.is-on {
  color: var(--paper);
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 0 1px var(--orange), 0 2px 8px rgba(252,123,38,0.35);
}
.sound-toggle.is-on .on-wave { display: block; }
.sound-toggle.is-on .off-x   { display: none; }

/* gentle pulse when sound is on, so it's visible */
.sound-toggle.is-on::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--orange);
  opacity: 0.6;
  animation: r10-sound-pulse 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes r10-sound-pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0;   }
}
.sound-toggle { position: relative; }
.lang-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 14px;
  padding: 3px;
  border: 1px solid rgba(252,123,38,0.25);
  border-radius: 999px;
  background: rgba(34,35,40,0.5);
}
.lang-tabs button {
  appearance: none;
  background: transparent;
  border: none;
  color: #8a8a82;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.16em;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, background .15s;
  line-height: 1;
}
.lang-tabs button:hover { color: var(--paper); }
.lang-tabs button.active {
  color: var(--paper);
  background: var(--orange);
  box-shadow: 0 0 0 1px var(--orange), 0 2px 8px rgba(252,123,38,0.35);
}

/* ---------- spread container ---------- */
.book {
  display: flex;
  flex-direction: column;
  gap: 56px;
  padding: 56px 24px 120px;
  align-items: center;
  /* allow children to flip in 3D */
  transform-style: preserve-3d;
}

.spread {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(1600px, calc(100vw - 48px));
  aspect-ratio: 2 / 1;
  background: var(--ink);
  position: relative;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.55),
    0 8px 22px rgba(0,0,0,0.45),
    0 0 0 1px rgba(252, 123, 38, 0.06);
  overflow: hidden;
  isolation: isolate;

  /* page-flip mechanics — gentle, like yokohama-timberwharf */
  scroll-snap-align: center;
  scroll-snap-stop: always;
  scroll-margin-top: 64px;
  transform: translateY(60px);
  opacity: 0;
  transition:
    transform 1.2s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity   1.0s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}
.spread.in-view,
.spread.was-in-view {
  transform: translateY(0);
  opacity: 1;
}

/* gutter shadow between two pages */
.spread::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(
    90deg,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.35) 45%,
    rgba(0,0,0,0.55) 50%,
    rgba(0,0,0,0.35) 55%,
    rgba(0,0,0,0) 100%
  );
  pointer-events: none;
  z-index: 5;
}

.page {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page.left  { background: var(--ink); }
.page.right { background: var(--ink); }

/* page-content respects 0.5in margins unless .bleed */
.page-inner {
  position: absolute;
  inset: 0;
  padding: 5%;
  display: flex;
  flex-direction: column;
}
.page.bleed .page-inner {
  padding: 0;
}

/* ---------- page number ---------- */
.pagenum {
  position: absolute;
  bottom: 3.2%;
  font-family: 'Poppins', sans-serif;
  font-size: clamp(9px, 0.78cqi, 13px);
  letter-spacing: 0.12em;
  color: var(--rule);
  font-weight: 400;
  z-index: 4;
}
.page.left  .pagenum { left: 5%; }
.page.right .pagenum { right: 5%; }

/* ---------- kicker line ---------- */
.kicker {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 0.85cqi, 14px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 10px;
}
.kicker.rule::after {
  content: '';
  display: block;
  width: 1in;
  height: 0.5px;
  background: var(--orange);
  margin-top: 8px;
}

/* ---------- typography helpers ---------- */
.display {
  font-family: 'Racing Sans One', sans-serif;
  font-style: italic;
  line-height: 1.0;
  letter-spacing: -0.01em;
}
/* For Vietnamese display text — Racing Sans One has no VN subset.
   Oswald has italic + Vietnamese + sporty condensed display feel. */
.display-vi {
  font-family: 'Oswald', sans-serif;
  font-style: italic;
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.005em;
}
.subtitle {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.14em;
  color: var(--orange);
}
.bebas {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.12em;
}
.body {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  line-height: 1.5;
  color: var(--paper);
}
.caption {
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.pull {
  font-family: 'Racing Sans One', sans-serif;
  font-style: italic;
  color: var(--orange-light);
  line-height: 1.15;
}
.pull-vi {
  font-family: 'Oswald', sans-serif;
  font-style: italic;
  font-weight: 700;
  color: var(--orange-light);
  line-height: 1.2;
  letter-spacing: 0.01em;
}

/* Racing Sans One doesn't include Vietnamese tone marks → swap to
   Oswald (which is VN-safe) on every .display when html lang=vi.
   The .display-vi class already does this; this rule covers .display
   blocks whose content was translated to Vietnamese dynamically. */
html[lang="vi"] .display {
  font-family: 'Oswald', sans-serif;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.005em;
}

/* Bebas Neue also lacks Vietnamese diacritics — swap to Oswald 600
   (slightly less condensed but VN-complete) when html lang=vi. */
html[lang="vi"] .bebas,
html[lang="vi"] .subtitle {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
}

/* container queries on each page so type scales with spread */
.page { container-type: inline-size; }

/* scaled type using container query units */
.t-cover    { font-size: 13cqi; }
.t-title    { font-size: 11.5cqi; }
.t-subtitle { font-size: 3.6cqi; }
.t-pull     { font-size: 4.2cqi; line-height: 1.18; }
.t-bignum   { font-size: 9cqi; }
.t-body     { font-size: 2.1cqi; line-height: 1.55; }
.t-bodyL    { font-size: 2.5cqi; line-height: 1.55; }
.t-caption  { font-size: 1.55cqi; }
.t-kicker   { font-size: 1.55cqi; }
.t-micro    { font-size: 1.4cqi; line-height: 1.5; }

/* ---------- texture / grain ---------- */
.grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  mix-blend-mode: overlay;
  opacity: 0.5;
  z-index: 8;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 0.85 0 0 0 0 0.6 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
}
.dust {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 7;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255, 200, 140, 0.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 70% 60%, rgba(255, 168, 92, 0.30), transparent 60%),
    radial-gradient(1px 1px at 45% 80%, rgba(255, 220, 180, 0.28), transparent 60%),
    radial-gradient(1.2px 1.2px at 85% 20%, rgba(255, 168, 92, 0.25), transparent 60%),
    radial-gradient(1px 1px at 10% 70%, rgba(255, 200, 140, 0.25), transparent 60%);
}

/* warm photo treatment overlay */
.warm-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(252,123,38,0.18), rgba(22,23,27,0.55) 70%);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 3;
}

/* ---------- placeholder photo ---------- */
.ph {
  position: relative;
  overflow: hidden;
  background-color: var(--ink-2);
  background-image:
    repeating-linear-gradient(
      135deg,
      rgba(252, 123, 38, 0.16) 0 12px,
      rgba(252, 123, 38, 0.05) 12px 24px
    );
  border: 1px solid rgba(252, 123, 38, 0.22);
  display: flex;
  align-items: flex-end;
  padding: 14px 16px;
  color: var(--orange-light);
  font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: clamp(8px, 0.95cqi, 12px);
  letter-spacing: 0.06em;
  line-height: 1.4;
}
.ph .ph-tag {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.22em;
  color: var(--orange);
  font-size: clamp(10px, 1.2cqi, 16px);
  margin-bottom: 4px;
}
.ph .ph-corner {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 14px;
  height: 14px;
  border-top: 1px solid var(--orange);
  border-left: 1px solid var(--orange);
  opacity: 0.7;
}
.ph .ph-corner.br {
  top: auto; left: auto;
  bottom: 12px; right: 14px;
  border: none;
  border-bottom: 1px solid var(--orange);
  border-right: 1px solid var(--orange);
}

/* ---------- bleed (full image) ---------- */
.fullbleed {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* ---------- foot links ---------- */
.foot {
  text-align: center;
  color: #555;
  font-size: 11px;
  padding: 30px 0 60px;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ============ MOBILE ============ */
@media (max-width: 860px) {
  body {
    perspective: 1800px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }
  .topbar nav { display: none; }
  .topbar .meta { display: none; }
  .topbar .brand { font-size: 10px; }
  .lang-tabs { margin-left: 0; }
  .lang-tabs button { padding: 4px 7px; font-size: 9.5px; }
  .nav-jump { display: none; }

  .book {
    gap: 32px;
    padding: 32px 12px 80px;
  }

  /* Spreads stack their two pages vertically */
  .spread {
    width: calc(100vw - 24px);
    aspect-ratio: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    scroll-margin-top: 56px;
    transform: translateY(30px);
  }
  .spread.in-view,
  .spread.was-in-view {
    transform: translateY(0);
  }
  .spread::before {
    /* gutter shadow becomes horizontal between stacked pages */
    left: 0;
    right: 0;
    top: 50%;
    bottom: auto;
    width: 100%;
    height: 28px;
    transform: translateY(-50%);
    background: linear-gradient(
      180deg,
      rgba(0,0,0,0) 0%,
      rgba(0,0,0,0.30) 45%,
      rgba(0,0,0,0.45) 50%,
      rgba(0,0,0,0.30) 55%,
      rgba(0,0,0,0) 100%
    );
  }
  .page {
    aspect-ratio: 1 / 1;
  }
  /* the cqi-based type scales naturally; bump body min sizes for readability */
  .t-body, .t-bodyL { font-size: max(2.4cqi, 13px); }
  .t-caption, .t-kicker, .t-micro { font-size: max(1.7cqi, 11px); }
}

/* very narrow phones */
@media (max-width: 480px) {
  .topbar .brand span:last-child { display: none; } /* keep only the dot */
  .topbar .brand { gap: 0; }
  .lang-tabs button { padding: 3px 6px; font-size: 9px; }
}

/* ============ PRINT ============ */
@media print {
  @page {
    size: 10in 10in;
    margin: 0;
  }
  body {
    background: white;
    scroll-snap-type: none;
    perspective: none;
  }
  .topbar, .foot, .nav-jump, .sound-toggle { display: none !important; }
  .book {
    gap: 0;
    padding: 0;
  }
  .spread {
    width: 20in;
    height: 10in;
    aspect-ratio: auto;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
    /* disable 3D flip when printing */
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
  }
  .spread::before { display: none; }
}
