/* ═══════════════════════════════════════════════
   PIECE BY PIECE  —  style.css
   ═══════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────── */
:root {
  --cream:     #F8F3EE;
  --cream-2:   #EDE5D8;
  --cream-3:   #DDD1C0;
  --pink:      #C8917F;
  --pink-lt:   #E4BFAF;
  --sage:      #7E9E82;
  --charcoal:  #252320;
  --ch2:       #4A4540;
  --ch3:       #8A8278;
  --white:     #FFFFFF;

  --f-d: 'Cormorant Garamond', Georgia, serif;
  --f-u: 'DM Sans', system-ui, sans-serif;

  --sh-sm:   0 2px 8px  rgba(37,35,32,.08);
  --sh-md:   0 4px 20px rgba(37,35,32,.12);
  --sh-lg:   0 8px 32px rgba(37,35,32,.18);
  --sh-drag: 0 14px 44px rgba(37,35,32,.30);

  --r-sm: 6px;
  --r-md: 12px;

  --ease-snap: cubic-bezier(.34,1.56,.64,1);
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--f-u);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ── Screens ────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--cream);
  opacity: 0;
  pointer-events: none;
  transition: opacity .38s ease;
  overflow: hidden;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.screen-inner {
  width: 100%;
  max-width: 520px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* ── Typography ─────────────────────────────────── */
.eyebrow {
  font-family: var(--f-u);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .18em;
  color: var(--ch3);
  text-transform: uppercase;
}

.game-title {
  font-family: var(--f-d);
  font-size: clamp(28px, 8.5vw, 46px);
  font-weight: 400;
  letter-spacing: .24em;
  color: var(--charcoal);
  line-height: 1;
}

.game-sub {
  font-family: var(--f-d);
  font-size: clamp(16px, 4.5vw, 22px);
  font-weight: 300;
  font-style: italic;
  color: var(--pink);
  margin-top: 4px;
  letter-spacing: .02em;
}

/* ── Fade animation ─────────────────────────────── */
.fade-line {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .7s ease, transform .7s ease;
}
.fade-line.show {
  opacity: 1;
  transform: translateY(0);
}

.fade-btn {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .5s ease, transform .5s ease, background .15s ease, transform .1s ease;
}
.fade-btn.show {
  opacity: 1;
  transform: translateY(0);
}
.fade-btn.show:active { transform: scale(.96); }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 38px;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--f-u);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .13em;
  cursor: pointer;
  min-height: 52px;
  min-width: 160px;
  touch-action: manipulation;
}

.btn-dark {
  background: var(--charcoal);
  color: var(--cream);
  box-shadow: var(--sh-sm);
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn-dark:active {
  background: var(--ch2);
  transform: scale(.97);
  box-shadow: none;
}

.btn-ghost {
  background: none;
  border: none;
  font-family: var(--f-u);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .07em;
  color: var(--ch3);
  cursor: pointer;
  padding: 10px 16px;
  min-height: 44px;
  touch-action: manipulation;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color .15s ease;
}
.btn-ghost:active { color: var(--ch2); }

.btn-pill {
  background: var(--cream-2);
  border: none;
  border-radius: 100px;
  font-family: var(--f-u);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  color: var(--ch2);
  cursor: pointer;
  padding: 10px 16px;
  min-height: 40px;
  min-width: 80px;
  text-align: center;
  touch-action: manipulation;
  transition: background .15s ease, opacity .15s ease;
}
.btn-pill:active { background: var(--cream-3); }
.btn-pill.muted  { opacity: .45; }

/* ── Pretty Level Buttons ──────────────────────── */
.level-btn {
  background: rgba(248, 243, 238, 0.4);
  color: var(--charcoal);
  border: 1px solid var(--pink-lt);
  padding: 10px 22px;
  border-radius: 30px;
  font-family: var(--f-d);
  font-size: 17px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: .02em;
  box-shadow: 0 4px 12px rgba(200, 145, 127, 0.15);
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 110px;
}
.level-btn:hover {
  background: var(--white);
  border-color: var(--pink);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(200, 145, 127, 0.25);
}
.level-btn:active {
  transform: translateY(0);
}

.author-text {
  font-family: var(--f-d);
  font-size: clamp(14px, 3.8vw, 18px);
  font-style: italic;
  font-weight: 400;
  color: var(--ch3);
  letter-spacing: .05em;
}
.heart-icon {
  color: var(--pink);
  font-size: 14px;
  vertical-align: middle;
  padding: 0 4px;
}



/* ═══════════════════════════════════════════════
   INTRO SCREEN
   ═══════════════════════════════════════════════ */
#screen-intro { 
  justify-content: flex-start;
  overflow-y: auto;
}

