/* ─── Bleu Atelier ─── */
:root {
  --ink: #0E1828;
  --ink-deep: #08101C;
  --wash: #1A2A42;
  --chalk: #EDE6D6;
  --chalk-dim: #C8C2B6;
  --graphite: #6E7588;
  --graphite-deep: #4A4F5E;
  --vermillion: #C13B2C;
  --vermillion-soft: #8E2A1F;

  --serif: 'EB Garamond', Georgia, serif;
  --hand: 'Caveat', cursive;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-slow: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-mech: cubic-bezier(0.65, 0, 0.35, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

body {
  background: var(--ink);
  color: var(--chalk);
  font-family: var(--serif);
  font-feature-settings: 'lnum' 1, 'kern' 1;
  cursor: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Living texture ─── */
body::before {
  content: '';
  position: fixed;
  inset: -10%;
  background:
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 30%, rgba(0,0,0,0.45) 100%),
    radial-gradient(ellipse 60% 40% at 30% 30%, rgba(26,42,66,0.6) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(26,42,66,0.5) 0%, transparent 60%);
  pointer-events: none;
  z-index: 1;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: overlay;
  opacity: 0.55;
}

/* ─── STAGE ─── */
#stage {
  position: fixed;
  inset: 0;
  z-index: 5;
}

/* ─── viewport-window — pannable container ─── */
#viewport-window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 5;
}

#elevation {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  /* width set by JS based on viewBox aspect; transform translate-x for pan */
  transform: translateX(0);
  will-change: transform;
  transition: transform 1.2s var(--ease-slow);
}
#elevation.dragging { transition: none; }

/* ─── SVG line styles ─── */
.wall {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 1.4;
  stroke-linecap: square;
  opacity: 0.85;
}
.wall-thin {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 0.7;
  opacity: 0.55;
  stroke-dasharray: 2 4;
}
.wall-door {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 1.4;
  opacity: 0.4;
  stroke-dasharray: 4 4;
}
.machine-fine {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 1.0;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.92;
}
.machine-stamp {
  fill: var(--vermillion);
  opacity: 0.92;
}
.streamline {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 0.6;
  opacity: 0.4;
  stroke-dasharray: 1 3;
}
.shelf line {
  stroke: var(--chalk);
  stroke-width: 0.5;
  opacity: 0.45;
}

/* ─── SVG typography ─── */
.title-major {
  font-family: 'EB Garamond';
  font-size: 92px;
  font-weight: 400;
  fill: var(--chalk);
  letter-spacing: 0.04em;
}
.title-minor {
  font-family: 'EB Garamond';
  font-size: 38px;
  font-style: italic;
  fill: var(--chalk);
  letter-spacing: 0.02em;
}
.sub-line {
  font-family: 'EB Garamond';
  font-size: 18px;
  font-style: italic;
  fill: var(--chalk);
  opacity: 0.7;
  letter-spacing: 0.18em;
}
.room-num {
  font-family: 'EB Garamond';
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.42em;
  fill: var(--vermillion);
  opacity: 0.85;
}
.room-name {
  font-family: 'EB Garamond';
  font-size: 17px;
  font-style: italic;
  fill: var(--chalk);
  opacity: 0.78;
  letter-spacing: 0.04em;
}
.surv-label {
  font-family: 'EB Garamond';
  font-size: 9px;
  fill: var(--graphite);
  letter-spacing: 0.2em;
  opacity: 0.55;
}
.survey circle {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 0.5;
  opacity: 0.5;
}
.spec text.spec, .spec-strip text.spec {
  font-family: 'EB Garamond';
  font-size: 11px;
  font-style: italic;
  fill: var(--graphite);
  opacity: 0.6;
  letter-spacing: 0.05em;
}
.annot-script {
  font-family: 'Caveat';
  font-size: 28px;
  font-weight: 400;
  fill: var(--chalk);
  opacity: 0.78;
}
.annot-script-small {
  font-family: 'Caveat';
  font-size: 20px;
  fill: var(--graphite);
  opacity: 0.6;
}
.annot-pencil {
  font-family: 'Caveat';
  font-size: 22px;
  fill: var(--graphite);
  opacity: 0.55;
}
.annotation .lead {
  stroke: var(--chalk);
  stroke-width: 0.4;
  opacity: 0.5;
  stroke-dasharray: 2 3;
}
.annotation .lead-dot {
  fill: var(--vermillion);
  opacity: 0.75;
}
.strip-label {
  font-family: 'EB Garamond';
  font-size: 11px;
  fill: var(--chalk);
  opacity: 0.35;
  letter-spacing: 0.32em;
}
.link-line {
  font-family: 'EB Garamond';
  font-size: 14px;
  font-style: italic;
  fill: var(--chalk);
  letter-spacing: 0.18em;
  opacity: 0.7;
}
/* Vermillion stamp */
.stamp-ring {
  fill: none;
  stroke: var(--vermillion);
  stroke-width: 1.4;
  opacity: 0.85;
}
.stamp-text {
  font-family: 'EB Garamond';
  font-size: 9px;
  font-style: italic;
  fill: var(--vermillion);
  text-anchor: middle;
  letter-spacing: 0.28em;
  opacity: 0.9;
}
.stamp-text-sm {
  font-family: 'EB Garamond';
  font-size: 6px;
  fill: var(--vermillion);
  text-anchor: middle;
  letter-spacing: 0.32em;
  opacity: 0.7;
}

