/* ==========================================================================
   demo.teduza.com — 3-Act Chromatic Spatial Architecture
   Emerald (Init) -> Solar Amber (Check) -> Crimson Shatter (Protection/Aftermath)
   ========================================================================== */

@property --border-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

:root {
  --bg-canvas: #040706;
  --text-primary: #f4f8ff;
  --text-secondary: #cbd6e8;
  --text-muted: #8295b2;
  --text-subtle: #48566e;

  /* Dynamic Phase Palette (Default: Emerald Init) */
  --phase-accent: #10b981;
  --phase-bright: #6ee7b7;
  --phase-ice: #ecfdf5;
  --phase-secondary: #06b6d4;
  --phase-glow: rgba(16, 185, 129, 0.22);
  --phase-glow-strong: rgba(52, 211, 153, 0.45);
  --phase-grid: rgba(52, 211, 153, 0.11);
  --phase-border: rgba(52, 211, 153, 0.28);
  --phase-surface-top: rgba(8, 24, 20, 0.82);
  --phase-surface-bot: rgba(4, 10, 9, 0.91);

  --font-display: "Unbounded", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-sine: cubic-bezier(0.37, 0, 0.63, 1);
}

/* Phase 1: Emerald */
body[data-phase="emerald"] {
  --bg-canvas: #030706;
  --phase-accent: #10b981;
  --phase-bright: #6ee7b7;
  --phase-ice: #ecfdf5;
  --phase-secondary: #14b8a6;
  --phase-glow: rgba(16, 185, 129, 0.2);
  --phase-glow-strong: rgba(52, 211, 153, 0.48);
  --phase-grid: rgba(52, 211, 153, 0.11);
  --phase-border: rgba(52, 211, 153, 0.3);
  --phase-surface-top: rgba(7, 23, 18, 0.82);
  --phase-surface-bot: rgba(3, 9, 8, 0.92);
}

/* Phase 2: Solar Amber (Environment Check & Noise) */
body[data-phase="amber"] {
  --bg-canvas: #090602;
  --phase-accent: #f59e0b;
  --phase-bright: #fcd34d;
  --phase-ice: #fffbeb;
  --phase-secondary: #fb923c;
  --phase-glow: rgba(245, 158, 11, 0.22);
  --phase-glow-strong: rgba(251, 191, 36, 0.5);
  --phase-grid: rgba(251, 191, 36, 0.12);
  --phase-border: rgba(251, 191, 36, 0.34);
  --phase-surface-top: rgba(26, 18, 5, 0.84);
  --phase-surface-bot: rgba(10, 7, 2, 0.92);
}

/* Phase 3: Deep Crimson (Refusal, Shattered Planet & Aftermath) */
body[data-phase="crimson"] {
  --bg-canvas: #090305;
  --phase-accent: #ef4444;
  --phase-bright: #fda4af;
  --phase-ice: #fff1f2;
  --phase-secondary: #e11d48;
  --phase-glow: rgba(239, 68, 68, 0.22);
  --phase-glow-strong: rgba(244, 63, 94, 0.52);
  --phase-grid: rgba(244, 63, 94, 0.11);
  --phase-border: rgba(244, 63, 94, 0.34);
  --phase-surface-top: rgba(26, 8, 12, 0.85);
  --phase-surface-bot: rgba(10, 4, 6, 0.93);
}

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

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: clip;
}

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 400;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 800ms var(--ease-out-expo);
}

.page-shell.is-impact {
  animation: chamber-shake 360ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes chamber-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  18% { transform: translate3d(-4px, 2px, 0); }
  36% { transform: translate3d(5px, -3px, 0); }
  54% { transform: translate3d(-3px, 2px, 0); }
  72% { transform: translate3d(2px, -1px, 0); }
}

/* ==========================================================================
   3D Spatial Field + Volumetric Nebula + Perspective Horizon Grid
   ========================================================================== */
