/* Shared layout + components for every wish-tree version. Themes only set the variables below
   (and add their own ornaments) in their own stylesheet. */
:root {
  --page-bg: #ede3d7;
  --ink: #2f4a3a;
  --ink-soft: #587061;
  --accent: #b8935a;
  --title-color: var(--ink);
  --title-font: 'Sriracha', 'Brush Script MT', cursive;
  --title-shadow: none;
  --heading-font: 'Cormorant Garamond', Georgia, serif;
  --motto-font: 'Dancing Script', cursive;
  --panel-bg: rgba(251, 246, 236, 0.94);
  --panel-ring: rgba(184, 147, 90, 0.28);
  --panel-shadow: 0 22px 44px -20px rgba(36, 30, 20, 0.55);
  --panel-text: var(--ink-soft);
  --panel-text-strong: var(--ink);
  --input-bg: #fffdf8;
  --input-border: rgba(184, 147, 90, 0.45);
  --input-text: var(--ink);
  --input-placeholder: #9aa79c;
  --input-focus: rgba(47, 74, 58, 0.12);
  --button-bg: var(--ink);
  --button-bg-hover: #233a2d;
  --button-text: #fbf6ec;
  --button-ring: transparent;
  --chip-bg: rgba(251, 246, 236, 0.82);
  --chip-text: var(--ink);
  --chip-ring: rgba(184, 147, 90, 0.35);
  --credit-color: rgba(251, 246, 236, 0.72);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none; /* no pull-to-refresh while dragging over the tree */
  background: var(--page-bg);
  color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Stage ---------- */
.stage { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; }

.stage__layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.stage__layer--scene { touch-action: none; } /* blocks pull-to-refresh / pinch over the tree */
.is-ready .stage__layer { opacity: 1; }

/* ---------- Brand header ---------- */
.brand {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + clamp(14px, 3vh, 30px));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.brand p { margin: 0; }

.brand__logo {
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: clamp(21px, 1.4vw + 14px, 30px);
  line-height: 1;
  letter-spacing: 0.02em;
}

.brand__logo span { color: var(--accent); }


.brand__title {
  margin: clamp(4px, 1vh, 10px) 0 0;
  font-family: var(--title-font);
  font-weight: 400;
  font-size: clamp(46px, 7vh, 80px);
  font-size: clamp(46px, 7dvh, 80px);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--title-color);
  text-shadow: var(--title-shadow);
}

.brand__tagline {
  margin-top: 2px !important;
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: clamp(14px, 0.8vw + 11px, 21px);
  letter-spacing: 0.08em;
}

.brand__divider {
  display: block;
  width: 44px;
  height: 1px;
  margin: 8px auto 6px;
  background: var(--accent);
}

.brand__date {
  font-size: 11px;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: var(--ink-soft);
}

/* ---------- Corner chips: version picker + music ---------- */
.corner-chip {
  position: absolute;
  z-index: 4;
  top: calc(var(--safe-top) + 14px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--chip-ring), 0 8px 18px -12px rgba(0, 0, 0, 0.5);
  color: var(--chip-text);
  font: 500 12px/1 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
}

.corner-chip--left { left: calc(env(safe-area-inset-left, 0px) + 14px); }
.corner-chip--right { right: calc(env(safe-area-inset-right, 0px) + 14px); }
.corner-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.corner-chip[hidden] { display: none; }

.sound-toggle__label { display: none; }
.sound-toggle[data-state='idle'] .sound-toggle__label { display: inline; }
.sound-toggle[data-state='idle'] { animation: chip-invite 2.4s ease-in-out infinite; }

.sound-toggle__bars { display: none; align-items: flex-end; gap: 2px; width: 18px; height: 16px; }
.sound-toggle__bars i { width: 3px; height: 30%; border-radius: 2px; background: currentColor; }
.sound-toggle[data-state='playing'] .sound-toggle__bars { display: inline-flex; }
.sound-toggle[data-state='playing'] .icon--note { display: none; }
.sound-toggle[data-state='playing'] .sound-toggle__bars i { animation: eq-bounce 1.1s ease-in-out infinite; }
.sound-toggle__bars i:nth-child(2) { animation-delay: -0.35s !important; }
.sound-toggle__bars i:nth-child(3) { animation-delay: -0.7s !important; }
.sound-toggle[data-state='muted'] { opacity: 0.7; }
.sound-toggle[data-state='muted'] .icon--note { stroke-dasharray: 2 2; }

