/* ============================================================================
   yairz — shared base styles
   Palette (CSS custom properties), monospace font stack, and reusable
   hacker/CRT utility classes. Every variant builds on top of this.
   ============================================================================ */

:root {
  /* --- core palette: near-black canvas, phosphor accents --- */
  --bg:          #05070a;   /* page background */
  --bg-1:        #0a0e14;   /* raised surface */
  --bg-2:        #10151d;   /* panel */
  --line:        #1c2530;   /* borders / rules */
  --fg:          #c7d0da;   /* default text */
  --fg-dim:      #6b7684;   /* muted text */
  --fg-faint:    #39424e;   /* very muted */

  /* accents */
  --green:       #7dff9b;   /* terminal / prompt */
  --green-deep:  #2fd66b;
  --cyan:        #35d6e6;
  --amber:       #ffb454;
  --magenta:     #ff5c8a;
  --red:         #ff5f56;
  --blue:        #5c9dff;
  --purple:      #b98cff;

  --accent:      var(--green);

  /* typography */
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", "SFMono-Regular",
          ui-monospace, "Cascadia Code", "Menlo", "Consolas", monospace;

  --glow: 0 0 6px rgba(125, 255, 155, 0.55), 0 0 14px rgba(125, 255, 155, 0.25);
}

/* ------------------------------- reset ----------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;               /* variants manage their own scroll */
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--cyan); text-decoration: none; }
::selection { background: rgba(125, 255, 155, 0.28); color: #fff; }

/* ------------------------- app mount container --------------------------- */
#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* full-screen variant root helper */
.v-root {
  position: absolute;
  inset: 0;
  overflow: hidden;
  animation: v-fade-in 320ms ease both;
}
@keyframes v-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* =========================================================================
   Reusable hacker/CRT utilities — variants opt in via class names.
   ========================================================================= */

/* Scanlines overlay: add class to a full-screen element, or use ::after */
.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  z-index: 40;
}

/* Subtle vignette + CRT curvature glow */
.crt::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 50%,
    rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 41;
}

/* Faint flicker for CRT elements */
.flicker { animation: crt-flicker 4.5s infinite steps(60); }
@keyframes crt-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.82; }
  98% { opacity: 0.96; }
  99% { opacity: 0.88; }
}

/* Phosphor text glow */
.glow { text-shadow: var(--glow); }
.glow-cyan  { text-shadow: 0 0 6px rgba(53, 214, 230, 0.6), 0 0 14px rgba(53, 214, 230, 0.25); }
.glow-amber { text-shadow: 0 0 6px rgba(255, 180, 84, 0.6), 0 0 14px rgba(255, 180, 84, 0.25); }

/* Glitch text: set data-text on element + class .glitch */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: inset(0 0 0 0);
}
.glitch::before { color: var(--cyan);    transform: translate(-2px, 0); animation: glitch-a 2.6s infinite steps(2); opacity: 0.75; }
.glitch::after  { color: var(--magenta); transform: translate(2px, 0);  animation: glitch-b 3.1s infinite steps(2); opacity: 0.75; }
@keyframes glitch-a {
  0%, 100% { clip-path: inset(0 0 85% 0); }
  20% { clip-path: inset(30% 0 40% 0); }
  40% { clip-path: inset(65% 0 10% 0); }
  60% { clip-path: inset(10% 0 70% 0); }
  80% { clip-path: inset(48% 0 30% 0); }
}
@keyframes glitch-b {
  0%, 100% { clip-path: inset(80% 0 5% 0); }
  25% { clip-path: inset(15% 0 55% 0); }
  50% { clip-path: inset(55% 0 20% 0); }
  75% { clip-path: inset(35% 0 45% 0); }
}

/* blinking block cursor */
.cursor-blink { animation: cursor-blink 1s steps(1) infinite; }
@keyframes cursor-blink { 50% { opacity: 0; } }

/* thin custom scrollbars for variants that scroll */
.scroll-thin { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   Variant switcher (rendered by main.js) — subtle, bottom-right.
   ========================================================================= */
.switcher {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  user-select: none;
}
.switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(6px);
  color: var(--fg-dim);
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.switcher__btn:hover { color: var(--green); border-color: var(--green-deep); }
.switcher__btn:active { transform: translateY(1px); }
.switcher__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: var(--glow); }
.switcher__name { letter-spacing: 0.06em; }

/* pop-up variant menu */
.switcher__menu {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 40px);
  z-index: 9001;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  display: none;
  flex-direction: column;
  gap: 2px;
}
.switcher__menu.open { display: flex; }
.switcher__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 5px;
  color: var(--fg-dim);
  font-size: 12px;
  transition: background 100ms ease, color 100ms ease;
}
.switcher__item:hover { background: rgba(125, 255, 155, 0.08); color: var(--fg); }
.switcher__item[aria-current="true"] { color: var(--green); }
.switcher__item[aria-current="true"] .switcher__key { border-color: var(--green-deep); color: var(--green); }
.switcher__key {
  min-width: 18px;
  text-align: center;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg-faint);
  font-size: 11px;
}

/* =========================================================================
   Reduced motion: variants also check the media query in JS, but kill the
   heaviest CSS animations here as a safety net.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .flicker, .glitch::before, .glitch::after, .cursor-blink { animation: none !important; }
  .v-root { animation: none; }
}

/* small screens: tighten switcher */
@media (max-width: 560px) {
  .switcher__name { display: none; }
}
