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

:root {
  --scroll-ratio: 0;
  --scroll-vel: 0;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

/* Modern Web Guidance: improve-text-layout-and-legibility */
h1, h2, h3, h4 {
  text-wrap: balance;
}

p, li, dd, blockquote {
  text-wrap: pretty;
}

/* Prevent scroll bleed when dialog/modal is open */
body:has(dialog[open]),
body:has(.cmd-modal-backdrop:not([hidden])) {
  overflow: hidden;
}

/* Modern Web Guidance (motion): handle prefers-reduced-motion per component instead of global 0.01ms duration */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .marquee-track,
  .ticker-track {
    animation-duration: 68s;
  }
  .intro-logo-frame {
    animation: none;
  }
  .reveal:not(.in) {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.marquee-band,
.monolith-ticker {
  transform: skewX(calc(var(--marquee-skew, 0deg) + var(--scroll-skew, 0deg)));
  transition: transform 0.18s ease-out;
}

body.is-motion-paused .marquee-track,
body.is-motion-paused .ticker-track,
body.is-motion-paused .intro-logo-frame {
  animation-play-state: paused !important;
}

body {
  margin: 0;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

img, video, svg, canvas {
  max-width: 100%;
  display: block;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 10px 16px;
  border-radius: 4px;
  background: #ffffff;
  color: #050505;
  font-weight: 800;
  text-decoration: none;
  transition: top .2s ease;
}

.skip-link:focus {
  top: 14px;
}

/* Native CSS Scroll-Driven Top Progress Bar */
.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 9990;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--accent-primary, #ffffff), var(--accent-secondary, #888888));
  transform: scaleX(var(--scroll-ratio, 0));
}

@supports (animation-timeline: scroll()) {
  .scroll-progress-bar {
    transform: scaleX(0);
    animation: scrollProgressGrow linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes scrollProgressGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ============================================================================
 * FUTURISTIC INTRO PORTAL OVERLAY
 * ============================================================================ */
.futuristic-intro {
  position: fixed;
  inset: 0;
  z-index: 9950;
  background: #040405;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(20px, 4vw, 44px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.futuristic-intro.is-dismissed {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.intro-top-bar,
.intro-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
}

.intro-center {
  margin: auto;
  text-align: center;
  max-width: 540px;
  width: 100%;
  display: grid;
  gap: 18px;
  justify-items: center;
}

.intro-logo-frame {
  width: 96px;
  height: 96px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  padding: 14px;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 70%);
  animation: introPulse 2.4s ease-in-out infinite;
}

@keyframes introPulse {
  0%, 100% { border-color: rgba(255,255,255,0.24); transform: scale(1); }
  50% { border-color: rgba(255,255,255,0.75); transform: scale(1.04); }
}

.intro-title {
  margin: 0;
  font-size: clamp(1.5rem, 3.6vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.intro-sub {
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.64);
  text-transform: uppercase;
}

.intro-progress-track {
  width: min(360px, 85vw);
  height: 2px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
  position: relative;
}

.intro-progress-fill {
  height: 100%;
  width: 12%;
  background: #ffffff;
  transition: width 0.08s linear;
}

.intro-enter-btn {
  padding: 11px 24px;
  background: #ffffff;
  color: #050505;
  border: 1px solid #ffffff;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.intro-enter-btn:hover {
  background: transparent;
  color: #ffffff;
  transform: translateY(-1px);
}

/* ============================================================================
 * CUSTOM LIGHTWEIGHT FUTURISTIC CURSOR RETICLE
 * ============================================================================ */
.futuristic-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9980;
  pointer-events: none;
  mix-blend-mode: difference;
  will-change: transform;
}

.futuristic-cursor .cursor-ring {
  position: absolute;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  margin-top: -14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  transition: width 0.2s ease, height 0.2s ease, margin 0.2s ease, border-radius 0.2s ease, border-color 0.2s ease;
}

.futuristic-cursor .cursor-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  margin-top: -2px;
  background: #ffffff;
  border-radius: 50%;
}

.futuristic-cursor.is-hover .cursor-ring {
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 4px;
  border-color: #ffffff;
}

/* ============================================================================
 * STAGGERED REVEAL & 3D TILT SURFACES
 * ============================================================================ */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s cubic-bezier(0.16, 1, 0.3, 1), transform .55s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.in {
  opacity: 1;
  transform: translateY(0);
}

[data-tilt] {
  position: relative;
  transition: transform .24s cubic-bezier(0.16, 1, 0.3, 1), border-color .24s ease, box-shadow .24s ease;
  will-change: transform;
}

[data-tilt]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.11), transparent 65%);
  opacity: 0;
  transition: opacity .25s ease;
}

[data-tilt]:hover::after {
  opacity: 1;
}

.btn-magnetic {
  transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .2s ease, background .2s ease;
}

