/* ============================================
   Reset & Variables
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #000000;
  --bg-card: #0A0A0A;
  --bg-terminal: #080808;
  --text: #FFFFFF;
  --text-secondary: #888888;
  --text-dim: #444444;
  --border: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --green: #22C55E;
  --yellow: #EAB308;
  --red: #EF4444;
  --font-sans: 'Inter Tight', 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --max-width: 640px;
  --radius: 0;
  color-scheme: dark;
}

/* ============================================
   Body
   ============================================ */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 {
  text-wrap: balance;
}

[id] {
  scroll-margin-top: 4rem;
}

/* ============================================
   Background Terminal Grid
   ============================================ */
.bg-grid {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--bg);
}

.panel {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  min-height: 0;
  background: var(--bg);
}

.panel:last-child {
  border-right: none;
}

.bg-grid > div:nth-child(4n) {
  border-right: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.panel-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.panel-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.panel-body {
  font-family: var(--font-mono);
  font-size: 0.45rem;
  line-height: 1.55;
  color: var(--text-secondary);
  opacity: 0.25;
  overflow: hidden;
  flex: 1;
}

.pl {
  color: var(--text-secondary);
  opacity: 0.3;
  margin-right: 0.25rem;
}

.dot-green { background: var(--green); opacity: 0.2; }
.dot-yellow { background: var(--yellow); opacity: 0.2; }
.dot-red { background: var(--red); opacity: 0.2; }

/* === FIXED ANIMATION === */

/* Depth: push bg-grid further behind content */
.bg-grid {
  opacity: 0.6;
}

@media (max-width: 768px) {
  .bg-grid {
    opacity: 0.85;
  }

  .panel-body {
    opacity: 0.55;
  }

  .panel-body .scroll-content {
    opacity: 0.55;
  }
}

/* Vertical scroll animation on panel-body */
.panel-body {
  position: relative;
  overflow: hidden;
  animation: panelFlicker var(--flicker-duration, 8s) ease-in-out infinite;
  will-change: opacity;
}

/* Move base opacity to scroll-content so flicker scales correctly */
.panel-body .scroll-content {
  display: block;
  opacity: 0.25;
  animation: scrollUp var(--scroll-duration, 18s) linear infinite;
  will-change: transform;
}

@keyframes scrollUp {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

/* Variation: stagger animation speeds across panels (groups of 4 per row) */
.bg-grid > .panel:nth-child(4n+1) .panel-body .scroll-content {
  --scroll-duration: 16s;
}
.bg-grid > .panel:nth-child(4n+2) .panel-body .scroll-content {
  --scroll-duration: 22s;
}
.bg-grid > .panel:nth-child(4n+3) .panel-body .scroll-content {
  --scroll-duration: 19s;
}
.bg-grid > .panel:nth-child(4n) .panel-body .scroll-content {
  --scroll-duration: 25s;
}

/* Subtle flicker effect — targets panel-body container, scroll-content holds base opacity */
@keyframes panelFlicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Stagger flicker speeds */
.bg-grid > .panel:nth-child(4n+1) .panel-body {
  --flicker-duration: 7s;
}
.bg-grid > .panel:nth-child(4n+2) .panel-body {
  --flicker-duration: 11s;
}
.bg-grid > .panel:nth-child(4n+3) .panel-body {
  --flicker-duration: 9s;
}
.bg-grid > .panel:nth-child(4n) .panel-body {
  --flicker-duration: 13s;
}

/* Randomize start phase so panels don't sync */
.bg-grid > .panel:nth-child(odd) .panel-body .scroll-content {
  animation-delay: -5s;
}
.bg-grid > .panel:nth-child(3n) .panel-body .scroll-content {
  animation-delay: -12s;
}
.bg-grid > .panel:nth-child(5n) .panel-body {
  animation-delay: -3s;
}
.bg-grid > .panel:nth-child(7n) .panel-body {
  animation-delay: -7s;
}

/* === END FIXED ANIMATION === */

/* ============================================
   Skip Link
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: #FFFFFF;
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 0;
  z-index: 100;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-mono);
}

.skip-link:focus {
  top: 1rem;
}

/* ============================================
   Navigation
   ============================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-link:hover {
  color: var(--text);
}

.nav-cta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #000;
  background: #FFFFFF;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.nav-cta:hover {
  background: #E0E0E0;
}

/* ============================================
   Container
   ============================================ */
.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0;
  margin-left: 8%;
  padding: 6rem 1.25rem 4rem;
}

/* ============================================
   Hero
   ============================================ */
.hero {
  text-align: left;
  padding: 3rem 0 4rem;
}

.hero-name {
  font-family: var(--font-mono);
  font-size: clamp(3.75rem, 10vw, 6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.hero-tagline {
  color: var(--text-secondary);
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  max-width: 480px;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.hero-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0;
  cursor: pointer;
}

.btn-primary {
  background: #FFFFFF;
  color: #000;
}

.btn-primary:hover {
  background: #E0E0E0;
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-card);
}

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

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

/* ============================================
   Sections
   ============================================ */
.section {
  padding: 3rem 0;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.section-cta {
  text-align: left;
  padding: 4rem 0;
}

/* ============================================
   Projects
   ============================================ */
.projects-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 0;
  padding: 1.5rem;
  min-height: 10rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.project-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.project-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
  color: var(--text);
}

.project-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 0;
}

.badge-green {
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}

.badge-yellow {
  color: var(--yellow);
  background: rgba(234, 179, 8, 0.08);
}

/* ============================================
   Terminal
   ============================================ */
.terminal {
  background: var(--bg-terminal);
  border: 1px solid var(--border-card);
  border-radius: 0;
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-card);
  background: var(--bg-card);
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-red { background: #FF5F57; }
.dot-yellow { background: #FEBC2E; }
.dot-green { background: #28C840; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 0.5rem;
}

.terminal-body {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.9;
  padding: 1.25rem;
  color: var(--text-secondary);
  overflow-x: auto;
}

.terminal-body .line {
  display: block;
}

.terminal-body .prompt {
  color: var(--green);
  margin-right: 0.5rem;
}

.terminal-body .cmd {
  color: var(--text);
}

.terminal-body .output {
  display: block;
  padding-left: 1.25rem;
}

.terminal-body .output-green {
  color: var(--green);
}

.terminal-body .output-yellow {
  color: var(--yellow);
}

.terminal-body .output-red {
  color: var(--red);
}

.terminal-body .cursor {
  color: var(--green);
  animation: blink 1s step-end infinite;
}

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

/* ============================================
   Focus List
   ============================================ */
.focus-list {
  list-style: none;
}

.focus-list li {
  padding: 0.5rem 0 0.5rem 1.25rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.focus-list li::before {
  content: '$';
  position: absolute;
  left: 0;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ============================================
   Links
   ============================================ */
.links-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.link-item {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.link-item:hover {
  color: var(--text);
}

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

/* ============================================
   CTA
   ============================================ */
.cta-text {
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .container {
    margin-left: 1.25rem;
  }

  .hero-name {
    font-size: clamp(2.75rem, 12vw, 4.25rem);
  }

  .nav-links {
    gap: 1rem;
  }

  .nav-link {
    display: none;
  }

  .nav-link:last-of-type {
    display: inline;
  }
}

@media (max-width: 400px) {
  .hero-buttons {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}