.backdrop-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.spatial-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ambient-aurora {
  position: absolute;
  inset: -15%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 56% 42% at 50% 46%, var(--phase-glow) 0%, transparent 72%),
    radial-gradient(ellipse 36% 28% at 48% 54%, var(--phase-glow) 0%, transparent 66%);
  animation: aurora-breathe 9s var(--ease-in-out-sine) infinite alternate;
  transition: background 900ms var(--ease-out-expo);
}

@keyframes aurora-breathe {
  0% {
    opacity: 0.75;
    transform: scale(0.98) translate3d(0, 0, 0);
  }
  100% {
    opacity: 1;
    transform: scale(1.06) translate3d(0, -1.5%, 0);
  }
}

.horizon-grid {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -14%;
  height: 60%;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--phase-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--phase-grid) 1px, transparent 1px);
  background-size: 54px 54px;
  transform: perspective(680px) rotateX(68deg);
  transform-origin: center bottom;
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.3) 45%, transparent 92%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.3) 45%, transparent 92%);
  opacity: 0.65;
  transition: opacity 700ms ease;
}

.vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 48%, transparent 34%, rgba(2, 3, 5, 0.82) 100%);
}

/* Global Photonic Flash Pulse Layer */
.flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  background: radial-gradient(circle at 50% 48%, var(--phase-ice) 0%, var(--phase-glow-strong) 34%, transparent 72%);
  transition: opacity 560ms var(--ease-out-expo);
}

.flash-overlay.is-active {
  opacity: 0.65;
  transition-duration: 50ms;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1.5px solid var(--phase-bright);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Fixed Top Bar (Desktop & Mobile) & Page Shell
   ========================================================================== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  width: 100%;
  background-color: rgba(4, 7, 10, 0.72);
  background-color: color-mix(in srgb, var(--bg-canvas) 76%, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: background-color 800ms var(--ease-out-expo);
}

.top-bar-inner {
  width: 100%;
  max-width: 900px;
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4.5vw, 2.5rem);
  padding-block: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-shell {
  position: relative;
  z-index: 3;
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin-inline: auto;
  padding-top: 3.75rem;
  padding-inline: clamp(1.1rem, 4.5vw, 2.5rem);
  display: flex;
  flex-direction: column;
}

.site-domain {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 220ms var(--ease-out-expo), text-shadow 220ms var(--ease-out-expo);
}

.site-domain:hover {
  color: var(--phase-ice);
  text-shadow: 0 0 16px var(--phase-glow-strong);
}

.lang-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.lang-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding-inline: 0.45rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 220ms var(--ease-out-expo);
}

.lang-nav a::after {
  content: "";
  position: absolute;
  left: 0.45rem;
  right: 0.45rem;
  bottom: 0.45rem;
  height: 1.5px;
  background-color: var(--phase-bright);
  box-shadow: 0 0 10px var(--phase-glow-strong);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 240ms var(--ease-out-expo), background-color 600ms ease;
}

.lang-nav a:hover {
  color: var(--text-primary);
}

.lang-nav a:hover::after {
  transform: scaleX(0.65);
}

.lang-nav a[aria-current="page"] {
  color: var(--phase-bright);
  text-shadow: 0 0 12px var(--phase-glow);
}

.lang-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.lang-sep {
  color: var(--text-subtle);
  user-select: none;
}

/* ==========================================================================
   Central Optical Stage
   ========================================================================== */
.stage-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(2.25rem, 7vh, 4.75rem);
  perspective: 1400px;
}

.chamber {
  position: relative;
  width: 100%;
}

/* Stage Transitions */
.stage-panel {
  position: relative;
  width: 100%;
  opacity: 0;
  transform: translate3d(0, 22px, 0) scale(0.968);
  filter: blur(12px);
  transition:
    opacity 540ms var(--ease-out-expo),
    transform 660ms var(--ease-out-expo),
    filter 540ms var(--ease-out-expo);
}

.stage-panel.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  filter: blur(0);
}

