:root {
  --bg: #020202;
  --fg: #f2f2f2;
  --dim: #6a6a6a;
  --mega-face: rgba(255, 255, 255, 0.04);
  --mega-shade: rgba(0, 0, 0, 0.42);
  --mega-rim: rgba(255, 255, 255, 0.1);
}

/* Hover / route “light” UI: page stays near-black; only buttons become a high-contrast matrix window. */
html[data-theme="light"] {
  --mega-face: rgba(255, 255, 255, 0.02);
  --mega-shade: rgba(0, 0, 0, 0.2);
  --mega-rim: rgba(255, 255, 255, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
  overflow: hidden;
}

body.glitching {
  animation: body-glitch 0.55s ease-in-out 1;
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  animation: canvas-drift 18s ease-in-out infinite alternate;
  opacity: 0.92;
  transition: opacity 0.38s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes canvas-drift {
  0% {
    filter: contrast(1.03) saturate(0);
    transform: translate(0, 0) skewX(0deg);
  }
  50% {
    filter: contrast(1.06) saturate(0);
    transform: translate(0.3px, -0.3px) skewX(0.06deg);
  }
  100% {
    filter: contrast(1.04) saturate(0);
    transform: translate(-0.3px, 0.3px) skewX(-0.05deg);
  }
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 3;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.022) 0px,
    rgba(255, 255, 255, 0.022) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: soft-light;
  opacity: 0.32;
  animation: scan-drift 10s linear infinite;
}

@keyframes scan-drift {
  0% {
    transform: translateY(0);
    opacity: 0.28;
  }
  50% {
    transform: translateY(2px);
    opacity: 0.38;
  }
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
}

.code-rise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: stretch;
  opacity: 0;
  transition: opacity 0.45s ease;
  mix-blend-mode: overlay;
  overflow: hidden;
}

.code-rise.on {
  opacity: 0.26;
}

.code-rise__col {
  flex: 0 0 11px;
  width: 11px;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.code-rise__track {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  animation: code-rise-scroll linear infinite;
  will-change: transform;
}

.code-rise__half {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  min-height: 100vh;
  font-size: 10px;
  line-height: 11px;
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
}

.code-rise__half span {
  display: block;
  width: 100%;
  text-align: center;
  color: rgba(220, 220, 220, 0.26);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.08);
}

.code-rise-solo {
  pointer-events: none;
  position: fixed;
  left: 50%;
  bottom: 0;
  top: 0;
  width: 22px;
  margin-left: -11px;
  z-index: 4;
  overflow: hidden;
  mix-blend-mode: soft-light;
  opacity: 0.11;
}

.code-rise-solo__col {
  position: absolute;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

.code-rise-solo__track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  display: flex;
  flex-direction: column;
  animation: code-rise-scroll linear infinite;
  will-change: transform;
}

.code-rise-solo__half {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  flex: 0 0 auto;
  min-height: 100vh;
  font-size: 10px;
  line-height: 11px;
  font-family: Consolas, "Courier New", monospace;
}

.code-rise-solo__half span {
  display: block;
  width: 100%;
  text-align: center;
  color: rgba(200, 200, 200, 0.22);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.06);
}

@keyframes code-rise-scroll {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

#app {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: clamp(12px, 3vw, 28px);
  width: 100%;
  max-width: 100%;
}

.screen.hidden {
  display: none;
}

