/*
  Hacker/terminal aesthetic (green on black) with a subtle 90s/00s vibe.
  Mobile-first, responsive, accessible.

  NOTE: This file contains legacy styles from an earlier layout.
  The current HTML uses `.wrap`, `.topbar__inner`, `.link` etc.
*/

:root {
  --bg: #050805;
  --panel: rgba(0, 0, 0, 0.55);
  --text: #b7ffb7;
  --muted: #7dff7d;
  --green: #39ff14;
  --green-2: #00ff66;
  --danger: #ff3b3b;

  --border: rgba(57, 255, 20, 0.35);
  --border-strong: rgba(57, 255, 20, 0.65);
  --shadow: 0 0 0.75rem rgba(57, 255, 20, 0.18);

  --radius: 14px;
  --radius-sm: 10px;

  /* FX tuning */
  --px: 10px; /* pixel size for the blocky overlay */

  --max: 860px;
  --pad: 18px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --display: "VT323", var(--mono);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--mono);
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, rgba(57, 255, 20, 0.10), transparent 55%),
              radial-gradient(900px 700px at 80% 30%, rgba(0, 255, 102, 0.08), transparent 60%),
              linear-gradient(180deg, #020402, #050805 40%, #020402);
  overflow-x: hidden;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

/* Background layers from HTML */
.bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/*
  FX toggle wiring:
  - JS sets `document.documentElement.dataset.fx` to 'on' or 'off'
  - Default is ON

  Make the difference obvious:
  - FX ON: scanlines + noise + glow + subtle pixelation
  - FX OFF: clean, no overlays, no pixelation, reduced glow/shadows
*/

/* OFF: remove overlays + remove extra glow/shadows */
:root[data-fx='off'] .scanlines,
:root[data-fx='off'] .noise,
:root[data-fx='off'] .glow {
  opacity: 0 !important;
  visibility: hidden !important;
}

:root[data-fx='off'] body {
  background: linear-gradient(180deg, #020402, #050805 40%, #020402);
}

:root[data-fx='off'] .topbar__inner,
:root[data-fx='off'] .terminal,
:root[data-fx='off'] .card,
:root[data-fx='off'] .link {
  box-shadow: none !important;
}

:root[data-fx='off'] .title,
:root[data-fx='off'] .ascii {
  text-shadow: none !important;
}

/* Pixelation layer (FX ON only) */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  mix-blend-mode: overlay;
  /* blocky dithering pattern */
  background:
    linear-gradient(90deg, rgba(0,0,0,0.28) 50%, rgba(0,0,0,0) 0) 0 0 / var(--px) var(--px),
    linear-gradient(0deg, rgba(0,0,0,0.22) 50%, rgba(0,0,0,0) 0) 0 0 / var(--px) var(--px);
  image-rendering: pixelated;
}

:root[data-fx='off'] .bg::after {
  opacity: 0 !important;
  visibility: hidden !important;
}

.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.0) 0px,
    rgba(0, 0, 0, 0.0) 2px,
    rgba(0, 0, 0, 0.22) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.7;
}
.noise {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='96' height='96' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  opacity: 0.14;
  mix-blend-mode: overlay;
  image-rendering: pixelated;
}
.glow {
  position: absolute; inset: -20px;
  background: radial-gradient(circle at center, transparent 35%, rgba(0,0,0,0.62) 100%);
  opacity: 0.75;
}

/* Konami “sparkle mode” (6s): JS toggles :root[data-konami='1'] */
:root[data-konami='1'] {
  /* boost overall glow + shift the green a bit */
  filter: saturate(1.25) hue-rotate(18deg);
}

:root[data-konami='1'] .topbar__inner,
:root[data-konami='1'] .terminal,
:root[data-konami='1'] .card,
:root[data-konami='1'] .link {
  box-shadow:
    0 0 1.2rem rgba(57, 255, 20, 0.28),
    0 0 2.2rem rgba(0, 255, 102, 0.18);
  border-color: rgba(57, 255, 20, 0.75);
}

:root[data-konami='1'] .title,
:root[data-konami='1'] .ascii {
  text-shadow:
    0 0 22px rgba(57, 255, 20, 0.35),
    0 0 44px rgba(0, 255, 102, 0.18);
}

