/* =============================================================================
   Sterrewag — Portfolio Shell
   Celestial-almanac aesthetic: indigo night sky, cyan chrome, gold stars,
   scroll-driven reveals. Light mode is an aged navy-on-parchment star atlas.
   No build step, pure static HTML/CSS/vanilla JS.
   NB: mirrors the token names in tokens.css so pages that also load
   projects.css / arcade.css stay in step. Light mode is driven by the
   data-theme toggle (not @media), matching tokens.css.
   ============================================================================= */

:root {
  --bg: #0b1026;
  --bg-2: #10173a;
  --surface: rgba(79, 214, 224, 0.05);
  --surface-2: rgba(79, 214, 224, 0.10);
  --border: rgba(79, 214, 224, 0.20);
  --border-2: rgba(230, 233, 242, 0.10);

  --text: #d3d8ea;
  --text-mut: #8b93b8;
  --text-bright: #f2f4fc;
  --accent: #4fd6e0;
  --accent-2: #8fe9f0;
  --accent-3: #d9b45b;

  --mono: 'Courier Prime', 'JetBrains Mono', ui-monospace, monospace;
  --serif: 'Fraunces', Georgia, serif;

  --radius: 4px;
  --radius-sm: 3px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  --glow: 0 0 16px rgba(79, 214, 224, 0.4);
  --glow-dim: 0 0 8px rgba(79, 214, 224, 0.25);
  --maxw: 1100px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Starfield texture (see body::before) */
  --star: rgba(232, 235, 244, 0.75);
  --star-2: rgba(232, 235, 244, 0.42);
  --star-gold: rgba(217, 180, 91, 0.75);
  --star-cyan: rgba(79, 214, 224, 0.65);
}

:root[data-theme="light"] {
  --bg: #e9dfc7;
  --bg-2: #e2d6b9;
  --surface: rgba(44, 107, 134, 0.06);
  --surface-2: rgba(44, 107, 134, 0.12);
  --border: rgba(38, 49, 78, 0.22);
  --border-2: rgba(38, 49, 78, 0.12);
  --text: #26314e;
  --text-mut: #5f6178;
  --text-bright: #171f38;
  --accent: #2c6b86;
  --accent-2: #3f7f96;
  --accent-3: #8a6d24;
  --glow: 0 0 0 1px rgba(38, 49, 78, 0.08);
  --glow-dim: 0 0 6px rgba(44, 107, 134, 0.18);
  --star: rgba(38, 49, 78, 0.5);
  --star-2: rgba(38, 49, 78, 0.28);
  --star-gold: rgba(138, 109, 36, 0.55);
  --star-cyan: rgba(44, 107, 134, 0.5);
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  font-family: var(--serif);
  line-height: 1.65;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(700px 500px at 85% -8%, rgba(79, 214, 224, 0.07), transparent 60%),
    radial-gradient(600px 450px at 0% 8%, rgba(217, 180, 91, 0.05), transparent 55%),
    var(--bg);
}

/* Starfield (behind content, toggleable via .no-scan) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 27% 62%, var(--star-2), transparent 60%),
    radial-gradient(1px 1px at 42% 30%, var(--star-2), transparent 60%),
    radial-gradient(1.6px 1.6px at 58% 78%, var(--star-gold), transparent 60%),
    radial-gradient(1px 1px at 66% 12%, var(--star-2), transparent 60%),
    radial-gradient(1.3px 1.3px at 74% 46%, var(--star-cyan), transparent 60%),
    radial-gradient(1px 1px at 83% 68%, var(--star-2), transparent 60%),
    radial-gradient(1.5px 1.5px at 90% 24%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 8% 85%, var(--star-2), transparent 60%),
    radial-gradient(1.2px 1.2px at 35% 90%, var(--star), transparent 60%),
    radial-gradient(1px 1px at 50% 55%, var(--star-2), transparent 60%),
    radial-gradient(1.1px 1.1px at 20% 42%, var(--star), transparent 60%);
  background-repeat: repeat;
  background-size: 540px 540px;
}

body.no-scan::before {
  display: none;
}

h1, h2, h3 {
  font-family: var(--serif);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--accent-2);
  text-shadow: var(--glow-dim);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
}

a:hover {
  color: var(--accent-2);
  text-shadow: var(--glow-dim);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 0;
}

/* Vignette effect */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 9997;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 50%,
    transparent 40%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* Canvas scanlines */
#scanlines {
  position: fixed;
  inset: 0;
  z-index: 9996;
  pointer-events: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   Navigation
   ======================================== */
.nav-main {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 16, 38, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.4rem;
  font-family: var(--mono);
}

.nav-container {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.nav-logo .prompt {
  color: var(--accent-3);
  opacity: 0.7;
}

.nav-logo:hover .name {
  text-shadow: var(--glow);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--accent);
  transition: all 0.3s var(--ease);
  border-radius: 1px;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(11px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-11px) rotate(-45deg);
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav-menu a {
  display: block;
  padding: 0.4rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-mut);
  border: 1px solid transparent;
  border-radius: 0;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.nav-menu a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

.nav-menu a[aria-current="page"] {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  text-shadow: var(--glow-dim);
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(11, 16, 38, 0.98);
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s var(--ease);
  }

  .nav-menu.active {
    max-height: 400px;
  }

  .nav-menu li {
    width: 100%;
  }

  .nav-menu a {
    display: block;
    padding: 0.8rem 1.4rem;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-2);
  }

  .nav-menu a[aria-current="page"] {
    border-bottom: 1px solid var(--border-2);
    background: var(--surface);
  }
}

