/* ============================================================
   chrome frame — the Heron-style technical drawing device:
   ruler ticks, corner crosses, a coordinate readout, a crosshair.
   ============================================================ */
:root {
  --fg: #efe7d6;
  --ink2: #15110c;
  --line: rgba(239, 231, 214, 0.35);
}

#chrome-frame { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.ruler { position: fixed; left: 0; right: 0; height: 22px; z-index: 91; pointer-events: none; }
.ruler--top { top: 0; }
.ruler--bottom { bottom: 0; }
.ruler::before {
  content: ""; position: absolute; inset: 0;
  background-image: var(--ruler-tile);
  background-repeat: repeat-x; background-position: left center;
  opacity: 0.55;
}
.corner-mark { position: fixed; z-index: 92; font-size: 14px; line-height: 1; color: var(--fg); opacity: 0.55; font-family: var(--font-mono); }
.corner-mark--tl { top: 6px; left: 8px; }
.corner-mark--tr { top: 6px; right: 8px; }
.corner-mark--bl { bottom: 6px; left: 8px; }
.corner-mark--br { bottom: 6px; right: 8px; }

.coord-badge {
  position: fixed; z-index: 93; top: 30px; right: 14px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--fg); background: rgba(10, 8, 6, 0.55); border: 1px solid var(--line);
  padding: 6px 10px; pointer-events: none; opacity: 0; transition: opacity 240ms;
  white-space: pre;
}
.coord-badge.is-on { opacity: 0.9; }
.crosshair-v, .crosshair-h { position: fixed; z-index: 91; background: var(--line); pointer-events: none; opacity: 0; transition: opacity 240ms; }
.crosshair-v { top: 0; bottom: 0; width: 1px; }
.crosshair-h { left: 0; right: 0; height: 1px; }
.crosshair-v.is-on, .crosshair-h.is-on { opacity: 1; }

@media (max-width: 760px) {
  .ruler, .corner-mark, .coord-badge, .crosshair-v, .crosshair-h { display: none; }
}

/* ============================================================
   lock screen — a simple gate so the link can go out early
   ============================================================ */
#lockscreen {
  position: fixed; inset: 0; z-index: 85; display: none;
  align-items: center; justify-content: center; background: var(--ink2);
  padding: 24px;
}
#lockscreen.is-active { display: flex; }
#lockscreen.is-unlocking { animation: fade-in 500ms reverse; }
.lock-card { width: min(360px, 100%); text-align: center; }
.lock-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--fg); opacity: 0.6; margin-bottom: 10px; }
.lock-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 7vw, 2.8rem); color: var(--fg); margin-bottom: 28px; letter-spacing: -0.02em; }
#lock-form { display: flex; flex-direction: column; gap: 12px; }
.lock-input {
  width: 100%; min-height: 3.2rem; padding: 0 1.1rem; border-radius: 999px; border: 0;
  background: rgba(239, 231, 214, 0.1); color: var(--fg); font-size: 1rem;
  font-family: var(--font-text); text-align: center; letter-spacing: 0.04em;
}
.lock-input::placeholder { color: var(--fg); opacity: 0.4; }
.lock-input:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
#lock-form .btn { width: 100%; background: var(--fg); color: var(--ink2); }
.lock-error { margin-top: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--accent-red); }
#lockscreen.is-shaking .lock-card { animation: lock-shake 400ms ease-in-out; }
@keyframes lock-shake { 10%, 90% { transform: translateX(-6px); } 20%, 80% { transform: translateX(8px); } 30%, 50%, 70% { transform: translateX(-10px); } 40%, 60% { transform: translateX(10px); } }

/* ============================================================
   boot sequence — preloader, castle, welcome
   ============================================================ */
#boot { position: fixed; inset: 0; z-index: 80; background: var(--ink2); }
.boot-scene {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; color: var(--fg); background: var(--ink2);
  text-align: center; padding: 48px 20px;
}
.boot-scene.is-active { display: flex; }
#boot.is-closing { animation: boot-out 700ms var(--ease-in-out) forwards; }
@keyframes boot-out { to { opacity: 0; visibility: hidden; } }

