/* ==========================================================================
   SYSTEMS & ARCHITECTURE PORTFOLIO
   Design System: Anti-AI Slop / High-Precision Enterprise
   Updated: Proper animation, Inter font, differentiated components
   ========================================================================== */

/* Import Inter — sharper, more legible than system stack at all weights */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Backgrounds — warm-tinted dark, not cold blue-gray */
  --bg-main:          #09090b;
  --bg-surface:       #111113;
  --bg-surface-2:     #18181b;
  --bg-overlay:       rgba(9, 9, 11, 0.88);

  /* Borders */
  --border-muted:     #27272a;
  --border-subtle:    #3f3f46;
  --border-focus:     #6366f1;

  /* Text */
  --text-primary:     #fafafa;
  --text-secondary:   #a1a1aa;
  --text-muted:       #71717a;

  /* Accent — single primary accent, used sparingly */
  --accent:           #818cf8;   /* indigo-400 — readable on dark, not neon */
  --accent-dim:       rgba(129, 140, 248, 0.12);
  --accent-border:    rgba(129, 140, 248, 0.25);

  /* Semantic colors — only for status indicators */
  --status-live:      #34d399;   /* emerald — "live product" dots */
  --status-danger:    #f87171;   /* red — trigger block */

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing Rhythm — strict 4px base */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Easing */
  --ease-apple:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-linear: linear;
  --dur-fast:    120ms;
  --dur-normal:  220ms;
  --dur-slow:    380ms;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11"; /* Inter optical features */
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

/* ============================================================
   HEADER & NAV
   ============================================================ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--border-muted);
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Live status indicator dot — only green dot has meaning (live system) */
.logo::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: var(--status-live);
  border-radius: 50%;
  /* Subtle breathe — single CSS animation, purposeful (signals "live") */
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

nav {
  display: flex;
  gap: var(--sp-1);
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-apple),
              background-color var(--dur-fast) var(--ease-apple);
}

nav a:hover {
  color: var(--text-primary);
  background: var(--border-muted);
}

nav a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: var(--sp-16) 0 var(--sp-12);
  border-bottom: 1px solid var(--border-muted);
  max-width: 780px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 3px var(--sp-3);
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-5);
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: var(--sp-5);
  color: var(--text-primary);
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 640px;
  margin-bottom: var(--sp-8);
}

.hero-btns {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary,
.btn-secondary,
.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 9px var(--sp-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-apple),
              color var(--dur-fast) var(--ease-apple),
              border-color var(--dur-fast) var(--ease-apple),
              transform var(--dur-fast) var(--ease-apple);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-main);
}

.btn-primary:hover {
  background: #fff;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-2);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.card-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
   SECTIONS
   ============================================================ */
section {
  padding: var(--sp-12) 0;
  border-bottom: 1px solid var(--border-muted);
}

section:last-of-type {
  border-bottom: none;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-2);
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: var(--sp-2);
}

.section-subtitle {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 620px;
  margin-bottom: var(--sp-10);
}

/* ============================================================
   GRID
   ============================================================ */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: var(--sp-4);
}

/* ============================================================
   CASE STUDY CARDS
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  transition: border-color var(--dur-normal) var(--ease-apple),
              box-shadow var(--dur-normal) var(--ease-apple);
  position: relative;
  overflow: hidden;
}

/* Top-edge accent — 3px rule, communicates card type */
.card[data-type="case-study"]::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    transparent 100%
  );
  opacity: 0.6;
  transition: opacity var(--dur-normal) var(--ease-apple);
}

.card[data-type="adr"]::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--border-subtle) 0%,
    transparent 100%
  );
  opacity: 1;
}

.card:hover {
  border-color: var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.card[data-type="case-study"]:hover::before {
  opacity: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Live indicator badge — only on live products */
.card-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--status-live);
}

.card-status::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--status-live);
  border-radius: 50%;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-primary);
}

