/**
 * PROMPT - Base Styles
 * Reset, typography, and foundational elements
 * ============================================
 */

/* ========================================
 * CSS RESET / NORMALIZE
 * Modern reset with sensible defaults
 * ======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  font-size: 16px;
  tab-size: 4;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  line-height: var(--line-height-normal);
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  overflow-x: hidden;
  position: relative;
}

/* Remove default list styles */
ul,
ol {
  list-style: none;
}

/* Remove default anchor styles */
a {
  color: inherit;
  text-decoration: none;
}

/* Reset button styles */
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* Reset form elements */
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

/* Reset media elements */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Reset table */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Remove built-in form typography styles */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove animations for people who've turned them off */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================
 * CRT SCANLINE OVERLAY
 * Subtle retro screen effect
 * ======================================== */

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-overlay);
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent var(--scanline-size),
    rgba(0, 0, 0, var(--scanline-opacity)) var(--scanline-size),
    rgba(0, 0, 0, var(--scanline-opacity)) calc(var(--scanline-size) * 2)
  );
  animation: scanline-flicker 8s ease-in-out infinite;
}

@keyframes scanline-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.98; }
  52% { opacity: 1; }
  54% { opacity: 0.97; }
  56% { opacity: 1; }
}

/* Additional subtle noise texture */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: calc(var(--z-overlay) - 1);
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  animation: noise-shift 0.5s steps(10) infinite;
}

@keyframes noise-shift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-10%, -10%); }
}

/* ========================================
 * CUSTOM SCROLLBAR
 * Thin, neon-accented
 * ======================================== */

/* Webkit browsers */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-void-black);
  border-left: 1px solid rgba(139, 92, 246, 0.2);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    var(--color-synthetic-violet) 0%,
    var(--color-byte-magenta) 50%,
    var(--color-dream-teal) 100%
  );
  border-radius: var(--radius-full);
  box-shadow: var(--glow-violet-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    var(--color-byte-magenta) 0%,
    var(--color-synthetic-violet) 50%,
    var(--color-warning-orange) 100%
  );
  box-shadow: var(--glow-magenta-md);
}

::-webkit-scrollbar-corner {
  background: var(--color-void-black);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-synthetic-violet) var(--color-void-black);
}

/* ========================================
 * SELECTION COLORS
 * Magenta highlight for selected text
 * ======================================== */

::selection {
  background-color: var(--color-byte-magenta);
  color: var(--color-signal-white);
  text-shadow: none;
}

::-moz-selection {
  background-color: var(--color-byte-magenta);
  color: var(--color-signal-white);
  text-shadow: none;
}

/* ========================================
 * BASE TYPOGRAPHY
 * Terminal-inspired type system
 * ======================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  text-transform: uppercase;
}

h1 {
  font-size: var(--font-size-hero);
  letter-spacing: var(--letter-spacing-tighter);
}

h2 {
  font-size: var(--font-size-3xl);
}

h3 {
  font-size: var(--font-size-2xl);
}

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-md);
}

p {
  font-family: var(--font-mono);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  letter-spacing: var(--letter-spacing-wide);
  max-width: 65ch;
}

/* Terminal-style text */
.terminal-text,
code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  letter-spacing: var(--letter-spacing-terminal);
}

/* Emphasis */
strong, b {
  font-weight: var(--font-weight-bold);
  color: var(--color-signal-white);
}

em, i {
  font-style: italic;
  color: var(--color-circuit-gold);
}

/* Small text */
small {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Links */
a {
  color: var(--color-synthetic-violet);
  text-decoration: none;
  transition: color var(--duration-normal) var(--ease-out),
              text-shadow var(--duration-normal) var(--ease-out);
}

a:hover {
  color: var(--color-byte-magenta);
  text-shadow: var(--text-glow-magenta);
}

a:focus-visible {
  outline: 2px solid var(--color-synthetic-violet);
  outline-offset: 2px;
}

/* ========================================
 * CURSOR BLINK ANIMATION
 * The signature waiting state
 * ======================================== */

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: var(--color-signal-white);
  margin-left: 2px;
  animation: cursor-blink var(--cursor-blink-speed) step-end infinite;
  vertical-align: text-bottom;
}

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

