/* ==========================================
   PLEADING SANITY — COSMIC CORE MASTER v2.5-MERGED
   Infinity + Main + Frontend + v2.3 → ALL BEST PARTS COMBINED
   God Mode Ascension • Evolution, Not Erasure
   WCAG 2.1 AA • Reduced Motion • Fully Responsive
============================================ */

/* ✅ FONT — NO EXTERNAL DEPENDENCIES, LOADS INSTANTLY */
:root {
  /* System font stack only — nothing external to load */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  
  /* 🌟 COSMIC PALETTE — FINAL LOCKED • CONTRAST-VERIFIED */
  --cyan: #00fff0;
  --cyan-deep: #00c8c0;
  --cyan-glow: rgba(0, 255, 240, 0.6);
  --cyan-bg: rgba(0, 255, 240, 0.08);
  --magenta: #ff00ff;
  --magenta-deep: #c800c8;
  --magenta-glow: rgba(255, 0, 255, 0.6);
  --magenta-bg: rgba(255, 0, 255, 0.08);
  --gold: #ffd700;
  --gold-deep: #e6b800;
  --gold-glow: rgba(255, 215, 0, 0.6);
  --p1: #7c3aed;
  --p2: #06b6d4;
  --p3: #22d3ee;
  
  /* 🌌 DEPTH LAYERS */
  --deepest: #01030a;
  --deep: #060713;
  --mid: #0f1638;
  --mid-light: #1a2456;
  --surface: rgba(255,255,255,.06);
  
  /* ✨ TEXT */
  --text-bright: #ffffff;
  --text-soft: #e0e4ff;
  --text-muted: #9098c0;
  --text-dim: #606890;
  
  /* ⚡ MOTION */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.6s ease;
  --ease-cosmic: cubic-bezier(0.1, 0.8, 0.2, 1);
  
  /* 📐 SIZING */
  --nav-height: 70px;
  --section-gap: 4rem;
  --card-radius: 20px;
  --glow-soft: 0 0 15px;
  --glow-medium: 0 0 30px;
  --glow-strong: 0 0 50px;
  --border-thin: 1px solid rgba(255,255,255,0.1);

  /* 🧬 CARRIED FORWARD FROM v2.3 — still used by games, forms & error pages */
  --gold-yellow: var(--gold);
  --success: #00ff90;
  --success-bg: rgba(0, 255, 144, 0.1);
  --error: #ff3b5c;
  --error-bg: rgba(255, 59, 92, 0.1);
  --bg-dark: #000000;
  --nebula-gradient: linear-gradient(135deg, rgba(0,255,240,0.12), rgba(255,0,255,0.12));
  --cosmic-glow: radial-gradient(ellipse at top, rgba(0,255,240,0.15), transparent 60%),
                 radial-gradient(ellipse at bottom, rgba(255,0,255,0.12), transparent 60%);
  --button-gradient: linear-gradient(135deg, var(--cyan-deep), var(--magenta-deep));
  --hero-gradient: linear-gradient(180deg, var(--deepest), var(--deep) 40%, var(--mid));
  --card-gradient: linear-gradient(135deg, rgba(15,22,56,0.8), rgba(36,48,112,0.6));
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
}

/* ==========================================
   BASE RESET
========================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(180deg, var(--deepest), var(--deep) 50%, #02040B);
  color: var(--text-bright);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
   SKIP LINK — KEYBOARD USERS FIRST ✅
========================================== */
.skip-link {
  position: absolute;
  top: -50px;
  left: 6px;
  background: var(--cyan);
  color: #000;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 100000;
  transition: top 0.25s ease;
}
.skip-link:focus { top: 12px; }

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

/* Visually hidden announcer — use this class, never hide [aria-live] itself */
.live-region {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}


/* ==========================================
   COSMIC BACKGROUND — STARS + NEBULA ✨
========================================== */
.cosmic-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: radial-gradient(1200px 800px at 20% -10%, rgba(124,58,237,.15), transparent 60%),
              radial-gradient(900px 700px at 80% 20%, rgba(6,182,212,.12), transparent 60%);
  pointer-events: none;
}

