/* ===== SKY HEARTH — Weathered Blueprint System ===== */

:root {
  /* Paper */
  --paper: #ece1c7;
  --paper-deep: #e2d4b2;
  --paper-light: #f4ecd6;
  --paper-edge: #c9b890;

  /* Ink */
  --ink: #1a2e4a;
  --ink-soft: #2b466a;
  --ink-faded: rgba(26, 46, 74, 0.45);
  --ink-ghost: rgba(26, 46, 74, 0.18);
  --ink-trace: rgba(26, 46, 74, 0.08);

  /* Sepia / aged */
  --sepia: #6b4a2b;
  --sepia-soft: #8a6e4a;

  /* Stamps */
  --stamp-red: #a12b22;
  --stamp-amber: #b8632a;

  /* Elements */
  --el-air: #2a6f8a;
  --el-fire: #b8632a;
  --el-earth: #7a5230;
  --el-water: #355e7d;

  /* Active blend (Air + Fire) */
  --el-active-1: var(--el-air);
  --el-active-2: var(--el-fire);

  /* Grid */
  --grid-line: rgba(26, 46, 74, 0.07);
  --grid-major: rgba(26, 46, 74, 0.12);

  /* Status */
  --ok: #4d6e3f;
  --warn: #b8632a;
  --crit: #a12b22;
  --gold: #b08c3c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #1a1614;
  font-family: 'Special Elite', 'Courier New', monospace;
  color: var(--ink);
  overflow: hidden;
}

/* ===== Stage scaling ===== */
#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, #2a221a 0%, #0e0a08 100%);
}

#canvas {
  width: 1440px;
  height: 900px;
  position: relative;
  transform-origin: center center;
  overflow: hidden;
  background: var(--paper);
  /* Weathered parchment treatment — baked composite of:
     cream gradient · torn sheet on black @0.78 · vellum @0.30 mult · weathered @0.32 mult.
     Grid intentionally dropped (ship recipe: grid 0). */
  background-image: url("assets/textures/paper-composite.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow:
    inset 0 0 120px rgba(110, 80, 40, 0.25),
    inset 0 0 0 1px rgba(26, 46, 74, 0.4),
    0 0 80px rgba(0, 0, 0, 0.7);
}

/* paper noise / fiber overlay */
#canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.30  0 0 0 0 0.16  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.4'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.26;
  pointer-events: none;
  z-index: 1;
}

/* coffee-stain / age splotch in corners */
#canvas::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 280px 200px at 95% 95%, rgba(110, 70, 30, 0.18), transparent 70%),
    radial-gradient(ellipse 200px 160px at 5% 92%, rgba(110, 70, 30, 0.12), transparent 70%),
    radial-gradient(ellipse 180px 140px at 88% 4%, rgba(110, 70, 30, 0.10), transparent 70%);
  pointer-events: none;
  z-index: 2;
}

/* layer canvas content above noise */
.canvas-content {
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* ===== Typography ===== */
.fell { font-family: 'IM Fell English SC', 'IM Fell English', serif; font-weight: 400; letter-spacing: 0.02em; }
.elite { font-family: 'Special Elite', 'Courier New', monospace; }
.mono { font-family: 'JetBrains Mono', 'Courier New', monospace; font-weight: 400; }

h1, h2, h3, h4 { font-family: 'IM Fell English SC', serif; font-weight: 400; margin: 0; letter-spacing: 0.03em; }

/* ===== Re-usable: ink-stroke panel ===== */
.panel {
  position: relative;
  background: rgba(244, 236, 214, 0.55);
  border: 1.5px solid var(--ink);
  border-radius: 1px;
}
.panel-tight { border-width: 1px; }

/* ===== Re-usable: torn-parchment overlay card =====
   A floating panel that frays into the backdrop instead of a clean rectangle.
   The ::before paints opaque parchment masked to the torn-sheet silhouette
   (deckled edges read as soft transparency); content lives inside the padding,
   safely clear of the frayed margin. */
.frayed-card {
  position: relative;
  background-color: var(--paper);
  background-image: url("assets/textures/parchment-base.jpeg");
  background-size: cover;
  background-position: center;
  border: none;
  border-radius: 0;
  padding: 30px 34px;
  -webkit-mask-image: url("assets/textures/torn-mask.png");
          mask-image: url("assets/textures/torn-mask.png");
  -webkit-mask-size: 100% 100%;
          mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-mode: luminance;
          mask-mode: luminance;
  filter: drop-shadow(0 16px 38px rgba(12, 9, 6, 0.5));
}
/* age splotches in the corners, matching the canvas */
.frayed-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 240px 170px at 96% 94%, rgba(110, 70, 30, 0.13), transparent 70%),
    radial-gradient(ellipse 180px 150px at 4% 90%, rgba(110, 70, 30, 0.10), transparent 70%);
}
.frayed-card > * { position: relative; z-index: 1; }

