@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

html, body {
  margin: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

#scene-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

#scene-scale {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  transform-origin: center center;
  transform: translate(var(--scene-x), var(--scene-y)) scale(var(--scene-scale));
}

/* =========================================================
   VHS / CRT LOADER
   ========================================================= */
#loader {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  font-family: 'Array', sans-serif;
  color: #fff;
  overflow: hidden;
}

.intro-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  color: #fff;
  pointer-events: none;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

.utc-time {
  position: absolute;
  top: 2rem;
  left: 2rem;
  font-size: 0.75rem;
  color: #cfcfcf;
  animation: none;
}

.quote {
  position: static;
  max-width: 720px;
  width: 90%;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.8;
  animation: none;
  margin: 0;
}
.quote .author {
  display: block;
  margin-top: 1rem;
  font-size: 0.7rem;
  color: #9a9a9a;
}

.loader-bar {
  position: static;
  transform: none;
  width: min(420px, 72vw);
  height: 4px;
  background: rgba(255,255,255,0.15);
  overflow: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: #fff;
  animation: loadProgress 5s forwards;
}
.loader-bar.is-hidden {
  opacity: 0;
  transform: none;
}

.close-btn {
  position: static;
  transform: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: none;
  border: none;
  color: #fff;
  display: none;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  animation: none;
  --flip-depth: 18px;
}
.close-btn.is-visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

#loader .close-btn,
#loader .close-btn.icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
}

#loader .close-btn .face {
  font-family: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

@keyframes loadProgress {
  to { width: 100%; }
}

@keyframes opacity {
  0% { opacity: .6; }
  20% { opacity: .3; }
  35% { opacity: .5; }
  50% { opacity: .8; }
  60% { opacity: .4; }
  80% { opacity: .7; }
  100% { opacity: .6; }
}

/* ===== FOREGROUND ROW ===== */
.fg-strip {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 14vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}

.fg-track {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  height: 100%;
  width: max-content;
  will-change: transform;
  animation: scrollLeft 70s linear infinite;
  animation-play-state: paused;
}

.fg-unit {
  position: relative;
  height: 100%;
  flex-shrink: 0;
}

.fg-unit + .fg-unit {
  margin-left: -60px;
}

.fg-unit img.lightA {
  height: 100%;
  display: block;
}

.fg-unit img.lightB {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  opacity: 0;
}

@keyframes scrollLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ===== MIDGROUND ROW ===== */
.mg-strip {
  position: absolute;
  bottom: 2vh;
  left: 0;
  width: 100%;
  height: 18vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}

.mg-track {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  height: 100%;
  width: max-content;
  will-change: transform;
  animation: scrollLeft 110s linear infinite;
  filter: brightness(0.8);
  animation-play-state: paused;
}

.mg-unit {
  position: relative;
  height: 100%;
  flex-shrink: 0;
}

.mg-unit + .mg-unit {
  margin-left: -40px;
}

.mg-unit img.lightA {
  height: 100%;
  display: block;
}

.mg-unit img.lightB {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  opacity: 0;
}

/* ===== STAR FIELD ===== */
#stars {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 1; /* stars above deep space */
  pointer-events: none;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  opacity: 0.6;
  animation: blink 3s infinite ease-in-out, drift linear infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

@keyframes drift {
  from { transform: translateY(0); }
  to   { transform: translateY(40px); }
}

/* =========================================================
   DEEP SPACE COMETS (BEHIND STARS)
   ========================================================= */

#comet-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0; /* behind stars */
}

/* Wrapper gets positioned + moved (JS will animate it) */
.comet-wrap {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform, opacity;
}

/* The comet visual itself (rotated to match direction) */
.comet {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;

  /* “hot nucleus” look */
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255,255,255,0.95) 0%,
    rgba(255,255,255,0.45) 20%,
    currentColor 55%,
    rgba(0,0,0,0) 75%
  );

  /* bloom */
  filter: blur(0.2px);
  box-shadow:
    0 0 10px currentColor,
    0 0 26px currentColor,
    0 0 60px currentColor;

  /* direction control (JS will set --angle) */
  transform: rotate(var(--angle, -45deg));
  transform-origin: center;
  will-change: transform;
}

/* Tail plume (soft) */
.comet::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 340px;
  height: 14px;
  transform: translate(-100%, -50%);
  background: radial-gradient(
    closest-side,
    rgba(255,255,255,0.18),
    rgba(255,255,255,0.06) 55%,
    rgba(0,0,0,0) 100%
  );
  filter: blur(6px);
  opacity: 0.75;
}