.stars {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: 
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,.8), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(0,255,240,.6), transparent),
    radial-gradient(2px 2px at 160px 120px, rgba(255,0,255,.5), transparent);
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.6;
  animation: starsTwinkle 8s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes starsTwinkle {
  0% { opacity: 0.4; }
  100% { opacity: 0.8; }
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(1000px 600px at 30% 0%, rgba(0,255,240,.18), transparent 55%),
              radial-gradient(800px 500px at 70% 10%, rgba(255,0,255,.15), transparent 55%);
  filter: blur(10px);
  animation: auroraDrift 12s ease-in-out infinite alternate;
}
@keyframes auroraDrift {
  to { transform: translate3d(2%, -5%, 0) scale(1.05); }
}

.nebula {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(0,255,240,0.08), transparent 50%),
    radial-gradient(ellipse at 80% 30%, rgba(255,0,255,0.06), transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(0,200,192,0.05), transparent 55%);
  animation: nebulaDrift 25s ease-in-out infinite alternate;
}
@keyframes nebulaDrift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(2%, 1%) scale(1.05); }
}

.shooting-star {
  position: absolute;
  width: 100px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  border-radius: 1px;
  filter: blur(0.5px);
  animation: shoot 4s ease-in-out infinite;
}
@keyframes shoot {
  0% { transform: translateX(-150px) translateY(-50px); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateX(150vw) translateY(80px); opacity: 0; }
}

/* ==========================================
   NAVIGATION — GLASS EFFECT ✨
========================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--cyan);
  text-shadow: 0 0 15px var(--cyan-glow);
}
.brand img { height: 34px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  transition: all var(--transition-fast);
}
.nav-links a:hover,
.nav-links a:focus {
  background: rgba(255,255,255,.08);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(0,255,240,.3);
}

/* ==========================================
   TYPOGRAPHY
========================================== */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: var(--cyan);
  margin-bottom: 0.75rem;
}

h3 {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  color: var(--magenta);
  margin-bottom: 0.5rem;
}

p {
  color: var(--text-soft);
  margin-bottom: 1rem;
  font-size: 1.05rem;
  max-width: 70ch;
}

a {
  color: var(--cyan);
  text-decoration: none;
  transition: all var(--transition-normal);
}
a:hover,
a:focus {
  color: var(--magenta);
  text-shadow: 0 0 8px var(--magenta-glow);
}
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================
   FOCUS MANAGEMENT — KEYBOARD vs MOUSE ✅
========================================== */
.focus-ring:focus,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(0, 255, 240, 0.5);
}

/* ==========================================
   BUTTONS — COSMIC GLOW 🔥
========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  transition: all var(--transition-normal);
  text-align: center;
}

.btn-primary {
  background: linear-gradient(90deg, var(--cyan-deep), var(--magenta-deep));
  color: #000;
  box-shadow: 0 8px 26px rgba(0,255,240,.35);
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(0,255,240,.45), 0 0 25px rgba(255,0,255,.25);
}

.btn-secondary {
  background: transparent;
  color: var(--cyan);
  border: 2px solid var(--cyan);
}
.btn-secondary:hover {
  background: rgba(0,255,240,.1);
  box-shadow: inset 0 0 15px var(--cyan-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-soft);
  border: 2px solid rgba(255,255,255,.2);
  padding: 0.65rem 1.5rem;
}
.btn-outline:hover {
  border-color: var(--magenta);
  color: var(--magenta);
  background: rgba(255,0,255,.08);
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ==========================================
   FORM ELEMENTS — ACCESSIBLE ✅
========================================== */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-soft);
}

input[type="email"],
input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 14px 16px;
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-bright);
  border-radius: 10px;
  transition: all var(--transition-normal);
  font-family: inherit;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 255, 240, 0.35);
  outline: none;
}
input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 59, 92, 0.3);
}
input[aria-invalid="false"] {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(0, 255, 144, 0.3);
}

/* ==========================================
   CARDS — GLASS EFFECT ✨
========================================== */
.cosmic-card {
  background: rgba(15,22,56,.6);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--card-radius);
  padding: 1.75rem;
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
}
.cosmic-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0,255,240,.35);
  box-shadow: 0 10px 30px rgba(0,255,240,.12);
}

.cosmic-card:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 255, 240, 0.3);
}