.card > p,
.card > div > p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.card-tech {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.tech-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px var(--sp-2);
  background: var(--bg-main);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.card-btn {
  width: 100%;
  background: var(--bg-main);
  color: var(--text-secondary);
  border: 1px solid var(--border-muted);
  font-size: 0.8rem;
  padding: 8px var(--sp-4);
}

.card-btn:hover {
  background: var(--bg-surface-2);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* ============================================================
   ARCHITECTURE FLOW VISUALIZER
   ============================================================ */
.architecture-flow {
  background: var(--bg-main);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
}

.flow-title {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-3);
}

.flow-steps {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.flow-steps::-webkit-scrollbar { display: none; }

.flow-node {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Active node — purposeful pulse, communicates "current state" */
.flow-node.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  animation: node-pulse 2.5s ease-in-out infinite;
}

.flow-node.active-danger {
  border-color: var(--status-danger);
  color: var(--status-danger);
  background: rgba(248, 113, 113, 0.08);
}

@keyframes node-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.flow-arrow {
  color: var(--border-subtle);
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-10);
  padding-left: var(--sp-6);
  border-left: 1px solid var(--border-muted);
  max-width: 760px;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-6) - 4px);
  top: 7px;
  width: 8px;
  height: 8px;
  background: var(--bg-main);
  border: 2px solid var(--border-subtle);
  border-radius: 50%;
  transition: border-color var(--dur-fast) var(--ease-apple),
              background-color var(--dur-fast) var(--ease-apple);
}

.timeline-item:hover::before {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.timeline-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-role {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}

.timeline-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* ============================================================
   MODAL — CORRECT ANIMATION PATTERN
   CSS trick: visibility + opacity for animatable overlay
   display:none → display:flex cannot animate; this can.
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  /* Invisible but present in DOM — this allows animation */
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-normal) var(--ease-apple),
              visibility var(--dur-normal) var(--ease-apple);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 740px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: var(--sp-8);
  position: relative;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 24px 48px rgba(0, 0, 0, 0.7);
  transform: scale(0.96) translateY(6px);
  transition: transform var(--dur-slow) var(--ease-apple);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

/* Modal scrollbar — discreet */
.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

.modal-close {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  background: var(--bg-main);
  border: 1px solid var(--border-muted);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast) var(--ease-apple),
              background-color var(--dur-fast) var(--ease-apple);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface-2);
}

.modal-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
  padding-right: var(--sp-10);
  line-height: 1.3;
}

/* ============================================================
   CODE BLOCKS — token coloring without a library
   ============================================================ */
.code-wrap {
  margin-top: var(--sp-4);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border-muted);
  padding: var(--sp-2) var(--sp-4);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

pre {
  background: var(--bg-main);
  padding: var(--sp-5);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  color: #e4e4e7;
  overflow-x: auto;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Inline comment coloring in <pre> — avoids a JS library */
.c-comment  { color: #52525b; font-style: italic; }
.c-keyword  { color: #a78bfa; }
.c-string   { color: #6ee7b7; }
.c-type     { color: #93c5fd; }
.c-operator { color: #e4e4e7; }

/* ============================================================
   SCROLL-DRIVEN REVEAL
   Stagger delays applied via data-delay attribute in HTML
   ============================================================ */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--dur-slow) var(--ease-apple),
              transform var(--dur-slow) var(--ease-apple);
}

.reveal-on-scroll.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger: cards in grid get a small delay multiplier */
.reveal-delay-1 { transition-delay: 60ms; }
.reveal-delay-2 { transition-delay: 120ms; }
.reveal-delay-3 { transition-delay: 180ms; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  padding: var(--sp-8) 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-muted);
}

/* ============================================================
   RESPONSIVE
   Three explicit breakpoints — 375, 768, 1280
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.2rem;
  }

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

  .modal-content {
    padding: var(--sp-6);
    max-height: 90vh;
  }
}

/* Mobile */
@media (max-width: 480px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }

  nav {
    gap: 2px;
    width: 100%;
  }

  nav a {
    font-size: 0.8rem;
    padding: var(--sp-1) var(--sp-2);
  }

  .container {
    padding: 0 var(--sp-4);
  }

  .hero {
    padding: var(--sp-10) 0 var(--sp-8);
  }

  .hero h1 {
    font-size: 1.75rem;
    letter-spacing: -0.02em;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .hero-btns {
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .timeline {
    padding-left: var(--sp-5);
  }

  .modal-content {
    padding: var(--sp-5);
    border-radius: var(--radius-md);
  }
}