/* Tail core (brighter streak) */
.comet::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 5px;
  transform: translate(-100%, -50%);
  background: linear-gradient(
    to right,
    rgba(0,0,0,0) 0%,
    rgba(255,255,255,0.15) 35%,
    currentColor 100%
  );
  filter: blur(1.2px);
  opacity: 0.9;
}

/* =========================================================
   IMPACT GLOW (HALF-CIRCLE AT BOTTOM HIT POINT)
   ========================================================= */

.impact {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: 320px;
  height: 160px;
  transform: translate(-50%, 45%) scale(0.2);
  transform-origin: 50% 100%;
  pointer-events: none;
  opacity: 0;

  /* half-dome light */
  background: radial-gradient(
    circle at 50% 100%,
    rgba(255,255,255,0.38) 0%,
    currentColor 22%,
    rgba(0,0,0,0) 70%
  );

  filter: blur(6px);
  mix-blend-mode: screen; /* modern compositing look */
  will-change: transform, opacity;
}

/* ===== BACKGROUND ROW ===== */
.bg-strip {
  position: absolute;
  bottom: 10vh;
  left: 0;
  width: 100%;
  height: 20vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 4; /* ✅ above fog */
}

.bg-track {
  position: absolute;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  height: 100%;
  width: max-content;
  will-change: transform;
  animation: scrollLeft 260s linear infinite;
  filter: brightness(0.7);
  animation-play-state: paused;
}

.bg-unit {
  position: relative;
  height: 100%;
  flex-shrink: 0;
}

.bg-unit + .bg-unit {
  margin-left: -20px;
}

.bg-unit img.lightA {
  height: 100%;
  display: block;
}

.bg-unit img.lightB {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  opacity: 0;
}

/* ===== GROUND FOG ===== */
#ground-fog {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 30vh;
  pointer-events: none;
  z-index: 3; /* fog above ground */
  overflow: hidden;

  mask-image: linear-gradient(
    to top,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 65%,
    rgba(0,0,0,0) 100%
  );
  -webkit-mask-image: linear-gradient(
    to top,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 65%,
    rgba(0,0,0,0) 100%
  );
}

#ground-fog::before,
#ground-fog::after {
  content: '';
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 20% 60%, rgba(180,180,180,0.25), transparent 60%),
    radial-gradient(circle at 70% 50%, rgba(160,160,160,0.22), transparent 65%),
    radial-gradient(circle at 45% 70%, rgba(200,200,200,0.18), transparent 70%);
  filter: blur(60px);
  animation: fogDrift 140s linear infinite;
}

#ground-fog::after {
  animation-duration: 220s;
  opacity: 0.6;
}

@keyframes fogDrift {
  from { transform: translateX(-10%) translateY(0); }
  to   { transform: translateX(10%) translateY(-5%); }
}

/* ===== SKY LIGHTS - FRONT ===== */
#sky-lights-front {
  position: absolute;
  inset: -40vh 0;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

/* ===== SKY LIGHTS - BACK ===== */
#sky-lights-back {
  position: absolute;
  inset: -40vh 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

/* ===== SKY LIGHT BASE ===== */
.sky-light {
  position: absolute;
  top: -10vh;
  bottom: -10vh;
  width: 6px;
  height: 100%;
  transform-origin: bottom center;
  pointer-events: none;
  isolation: isolate;
}

/* GREEN - gentle upward sweep */
@keyframes beamSwayGreen {
  0%   { transform: rotate(6deg); }
  50%  { transform: rotate(14deg); }
  100% { transform: rotate(6deg); }
}

/* PURPLE - reversed + more downward */
@keyframes beamSwayPurple {
  0%   { transform: rotate(-22deg); }
  50%  { transform: rotate(-16deg); }
  100% { transform: rotate(-22deg); }
}

/* ORANGE - massive sweeping motion */
@keyframes beamSwayOrange {
  0%   { transform: rotate(45deg); }
  50%  { transform: rotate(-5deg); }
  100% { transform: rotate(45deg); }
}

/* SKY BLUE - slow drift toward left */
@keyframes beamSwaySkyBlue {
  0%   { transform: rotate(10deg); }
  50%  { transform: rotate(-6deg); }
  100% { transform: rotate(10deg); }
}

@keyframes beamPulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