@keyframes eq-bounce { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@keyframes chip-invite {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--chip-ring), 0 0 0 0 var(--chip-ring); }
  50% { box-shadow: inset 0 0 0 1px var(--chip-ring), 0 0 0 7px transparent; }
}

/* ---------- Wish panel ---------- */
.wish-panel {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 34px); /* leaves room for the credit line underneath */
  width: min(460px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 12px 12px 8px;
  border-radius: 24px;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow), inset 0 0 0 1px var(--panel-ring);
}

.wish-panel p { margin: 0; text-align: center; }

.wish-panel__counter { margin-bottom: 10px !important; font-size: 13px; color: var(--panel-text); }
.wish-panel__counter strong { display: inline-block; margin: 0 2px; font-weight: 600; color: var(--panel-text-strong); }
.wish-panel__counter strong.is-bumped { animation: count-bump 0.6s ease; }

@keyframes count-bump { 35% { transform: translateY(-3px) scale(1.12); color: var(--accent); } }

.wish-panel__motto { margin-top: 6px !important; font-family: var(--motto-font); font-size: 16px; color: var(--accent); }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--spark { width: 12px; height: 12px; margin-right: 2px; vertical-align: -1px; fill: var(--accent); stroke: none; }

.wish-form { display: flex; gap: 8px; }
.wish-form__field { position: relative; flex: 1; min-width: 0; }

.icon--leaf {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--panel-text);
  pointer-events: none;
}

.wish-form__input {
  width: 100%;
  height: 50px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--input-text);
  font: 400 16px/1 'Be Vietnam Pro', system-ui, sans-serif; /* ≥16px keeps iOS from zooming */
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wish-form__input::placeholder { color: var(--input-placeholder); }
.wish-form__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--input-focus); }

.wish-form__button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--button-bg);
  box-shadow: inset 0 0 0 1px var(--button-ring), 0 10px 20px -10px rgba(0, 0, 0, 0.7);
  color: var(--button-text);
  font: 600 13px/1 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.wish-form__button:hover { background: var(--button-bg-hover); }
.wish-form__button:active { transform: scale(0.96); }
.wish-form__button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wish-form__button:disabled { opacity: 0.6; cursor: progress; }
.wish-form__label-short { display: none; }

@media (max-width: 420px) {
  .wish-form__label-long { display: none; }
  .wish-form__label-short { display: inline; }
  .wish-form__button { padding: 0 18px; }
}

@media (max-height: 600px) {
  .brand__tagline, .brand__divider, .brand__date, .wish-panel__motto { display: none; }
  .brand__title { font-size: 42px; }
  .wish-panel__counter { margin-bottom: 6px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sound-toggle[data-state='idle'], .sound-toggle__bars i { animation: none !important; }
}

/* ---------- Credit ---------- */
.credit {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 8px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--credit-color);
  font: 500 10px/1 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

/* The logo is dark blue/green, so it sits on a light pill to read on night and sunrise alike */
.credit__logo {
  display: block;
  width: auto;
  height: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.credit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 999px; }

/* ---------- FPS read-out beside the menu chip ---------- */
.fps-badge {
  position: absolute;
  z-index: 4;
  top: calc(var(--safe-top) + 24px);
  left: calc(env(safe-area-inset-left, 0px) + 62px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--chip-ring);
  color: var(--chip-text);
  font: 600 10px/1 ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.fps-badge[hidden] { display: none; }
.fps-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #9a9a9a; }
.fps-badge[data-level='good']::before { background: #3bb273; }
.fps-badge[data-level='fair']::before { background: #e0a030; }
.fps-badge[data-level='poor']::before { background: #e0453a; }

/* Phones: tuck it under the menu chip so it never touches the logo */
@media (max-width: 480px) {
  .fps-badge { top: calc(var(--safe-top) + 60px); left: calc(env(safe-area-inset-left, 0px) + 14px); }
}

/* Until the scene is ready the button looks (and is) inactive */
body:not(.is-ready) .wish-form__button { opacity: 0.6; pointer-events: none; }