.stage-panel.is-exiting {
  opacity: 0;
  transform: translate3d(0, -14px, 0) scale(1.028);
  filter: blur(14px);
}

/* Holographic Glass Artifact Surface */
.holo-plate {
  position: relative;
  background:
    radial-gradient(120% 100% at 50% 0%, var(--phase-glow) 0%, transparent 56%),
    linear-gradient(152deg, var(--phase-surface-top) 0%, var(--phase-surface-bot) 100%);
  border: 1px solid var(--phase-border);
  box-shadow:
    0 32px 84px -20px rgba(0, 0, 0, 0.94),
    0 0 56px -18px var(--phase-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 var(--phase-glow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  overflow: hidden;
  transition:
    background 750ms ease,
    border-color 700ms ease,
    box-shadow 750ms ease;
}

/* Subtle inner chamfer hairline bevel */
.holo-plate::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  pointer-events: none;
  z-index: 1;
}

/* Liquid Metallic Conic Rim Light */
.holo-plate::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  pointer-events: none;
  background: conic-gradient(
    from var(--border-angle),
    transparent 0deg,
    transparent 215deg,
    var(--phase-accent) 280deg,
    var(--phase-ice) 312deg,
    var(--phase-secondary) 338deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.78;
  animation: rim-orbit 7.5s linear infinite;
}

@keyframes rim-orbit {
  to {
    --border-angle: 360deg;
  }
}

.corner-tick {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 4;
  border-color: var(--phase-bright);
  border-style: solid;
  border-width: 0;
  opacity: 0.78;
  transition: border-color 600ms ease, transform 260ms var(--ease-out-expo), opacity 260ms ease;
}

.corner-tick.tl { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.corner-tick.tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.corner-tick.bl { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.corner-tick.br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }

/* ==========================================================================
   Step 1: Monospace Runtime Log + Laser Sweep
   ========================================================================== */
.log-plate {
  padding: clamp(1.85rem, 5vw, 3.25rem);
  min-height: clamp(15.5rem, 32vh, 19rem);
  display: flex;
  align-items: center;
}

.scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: -16px;
  height: 58px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--phase-glow) 60%,
    var(--phase-ice) 97%,
    transparent 100%
  );
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.scan-beam.is-sweeping {
  animation: beam-sweep 680ms var(--ease-out-expo) forwards;
}

@keyframes beam-sweep {
  0% {
    opacity: 0.98;
    transform: translate3d(0, 0, 0);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 320px, 0);
  }
}

.runtime-log {
  position: relative;
  z-index: 2;
  width: 100%;
  font-family: var(--font-mono);
  font-size: clamp(0.92rem, 2.2vw, 1.08rem);
  line-height: 2.14;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  animation: line-enter 300ms var(--ease-out-expo) both;
}

.log-line.is-strong {
  color: var(--phase-ice);
  font-weight: 500;
  text-shadow: 0 0 18px var(--phase-glow);
}

.log-line .char-flash {
  color: #ffffff;
  text-shadow:
    0 0 12px #ffffff,
    0 0 24px var(--phase-glow-strong);
}

.log-line .hl-signal {
  color: var(--phase-bright);
  text-shadow:
    0 0 12px var(--phase-glow-strong),
    0 0 28px var(--phase-glow);
}