/* GREEN (RIGHT) - lateral wave, left + right */
@keyframes beamSwayGreenSide {
  0%   { transform: rotate(-26deg); }
  50%  { transform: rotate(8deg); }
  100% { transform: rotate(-26deg); }
}

/* LIGHT PURPLE - lateral wave (side to side) */
@keyframes beamWaveLavender {
  0%   { transform: rotate(-20deg) translateX(0); }
  50%  { transform: rotate(8deg) translateX(-40px); }
  100% { transform: rotate(-20deg) translateX(0); }
}

/* GREEN beam */
.sky-light.green {
  left: 5vw;
  animation:
    beamSwayGreen 11s ease-in-out infinite,
    beamPulse 4.5s ease-in-out infinite;
  background: linear-gradient(
    to top,
    rgba(20, 241, 149, 1.0) 0%,
    rgba(20, 241, 149, 0.7) 20%,
    rgba(20, 241, 149, 0.35) 45%,
    rgba(20, 241, 149, 0.15) 70%,
    rgba(20, 241, 149, 0.06) 100%
  );
  filter: blur(1px) drop-shadow(0 0 12px rgba(20, 241, 149, 0.35));
}

/* GREEN beam - right side, waving left + right */
.sky-light.green.green-right {
  left: 92vw;
  animation:
    beamSwayGreenSide 13s ease-in-out infinite,
    beamPulse 4.8s ease-in-out infinite;
}

/* PURPLE beam */
.sky-light.purple {
  left: 70vw;
  animation:
    beamSwayPurple 14s ease-in-out infinite,
    beamPulse 3.8s ease-in-out infinite;
  background: linear-gradient(
    to top,
    rgba(153, 69, 255, 1.0) 0%,
    rgba(153, 69, 255, 0.7) 20%,
    rgba(153, 69, 255, 0.35) 45%,
    rgba(153, 69, 255, 0.15) 70%,
    rgba(153, 69, 255, 0.06) 100%
  );
  filter: blur(1px) drop-shadow(0 0 12px rgba(153, 69, 255, 0.35));
}

/* ORANGE beam */
.sky-light.orange {
  left: 58vw;
  animation:
    beamSwayOrange 18s ease-in-out infinite,
    beamPulse 4.2s ease-in-out infinite;
  background: linear-gradient(
    to top,
    rgba(255, 165, 70, 1.0) 0%,
    rgba(255, 165, 70, 0.7) 22%,
    rgba(255, 165, 70, 0.35) 48%,
    rgba(255, 165, 70, 0.15) 72%,
    rgba(255, 165, 70, 0.06) 100%
  );
  filter: blur(1px) drop-shadow(0 0 12px rgba(255, 165, 70, 0.35));
}

/* SKY BLUE beam (back layer, near green, drifting left) */
.sky-light.skyblue {
  left: 19vw;
  animation:
    beamSwaySkyBlue 16s ease-in-out infinite,
    beamPulse 5.2s ease-in-out infinite;
  background: linear-gradient(
    to top,
    rgba(120, 200, 255, 0.95) 0%,
    rgba(120, 200, 255, 0.65) 22%,
    rgba(120, 200, 255, 0.35) 48%,
    rgba(120, 200, 255, 0.14) 72%,
    rgba(120, 200, 255, 0.05) 100%
  );
  filter: blur(1.2px) drop-shadow(0 0 10px rgba(120, 200, 255, 0.28));
}

/* LIGHT PURPLE beam - mid depth, side-to-side wave */
.sky-light.lavender {
  left: 50vw;
  height: 95%;
  animation:
    beamWaveLavender 14s ease-in-out infinite,
    beamPulse 5.6s ease-in-out infinite;
  background: linear-gradient(
    to top,
    rgba(200, 160, 255, 0.9) 0%,
    rgba(200, 160, 255, 0.6) 22%,
    rgba(200, 160, 255, 0.32) 48%,
    rgba(200, 160, 255, 0.14) 72%,
    rgba(200, 160, 255, 0.05) 100%
  );
  filter:
    blur(1.4px)
    drop-shadow(0 0 10px rgba(200, 160, 255, 0.28));
}

/* =========================================================
   ORBITAL RELAY - LEFT (FAR BACKGROUND)
   ========================================================= */

#orbital-left img {
  width: 80%;
  height: 80%;
  display: block;
  will-change: transform;
  filter:
    brightness(0.35)
    contrast(0.95)
    saturate(0.85);
}

/* =========================================================
   ORBITAL RELAY - RIGHT (FAR BACKGROUND)
   ========================================================= */

