/* ===========================
   CSS Variables (Theme)
   =========================== */
:root {
  --bg-color: #ffe;
  --text-color: #228567;
  --name-color: #000;
  --date-color: #808080;
  --stage-w: 1100px;
  --stage-h: 680px;
  --tree-shift-x: 260px;
}

/* ===========================
   Global Styles
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-color);
  font: 14px/1.4 sans-serif;
  overflow: hidden;
  min-width: 100vw;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===========================
   Main Canvas Container
   =========================== */
#viewport {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  max-width: 100vw;
  max-height: 100svh;
  overflow: hidden;
  contain: layout size style;
}

#main {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  transform-origin: top left;
}

#ground-canvas,
#static-canvas,
#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--stage-w);
  height: var(--stage-h);
  will-change: transform;
}

#ground-canvas {
  z-index: 0;
}

#static-canvas {
  transition: transform 1.5s ease-in-out;
  z-index: 1;
}

#static-canvas.shifted {
  transform: translateX(var(--tree-shift-x));
}

#canvas {
  z-index: 2;
}

/* ===========================
   Love Letter Content
   =========================== */
#letter {
  position: absolute;
  width: 420px;
  /* Lifted up and given more room so long letters can never reach the
     names / countdown block below (which starts at 550px). */
  height: 470px;
  max-height: 470px;
  left: 60px;
  top: 40px;
  display: none;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-color);
  overflow: hidden;
  z-index: 3;
}

#letter p {
  margin: 0;
}

.typewriter-cursor {
  display: inline;
  color: var(--text-color);
  font-weight: 100;
  animation: blink 0.6s step-end infinite;
}

.typewriter-cursor--done {
  animation: blink 0.6s step-end 6;
  animation-fill-mode: forwards;
  opacity: 0;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===========================
   Time Counter Display
   =========================== */
#clock-box {
  position: absolute;
  left: 60px;
  top: 550px;
  font-size: 28px;
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 3;
}

#clock-box.clock-box--visible {
  opacity: 1;
}

#clock-text {
  color: var(--date-color);
}

#clock-text .name {
  color: var(--name-color);
}

#clock {
  margin-left: 48px;
}

#clock .digit {
  font-size: 64px;
}

/* ===========================
   Mobile Layout (phones)
   =========================== */
/* On desktop/tablet the letter + countdown live inside the scaled 1100x680
   stage next to the tree, which is how the original design intends them.
   On narrow phones that same stage would need to shrink to ~35% of its
   size to fit the width, making that text unreadable — so on phones
   js/ui.js physically moves #letter and #clock-box out of the scaled
   stage into #mobile-content below it, and these rules give them normal,
   always-legible sizing instead of fixed stage-pixel positioning. */

#mobile-content {
  display: none;
}

@media (max-width: 700px) {
  body {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100svh;
    padding: 28px 0 48px;
  }

  #viewport {
    margin: 0 auto;
  }

  #mobile-content {
    display: block;
    width: min(92vw, 440px);
    margin: 22px auto 0;
    z-index: 5;
  }

  #mobile-content #letter {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    left: auto;
    top: auto;
    font-size: clamp(14px, 4.2vw, 17px);
    line-height: 1.55;
    overflow: visible;
  }

  #mobile-content #clock-box {
    position: static;
    left: auto;
    top: auto;
    margin-top: 26px;
    font-size: clamp(15px, 4.4vw, 20px);
  }

  #mobile-content #clock {
    margin-left: 0;
    margin-top: 8px;
    display: block;
  }

  #mobile-content #clock .digit {
    font-size: clamp(26px, 9vw, 40px);
  }
}