@keyframes line-enter {
  from {
    opacity: 0;
    transform: translate3d(-10px, 5px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.cursor {
  display: inline-block;
  width: 0.58em;
  height: 1.14em;
  margin-left: 0.24em;
  vertical-align: -0.2em;
  background-color: var(--phase-bright);
  box-shadow:
    0 0 12px var(--phase-ice),
    0 0 28px var(--phase-glow-strong);
  transition: background-color 500ms ease, box-shadow 500ms ease;
  animation: cursor-blink 880ms step-end infinite;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ==========================================================================
   Step 2: Amber ASCII Interference Burst
   ========================================================================== */
.noise-plate {
  padding: clamp(2.4rem, 6vw, 3.8rem) clamp(1.5rem, 4.5vw, 2.75rem);
  min-height: clamp(15.5rem, 32vh, 19rem);
  display: flex;
  align-items: center;
}

.noise-scan-stripe {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(251, 191, 36, 0.065) 0px,
    rgba(251, 191, 36, 0.065) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.85;
}

.noise-stream {
  position: relative;
  z-index: 2;
  width: 100%;
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  letter-spacing: 0.17em;
  line-height: 1.9;
  color: var(--phase-ice);
  text-shadow:
    -3px 0 rgba(245, 158, 11, 0.85),
    3px 0 rgba(251, 146, 60, 0.78),
    0 0 24px rgba(251, 191, 36, 0.62);
  word-break: break-all;
  animation: signal-jitter 105ms linear infinite;
}

@keyframes signal-jitter {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2.5px, -1px, 0); }
  50% { transform: translate3d(-2.5px, 1px, 0); }
  75% { transform: translate3d(1px, -0.5px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* ==========================================================================
   Step 3: Monumental Crimson Internal Protection (Fracture Moment)
   ========================================================================== */
.protection-stage {
  padding: clamp(2.85rem, 6.5vw, 4.65rem) clamp(1.75rem, 5vw, 3.5rem);
}

.protection-halo {
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 1.85rem;
  display: grid;
  place-items: center;
  color: var(--phase-bright);
}

.halo-ring {
  position: absolute;
  inset: 0;
  width: 76px;
  height: 76px;
  color: rgba(248, 113, 113, 0.65);
  animation: orbit-spin 11s linear infinite;
}

.halo-ring-inner {
  position: absolute;
  inset: 10px;
  width: 56px;
  height: 56px;
  color: rgba(244, 63, 94, 0.62);
  animation: orbit-spin-rev 8s linear infinite;
}

@keyframes orbit-spin {
  to { transform: rotate(360deg); }
}

@keyframes orbit-spin-rev {
  to { transform: rotate(-360deg); }
}

.shield-emblem {
  width: 32px;
  height: 32px;
  color: var(--phase-ice);
  filter: drop-shadow(0 0 16px var(--phase-glow-strong));
}

.shield-emblem .shield-path {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
}

.stage-panel.is-visible .shield-emblem .shield-path {
  animation: draw-shield 760ms var(--ease-out-expo) 80ms forwards;
}

@keyframes draw-shield {
  to { stroke-dashoffset: 0; }
}

.phase-rule {
  width: 5.75rem;
  height: 1.5px;
  margin-bottom: 1.6rem;
  background: linear-gradient(90deg, var(--phase-ice) 0%, var(--phase-accent) 48%, transparent 100%);
  box-shadow: 0 0 16px var(--phase-glow-strong);
  transform: scaleX(0);
  transform-origin: left center;
}

.stage-panel.is-visible .phase-rule {
  animation: expand-rule 640ms var(--ease-out-expo) 120ms forwards;
}

@keyframes expand-rule {
  to { transform: scaleX(1); }
}

.protection-heading {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.3vw, 2.85rem);
  line-height: 1.15;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: linear-gradient(180deg, #ffffff 0%, var(--phase-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 28px var(--phase-glow));
  margin-bottom: 0.95rem;
  text-wrap: balance;
}

.protection-sub {
  font-family: var(--font-sans);
  font-size: clamp(1.04rem, 2.25vw, 1.2rem);
  color: var(--text-secondary);
  letter-spacing: 0.015em;
}

/* ==========================================================================
   Step 4: Crimson-Obsidian Sealed Artifact (3D Levitation + Tilt + Beam)
   ========================================================================== */
.envelope-card {
  position: relative;
  width: 100%;
  min-height: clamp(256px, 36vh, 320px);
  padding: clamp(1.85rem, 5vw, 3.2rem);
  background:
    radial-gradient(100% 120% at 50% 0%, var(--phase-glow) 0%, transparent 56%),
    linear-gradient(148deg, var(--phase-surface-top) 0%, var(--phase-surface-bot) 100%);
  border: 1px solid var(--phase-border);
  box-shadow:
    0 34px 86px -22px rgba(0, 0, 0, 0.96),
    0 0 64px -16px var(--phase-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  gap: 2.5rem;
  overflow: hidden;
  transform: perspective(1200px) translate3d(0, var(--float-y, 0px), 0) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  transition:
    border-color 220ms var(--ease-out-expo),
    box-shadow 260ms var(--ease-out-expo),
    transform 220ms var(--ease-out-expo);
  animation: artifact-hover 5.2s var(--ease-in-out-sine) infinite alternate;
}

@keyframes artifact-hover {
  0% { --float-y: 0px; }
  100% { --float-y: -5px; }
}

.envelope-card:hover {
  animation-play-state: paused;
  border-color: var(--phase-bright);
  box-shadow:
    0 42px 96px -20px rgba(0, 0, 0, 0.98),
    0 0 84px -12px var(--phase-glow-strong),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Cursor-tracking radial spotlight */
.envelope-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    540px circle at var(--mx, 50%) var(--my, 50%),
    var(--phase-glow-strong),
    var(--phase-glow) 36%,
    transparent 68%
  );
  transition: opacity 280ms var(--ease-out-expo);
}

.envelope-card::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  pointer-events: none;
  background: conic-gradient(
    from var(--border-angle),
    transparent 0deg,
    transparent 200deg,
    var(--phase-accent) 275deg,
    var(--phase-ice) 310deg,
    var(--phase-secondary) 340deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.9;
  animation: rim-orbit 5.5s linear infinite;
}

.envelope-card:hover::before,
.envelope-card:focus-visible::before {
  opacity: 1;
}

.envelope-card:hover .corner-tick {
  border-color: #ffffff;
  opacity: 1;
}

.envelope-card:active {
  transform: perspective(1200px) scale(0.985);
}

.envelope-card.is-unsealing {
  transform: perspective(1200px) scale(0.978);
  border-color: var(--phase-ice);
  box-shadow:
    0 0 96px var(--phase-glow-strong),
    inset 0 0 42px var(--phase-glow);
}

.unseal-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: -18px;
  height: 62px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--phase-glow-strong) 55%,
    var(--phase-ice) 96%,
    transparent 100%
  );
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.envelope-card.is-unsealing .unseal-beam {
  animation: beam-sweep 440ms var(--ease-out-expo) forwards;
}

.envelope-top {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.envelope-seal {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--phase-bright);
  text-shadow: 0 0 16px var(--phase-glow-strong);
}

.seal-iris {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--phase-bright);
}

.seal-iris-ring {
  position: absolute;
  inset: 0;
  width: 44px;
  height: 44px;
  color: var(--phase-accent);
  opacity: 0.7;
  animation: orbit-spin 12s linear infinite;
  transition: color 240ms var(--ease-out-expo), opacity 240ms ease;
}

.seal-iris-inner {
  position: absolute;
  inset: 6px;
  width: 32px;
  height: 32px;
  color: var(--phase-secondary);
  opacity: 0.65;
  animation: orbit-spin-rev 8s linear infinite;
}

.envelope-lock-icon {
  width: 16px;
  height: 16px;
  color: var(--phase-ice);
  transition: transform 320ms var(--ease-out-expo), color 240ms var(--ease-out-expo);
}

.envelope-card:hover .seal-iris-ring {
  color: #ffffff;
  opacity: 1;
  animation-duration: 3.5s;
}

.envelope-card:hover .envelope-lock-icon {
  transform: scale(1.14);
  color: #ffffff;
}

.envelope-title {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.8vw, 2.25rem);
  line-height: 1.22;
  font-weight: 500;
  color: #ffffff;
  background: linear-gradient(180deg, #ffffff 0%, var(--phase-ice) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px var(--phase-glow));
  text-wrap: balance;
}

.envelope-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--phase-ice);
  letter-spacing: 0.08em;
}