.screen.vanish {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.screen--branch {
  z-index: 5;
  background: transparent;
}

.branch-inner {
  flex: 1;
  width: 100%;
  max-width: min(720px, 96vw);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(12px, 2vh, 24px) 0;
  opacity: 0;
  transform: translateY(18px);
  filter: blur(5px);
  transition:
    opacity 0.85s cubic-bezier(0.25, 0.85, 0.35, 1),
    transform 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.75s cubic-bezier(0.33, 0, 0.2, 1);
}

.screen--branch:not(.hidden) .branch-inner {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.branch-back {
  align-self: center;
  margin-bottom: clamp(12px, 2vh, 24px);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px 0;
}

.branch-back:hover,
.branch-back:focus-visible {
  color: var(--fg);
}

.branch-back:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 6px;
}

.revolving--branch {
  max-width: 100%;
}

.hub-nav--branch {
  gap: clamp(14px, 2.8vw, 28px);
}

.mega--branch {
  --rx: #e8e8e8;
}

.mega--branch:hover {
  border-color: var(--rx);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 8px rgba(0, 0, 0, 0.5),
    0 18px 40px rgba(0, 0, 0, 0.52),
    0 0 32px rgba(255, 255, 255, 0.07);
}

.mega--branch:hover .mega-label,
.mega--branch:focus-visible .mega-label {
  color: var(--rx);
  text-shadow:
    0 0 12px var(--rx),
    0 0 38px var(--rx),
    0 0 72px rgba(255, 255, 255, 0.12);
}

.mega--b1 {
  transform-origin: 100% 50%;
  animation: door-left 11s ease-in-out infinite alternate;
}

.mega--b2 {
  transform-origin: 50% 50%;
  animation: door-mid 12s ease-in-out infinite alternate;
}

.mega--b3 {
  transform-origin: 0% 50%;
  animation: door-right 11s ease-in-out infinite alternate;
}

@keyframes door-mid {
  0% {
    transform: rotateY(0deg) translateZ(14px);
  }
  100% {
    transform: rotateY(5deg) translateZ(26px);
  }
}

.screen--ender {
  background: #000;
  align-items: center;
  justify-content: center;
}

.ender-minimal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  max-width: 96vw;
  gap: clamp(2rem, 6vh, 4rem);
  text-align: center;
}

.ender-cipher {
  margin: 0;
  font-size: clamp(9px, 1.4vw, 11px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.22);
  max-width: 90vw;
}

.enter-minimal {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.35em 0.1em;
  color: #fff;
  font: 800 clamp(2.5rem, 10vw, 5.5rem) "IBM Plex Mono", Consolas, monospace;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  line-height: 1;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.4);
  transition:
    color 0.34s cubic-bezier(0.25, 0.1, 0.25, 1),
    opacity 0.28s ease;
}

.enter-text {
  display: inline-block;
  transform: rotate(-90deg);
  transform-origin: center center;
  transition:
    color 0.34s cubic-bezier(0.25, 0.1, 0.25, 1),
    transform 0.48s cubic-bezier(0.34, 1.1, 0.64, 1),
    text-shadow 0.34s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.enter-minimal:hover .enter-text,
.enter-minimal:focus-visible .enter-text {
  color: #ffffff;
  transform: rotate(0deg);
  text-shadow:
    0 0 14px rgba(255, 255, 255, 0.85),
    0 0 40px rgba(255, 255, 255, 0.35);
}

.enter-minimal:active .enter-text {
  transform: rotate(0deg) scale(0.98);
}

.enter-minimal:hover {
  opacity: 1;
}

.enter-minimal:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.5);
  outline-offset: 12px;
}

