/* ============== TOKENS ============== */
:root {
  --bw: 220px;
  --bd: 145px;
  --bh: 440px;

  --img-w: calc(2 * var(--bw) + 2 * var(--bd));
  --img-h: calc(2 * var(--bd) + var(--bh));

  --design: url('assets/option-1.png');

  --c-ink:    #14110E;
  --c-cream:  #FBF6EC;
  --c-soft:   #5A5448;
  --c-muted:  #8a8378;
  --c-accent: #E66C3A;
  --bg:       #ECE5D5;

  --hinge-ease: cubic-bezier(.65,.02,.25,1);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background:
    radial-gradient(900px 500px at 90% 8%, #fcdcb6 0%, transparent 55%),
    radial-gradient(900px 600px at 8% 96%, #d5e7c8 0%, transparent 55%),
    var(--bg);
  color: var(--c-ink);
  -webkit-font-smoothing: antialiased;
}

/* ============== TOPBAR ============== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: flex-start;
  padding: 18px 30px;
  background: linear-gradient(180deg, rgba(236,229,213,.85) 0%, rgba(236,229,213,0) 100%);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.brand-logo { height: 36px; width: auto; display: block; }

/* ============== SCREENS ============== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity .7s ease, visibility .7s ease;
}
.intro-screen { z-index: 50; opacity: 1; }
.intro-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.box-screen { z-index: 40; opacity: 0; visibility: hidden; pointer-events: none; }
.box-screen.show { opacity: 1; visibility: visible; pointer-events: auto; }

/* ============== INTRO STORY ============== */
.story {
  position: relative;
  width: 100%;
  max-width: 820px;
  height: 100%;
  padding: 80px 32px 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter {
  position: absolute;
  inset: 80px 32px 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .85s ease, transform .85s ease;
  transform: translateY(24px);
}
.chapter.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.chapter.exit-up   { opacity: 0; transform: translateY(-24px); }
.chapter.exit-down { opacity: 0; transform: translateY(24px); }

.ch-inner {
  max-width: 720px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.emoji { display: block; width: auto; user-select: none; pointer-events: none; }
.emoji-sm { height: 92px; }
.emoji-md { height: 160px; }
.emoji.thumbs { transform: rotate(-6deg); }

.hero-line {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: clamp(48px, 9vw, 88px);
  line-height: .95;
  letter-spacing: -.02em;
}
.lede {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(17px, 2.2vw, 22px);
  line-height: 1.45;
  color: var(--c-soft);
  max-width: 580px;
}
.lede.center { text-align: center; }
.lede b { font-weight: 700; color: var(--c-ink); font-style: normal; }

.big-quote {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: clamp(26px, 4.6vw, 46px);
  line-height: 1.15;
  letter-spacing: -.015em;
}
.big-quote.tight { font-size: clamp(22px, 3.8vw, 38px); }
.big-quote em {
  font-style: italic;
  font-weight: 400;
  color: var(--c-soft);
}
.aside {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: clamp(14px, 1.7vw, 17px);
  line-height: 1.5;
  color: var(--c-muted);
  max-width: 520px;
}

.fav-note {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 20px;
  color: var(--c-accent);
}

.scroll-cue {
  margin-top: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.scroll-cue .arrow {
  font-size: 18px;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* dots */
.dots {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 51;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(20,17,14,.18);
  transition: background .3s, transform .3s;
  cursor: pointer;
}
.dot.is-on { background: var(--c-ink); transform: scale(1.4); }

/* ============== BOX SCREEN ============== */
.box-screen {
  padding: 80px 24px 24px;
  gap: 14px;
}

.design-chip {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 14px;
  padding: 7px 16px;
  border: 1px solid rgba(20,17,14,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(6px);
  color: var(--c-ink);
}

.stage {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  perspective: 2400px;
  perspective-origin: 50% 45%;
}
.floor {
  position: absolute;
  bottom: 14%; left: 50%;
  width: 320px; height: 46px;
  background: radial-gradient(closest-side, rgba(0,0,0,.22), transparent 75%);
  transform: translateX(-50%);
  filter: blur(8px);
  pointer-events: none;
}

.scene {
  width: var(--bw);
  height: var(--bh);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.1s var(--hinge-ease);
}
.box {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .9s var(--hinge-ease);
  transform: rotateX(-10deg) rotateY(-26deg);
  will-change: transform;
  touch-action: none;
  cursor: grab;
}
.box:active { cursor: grabbing; }
.dragging .box { transition: none !important; }

.face {
  position: absolute;
  top: 50%; left: 50%;
  backface-visibility: hidden;
  background-image: var(--design);
  background-size: var(--img-w) var(--img-h);
  background-repeat: no-repeat;
  background-color: var(--c-cream);
  box-shadow:
    0 40px 70px -40px rgba(20,17,14,.45),
    inset 0 0 0 .5px rgba(20,17,14,.08);
  transition: transform 1.1s var(--hinge-ease), box-shadow .5s ease;
}

.face.front, .face.back { width: var(--bw); height: var(--bh); }
.face.left, .face.right { width: var(--bd); height: var(--bh); }
.face.top, .face.bottom { width: var(--bw); height: var(--bd); }

.face.front  { background-position: calc(-1 * var(--bd)) calc(-1 * var(--bd)); }
.face.left   { background-position: 0 calc(-1 * var(--bd)); }
.face.right  { background-position: calc(-1 * (var(--bd) + var(--bw))) calc(-1 * var(--bd)); }
.face.back   { background-position: calc(-1 * (2 * var(--bd) + var(--bw))) calc(-1 * var(--bd)); }
.face.top    { background-position: calc(-1 * var(--bd)) 0; }
.face.bottom { background-position: calc(-1 * var(--bd)) calc(-1 * (var(--bd) + var(--bh))); }

.face.front  { transform: translate(-50%, -50%) translateZ(calc(var(--bd) / 2)); }
.face.back   { transform: translate(-50%, -50%) rotateY(180deg) translateZ(calc(var(--bd) / 2)); }
.face.left   { transform: translate(-50%, -50%) rotateY(-90deg) translateZ(calc(var(--bw) / 2)); }
.face.right  { transform: translate(-50%, -50%) rotateY(90deg)  translateZ(calc(var(--bw) / 2)); }
.face.top    { transform: translate(-50%, -50%) rotateX(90deg)  translateZ(calc(var(--bh) / 2)); }
.face.bottom { transform: translate(-50%, -50%) rotateX(-90deg) translateZ(calc(var(--bh) / 2)); }

.scene.unfold .box { transform: rotateX(0deg) rotateY(0deg); }
.scene.unfold .face.front  { transform: translate(-50%, -50%); }
.scene.unfold .face.left   { transform: translate(-50%, -50%) translateX(calc(-1 * (var(--bw)/2 + var(--bd)/2))); }
.scene.unfold .face.right  { transform: translate(-50%, -50%) translateX(calc(var(--bw)/2 + var(--bd)/2)); }
.scene.unfold .face.back   { transform: translate(-50%, -50%) translateX(calc(var(--bw) + var(--bd))); }
.scene.unfold .face.top    { transform: translate(-50%, -50%) translateY(calc(-1 * (var(--bh)/2 + var(--bd)/2))); }
.scene.unfold .face.bottom { transform: translate(-50%, -50%) translateY(calc(var(--bh)/2 + var(--bd)/2)); }
.scene.unfold {
  transform: scale(.6) translateX(calc((var(--bw) + var(--bd)) / 2));
}
.scene.unfold .face {
  box-shadow: 0 10px 24px -14px rgba(0,0,0,.2), inset 0 0 0 .5px rgba(20,17,14,.1);
  outline: 1px dashed rgba(230,108,58,.55);
  outline-offset: -1px;
}

/* ============== PICKER ============== */
.picker-row {
  display: flex;
  gap: 8px;
  padding: 5px;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(20,17,14,.1);
  border-radius: 999px;
  flex-wrap: wrap;
  justify-content: center;
}
.opt-btn {
  position: relative;
  min-width: 42px;
  height: 38px;
  padding: 0 13px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font: 600 14px/1 'Inter', sans-serif;
  cursor: pointer;
  color: var(--c-ink);
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.opt-btn:hover { background: rgba(20,17,14,.06); }
.opt-btn.active { background: var(--c-ink); color: var(--c-cream); }
.opt-btn .opt-fav { font-size: 10px; color: var(--c-accent); margin-left: 2px; }
.opt-btn.active .opt-fav { color: #FFC93C; }
.opt-btn.opt-ai { background: rgba(20,17,14,.04); padding: 0 12px; }
.opt-btn.opt-ai .opt-ai-lbl { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.opt-btn.opt-ai .opt-ai-ico { font-size: 14px; line-height: 1; }
.opt-btn.opt-ai.active { background: #B33A1A; color: #fff; }

/* controls */
.ctl-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ctl {
  display: inline-flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(20,17,14,.1);
  border-radius: 999px;
  padding: 10px 18px;
  font: 600 10px/1 'Inter', sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .2s ease;
  color: var(--c-ink);
}
.ctl:hover { background: rgba(255,255,255,.95); }
.ctl-primary { background: var(--c-ink); color: var(--c-cream); border-color: var(--c-ink); }
.ctl-primary.active { background: var(--c-accent); border-color: var(--c-accent); color: white; }
.ctl-back { font-style: italic; font-family: 'Fraunces', serif; text-transform: none; letter-spacing: .02em; font-size: 12px; padding: 8px 16px; }

.hint-line {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--c-muted);
  text-align: center;
}

/* ============== MOBILE ============== */
@media (max-width: 720px) {
  :root { --bw: 160px; --bd: 106px; --bh: 320px; }
  .topbar { padding: 14px 20px; }
  .brand-logo { height: 30px; }
  .story { padding: 70px 22px 90px; }
  .chapter { inset: 70px 22px 90px; }
  .ch-inner { gap: 20px; }
  .emoji-sm { height: 70px; }
  .emoji-md { height: 120px; }
  .dots { right: 14px; gap: 8px; }
  .dot { width: 7px; height: 7px; }
  .box-screen { padding: 70px 14px 18px; gap: 10px; }
  .design-chip { font-size: 13px; padding: 6px 14px; }
  .picker-row { width: 100%; max-width: 360px; gap: 4px; padding: 4px; }
  .opt-btn { min-width: 36px; height: 34px; padding: 0 10px; font-size: 13px; }
  .opt-btn.opt-ai { padding: 0 10px; }
  .opt-btn.opt-ai .opt-ai-lbl { font-size: 9px; letter-spacing: .1em; }
  .opt-btn.opt-ai .opt-ai-ico { font-size: 12px; }
  .ctl { padding: 9px 14px; font-size: 9.5px; letter-spacing: .14em; }
  .ctl-back { font-size: 11px; }
  .hint-line { font-size: 11px; padding: 0 16px; }
}

@media (max-width: 420px) {
  :root { --bw: 130px; --bd: 86px; --bh: 260px; }
  .scene.unfold { transform: scale(.52) translateX(calc((var(--bw) + var(--bd)) / 2)); }
  .ctl-back { display: none; }
}