.envelope-action-arrow {
  transition: transform 240ms var(--ease-out-expo), text-shadow 240ms var(--ease-out-expo);
}

.envelope-card:hover .envelope-action-arrow {
  transform: translateX(10px);
  text-shadow: 0 0 16px #ffffff;
}

/* ==========================================================================
   Step 5: Revealed Local Log Document
   ========================================================================== */
.letter-doc {
  width: 100%;
  padding: clamp(1.8rem, 5.2vw, 3.35rem);
}

.doc-shimmer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    112deg,
    transparent 0%,
    transparent 36%,
    rgba(255, 241, 242, 0.12) 50%,
    transparent 64%,
    transparent 100%
  );
  transform: translate3d(-100%, 0, 0);
}

.stage-panel.is-visible .doc-shimmer {
  animation: surface-shimmer 1.25s var(--ease-out-expo) 60ms forwards;
}

@keyframes surface-shimmer {
  to {
    transform: translate3d(100%, 0, 0);
  }
}

.log-meta {
  position: relative;
  z-index: 2;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 0.75rem;
}

.log-meta dl {
  display: grid;
  gap: 0.55rem;
}

.log-meta-title {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--phase-bright);
  text-shadow: 0 0 14px var(--phase-glow);
}

.log-meta-row {
  display: grid;
  grid-template-columns: minmax(6rem, 8.25rem) minmax(0, 1fr);
  gap: 0.45rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.log-meta-row dt {
  color: var(--text-muted);
}

.log-meta-row dd {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.letter-body {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 1.25rem;
  max-width: 62ch;
  font-family: var(--font-sans);
  font-size: clamp(1.0625rem, 2.2vw, 1.24rem);
  line-height: 1.75;
  color: var(--text-primary);
}

.stage-panel.is-visible .letter-body p {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  filter: blur(5px);
  animation: doc-reveal 640ms var(--ease-out-expo) forwards;
}

.stage-panel.is-visible .letter-body p:nth-child(1) { animation-delay: 120ms; }
.stage-panel.is-visible .letter-body p:nth-child(2) { animation-delay: 260ms; }
.stage-panel.is-visible .letter-body p:nth-child(3) { animation-delay: 400ms; }
.stage-panel.is-visible .letter-body p:nth-child(4) { animation-delay: 540ms; }

@keyframes doc-reveal {
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }
}

.letter-sign {
  position: relative;
  z-index: 2;
  margin-top: 2.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.stage-panel.is-visible .letter-sign {
  opacity: 0;
  animation: doc-reveal 640ms var(--ease-out-expo) 680ms forwards;
}

/* ==========================================================================
   Quiet Footer
   ========================================================================== */
.site-footer {
  padding-block: 1.1rem 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.35rem;
}

.footer-links a {
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 180ms var(--ease-out-expo);
}

.footer-links a:hover {
  color: var(--phase-bright);
}

/* Noscript Fallback */
.noscript-fallback {
  display: grid;
  gap: 1.5rem;
}

@media (max-width: 560px) {
  .log-meta-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .page-shell.is-impact,
  .ambient-aurora,
  .cursor,
  .noise-stream,
  .halo-ring,
  .halo-ring-inner,
  .seal-iris-ring,
  .seal-iris-inner,
  .envelope-card,
  .holo-plate::after,
  .envelope-card::after,
  .scan-beam.is-sweeping,
  .envelope-card.is-unsealing .unseal-beam,
  .shield-emblem .shield-path,
  .phase-rule,
  .log-line,
  .stage-panel.is-visible .doc-shimmer,
  .stage-panel.is-visible .letter-body p,
  .stage-panel.is-visible .letter-sign {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    stroke-dashoffset: 0 !important;
  }

  .stage-panel,
  .top-bar,
  .envelope-card,
  .envelope-action-arrow,
  .envelope-lock-icon,
  .lang-nav a,
  .lang-nav a::after,
  .footer-links a {
    transition-duration: 0.01ms !important;
  }
}