/* hand-drafted corner brackets */
.brackets::before, .brackets::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--ink);
}
.brackets::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.brackets::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* ink stamp */
.stamp {
  display: inline-block;
  font-family: 'IM Fell English SC', serif;
  border: 2px solid var(--stamp-red);
  color: var(--stamp-red);
  padding: 4px 10px 3px;
  letter-spacing: 0.12em;
  font-size: 11px;
  transform: rotate(-3deg);
  opacity: 0.85;
  background: rgba(161, 43, 34, 0.04);
}
.stamp-amber { border-color: var(--stamp-amber); color: var(--stamp-amber); background: rgba(184, 99, 42, 0.05); }
.stamp-blue { border-color: var(--ink); color: var(--ink); background: rgba(26, 46, 74, 0.04); }

/* labels */
.label {
  font-family: 'Special Elite', monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sepia);
}
.label-ink { color: var(--ink); }
.label-faded { color: var(--ink-faded); }

/* dashed leader lines */
.leader {
  border-top: 1px dashed var(--ink-faded);
  flex: 1;
  margin: 0 8px;
  transform: translateY(-3px);
}

/* ===== Buttons ===== */
.btn {
  font-family: 'IM Fell English SC', serif;
  background: rgba(244, 236, 214, 0.6);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  padding: 10px 18px;
  cursor: pointer;
  letter-spacing: 0.08em;
  font-size: 15px;
  position: relative;
  transition: background 120ms ease, transform 120ms ease;
}
.btn:hover { background: rgba(26, 46, 74, 0.08); }
.btn:active { transform: translateY(1px); }
.btn-launch {
  background: var(--ink);
  color: var(--paper-light);
  padding: 14px 32px;
  font-size: 18px;
  letter-spacing: 0.18em;
}
.btn-launch:hover { background: var(--ink-soft); }

/* ===== Progress meter ===== */
.meter {
  position: relative;
  height: 18px;
  border: 1.5px solid var(--ink);
  background: rgba(255,255,255,0.15);
  display: flex;
  gap: 2px;
  padding: 2px;
}
.meter-segment {
  flex: 1;
  background: var(--ink-trace);
  transition: background 200ms ease;
}
.meter-segment.filled { background: var(--ink); }
.meter-segment.preview { background: repeating-linear-gradient(45deg, var(--ink), var(--ink) 3px, transparent 3px, transparent 6px); animation: preview-pulse 1s ease-in-out infinite; }

@keyframes preview-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

/* ===== Stability dial ===== */
.stability-dial {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Odometer-style number ===== */
.odometer {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  position: relative;
}
.odometer.flash { animation: ink-flash 400ms ease-out; }
@keyframes ink-flash {
  0% { color: var(--stamp-amber); transform: scale(1.08); }
  100% { color: inherit; transform: scale(1); }
}

/* ===== Page transitions ===== */
.fade-enter { opacity: 0; }
.fade-enter-active { opacity: 1; transition: opacity 400ms ease; }
.fade-exit { opacity: 1; }
.fade-exit-active { opacity: 0; transition: opacity 400ms ease; }

/* ===== Iris wipe ===== */
.iris {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0%, transparent var(--iris-r, 100%), #0e0a08 var(--iris-r, 100%));
  transition: --iris-r 700ms ease;
}

/* ===== Floaty text ===== */
.floaty {
  position: absolute;
  font-family: 'IM Fell English SC', serif;
  font-size: 28px;
  color: var(--ink);
  pointer-events: none;
  animation: floaty-rise 900ms ease-out forwards;
  z-index: 10;
  text-shadow: 0 0 12px rgba(244, 236, 214, 0.9);
}
@keyframes floaty-rise {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-50px); opacity: 0; }
}

/* ===== Screen shake ===== */
.shake { animation: shake 220ms ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0,0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(2px, -2px); }
  60% { transform: translate(-1px, 2px); }
  80% { transform: translate(2px, 1px); }
}

/* ===== Ascension fanfare ===== */
/* transform-only entrance (no opacity gate — keeps the card visible even if
   the animation is throttled, matching the project's modal convention) */