/* ---- preloader ---- */
#scene-preloader { justify-content: space-between; padding: 28px clamp(20px, 4vw, 48px); }
.pre-top { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; color: var(--fg); opacity: 0.8; }
.pre-mid { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
.pre-pct { font-family: var(--font-display); font-weight: 700; font-size: clamp(4rem, 16vw, 11rem); letter-spacing: -0.03em; color: var(--fg); }
.pre-bottom { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pre-specs { text-align: left; font-family: var(--font-mono); font-size: 11px; line-height: 1.9; opacity: 0.85; }
.pre-specs .row { display: flex; gap: 10px; }
.pre-specs .k { width: 76px; flex: none; opacity: 0.6; }
.pre-log { text-align: right; font-family: var(--font-mono); font-size: 11px; line-height: 1.9; opacity: 0.85; }
.pre-log div { opacity: 0.25; transition: opacity 200ms; }
.pre-log div.is-done { opacity: 0.95; }
.pre-bar { position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--ink2); transform: translateY(-50%); }
.pre-bar::before { content: ""; position: absolute; inset: 0; background: var(--accent-red); width: var(--pct, 0%); transition: width 120ms linear; }

/* ---- castle ---- */
#scene-castle { background: #0a0712; overflow: hidden; }
.castle-sky { position: absolute; inset: 0; overflow: hidden; }
.star { position: absolute; width: 3px; height: 3px; background: var(--fg); border-radius: 50%; opacity: 0; animation: star-in 900ms ease-out forwards, star-twinkle 3.2s ease-in-out infinite; }
@keyframes star-in { to { opacity: 0.8; } }
@keyframes star-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.95; } }

.castle-wrap { position: relative; width: min(82vw, 980px); aspect-ratio: 2130 / 650; margin-top: auto; margin-bottom: 8vh; border: 0; background: none; padding: 0; cursor: pointer; }
.castle-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity 1.4s var(--ease-in-out); }
.castle-silhouette { opacity: 1; }
.castle-warm { opacity: 0; }
.castle-detail { opacity: 0; }
#scene-castle.is-lit .castle-silhouette { opacity: 0; }
#scene-castle.is-lit .castle-warm { opacity: 1; }
#scene-castle.is-lit .castle-detail { opacity: 1; transition-delay: 0.3s; }

.castle-glow { position: absolute; width: 2.6%; height: 4.2%; border-radius: 2px; background: radial-gradient(circle, rgba(255, 200, 110, 0.95), rgba(255, 170, 60, 0.15) 70%, transparent); opacity: 0; transition: opacity 500ms ease-out; }
#scene-castle.is-lit .castle-glow { opacity: 1; }
.castle-glow:nth-of-type(1) { transition-delay: 0.1s; } .castle-glow:nth-of-type(2) { transition-delay: 0.3s; }
.castle-glow:nth-of-type(3) { transition-delay: 0.5s; } .castle-glow:nth-of-type(4) { transition-delay: 0.2s; }
.castle-glow:nth-of-type(5) { transition-delay: 0.6s; } .castle-glow:nth-of-type(6) { transition-delay: 0.4s; }
.castle-glow:nth-of-type(7) { transition-delay: 0.7s; } .castle-glow:nth-of-type(8) { transition-delay: 0.35s; }
.castle-glow:nth-of-type(9) { transition-delay: 0.55s; }

.castle-flags { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 600ms ease-out 0.8s; pointer-events: none; }
#scene-castle.is-lit .castle-flags { opacity: 1; }
.flag { transform-origin: 0% 50%; animation: flag-wave 2.6s ease-in-out infinite; }
.flag:nth-child(2) { animation-delay: -0.6s; } .flag:nth-child(3) { animation-delay: -1.3s; }
@keyframes flag-wave { 0%, 100% { transform: skewY(-6deg); } 50% { transform: skewY(6deg); } }

