/* ASCII surfaces, hover decoder, CRT layer, boot overlay, and reveal motion. */

/* --- ASCII surfaces ----------------------------------------------------- */

.ascii {
  font-family: var(--font-mono);
  white-space: pre;
  line-height: 1.05;
  letter-spacing: 0;
}

.ascii-banner {
  font-size: clamp(4px, 1.55vw, 11px);
  line-height: 1.08;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--glow-cyan);
  overflow: hidden;
}

.ascii-torus {
  display: block;
  padding: var(--gap-xs) 0;
  /* Sized against the panel, not the viewport: the sidebar is narrow on
     desktop but the same panel goes full width on mobile. 38 columns of
     Fira Code occupy about 23 character widths, so ~4cqw fills the box. */
  font-size: 11px;
  font-size: clamp(7px, 4cqw, 14px);
  line-height: 1.06;
  text-align: center;
  color: var(--emerald);
  text-shadow: 0 0 10px var(--glow-emerald);
}

.ascii-wave {
  display: block;
  margin-top: 0.4rem;
  font-size: var(--text-2xs);
  line-height: 1.05;
  color: var(--cyan-deep);
  overflow: hidden;
}

/* --- Hover decoder ------------------------------------------------------ */

/* `glitchable` is applied by scripts/glitch-text.js, which owns the list of
   hoverable elements. Only hint at it while the effect is actually armed. */
.glitch-armed .glitchable {
  cursor: crosshair;
}

/* Glow the block being decoded. Deliberately not a color change — these
   elements contain links and emphasis that carry their own colors. */
.is-glitching {
  text-shadow: 0 0 10px var(--glow-cyan);
}

/* --- CRT layer ---------------------------------------------------------- */

.crt-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

body.crt .crt-layer {
  opacity: 1;
}

/* Scanlines. */
.crt-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0.16) 4px
  );
}

/* Corner vignette plus a slow drifting brightness band. */
.crt-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(56, 189, 248, 0.03), rgba(52, 211, 153, 0.02)),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
  animation: crt-drift 7s linear infinite;
}

@keyframes crt-drift {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 0 100vh, 0 0; }
}

/* --- Boot overlay ------------------------------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-md);
  background: var(--bg-void);
  transition: opacity var(--dur-slow) var(--ease-out);
}

.boot.is-done {
  opacity: 0;
  pointer-events: none;
}

.boot__panel {
  width: min(46rem, 100%);
  font-family: var(--font-mono);
  font-size: clamp(9px, 1.6vw, 13px);
  line-height: 1.75;
  color: var(--emerald);
  text-shadow: 0 0 8px var(--glow-emerald);
}

.boot__log {
  white-space: pre-wrap;
  min-height: 15rem;
}

.boot__hint {
  margin-top: var(--gap-md);
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

.boot__hint.is-visible {
  opacity: 1;
}

.boot__cursor {
  display: inline-block;
  width: 0.6em;
  background: var(--emerald);
  animation: blink 1.05s steps(1) infinite;
}

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

/* --- Reveal on scroll --------------------------------------------------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
}

[data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* --- Corner brackets on hover ------------------------------------------- */

.bracketed {
  position: relative;
}

.bracketed::before,
.bracketed::after {
  content: "";
  position: absolute;
  width: 0.75rem;
  height: 0.75rem;
  border-color: var(--cyan);
  border-style: solid;
  opacity: 0;
  transition:
    opacity var(--dur) var(--ease-out),
    transform var(--dur) var(--ease-out);
}

.bracketed::before {
  top: -1px;
  left: -1px;
  border-width: 1px 0 0 1px;
  transform: translate(4px, 4px);
}

.bracketed::after {
  right: -1px;
  bottom: -1px;
  border-width: 0 1px 1px 0;
  transform: translate(-4px, -4px);
}

.bracketed:hover::before,
.bracketed:hover::after,
.bracketed:focus-within::before,
.bracketed:focus-within::after {
  opacity: 1;
  transform: none;
}

/* --- Status dot --------------------------------------------------------- */

.pulse-dot {
  color: var(--emerald);
  animation: pulse 2.4s var(--ease-in-out) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}