@keyframes ascend-rise {
  0%   { transform: translateY(24px) scale(0.94); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes ray-spin { 0% { transform: translate(-50%,-50%) rotate(0deg); } 100% { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes halo-pulse {
  0%, 100% { opacity: 0.7;  transform: translate(-50%,-50%) scale(1);    }
  50%      { opacity: 1;    transform: translate(-50%,-50%) scale(1.06); }
}
.ascend-portrait { animation: ascend-portrait-pulse 2.8s ease-in-out infinite; }
@keyframes ascend-portrait-pulse {
  0%, 100% { transform: translate(-50%,-50%) scale(1);    }
  50%      { transform: translate(-50%,-50%) scale(1.045); }
}
/* slow rising motes of light during fanfare */
@keyframes mote-drift {
  0%   { transform: translateY(14px); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: translateY(-70px); opacity: 0; }
}

/* ===== Death dissolve ===== */
@keyframes death-fade { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes mote-gather {
  0%, 100% { opacity: 0.65; transform: translate(-50%,-50%) scale(0.96); }
  50%      { opacity: 1;    transform: translate(-50%,-50%) scale(1.05); }
}

/* ===== Pulse used for low-time stability ===== */
.pulse-crit { animation: pulse-crit 900ms ease-in-out infinite; }
@keyframes pulse-crit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(161, 43, 34, 0); }
  50% { box-shadow: 0 0 24px 4px rgba(161, 43, 34, 0.35); }
}

/* ===== Scrollbars off ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-ghost); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Misc ===== */
.divider-h { border: none; border-top: 1px solid var(--ink-faded); margin: 8px 0; }
.divider-h-dashed { border: none; border-top: 1px dashed var(--ink-faded); margin: 8px 0; }
.divider-v { border: none; border-left: 1px solid var(--ink-faded); margin: 0 8px; align-self: stretch; }

.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }

/* ===== Telemetry ===== */
.telemetry {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
}
.tel-line {
  opacity: 1;
  transform: translateY(0);
}
.tel-line.fresh {
  animation: tel-slide 320ms ease-out both;
}
@keyframes tel-slide {
  0% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ===== Port mode body crossfade ===== */
@keyframes modeFadeIn {
  0%   { opacity: 0.5; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0);   }
}

/* Modal — just visible immediately, no entry animation (browser-dependent issues) */
.modal-backdrop { opacity: 1; }
.modal-card-down { opacity: 1; }
.modal-card-up { opacity: 1; }

@keyframes radar-sweep {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes marker-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184, 99, 42, 0.6); }
  50% { box-shadow: 0 0 0 10px rgba(184, 99, 42, 0); }
}
.tel-warn { color: var(--crit); }
.tel-gold { color: var(--gold); }
.tel-cyan { color: var(--el-air); }
.tel-faded { color: var(--ink-faded); }

/* ===== Node states ===== */
.node {
  position: absolute;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  border-radius: 50%;
  color: var(--ink);
  font-family: 'IM Fell English SC', serif;
  font-size: 22px;
  transition: all 300ms ease;
}
.node.unvisited { opacity: 0.4; border-style: dashed; }
.node.detected { animation: pulse-detect 1.6s ease-in-out infinite; }
@keyframes pulse-detect {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 111, 138, 0); }
  50% { box-shadow: 0 0 0 6px rgba(42, 111, 138, 0.15); }
}
.node.active { box-shadow: 0 0 0 6px rgba(184, 99, 42, 0.25); border-color: var(--stamp-amber); }
.node.success { background: rgba(77, 110, 63, 0.18); border-color: var(--ok); }
.node.fail { background: rgba(161, 43, 34, 0.12); border-color: var(--crit); }
.node.choice { background: rgba(184, 99, 42, 0.15); border-color: var(--stamp-amber); border-style: double; border-width: 4px; }
.node.terminal { background: var(--ink); color: var(--paper-light); width: 70px; height: 70px; }

/* hand-rotated stickers */
.tilt-l { transform: rotate(-1.5deg); }
.tilt-r { transform: rotate(1.2deg); }

/* ===== Crosshatch ===== */
.crosshatch {
  background-image:
    repeating-linear-gradient(45deg, var(--ink-faded) 0, var(--ink-faded) 1px, transparent 1px, transparent 5px),
    repeating-linear-gradient(-45deg, var(--ink-faded) 0, var(--ink-faded) 1px, transparent 1px, transparent 5px);
}

.strike-out {
  text-decoration: line-through;
  text-decoration-color: var(--crit);
  text-decoration-thickness: 2px;
}