.revolving {
  flex: 0 1 auto;
  width: 100%;
  max-width: min(580px, 94vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1400px;
  perspective-origin: 50% 45%;
}

.screen--hub .revolving {
  margin-top: auto;
  margin-bottom: auto;
}

.hub-nav {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: clamp(18px, 4vw, 42px);
  padding: clamp(8px, 1.5vh, 20px) 0;
  transform-style: preserve-3d;
}

.mega {
  flex: 0 1 auto;
  width: min(204px, 30vw);
  max-width: 100%;
  min-height: min(82vh, 960px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  text-decoration: none;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid var(--mega-rim);
  background: linear-gradient(155deg, var(--mega-face), var(--mega-shade));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 6px rgba(0, 0, 0, 0.45),
    0 14px 32px rgba(0, 0, 0, 0.5),
    0 2px 0 rgba(255, 255, 255, 0.04);
  transform-style: preserve-3d;
  transition:
    transform 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.36s cubic-bezier(0.25, 0.1, 0.25, 1),
    border-color 0.36s cubic-bezier(0.25, 0.1, 0.25, 1),
    background 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
    backdrop-filter 0.55s cubic-bezier(0.25, 0.1, 0.25, 1),
    -webkit-backdrop-filter 0.55s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.mega--projects {
  transform-origin: 100% 50%;
  animation: door-left 11s ease-in-out infinite alternate;
}

.mega--store {
  transform-origin: 0% 50%;
  animation: door-right 11s ease-in-out infinite alternate;
}

@keyframes door-left {
  0% {
    transform: rotateY(10deg) rotateX(1deg) translateZ(8px);
  }
  100% {
    transform: rotateY(4deg) rotateX(0deg) translateZ(28px);
  }
}

@keyframes door-right {
  0% {
    transform: rotateY(-10deg) rotateX(1deg) translateZ(8px);
  }
  100% {
    transform: rotateY(-4deg) rotateX(0deg) translateZ(28px);
  }
}

.mega--projects:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -3px 8px rgba(0, 0, 0, 0.55),
    0 20px 44px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.45),
    0 0 28px rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
}

.mega--store:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -3px 8px rgba(0, 0, 0, 0.55),
    0 20px 44px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.45),
    0 0 28px rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
}

.mega:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 8px;
}

html[data-theme="light"] .mega {
  /* ~3× more matrix read-through; clip so inside reads as one “window”. */
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.03);
  border: 2px solid rgba(248, 248, 248, 0.88);
  /* Inverted backdrop: keep contrast but let the canvas show through more. */
  -webkit-backdrop-filter: invert(1) saturate(0) brightness(1.08) contrast(1.92);
  backdrop-filter: invert(1) saturate(0) brightness(1.08) contrast(1.92);
  /* Outer ring matches page black so you see a hard switch from outside → inside. */
  box-shadow:
    0 0 0 4px var(--bg),
    0 0 0 5px rgba(255, 255, 255, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 14px rgba(0, 0, 0, 0.22),
    0 18px 48px rgba(0, 0, 0, 0.65),
    0 0 36px rgba(255, 255, 255, 0.18);
}

html[data-theme="light"] .mega--projects:hover,
html[data-theme="light"] .mega--store:hover,
html[data-theme="light"] .mega--branch:hover {
  border-color: rgba(255, 255, 255, 1);
  background: rgba(0, 0, 0, 0.045);
  -webkit-backdrop-filter: invert(1) saturate(0) brightness(1.06) contrast(2.08);
  backdrop-filter: invert(1) saturate(0) brightness(1.06) contrast(2.08);
  box-shadow:
    0 0 0 4px var(--bg),
    0 0 0 6px rgba(255, 255, 255, 0.75),
    inset 0 0 0 1px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -2px 14px rgba(0, 0, 0, 0.18),
    0 22px 56px rgba(0, 0, 0, 0.72),
    0 0 48px rgba(255, 255, 255, 0.28);
}

.mega-label {
  pointer-events: none;
  display: inline-block;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  font-weight: 800;
  font-size: clamp(1.06rem, 2.9vw, 1.65rem);
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 1),
    0 0 28px rgba(255, 255, 255, 0.82),
    0 0 64px rgba(255, 255, 255, 0.35),
    0 0 120px rgba(255, 255, 255, 0.15);
  mix-blend-mode: screen;
  opacity: 0.98;
  text-align: center;
  transform: rotate(-90deg);
  transform-origin: center center;
  transition:
    color 0.36s cubic-bezier(0.25, 0.1, 0.25, 1),
    text-shadow 0.36s cubic-bezier(0.25, 0.1, 0.25, 1),
    mix-blend-mode 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
    transform 0.48s cubic-bezier(0.34, 1.1, 0.64, 1);
}

.mega:hover .mega-label,
.mega:focus-visible .mega-label {
  transform: rotate(0deg);
}