#orbital-right img {
  width: 80%;
  height: 80%;
  display: block;
  will-change: transform;
  filter:
    brightness(0.32)
    contrast(0.95)
    saturate(0.85);
}

/* =========================================================
   LEFT GLASS UI PANEL
   ========================================================= */

:root {
  --ui-glass-dark: rgba(6, 8, 12, 0.72);
  --ui-panel-stroke: rgba(140, 210, 255, 0.22);
  --ui-panel-glow: rgba(110, 180, 255, 0.26);
  --ui-text: #e6f1ff;
  --ui-muted: rgba(230, 241, 255, 0.55);
  --vh: 1vh;
  --impact-width-factor: 0.9;
  --impact-height-ratio: 0.5;
  --impact-blur: 18;
  --impact-peak-opacity: 0.95;
  --impact-scale-start: 0.08;
  --impact-scale-peak: 1.05;
  --impact-scale-end: 1.35;
}

.ui-panel {
  position: fixed;
  left: var(--ui-left);
  top: var(--ui-top);
  width: var(--ui-width);
  height: auto;
  padding: var(--ui-pad);
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap);
  color: var(--ui-text);
  font-family: "Satoshi", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  background:
    radial-gradient(circle at 20% 15%, rgba(130, 200, 255, 0.08), transparent 45%),
    linear-gradient(140deg, rgba(18, 24, 34, 0.72), rgba(6, 8, 12, 0.62));
  border-radius: 0;
  border: 1px solid var(--ui-panel-stroke);
  z-index: 12;
  pointer-events: auto;
  overflow: hidden;
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  box-shadow:
    0 0 22px var(--ui-panel-glow),
    0 12px 30px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 40px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}

.ui-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 2px,
      transparent 4px
    ),
    repeating-radial-gradient(
      circle at 20% 20%,
      rgba(255, 255, 255, 0.03) 0 1px,
      rgba(0, 0, 0, 0.04) 1px 2px
    );
  opacity: 0.18;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
}

.ui-panel::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 0;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(120, 200, 255, 0) 70deg,
    rgba(140, 220, 255, 0.55) 110deg,
    rgba(120, 200, 255, 0) 150deg,
    transparent 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.6;
  animation: borderSweep 8s linear infinite;
  pointer-events: none;
  z-index: 1;
}

.ui-panel > * {
  position: relative;
  z-index: 2;
}

.ui-panel__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-strip {
  display: flex;
  align-items: center;
}

.title-boxes {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.title-box {
  width: clamp(18px, 2.2vw, 26px);
  height: clamp(22px, 2.6vw, 30px);
  background: #0a0d12;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0;
  color: #f1f5ff;
  font-size: clamp(10px, 1.1vw, 13px);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.12em;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.title-box.is-empty::after {
  content: ".";
  opacity: 0.18;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(9px, 1vw, 11px);
  letter-spacing: 0.2em;
  color: var(--ui-muted);
  white-space: nowrap;
}

.sound-label {
  opacity: 0.7;
}

.sound-option {
  background: none;
  border: none;
  color: var(--ui-muted);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}

.sound-option.is-active {
  color: var(--ui-text);
  text-shadow: 0 0 8px rgba(120, 200, 255, 0.35);
}

.sound-option:focus-visible {
  outline: 1px solid rgba(120, 200, 255, 0.6);
  outline-offset: 2px;
}

.ui-terminal {
  flex: 0 0 auto;
  height: auto;
  padding: var(--ui-terminal-pad);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.2)),
    var(--ui-glass-dark);
  border: 1px solid rgba(130, 190, 255, 0.12);
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  line-height: var(--ui-terminal-line);
  font-size: var(--ui-terminal-font);
  letter-spacing: 0.12em;
  text-shadow: 0 0 6px rgba(120, 200, 255, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(90, 170, 255, 0.12);
}

.ui-terminal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 2px,
      transparent 5px
    );
  opacity: 0.35;
  pointer-events: none;
}

.ui-terminal::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: rgba(200, 230, 255, 0.18);
  opacity: 0.6;
  pointer-events: none;
}

.ui-terminal p {
  margin: 0;
}

.ui-copy {
  margin: 0;
  white-space: nowrap;
}

.ui-copy--mobile {
  display: none;
}

@container (max-width: 420px) {
  .ui-copy--desktop {
    display: none;
  }

  .ui-copy--mobile {
    display: block;
  }
}

@keyframes borderSweep {
  to { transform: rotate(1turn); }
}