/* Animated hue shift (disabled if user prefers reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  :root[data-konami='1'] {
    animation: konamiHue 1.6s linear infinite;
  }
}

@keyframes konamiHue {
  0% { filter: saturate(1.25) hue-rotate(0deg); }
  100% { filter: saturate(1.25) hue-rotate(360deg); }
}

/* Subtle background “twinkle” overlay */
.bg::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(2px 2px at 12% 18%, rgba(57,255,20,0.55), transparent 60%),
    radial-gradient(2px 2px at 78% 22%, rgba(0,255,102,0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 72%, rgba(57,255,20,0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 28% 66%, rgba(0,255,102,0.35), transparent 60%),
    radial-gradient(2px 2px at 44% 40%, rgba(57,255,20,0.35), transparent 60%);
  mix-blend-mode: screen;
}

:root[data-konami='1'] .bg::before {
  opacity: 0.55;
}

@media (prefers-reduced-motion: no-preference) {
  :root[data-konami='1'] .bg::before {
    animation: konamiTwinkle 900ms steps(2, end) infinite;
  }
}

@keyframes konamiTwinkle {
  0% { opacity: 0.25; }
  50% { opacity: 0.65; }
  100% { opacity: 0.35; }
}

/* Centering / width constraints */
.wrap,
.topbar__inner {
  width: min(var(--max), calc(100% - 2 * var(--pad)));
  margin-inline: auto;
}

.wrap {
  padding: 28px 0 44px;
  position: relative;
  z-index: 1;
}

/* Skip link */
.skip {
  position: absolute;
  left: -999px;
  top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(0,0,0,0.75);
  color: var(--green);
  z-index: 2;
}
.skip:focus { left: 10px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 0;
  backdrop-filter: blur(6px);
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(57,255,20,0.18);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.35);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand__prompt { color: var(--muted); white-space: nowrap; }
.brand__name {
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.caret {
  width: 0.65ch;
  height: 1.1em;
  background: var(--green);
  display: inline-block;
  transform: translateY(0.15em);
  animation: blink 1.05s steps(1) infinite;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.8);
}

/* Hero */
.hero {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Desktop: 2-column hero (text + image card) */
@media (min-width: 860px) {
  .hero {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: start;
  }
}

.title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(57,255,20,0.18);
}

.title__line { display: block; }

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  color: var(--green);
  cursor: pointer;
  font: inherit;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 0 0.9rem rgba(57, 255, 20, 0.18);
}

.btn--ghost {
  color: var(--text);
  border-color: var(--border);
}

/* Terminal */
.terminal {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.35);
  box-shadow: var(--shadow);
  overflow: hidden;

  /* Needed for glitch overlay pseudo-elements */
  position: relative;

  /* Easter egg animations: keep them GPU-friendly */
  transform: translateZ(0);
  will-change: transform, opacity, filter;
}

/* Window-style buttons */
.winBtn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  opacity: 0.95;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset;
}

.winBtn--close { background: #ff5f56; }
.winBtn--min { background: #ffbd2e; }
.winBtn--zoom { background: #27c93f; }

.winBtn:hover { opacity: 1; filter: brightness(1.05); }

.winBtn:active { transform: scale(0.92); }

.winBtn:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

/* Close + glitch re-intro sequence (<= 3s total) */
.terminal.is-closing {
  pointer-events: none;
  animation: termClose 520ms cubic-bezier(.2,.9,.2,1) forwards;
}

.terminal.is-glitching {
  pointer-events: none;
  animation: termGlitchIn 520ms steps(2, end) both;
}

.terminal.is-settling {
  animation: termSettle 260ms ease-out both;
}

@keyframes termClose {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: none;
  }
  100% {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    filter: blur(1px);
  }
}

@keyframes termGlitchIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    filter: blur(2px) saturate(1.2) contrast(1.15);
  }
  20% {
    opacity: 1;
    transform: translateY(-2px) scale(1.01) skewX(-1deg);
    filter: blur(0.6px) saturate(1.35) contrast(1.25) hue-rotate(10deg);
  }
  40% {
    transform: translateX(2px) translateY(0) scale(1) skewX(1deg);
    filter: blur(0.2px) saturate(1.25) contrast(1.2) hue-rotate(-8deg);
  }
  60% {
    transform: translateX(-2px) translateY(1px) scale(1.005);
    filter: blur(0.4px) saturate(1.3) contrast(1.25);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: none;
  }
}