.intro-inner {
  margin: auto;
  justify-content: center;
  gap: 52px;
  padding-top: 40px;
  padding-bottom: 40px;
}

.intro-brand { text-align: center; }

.intro-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.intro-text .fade-line {
  font-family: var(--f-d);
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 300;
  font-style: italic;
  color: var(--ch2);
  line-height: 1.5;
  letter-spacing: .02em;
}

.intro-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ═══════════════════════════════════════════════
   TRANSITION SCREEN
   ═══════════════════════════════════════════════ */
#screen-transition { justify-content: center; }

.trans-inner {
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.trans-big {
  font-family: var(--f-d);
  font-size: clamp(30px, 8.5vw, 50px);
  font-weight: 300;
  color: var(--charcoal);
  line-height: 1.15;
}
.trans-med {
  font-family: var(--f-d);
  font-size: clamp(16px, 4.5vw, 24px);
  font-weight: 300;
  font-style: italic;
  color: var(--ch2);
}
.trans-small {
  font-family: var(--f-d);
  font-size: clamp(14px, 3.8vw, 20px);
  font-weight: 300;
  font-style: italic;
  color: var(--ch3);
}
#btn-continue { margin-top: 8px; }

/* ═══════════════════════════════════════════════
   PLAYING SCREEN
   ═══════════════════════════════════════════════ */
#screen-playing {
  justify-content: flex-start;
  align-items: stretch;
}

/* ── HUD ─────────────────────────────────────── */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  flex-shrink: 0;
}

.hud-left {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: flex-start;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 2;
  text-align: center;
}

.hud-num {
  font-family: var(--f-u);
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--ch3);
}
.hud-title {
  font-family: var(--f-d);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: .07em;
  color: var(--charcoal);
}

.hud-right {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

/* ── Workspace ───────────────────────────────── */
#workspace-area {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden; /* canvas handles pan/zoom */
  background: var(--cream);
  touch-action: none;
}

#puzzle-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Photo Modal ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(37,35,32,0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 100%;
  z-index: 1;
}

#ref-photo {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
}

/* ═══════════════════════════════════════════════
   LEVEL COMPLETE SCREEN
   ═══════════════════════════════════════════════ */
#screen-complete { justify-content: center; }

.complete-inner {
  justify-content: center;
  gap: 26px;
  align-items: center;
  padding-top: 0;
}

#cp-photo-wrap {
  width: 100%;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--sh-lg);
}
#cp-photo { width: 100%; height: auto; display: block; }

.cp-caption {
  font-family: var(--f-d);
  font-size: clamp(18px, 5.2vw, 26px);
  font-weight: 300;
  font-style: italic;
  color: var(--ch2);
  text-align: center;
  line-height: 1.55;
  max-width: 280px;
}

#btn-next    { min-width: 180px; }
#btn-restart { margin-top: -6px; }

/* ═══════════════════════════════════════════════
   FINAL SCREEN
   ═══════════════════════════════════════════════ */
#screen-final { justify-content: center; }

.final-inner {
  justify-content: center;
  gap: 0;
  text-align: center;
  max-width: 340px;
  padding-top: 0;
}

#final-lines {
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin-bottom: 60px;
}

.final-line {
  font-family: var(--f-d);
  font-size: clamp(16px, 4.6vw, 22px);
  font-weight: 300;
  color: var(--charcoal);
  line-height: 1.65;
}
.final-line.italic { font-style: italic; color: var(--ch2); }
.final-line.small  { font-size: clamp(13px, 3.8vw, 17px); color: var(--ch3); }

.final-heart {
  display: block;
  font-size: 22px;
  color: var(--pink);
  margin-bottom: 30px;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.final-heart.show { opacity: 1; }

#btn-play-again { margin-top: 4px; }

/* ── Safe area (iPhone notch / home bar) ───────── */
@supports (padding: max(0px)) {
  .hud    { padding-top: max(14px, env(safe-area-inset-top)); }
  #workspace-area { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
}

/* ── Reduced motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fade-line, .fade-btn { transition: opacity .1s ease; transform: none !important; }
  .drag-proxy { box-shadow: none; }
  #board-guide { transition: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── Prevent overscroll bounce on iOS ───────────── */
html { overscroll-behavior: none; }
#workspace-area { overscroll-behavior: contain; }

/* -- Secret Message Modal ------------------------ */
.text-modal {
  padding: 40px 30px;
  background: var(--cream);
  max-width: 90%;
  width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
}

.secret-text {
  font-family: var(--f-d);
  font-size: clamp(17px, 4.5vw, 22px);
  font-style: italic;
  font-weight: 400;
  color: var(--charcoal);
  line-height: 1.6;
  text-align: center;
  margin-bottom: 25px;
}

.secret-text p {
  margin: 8px 0;
}