/* ===== BUTTON GRID (fits panel bottom) ===== */
.ui-btn-grid{
  display: flex;
  gap: var(--ui-btn-gap);
  align-items: center;
}

.ui-btn-grid .wide{
  flex: 1 1 var(--ui-btn-projects-max);
  min-width: var(--ui-btn-projects-min);
  width: auto;
}
.ui-btn-grid .icon{
  flex: 0 0 var(--ui-btn-icon);
}
.ui-btn-grid .caps{
  flex: 0 2 var(--ui-btn-caps-max);
  min-width: var(--ui-btn-caps-min);
  width: auto;
}

/* ===== BASE FLIP BUTTON ===== */
.flip-btn{
  position: relative;
  height: var(--ui-btn-h);
  --flip-depth: 26px;
  text-decoration: none;
  display: block;
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(0deg);
  transition: transform 0.85s cubic-bezier(.2,.8,.2,1);
  will-change: transform;
  border-radius: 0;
}

.flip-btn.wide{ width: 100%; min-width: 0; }
.flip-btn.icon{ min-width: var(--ui-btn-icon); width: var(--ui-btn-icon); }

.flip-btn:hover{
  transform: perspective(900px) rotateX(360deg);
}

.flip-btn:active{
  transform: perspective(900px) rotateX(360deg) translateY(1px);
}

/* Faces */
.flip-btn .face{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: "Satoshi", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 0;
  box-sizing: border-box;
  border: 1px solid rgba(140, 210, 255, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.05),
    0 0 14px rgba(90,170,255,0.16),
    0 10px 24px rgba(0,0,0,0.4);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.28)),
    rgba(9,12,16,0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255,255,255,0.90);
  overflow: hidden;
}

/* 3D face positions */
.flip-btn .f1{ transform: rotateX(360deg) translateZ(var(--flip-depth)); }
.flip-btn .f2{ transform: rotateX(270deg) translateZ(var(--flip-depth)); }
.flip-btn .f3{ transform: rotateX(180deg) translateZ(var(--flip-depth)); }
.flip-btn .f4{ transform: rotateX(90deg)  translateZ(var(--flip-depth)); }

/* Corner target marks */
.btn-terminal{
  --corner-size: 12px;
  --corner-thickness: 2px;
  --corner-color: rgba(140, 210, 255, 0.4);
}

.btn-terminal .face::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(var(--corner-color) 0 0) left top/var(--corner-size) var(--corner-thickness),
    linear-gradient(var(--corner-color) 0 0) left top/var(--corner-thickness) var(--corner-size),
    linear-gradient(var(--corner-color) 0 0) right top/var(--corner-size) var(--corner-thickness),
    linear-gradient(var(--corner-color) 0 0) right top/var(--corner-thickness) var(--corner-size),
    linear-gradient(var(--corner-color) 0 0) left bottom/var(--corner-size) var(--corner-thickness),
    linear-gradient(var(--corner-color) 0 0) left bottom/var(--corner-thickness) var(--corner-size),
    linear-gradient(var(--corner-color) 0 0) right bottom/var(--corner-size) var(--corner-thickness),
    linear-gradient(var(--corner-color) 0 0) right bottom/var(--corner-thickness) var(--corner-size);
  background-repeat: no-repeat;
  opacity: 0.7;
  filter: drop-shadow(0 0 6px rgba(120,200,255,0.18));
}

/* ===== MICRO GLITCH BURST ===== */
.flip-btn::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: 0;
  pointer-events:none;
  opacity:0;
  background:
    linear-gradient(90deg, rgba(0,255,255,0.25), rgba(255,0,255,0.18), rgba(0,255,120,0.18));
  mix-blend-mode: screen;
}

.flip-btn:hover::after{
  animation: glitchFlash 0.16s steps(2,end) 1;
}

.flip-btn:active::after{
  animation: glitchFlashActive 0.1s steps(2,end) 1;
}

.flip-btn.glitch-out::after{
  animation: glitchFlashOut 0.18s steps(2,end) 1;
}