.castle-hint {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; opacity: 0;
  margin-top: 18px; animation: hint-in 700ms ease-out 2.2s forwards;
}
@keyframes hint-in { to { opacity: 0.75; } }
@media (prefers-reduced-motion: reduce) { .castle-hint { animation-delay: 0.3s; } }

#scene-castle.is-entering .castle-wrap { animation: castle-zoom 900ms var(--ease-in-out) forwards; }
#scene-castle.is-entering .castle-hint { opacity: 0; }
@keyframes castle-zoom { to { transform: scale(2.4); opacity: 0; } }

/* ---- welcome ---- */
#scene-welcome { background: #0a0712; }
.welcome-line { opacity: 0; transform: translateY(16px); transition: opacity 650ms var(--ease-out), transform 650ms var(--ease-out); font-family: var(--font-display); font-weight: 700; }
.welcome-line.is-in { opacity: 1; transform: none; }
.welcome-line--big { font-size: clamp(2.2rem, 7vw, 4.6rem); line-height: 1; letter-spacing: -0.02em; }
.welcome-line--small { font-size: clamp(1.1rem, 3vw, 1.6rem); font-weight: 500; opacity: 0; margin-top: 14px; max-width: 32ch; }
.welcome-line--small.is-in { opacity: 0.85; }

@media (prefers-reduced-motion: reduce) {
  .castle-layer, #boot.is-closing, .castle-wrap, .welcome-line { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ============================================================
   living room anchor figure + easter egg + amerigo
   ============================================================ */
.sint-anchor { position: absolute; z-index: 4; left: 1%; bottom: 0; width: min(30vw, 360px); pointer-events: none; }
.sint-anchor img { width: 100%; height: auto; display: block; animation: sint-breathe 4.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes sint-breathe { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.015) rotate(-0.4deg); } }
@media (max-width: 760px) { .sint-anchor { width: 46vw; left: -2%; } }

.hotspot {
  position: absolute; z-index: 7; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-red); border: 0; cursor: pointer; pointer-events: auto;
  animation: hotspot-pulse 1.8s ease-in-out infinite;
}
@keyframes hotspot-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 54, 43, 0.5); } 50% { box-shadow: 0 0 0 8px rgba(214, 54, 43, 0); } }
.fireplace { position: absolute; right: 2%; bottom: 0; width: min(26vw, 300px); z-index: 2; }
@media (max-width: 760px) { .fireplace { width: 44vw; } .hotspot { width: 26px; height: 26px; } }

.violation {
  position: absolute; z-index: 6; background: var(--accent-red); color: #fff;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5; padding: 10px 14px;
  max-width: 200px; opacity: 0; transform: scale(0.85); transition: opacity 220ms, transform 220ms;
  pointer-events: none;
}
.violation.is-on { opacity: 1; transform: scale(1); }
.violation b { display: block; font-family: var(--font-display); font-size: 12.5px; margin-top: 2px; }

.wordmark-giant {
  font-family: var(--font-display); font-weight: 700; text-align: center;
  font-size: clamp(3rem, 14vw, 11rem); line-height: 0.9; letter-spacing: -0.03em;
  color: transparent; -webkit-text-stroke: 1.5px currentColor; color: var(--chapter-ink);
  opacity: 0.5; padding: 10vh 4vw 14vh; pointer-events: none;
}

/* ---- amerigo, galloping across whatever is on screen ---- */
#amerigo { position: fixed; z-index: 95; bottom: 6%; left: -22vw; width: 18vw; max-width: 230px; pointer-events: none; opacity: 0; }
#amerigo.is-running { animation: amerigo-run var(--amerigo-dur, 7s) linear forwards; opacity: 1; }
#amerigo svg { width: 100%; height: auto; display: block; animation: amerigo-bob 0.45s ease-in-out infinite; }
@keyframes amerigo-run { from { left: -22vw; } to { left: 112vw; } }
@keyframes amerigo-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3%) rotate(-1.5deg); } }
@media (prefers-reduced-motion: reduce) { #amerigo { display: none; } }