/* Chamber active state — stronger lines */
.chamber {
  transition: opacity 0.9s var(--ease);
  opacity: 0.92;
}
.chamber.is-active .machine-fine,
.chamber.is-active .wall {
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(237, 230, 214, 0.18));
}
.chamber.is-far {
  opacity: 0.55;
}

/* ─── Floor markers (left edge) ─── */
#floor-marker {
  position: fixed;
  top: 50%;
  left: 1.4rem;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  pointer-events: none;
}
#floor-marker span {
  font-family: var(--serif);
  font-size: 0.6rem;
  font-style: italic;
  letter-spacing: 0.32em;
  color: var(--graphite);
  opacity: 0.45;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
#floor-marker span::before {
  content: '';
  display: block;
  width: 14px;
  height: 1px;
  background: var(--graphite);
  opacity: 0.6;
}
#floor-marker .ground {
  color: var(--vermillion);
  opacity: 0.85;
}
#floor-marker .ground::before { background: var(--vermillion); }

/* ─── Compass marker (right edge) ─── */
#compass-marker {
  position: fixed;
  top: 50%;
  right: 1.4rem;
  transform: translateY(-50%);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
}
#compass-marker .cardinal {
  font-family: var(--serif);
  font-size: 0.62rem;
  letter-spacing: 0.4em;
  color: var(--chalk);
  opacity: 0.5;
  font-style: italic;
}
.compass-bar {
  width: 1px;
  height: 200px;
  background: linear-gradient(to bottom,
    rgba(237,230,214,0.05) 0%,
    rgba(237,230,214,0.4) 50%,
    rgba(237,230,214,0.05) 100%);
  position: relative;
}
.compass-tick {
  position: absolute;
  left: -3px;
  top: 50%;
  width: 7px;
  height: 1px;
  background: var(--vermillion);
  transform: translateY(-50%);
  transition: top 0.6s var(--ease);
}

/* ─── Masthead (top-left) ─── */
#masthead {
  position: fixed;
  top: 1.4rem;
  left: 1.4rem;
  z-index: 12;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-family: var(--serif);
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  color: var(--chalk);
  opacity: 0;
  transition: opacity 1.6s var(--ease-slow) 0.3s;
  pointer-events: none;
}
#masthead.visible { opacity: 0.7; }
.mast-name { font-weight: 500; }
.mast-sep { color: var(--vermillion); }
.mast-tagline {
  font-style: italic;
  font-size: 0.68rem;
  color: var(--chalk-dim);
  letter-spacing: 0.18em;
}

/* ─── Coordinate (top-right) ─── */
#coord {
  position: fixed;
  top: 1.4rem;
  right: 1.4rem;
  z-index: 12;
  font-family: var(--serif);
  font-size: 0.65rem;
  font-style: italic;
  letter-spacing: 0.18em;
  color: var(--graphite);
  opacity: 0;
  transition: opacity 1.6s var(--ease-slow) 0.3s;
  pointer-events: none;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-feature-settings: 'tnum' 1;
}
#coord.visible { opacity: 0.55; }
#coord .coord-sep { color: var(--graphite-deep); }
#coord .coord-unit { font-size: 0.55rem; letter-spacing: 0.22em; opacity: 0.6; }
#coord-x, #coord-x-max { color: var(--chalk); }

/* ─── Hint ─── */
#hint {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  font-family: var(--serif);
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.12em;
  color: var(--chalk);
  opacity: 0;
  transition: opacity 1s var(--ease) 2.4s;
  pointer-events: none;
}
#hint.visible { opacity: 0.55; }
#hint.fade { opacity: 0; transition: opacity 0.4s ease; }
#hint em {
  font-style: normal;
  color: var(--vermillion);
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 0.6rem;
}

/* ─── Velocity colophon ─── */
#colophon {
  position: fixed;
  bottom: 1.5rem;
  right: 1.4rem;
  z-index: 12;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--serif);
  font-size: 0.6rem;
  font-style: italic;
  letter-spacing: 0.22em;
  color: var(--graphite);
  text-decoration: none;
  opacity: 0;
  transition: opacity 1.6s var(--ease-slow) 0.6s, color 0.4s ease;
  pointer-events: auto;
  cursor: none;
}
#colophon.visible { opacity: 0.55; }
#colophon:hover { color: var(--vermillion); opacity: 1; }
#colophon em {
  font-style: italic;
  color: var(--chalk);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  font-weight: 500;
}
#colophon .colo-mark { font-style: normal; font-size: 0.55rem; opacity: 0.7; }
#colophon .colo-sep { color: var(--vermillion); font-style: normal; }
#colophon .colo-year { font-feature-settings: 'lnum' 1; letter-spacing: 0.32em; font-size: 0.55rem; }