/* ========================================
   Hero Section
   ======================================== */
.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3rem 1.4rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4rem;
}

/* Boot sequence animation */
.boot-sequence {
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.boot-line {
  margin: 0.4rem 0;
  opacity: 0;
  animation: boot-fade 0.4s var(--ease) forwards;
}

.boot-line-delay-1 {
  animation-delay: 1.2s;
}

.boot-line-delay-2 {
  animation-delay: 2.4s;
}

@keyframes boot-fade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.prompt {
  color: var(--accent);
  margin-right: 0.4rem;
}

.cmd {
  color: var(--text-bright);
  font-weight: 700;
}

.boot-output {
  color: var(--accent);
  text-shadow: var(--glow-dim);
  margin-left: 0.4rem;
}

#portfolio-text {
  margin-top: 0.8rem;
  font-weight: 700;
}

#portfolio-text div {
  margin: 0.2rem 0;
}

/* Clock display */
.clock-display {
  text-align: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.15em;
  color: var(--accent-3);
  font-size: 1.1rem;
  margin: 2rem 0;
  text-shadow: 0 0 10px rgba(217, 180, 91, 0.3);
}

.time {
  display: block;
  font-weight: 700;
  font-size: 1.3rem;
}

.date {
  display: block;
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 0.4rem;
}

/* CTA Section */
.cta-section {
  text-align: center;
}

.cta-section h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  margin-bottom: 2rem;
  letter-spacing: -0.03em;
}

.cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cta-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1.4rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  border-radius: 0;
  transition: all 0.3s var(--ease);
  position: relative;
  overflow: hidden;
}

.cta-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--surface-2) 0%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}

.cta-btn:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--glow-dim);
  transform: translateY(-4px);
}

.cta-btn:hover::before {
  opacity: 1;
}

.cta-btn .icon {
  font-family: var(--mono);
  color: var(--accent-3);
  font-weight: 700;
  font-size: 1.2rem;
}

.cta-btn .label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent-2);
}

.cta-btn .subtext {
  font-size: 0.75rem;
  color: var(--text-mut);
  font-weight: 400;
  letter-spacing: 0.05em;
}

/* Featured Projects */
.featured {
  margin-top: 4rem;
}

.featured h2 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.6rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0;
  transition: all 0.3s var(--ease);
  position: relative;
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--surface-2) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
  border-radius: 0;
}

.project-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: var(--glow-dim);
  transform: translateY(-6px);
}

.project-card:hover::before {
  opacity: 1;
}

.card-icon {
  font-size: 2.4rem;
  line-height: 1;
  height: 2.4rem;
  z-index: 1;
}

.project-card h3 {
  font-size: 1.2rem;
  color: var(--accent-2);
  z-index: 1;
}

.project-card p {
  font-family: var(--serif);
  color: var(--text);
  font-size: 0.95rem;
  flex-grow: 1;
  z-index: 1;
}

.card-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  transition: all 0.2s var(--ease);
  z-index: 1;
}

.card-link:hover {
  transform: translateX(6px);
  text-shadow: var(--glow-dim);
}

/* ========================================
   Scroll Reveal Animation
   ======================================== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ========================================
   Footer
   ======================================== */
.footer {
  background: rgba(11, 16, 38, 0.9);
  border-top: 1px solid var(--border);
  padding: 2rem 1.4rem;
  margin-top: 4rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text-mut);
}

.footer-content {
  max-width: var(--maxw);
  margin: 0 auto;
  text-align: center;
}

.footer-content p {
  margin: 0.6rem 0;
  line-height: 1.6;
}

.footer-note {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 1rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
  transition: text-shadow 0.2s;
}

.footer a:hover {
  text-shadow: var(--glow-dim);
}

/* ========================================
   Light mode — aged star-atlas chrome
   ======================================== */
:root[data-theme="light"] .nav-main,
:root[data-theme="light"] .footer {
  background: rgba(233, 223, 199, 0.9);
}
:root[data-theme="light"] .nav-menu {
  background: rgba(233, 223, 199, 0.98);
}
:root[data-theme="light"] .vignette {
  background: radial-gradient(circle at 50% 50%, transparent 45%, rgba(38, 49, 78, 0.14) 100%);
}
:root[data-theme="light"] h1,
:root[data-theme="light"] h2,
:root[data-theme="light"] h3 {
  text-shadow: none;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  .hero {
    padding: 2rem 1.4rem;
    gap: 2rem;
  }

  .cta-grid {
    grid-template-columns: 1fr;
  }

  .cta-btn {
    padding: 1rem;
  }

  .boot-sequence {
    font-size: 0.85rem;
  }

  .featured {
    margin-top: 2rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .project-card {
    padding: 1.2rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 0.95rem;
  }

  .nav-container {
    gap: 1rem;
  }

  .hero {
    padding: 1.4rem;
  }

  .boot-sequence {
    font-size: 0.8rem;
    line-height: 1.6;
  }

  .clock-display {
    font-size: 0.95rem;
    letter-spacing: 0.1em;
  }

  .cta-section h1 {
    font-size: 1.6rem;
    margin-bottom: 1.4rem;
  }

  .featured h2 {
    font-size: 1.4rem;
  }
}