/* ============================================================================
 * TOAST NOTIFICATION & COMMAND PALETTE (⌘K)
 * ============================================================================ */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  max-width: 380px;
  padding: 13px 16px;
  border-radius: 4px;
  background: #080809;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .65);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast[data-kind="error"] {
  border-color: #ffffff;
  background: #18090b;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.cmd-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9995;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: start center;
  padding: 10vh 16px 24px;
}

.cmd-modal-box {
  width: min(600px, 100%);
  border-radius: 6px;
  background: #08080a;
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow: 0 32px 80px rgba(0, 0, 0, .85);
  overflow: hidden;
  color: #ffffff;
}

.cmd-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.cmd-kbd-badge {
  padding: 4px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .1);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  color: #ffffff;
  white-space: nowrap;
}

#cmd-search-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: .95rem;
  outline: none;
}

.cmd-close-btn {
  padding: 4px 9px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: .72rem;
}

.cmd-results-list {
  max-height: 340px;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.cmd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: #ffffff;
  text-align: left;
  transition: background .14s ease;
}

.cmd-item:hover,
.cmd-item:focus-visible {
  background: rgba(255, 255, 255, .12);
  outline: none;
}

.cmd-item-title {
  font-weight: 700;
  font-size: .9rem;
}

.cmd-item-hint {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .74rem;
  color: rgba(255, 255, 255, .64);
}

.cmd-empty {
  padding: 20px;
  text-align: center;
  color: rgba(255, 255, 255, .55);
  font-size: .88rem;
}

/* ============================================================================
 * QUANTUM PARTICLE FORCE-FIELD & XY CHAOS PAD (SHARED)
 * ============================================================================ */
.particle-field-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.particle-console-strip {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.16));
  background: var(--surface-glass, rgba(10, 10, 14, 0.84));
  backdrop-filter: blur(14px);
  display: grid;
  gap: 10px;
}

.particle-console-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.particle-mode-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.particle-mode-btn {
  padding: 6px 10px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.18));
  background: transparent;
  color: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.particle-mode-btn.active,
.particle-mode-btn:hover {
  background: var(--btn-bg, #ffffff);
  color: var(--btn-fg, #050505);
  border-color: var(--btn-bg, #ffffff);
}

.particle-burst-btn {
  padding: 6px 11px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.42));
  background: rgba(128, 128, 128, 0.12);
  color: inherit;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.particle-burst-btn:hover {
  background: var(--btn-bg, #ffffff);
  color: var(--btn-fg, #050505);
}

/* Interactive 2D XY Chaos Pad */
.chaos-pad-box {
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.14));
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  align-items: center;
  background: rgba(128, 128, 128, 0.04);
}

.chaos-pad-surface {
  position: relative;
  width: 112px;
  height: 76px;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.38));
  background:
    linear-gradient(to right, rgba(128, 128, 128, 0.18) 1px, transparent 1px) 0 0 / 28px 19px,
    linear-gradient(to bottom, rgba(128, 128, 128, 0.18) 1px, transparent 1px) 0 0 / 28px 19px,
    radial-gradient(circle at var(--chaos-x, 58%) var(--chaos-y, 42%), rgba(128, 128, 128, 0.32), transparent 65%);
  cursor: crosshair;
  touch-action: none;
  overflow: hidden;
}

.chaos-pad-surface::before,
.chaos-pad-surface::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background: rgba(128, 128, 128, 0.36);
}

.chaos-pad-surface::before {
  top: 0;
  bottom: 0;
  width: 1px;
  left: var(--chaos-x, 58%);
}

.chaos-pad-surface::after {
  left: 0;
  right: 0;
  height: 1px;
  top: var(--chaos-y, 42%);
}

.chaos-puck {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  left: 58%;
  top: 42%;
  border: 2px solid var(--text, #ffffff);
  background: var(--bg, #050505);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

.chaos-pad-meta {
  display: grid;
  gap: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.chaos-pad-meta strong {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chaos-pad-meta span {
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  opacity: 0.78;
}

/* Top-Layer Lightbox Dialog (Modern Web Guidance: animate-to-from-top-layer + motion) */
dialog.media-lightbox {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #050506;
  color: #ffffff;
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.88);
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.24s cubic-bezier(0.16, 1, 0.3, 1),
    display 0.24s,
    overlay 0.24s;
  transition-behavior: allow-discrete;
}

dialog.media-lightbox::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition-property: background-color, backdrop-filter, display, overlay;
  transition-duration: 0.24s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}

:is(dialog.media-lightbox[open]):where(:not([data-closing])) {
  opacity: 1;
  transform: scale(1);

  @starting-style {
    opacity: 0;
    transform: scale(0.96);
  }

  &::backdrop {
    background-color: rgba(0, 0, 0, 0.84);
    backdrop-filter: blur(12px);

    @starting-style {
      background-color: rgba(0, 0, 0, 0);
      backdrop-filter: blur(0px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.media-lightbox {
    transform: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    :is(dialog.media-lightbox[open]):where(:not([data-closing])) {
      transform: none;
    }
  }
}