@media (max-width: 768px) {
  #colophon { bottom: 0.9rem; right: 0.6rem; font-size: 0.42rem; letter-spacing: 0.16em; gap: 0.3rem; }
  #colophon em { font-size: 0.46rem; }
  #colophon .colo-mark { font-size: 0.38rem; }
  #colophon .colo-year { font-size: 0.38rem; letter-spacing: 0.22em; }
}

/* ─── Compass cursor ─── */
#compas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
#compas.visible { opacity: 1; }
#compas svg {
  display: block;
  filter: drop-shadow(0 0 6px rgba(193, 59, 44, 0.18));
}
#comp-arms {
  transform-origin: 0 -22px;
  transition: transform 0.55s var(--ease-mech);
}
/* on hover state JS toggles */
#compas.open #comp-arm-l {
  transform: rotate(-12deg);
  transform-origin: 0 -22px;
  transition: transform 0.5s var(--ease-mech);
}
#compas.open #comp-arm-r {
  transform: rotate(12deg);
  transform-origin: 0 -22px;
  transition: transform 0.5s var(--ease-mech);
}
#comp-arm-l, #comp-arm-r {
  transition: transform 0.5s var(--ease-mech);
}
#comp-label {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--chalk);
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.3s ease;
  text-shadow: 0 0 8px rgba(14,24,40,0.95);
}
#compas.open #comp-label { opacity: 0.95; }

/* ─── Chamber rail (bottom) ─── */
#rail {
  position: fixed;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  opacity: 0;
  transition: opacity 1.6s var(--ease-slow) 0.5s;
}
#rail.visible { opacity: 1; }
.rail-tick {
  background: transparent;
  border: none;
  cursor: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--graphite);
  opacity: 0.45;
  padding: 0.4rem 0.2rem;
  transition: color 0.4s ease, opacity 0.4s ease, transform 0.4s var(--ease);
  position: relative;
}
.rail-tick:hover {
  color: var(--chalk);
  opacity: 0.95;
  transform: translateY(-2px);
}
.rail-tick.is-active {
  color: var(--vermillion);
  opacity: 1;
}
.rail-tick.is-active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--vermillion);
}
.rail-tick span { display: inline-block; }

/* ─── LOADER ─── */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  transition: opacity 1.4s var(--ease-slow), visibility 1.4s;
}
#loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#loader-svg {
  width: min(560px, 80vw);
  max-width: 560px;
  height: auto;
}
#ld-foundation, #ld-wall-l, #ld-wall-r, #ld-roof {
  animation: drawLine 1s var(--ease-slow) forwards;
}
#ld-foundation { animation-delay: 0.2s; }
#ld-wall-l { animation-delay: 0.9s; }
#ld-wall-r { animation-delay: 0.9s; }
#ld-roof { animation-delay: 1.5s; }

#ld-text-1, #ld-text-2 {
  opacity: 0;
  animation: fadeUp 1s var(--ease-slow) forwards;
}
#ld-text-1 { animation-delay: 1.9s; }
#ld-text-2 { animation-delay: 2.2s; }

#ld-stamp, #ld-stamp-text {
  animation: stampDrop 0.8s var(--ease-mech) 2.7s forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes stampDrop {
  0% { opacity: 0; transform: scale(2.2); transform-origin: center; }
  60% { opacity: 1; transform: scale(0.9); }
  100% { opacity: 0.9; transform: scale(1); }
}
#loader-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  color: var(--graphite);
  opacity: 0;
  animation: fadeUp 1s var(--ease) 3.2s forwards;
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
  body { cursor: auto; }
  #compas { display: none; }
  #floor-marker { left: 0.6rem; gap: 0.7rem; }
  #floor-marker span { font-size: 0.42rem; letter-spacing: 0.2em; }
  #floor-marker span::before { width: 8px; }
  #compass-marker { right: 0.6rem; }
  .compass-bar { height: 110px; }
  #compass-marker .cardinal { font-size: 0.45rem; letter-spacing: 0.3em; }
  #masthead { top: 1rem; left: 1rem; font-size: 0.55rem; letter-spacing: 0.2em; gap: 0.4rem; }
  .mast-tagline { font-size: 0.5rem; letter-spacing: 0.12em; }
  #coord { top: 1rem; right: 1rem; font-size: 0.5rem; }
  #coord .coord-unit { font-size: 0.42rem; }
  #rail { bottom: 0.9rem; gap: 0.7rem; }
  .rail-tick { font-size: 0.5rem; letter-spacing: 0.16em; padding: 0.3rem 0.15rem; }
  #hint { bottom: 3rem; font-size: 0.55rem; letter-spacing: 0.1em; }
  #hint em { font-size: 0.5rem; letter-spacing: 0.22em; }
  /* SVG scale: keep height fitting and let user pan */
  #elevation { height: 100%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* A Velocity atelier work — © MMXXVI */