@keyframes termSettle {
  0% { transform: translateY(0) scale(1.002); }
  100% { transform: translateY(0) scale(1); }
}

/* Lightweight scanline overlay during glitch only */
.terminal.is-glitching::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(57,255,20,0.18) 3px
  );
  mix-blend-mode: screen;
  opacity: 0.55;
}

/* RGB split + jitter layer (glitch only, lightweight) */
.terminal.is-glitching::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background:
    linear-gradient(90deg, rgba(255,0,0,0.22), transparent 35%),
    linear-gradient(90deg, transparent 65%, rgba(0,180,255,0.22));
  mix-blend-mode: screen;
  animation: termRgbJitter 520ms steps(2, end) both;
}

@keyframes termRgbJitter {
  0% { transform: translateX(0); opacity: 0.15; }
  25% { transform: translateX(2px); opacity: 0.35; }
  50% { transform: translateX(-2px); opacity: 0.28; }
  75% { transform: translateX(1px); opacity: 0.32; }
  100% { transform: translateX(0); opacity: 0.0; }
}

/* Reduced motion: keep it snappy and non-distracting */
@media (prefers-reduced-motion: reduce) {
  .terminal.is-closing,
  .terminal.is-glitching,
  .terminal.is-settling {
    animation-duration: 1ms !important;
  }
}

/* Terminal placed below the links grid */
.terminal--below {
  margin-top: 14px;
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.35);
}

.dot { width: 10px; height: 10px; border-radius: 50%; opacity: 0.9; }
.dot--r { background: #ff5f56; }
.dot--y { background: #ffbd2e; }
.dot--g { background: #27c93f; }

.terminal__title { margin-left: 6px; color: var(--muted); font-size: 0.95rem; }

.terminal__body {
  margin: 0;
  padding: 12px;
  font-size: 0.98rem;
  line-height: 1.55;
  white-space: pre-wrap;

  /* Reduce “flicker” during JS typing by isolating paint/layout work */
  contain: content;
  will-change: contents;
}

/* Right side cards */
.hero__right {
  display: grid;
  gap: 10px;
  width: 100%;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.35);
}

/*
  Image card:
  - Always full width of its container (so on mobile it matches the page width)
  - Keep a stable frame using the asset aspect ratio
  - Show the whole image (no cropping)
*/
.card__img {
  width: 100%;
  display: block;

  aspect-ratio: 299 / 246;
  object-fit: contain;
  object-position: center;

  background: radial-gradient(600px 200px at 50% 20%, rgba(57,255,20,0.12), transparent 60%);
}

.ascii {
  font-family: var(--display);
  font-size: 3rem;
  color: var(--green);
  text-shadow: 0 0 18px rgba(57,255,20,0.25);
}

.card__cap {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Links */
.sectionTitle {
  margin: 18px 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.link:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 0 0.9rem rgba(57, 255, 20, 0.18);
}

.link__k { color: var(--green); font-weight: 700; }
.link__v { color: var(--muted); }

/* Icon inside link */
.link__left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex: 0 0 auto;
  object-fit: contain;
}

/*
  Placeholder icon uses a text glyph (⑨) instead of an <img>.
  Make it align/size like the other icons.
*/
.icon.icon--text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/*
  VRChat icon: keep the *layout slot* the same size (18x18),
  but scale the SVG up inside that slot.

  Use a wrapper so the layout doesn't change (the wrapper is the fixed slot),
  and the image can be scaled without affecting layout.
*/
.iconSlot {
  /* fixed layout slot so the row doesn't reflow */
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
  flex: 0 0 auto;

  /* add extra space to the right so the scaled icon doesn't overlap the label */
  margin-right: 18px;
}

.iconSlot > .icon--wide {
  width: 18px;
  height: 18px;

  /* scale up, then nudge down a bit to visually center the VRChat wordmark */
  transform: translateY(2px) scale(2);
  transform-origin: left center;
}

/* Footer */
.footer {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.kbd {
  font-size: 0.85em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  color: var(--text);
}

@keyframes blink { 50% { opacity: 0; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; opacity: 1; }
  .btn, .link { transition: none; }
  .scanlines { opacity: 0.35; }
}