/* ==========================================
   LAYOUT CONTAINERS
========================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.hero {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2.5rem 2rem;
  border-radius: 24px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 15px 50px rgba(124,58,237,.2), 0 10px 40px rgba(6,182,212,.15);
  text-align: center;
}

.grid {
  display: grid;
  gap: 1.5rem;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ==========================================
   FOOTER — plain pages (the shared .ps-footer lives in site.css)
========================================== */
footer:not(.ps-footer) {
  max-width: 1200px;
  margin: 3rem auto 1rem;
  padding: 2rem;
  border-top: 1px solid rgba(255,255,255,.1);
  text-align: center;
  color: var(--text-muted);
}

/* ==========================================
   ERROR HANDLER — FULLY INTEGRATED ✅
========================================== */
.error-container {
  padding: 2.5rem 2rem;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
  background: var(--error-bg);
  border: 1px solid rgba(255, 59, 92, 0.3);
  border-radius: var(--card-radius);
  margin: 2rem auto;
  max-width: 520px;
}

.error-card {
  max-width: 480px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  background: rgba(10, 15, 40, 0.85);
  border: 1px solid rgba(0, 255, 240, 0.3);
  border-radius: var(--card-radius);
  box-shadow: 0 0 30px rgba(0, 255, 240, 0.15),
              inset 0 0 30px rgba(0, 255, 240, 0.05);
  backdrop-filter: blur(10px);
}

.error-title {
  font-size: 1.5rem;
  color: var(--cyan);
  margin-bottom: 0.75rem;
  text-shadow: 0 0 10px var(--cyan-glow);
}

.error-desc,
.error-description {
  color: var(--text-soft);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.error-buttons,
.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}
.error-actions .btn {
  min-width: 130px;
}

.tech-details,
.error-details {
  margin-top: 1.5rem;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 1rem;
}

.tech-details summary,
.error-details summary {
  cursor: pointer;
  color: var(--magenta);
  outline: none;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  transition: background 0.2s;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tech-details summary:hover,
.error-details summary:hover {
  background: rgba(255, 255, 255, 0.05);
}
.error-details summary::after {
  content: "▼";
  font-size: 0.75rem;
  opacity: 0.5;
  transition: transform 0.2s;
}
.error-details[open] summary::after {
  transform: rotate(180deg);
}

.tech-info,
.error-tech-info {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  margin-top: 0.75rem;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  overflow-x: auto;
}

/* ==========================================
   ANIMATIONS
========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}
/* `both` keeps content hidden only while the animation is pending —
   if motion is switched off it simply shows, never stuck invisible */
.fade-in,
.animate-fade-in {
  animation: fadeIn 0.6s ease-out both;
}
.fade-in.d1, .animate-delay-1 { animation-delay: 0.1s; }
.fade-in.d2, .animate-delay-2 { animation-delay: 0.2s; }
.fade-in.d3, .animate-delay-3 { animation-delay: 0.3s; }

/* ==========================================
   HIGH CONTRAST MODE — SYSTEM RESPECT ✅
========================================== */
@media (prefers-contrast: high) {
  :root {
    --cyan: #00ffff;
    --magenta: #ff00ff;
    --text-bright: #ffffff;
    --bg-dark: #000000;
  }
  * { border-width: 2px !important; }
  .cosmic-bg, .nebula, .stars { display: none; }
  .cosmic-card, .error-card { border-width: 3px; }
}

/* ==========================================
   REDUCED MOTION — RESPECT ✅
========================================== */
@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;
  }
  .btn:hover, .cosmic-card:hover { transform: none; }
  .stars, .aurora, .nebula, .shooting-star { animation: none !important; }
}

/* ==========================================
   MOBILE RESPONSIVE ✅
========================================== */
@media (max-width: 768px) {
  :root { --section-gap: 2.5rem; }
  .nav-inner { justify-content: center; }
  .hero { padding: 1.5rem 1rem; margin: 1rem; }
  .hero .btn, .error-actions .btn { width: 100%; }
  .cosmic-card { padding: 1.25rem; }
  .error-card, .error-container {
    padding: 2rem 1.25rem;
    margin: 1rem;
  }
  .error-buttons, .error-actions { flex-direction: column; }
}
