/* ============================================================
   Surat digital — deck 1:1 dengan template (1920x1080 per halaman)
   Semua koordinat dalam CSS = piksel template; halaman diskalakan
   dengan transform, jadi tata letaknya tidak pernah berubah.
   ============================================================ */

@font-face {
  font-family: "Cabin Sketch";
  src: url("/static/fonts/CabinSketch-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: block;
}
@font-face {
  font-family: "Coming Soon";
  src: url("/static/fonts/ComingSoon-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: block;
}

:root {
  --cream: #fdf6ee;
  --plum: #37283b;
  --coral: #f48482;
  --navy: #0f1a38;
  --mustard: #fcbf40;
  --peach: #f3ddc4;
  --ui: "Coming Soon", ui-rounded, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--plum);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { height: 100svh; overflow: hidden; }
body.is-preview { height: auto; overflow: auto; }

/* ---------------------------------------------------------------- deck */
.deck {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { width: 0; height: 0; }
.deck.no-smooth { scroll-behavior: auto; }

.slide {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  overflow: hidden;
  scroll-snap-align: center;
  background: var(--cream);
  contain: layout paint;
  box-shadow: 0 8px 34px rgba(55, 40, 59, 0.1);
}

.canvas {
  position: absolute;
  left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform: scale(var(--k, 1)) translate(var(--tx, 0px), var(--ty, 0px));
  transform-origin: 0 0;
  --k: calc(100cqw / 1920px);
  will-change: transform;
}

.plate {
  position: absolute;
  left: 0; top: 0;
  width: 1920px; height: 1080px;
  user-select: none;
  -webkit-user-drag: none;
}

.clips { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------------------------------------------------------- teks
   left  = x                    (dx = 0 di semua slot vs render referensi)
   top   = y + pad*skala        (baseline pertama = y + lh - 0.195*fs)
   satu <span> = satu baris, line-height = spcPts dari template            */
.t {
  position: absolute;
  margin: 0;
  padding: 0;
  left: calc(var(--x) * 1px);
  top: calc((var(--y) + var(--pad) * var(--s, 1)) * 1px);
  width: calc(var(--w) * 1px);
  height: calc(var(--h) * 1px);
  font-size: calc(var(--fs) * var(--s, 1) * 1px);
  line-height: calc(var(--lh) * var(--s, 1) * 1px);
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  text-rendering: geometricPrecision;
  font-synthesis: none;
}
.t > span { display: block; }
.f-cabin-sketch { font-family: "Cabin Sketch", cursive; }
.f-coming-soon { font-family: "Coming Soon", var(--ui); }

/* ---------------------------------------------------------------- foto */
.ph {
  position: absolute;
  left: calc(var(--x) * 1px);
  top: calc(var(--y) * 1px);
  width: calc(var(--w) * 1px);
  height: calc(var(--h) * 1px);
  object-fit: cover;
  object-position: center;
  display: block;
}

/* ---------------------------------------------------------------- sampul */
.slide.k-cover { cursor: pointer; }

.cta {
  position: absolute;
  left: 700px; top: 890px;
  width: 520px; height: 104px;
  display: flex; align-items: center; justify-content: center; gap: 22px;
  border: 0; border-radius: 999px;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--ui);
  font-size: 46px; line-height: 1;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(55, 40, 59, 0.18);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.cta-i { width: 44px; height: 44px; flex: none; }
.cta:hover, .cta:focus-visible { transform: translateY(3px); box-shadow: 0 3px 0 rgba(55, 40, 59, 0.2); }
.cta:active { transform: translateY(6px); box-shadow: 0 0 0 rgba(55, 40, 59, 0.2); }
.cta:focus-visible { outline: 4px solid var(--coral); outline-offset: 4px; }

body:not(.is-opened) .deck { height: 100svh; overflow: hidden; }
body:not(.is-opened):not(.is-opening) .slide { display: none; }
body:not(.is-opened) .slide.k-cover {
  display: block; height: 100svh; aspect-ratio: auto;
  --ar: calc(100svh / 100cqw);
}
/* sampul closed: kanvas 1920x1080 dipusatkan vertikal di layar penuh
   (lebar sudah pas = 100cqw, jadi hanya sumbu Y yang digeser) */
body:not(.is-opened) .slide.k-cover .canvas {
  left: 0; top: 0;
  transform: scale(var(--k)) translate(0px, calc((var(--ar) * 1920 - 1080) / 2 * 1px));
}
body:not(.is-opened) .dots,
body:not(.is-opened) .chrome,
body:not(.is-opened) .hint,
body:not(.is-opened) .progress { opacity: 0; pointer-events: none; }

body.is-opening .slide.k-cover {
  perspective: 1800px;
  transform-origin: 50% 0;
  animation: buka 0.9s cubic-bezier(0.45, 0, 0.2, 1) forwards;
}
@keyframes buka {
  0%   { transform: rotateX(0deg);   opacity: 1; }
  60%  { transform: rotateX(-58deg); opacity: 1; }
  100% { transform: rotateX(-104deg); opacity: 0; }
}
body.is-opening { overflow: hidden; }

.is-preview .slide.k-cover { cursor: default; }
.is-preview .cta { display: none; }
.is-preview .slide:first-child { display: none; }
.is-preview .deck { height: auto; overflow: visible; }
.is-preview .dots, .is-preview .hint { display: none; }
.is-preview .slide { display: block; }
.is-preview .chrome { display: none; }

/* ---------------------------------------------------------------- navigasi */
.dots {
  position: fixed;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
  z-index: 40;
  transition: opacity 0.3s;
}
.dot {
  width: 12px; height: 12px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(55, 40, 59, 0.18);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.dot:hover { background: rgba(55, 40, 59, 0.4); }
.dot.on { background: var(--coral); transform: scale(1.35); }

.progress {
  position: fixed; left: 0; top: 0; right: 0; height: 4px;
  background: rgba(55, 40, 59, 0.08);
  z-index: 45; transition: opacity 0.3s;
}
.progress i { display: block; height: 100%; width: 0; background: var(--coral); transition: width 0.15s linear; }

.chrome {
  position: fixed; left: 14px; bottom: 14px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  z-index: 40; transition: opacity 0.3s;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border: 0; border-radius: 999px;
  background: rgba(253, 246, 238, 0.92);
  color: var(--plum);
  font-family: var(--ui); font-size: 15px; line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(55, 40, 59, 0.14);
}
.chip.counter { cursor: default; opacity: 0.75; }
.chip.on { background: var(--coral); color: #fff; }

.hint {
  position: fixed; right: 16px; bottom: 16px;
  margin: 0; z-index: 40;
  font-size: 14px; color: rgba(55, 40, 59, 0.45);
  transition: opacity 0.4s;
}

/* ---------------------------------------------------------------- mode perbesar */
body.zoomed { overflow: hidden; }
body.zoomed .deck { height: 100svh; overflow: hidden; scroll-snap-type: none; }
body.zoomed .slide { height: 100svh; aspect-ratio: auto; display: none; }
body.zoomed .slide.cur { display: block; }
body.zoomed .canvas { --k: calc(100svh / 1080px * 2); cursor: grab; touch-action: none; }
body.zoomed .slide.cur .canvas { cursor: grabbing; }
body.zoomed .hint { display: none; }

/* ---------------------------------------------------------------- ponsel */
@media (max-width: 720px) {
  /* tombol buka diperbesar di layar kecil agar tetap terbaca/ Easy tap */
  .cta { font-size: 88px; }
  .cta-i { width: 78px; height: 78px; }
  .dots { right: 8px; gap: 7px; }
  .dot { width: 9px; height: 9px; }
  .chrome { left: 10px; bottom: 10px; }
  .chip { font-size: 14px; padding: 7px 13px; }
  .hint { font-size: 12px; right: 10px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .deck { scroll-behavior: auto; }
  body.is-opening .slide.k-cover { animation-duration: 0.01s; }
  .cta { transition: none; }
}

:root { --theme: var(--cream); }
.theme-cream { background: var(--cream); }
.theme-navy  { background: #e6ecff; }
.theme-plum  { background: #f3ecf7; }
.theme-teal  { background: #eaf7f3; }