/* ========================================
 * GLOW TEXT UTILITIES
 * Apply neon effects to text
 * ======================================== */

.glow-violet {
  color: var(--color-synthetic-violet);
  text-shadow: var(--text-glow-violet);
}

.glow-magenta {
  color: var(--color-byte-magenta);
  text-shadow: var(--text-glow-magenta);
}

.glow-gold {
  color: var(--color-circuit-gold);
  text-shadow: var(--text-glow-gold);
}

.glow-teal {
  color: var(--color-dream-teal);
  text-shadow: var(--text-glow-teal);
}

.glow-orange {
  color: var(--color-warning-orange);
  text-shadow: var(--text-glow-orange);
}

/* ========================================
 * PULSE ANIMATIONS
 * Subtle life for static elements
 * ======================================== */

@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    opacity: 0.8;
    filter: brightness(1.2);
  }
}

@keyframes pulse-subtle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes glitch {
  0%, 100% {
    transform: translate(0);
    filter: none;
  }
  20% {
    transform: translate(-2px, 2px);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: translate(-2px, -2px);
    filter: hue-rotate(-90deg);
  }
  60% {
    transform: translate(2px, 2px);
    filter: hue-rotate(180deg);
  }
  80% {
    transform: translate(2px, -2px);
    filter: none;
  }
}

@keyframes chromatic-shift {
  0%, 100% {
    text-shadow:
      -1px 0 var(--color-byte-magenta),
      1px 0 var(--color-dream-teal);
  }
  25% {
    text-shadow:
      1px 0 var(--color-byte-magenta),
      -1px 0 var(--color-dream-teal);
  }
  50% {
    text-shadow:
      -1px 0 var(--color-dream-teal),
      1px 0 var(--color-byte-magenta);
  }
  75% {
    text-shadow:
      1px 0 var(--color-dream-teal),
      -1px 0 var(--color-byte-magenta);
  }
}

/* Apply pulse to elements */
.pulse {
  animation: pulse-glow 3s ease-in-out infinite;
}

.pulse-subtle {
  animation: pulse-subtle 4s ease-in-out infinite;
}

.float {
  animation: float 6s ease-in-out infinite;
}

.glitch {
  animation: glitch 0.3s ease-in-out;
}

.chromatic {
  animation: chromatic-shift 2s ease-in-out infinite;
}

/* ========================================
 * FOCUS STATES
 * Accessible keyboard navigation
 * ======================================== */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-synthetic-violet);
  outline-offset: 2px;
  box-shadow: var(--glow-violet-sm);
}

/* ========================================
 * SR-ONLY (Screen Reader Only)
 * Visually hidden but accessible
 * ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
 * SKIP LINK
 * Accessibility navigation
 * ======================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-6);
  background: var(--color-void-black);
  color: var(--color-signal-white);
  border: 2px solid var(--color-synthetic-violet);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  z-index: var(--z-max);
  transition: top var(--duration-normal) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-4);
  box-shadow: var(--glow-violet-md);
}

/* ========================================
 * HORIZONTAL RULE
 * Styled divider
 * ======================================== */

hr {
  border: none;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--color-synthetic-violet) 20%,
    var(--color-byte-magenta) 50%,
    var(--color-dream-teal) 80%,
    transparent 100%
  );
  margin: var(--space-12) 0;
  opacity: 0.5;
}

/* ========================================
 * BLOCKQUOTE
 * Styled quotes for lore/lyrics
 * ======================================== */

blockquote {
  position: relative;
  padding: var(--space-6);
  padding-left: var(--space-8);
  margin: var(--space-8) 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
  border-left: 3px solid var(--color-circuit-gold);
}

blockquote::before {
  content: '"';
  position: absolute;
  top: 0;
  left: var(--space-2);
  font-size: var(--font-size-4xl);
  color: var(--color-circuit-gold);
  opacity: 0.3;
  line-height: 1;
}

blockquote cite {
  display: block;
  margin-top: var(--space-4);
  font-family: var(--font-mono);
  font-style: normal;
  font-size: var(--font-size-sm);
  color: var(--color-synthetic-violet);
}

blockquote cite::before {
  content: '// ';
}