@keyframes glitchFlash{
  0%   { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
  25%  { opacity:1; transform: translateX(-2px); clip-path: inset(10% 0 62% 0); }
  55%  { opacity:1; transform: translateX(2px);  clip-path: inset(58% 0 18% 0); }
  100% { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
}

@keyframes glitchFlashActive{
  0%   { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
  30%  { opacity:1; transform: translateX(2px); clip-path: inset(12% 0 58% 0); }
  70%  { opacity:1; transform: translateX(-2px); clip-path: inset(56% 0 18% 0); }
  100% { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
}

@keyframes glitchFlashOut{
  0%   { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
  30%  { opacity:1; transform: translateX(2px); clip-path: inset(14% 0 56% 0); }
  65%  { opacity:1; transform: translateX(-2px); clip-path: inset(52% 0 20% 0); }
  100% { opacity:0; transform: translateX(0); clip-path: inset(0 0 0 0); }
}
/* Hover state (shared) */
.btn-terminal:hover .face,
.btn-terminal:active .face{
  background:
    radial-gradient(circle at 30% 20%, rgba(180,255,255,0.16), transparent 40%),
    linear-gradient(90deg, rgba(160,80,255,0.28), rgba(0,255,160,0.22)),
    rgba(9,12,16,0.7);
  border-color: rgba(160, 230, 255, 0.4);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    0 0 20px rgba(120,200,255,0.22),
    0 10px 24px rgba(0,0,0,0.4);
}

.btn-terminal:hover,
.btn-terminal:active{
  --corner-color: rgba(170, 235, 255, 0.9);
}

.btn-label{
  display: inline-flex;
  gap: 2px;
}

.btn-label .ch{
  display: inline-block;
  --dx: 0px;
  --dy: 0px;
  --rot: 0deg;
  --drift-delay: 0ms;
}

.btn-terminal.wide:hover .ch{
  animation: letterDrift 2.2s ease-in-out infinite alternate;
  animation-delay: var(--drift-delay);
}

.btn-terminal.wide .ch:nth-child(1){ --dx: 2px; --dy: -1px; --rot: 0.6deg; --drift-delay: 0ms; }
.btn-terminal.wide .ch:nth-child(2){ --dx: -2px; --dy: 1px; --rot: -0.6deg; --drift-delay: 40ms; }
.btn-terminal.wide .ch:nth-child(3){ --dx: 1px; --dy: -2px; --rot: 0.4deg; --drift-delay: 80ms; }
.btn-terminal.wide .ch:nth-child(4){ --dx: -1px; --dy: 2px; --rot: -0.5deg; --drift-delay: 120ms; }
.btn-terminal.wide .ch:nth-child(5){ --dx: 3px; --dy: 0px; --rot: 0.8deg; --drift-delay: 160ms; }
.btn-terminal.wide .ch:nth-child(6){ --dx: -3px; --dy: 0px; --rot: -0.8deg; --drift-delay: 200ms; }
.btn-terminal.wide .ch:nth-child(7){ --dx: 1px; --dy: 2px; --rot: 0.5deg; --drift-delay: 240ms; }
.btn-terminal.wide .ch:nth-child(8){ --dx: -1px; --dy: -2px; --rot: -0.5deg; --drift-delay: 280ms; }

.btn-terminal.icon:hover .btn-ic{
  animation: iconDrift 2.4s ease-in-out infinite;
}

.btn-terminal.caps:hover .caps-logo{
  animation: logoDrift 2.4s ease-in-out infinite;
}

@keyframes letterDrift{
  from { transform: translate(0, 0) rotate(0deg); }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

@keyframes iconDrift{
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(2px, -1px) rotate(0.6deg); }
  100% { transform: translate(-2px, 1px) rotate(-0.6deg); }
}

@keyframes logoDrift{
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(calc(-50% + 2px), calc(-50% - 1px)) rotate(0.6deg) scale(1); }
  100% { transform: translate(calc(-50% - 2px), calc(-50% + 1px)) rotate(-0.6deg) scale(1); }
}

/* Icons */
.btn-ic{
  width: 22px;
  height: 22px;
  fill: rgba(255,255,255,0.90);
  filter: drop-shadow(0 0 6px rgba(120,190,255,0.15));
}

/* ===== CAPS BUTTON: text -> logo swap on hover ===== */
.flip-btn.caps .caps-logo{
  position:absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.12s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .ui-panel::after,
  .flip-btn{ transition:none; }
  .flip-btn:hover{ transform:none; }
  .flip-btn:hover::after,
  .flip-btn:active::after,
  .flip-btn.glitch-out::after{ animation:none; }
  .btn-terminal.wide:hover .ch,
  .btn-terminal.icon:hover .btn-ic{
    animation: none;
    transform: none;
  }
  .btn-terminal.caps:hover .caps-logo{
    animation: none;
    transform: translate(-50%, -50%) scale(1);
  }
}