.mega--projects:hover .mega-label,
.mega--projects:focus-visible .mega-label {
  color: #ffffff;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.95),
    0 0 32px rgba(255, 255, 255, 0.65),
    0 0 72px rgba(255, 255, 255, 0.35);
}

.mega--store:hover .mega-label,
.mega--store:focus-visible .mega-label {
  color: #ffffff;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.95),
    0 0 36px rgba(255, 255, 255, 0.6),
    0 0 80px rgba(255, 255, 255, 0.3);
}

/* Labels sit above the inverted matrix: black ink on the light window (matches matrix glyphs). */
html[data-theme="light"] .mega .mega-label {
  position: relative;
  z-index: 1;
  color: #000000;
  mix-blend-mode: normal;
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.95),
    0 0 10px rgba(255, 255, 255, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.45);
}

html[data-theme="light"] .mega:hover .mega-label,
html[data-theme="light"] .mega:focus-visible .mega-label {
  color: #000000;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 1),
    0 0 14px rgba(255, 255, 255, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.5);
}

.panels {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  pointer-events: none;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(1px);
  transition: background 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.panels:not(.hidden) {
  pointer-events: auto;
}

.panels.hidden {
  display: none;
}

.panel {
  width: min(640px, 100%);
  margin: 0 auto;
  text-align: center;
  border: 1px solid var(--mega-rim);
  padding: clamp(20px, 4vw, 40px);
  background: rgba(5, 5, 5, 0.78);
  backdrop-filter: blur(6px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(0, 0, 0, 0.25);
  transition:
    background 0.42s cubic-bezier(0.25, 0.1, 0.25, 1),
    color 0.42s cubic-bezier(0.25, 0.1, 0.25, 1),
    border-color 0.42s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.panel.hidden {
  display: none;
}

.panel-back {
  font: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  padding: 0;
}

.panel-back:hover,
.panel-back:focus-visible {
  color: var(--fg);
}

.panel-back:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

.panel-lead {
  margin: 0;
  font-size: clamp(13px, 2vw, 15px);
  line-height: 1.7;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes body-glitch {
  0% {
    filter: none;
    transform: translate(0, 0);
  }
  40% {
    filter: contrast(1.05) saturate(0);
    transform: translate(0.5px, -0.5px);
  }
  100% {
    filter: none;
    transform: translate(0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.glitching {
    animation: none;
  }

  .mega-label,
  .enter-text {
    transform: none;
    transition-duration: 0.01ms;
  }

  .code-rise__track {
    animation: none !important;
    transform: translateY(-25%);
  }

  .code-rise.on {
    opacity: 0.18;
  }

  .code-rise-solo__track {
    animation: none !important;
    transform: translateY(-35%);
  }

  #fx {
    animation: none;
  }

  .scanlines {
    animation: none;
  }

  .mega--projects,
  .mega--store {
    animation: none;
    transform: rotateY(6deg) translateZ(12px);
  }

  .mega--store {
    transform: rotateY(-6deg) translateZ(12px);
  }

  .mega--b1,
  .mega--b2,
  .mega--b3 {
    animation: none;
    transform: rotateY(0deg) translateZ(12px);
  }
}

@media (max-width: 640px) {
  .hub-nav {
    flex-direction: column;
  }

  .hub-nav--branch {
    flex-direction: column;
  }

  .revolving {
    max-width: min(380px, 95vw);
  }

  .revolving--branch {
    max-width: min(400px, 95vw);
  }

  .mega {
    width: 100%;
    max-width: 272px;
    min-height: 44vh;
  }

  .mega--projects,
  .mega--store {
    transform-origin: 50% 100%;
    animation: none;
  }

  .mega--b1,
  .mega--b2,
  .mega--b3 {
    transform-origin: 50% 100%;
    animation: none;
  }

  .mega-label {
    letter-spacing: 0.18em;
    font-size: clamp(1rem, 3.2vw, 1.45rem);
  }
}
