/* ============================================
   Design tokens — M3-aligned dark theme (default)
   Light theme auto-enabled for systems that prefer it
   ============================================ */

/* ── Light theme: applied when system prefers light ── */
@media (prefers-color-scheme: light) {
  :root {
    /* Colors — light surface palette */
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    --border: #a855f7;
    --border-subtle: rgba(0, 0, 0, 0.12);
    --border-strong: rgba(0, 0, 0, 0.18);

    --accent-primary: #a855f7;
    --accent-secondary: #0d9488;
    --accent-tertiary: #d97706;

    --text-primary: rgba(0, 0, 0, 0.87);
    --text-secondary: rgba(0, 0, 0, 0.60);
    --text-hinting: rgba(0, 0, 0, 0.40);
    --text-on-accent: #ffffff;

    --error: #dc2626;
    --success: #16a34a;

    /* Shadows — slightly softer on light surface */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
}

/* ── Dark theme: explicit preference (overrides default for parity) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0f;
    --surface: #111827;
    --surface-elevated: #1f2937;
    --border: #7c3aed;
    --border-subtle: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.18);

    --accent-primary: #a855f7;
    --accent-secondary: #14b8a6;
    --accent-tertiary: #f59e0b;

    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-hinting: rgba(255, 255, 255, 0.40);
    --text-on-accent: #ffffff;

    --error: #ef4444;
    --success: #22c55e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }

  /* ── Default (dark) — used when no system preference ── */
  :root {
    /* Colors */
    --bg: #0a0a0f;
    --surface: #111827;
    --surface-elevated: #1f2937;
    --border: #7c3aed;
    --border-subtle: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.18);

    --accent-primary: #a855f7;
    --accent-secondary: #14b8a6;
    --accent-tertiary: #f59e0b;

    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.60);
    --text-hinting: rgba(255, 255, 255, 0.40);
    --text-on-accent: #ffffff;

    --error: #ef4444;
    --success: #22c55e;

    /* Spacing (4px base) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-xxl: 32px;
    --space-xxxl: 48px;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;

    --text-display: clamp(36px, 6vw, 56px);
    --text-headline: clamp(24px, 4vw, 36px);
    --text-title: clamp(20px, 3vw, 28px);
    --text-body: clamp(14px, 2.5vw, 16px);
    --text-label: clamp(12px, 2vw, 14px);
  }

/* ============================================
   Reset & base
   ============================================ */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Layout
   ============================================ */

.wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-xxl) var(--space-lg);
  width: 100%;
}

/* ============================================
   Header / Hero
   ============================================ */

.site-header {
  text-align: center;
  padding: var(--space-xxl) 0 var(--space-xxl);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xxl);
}

.site-header .logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.site-header .logo svg {
  width: 32px;
  height: 32px;
  color: var(--accent-primary);
}

.site-header .brand {
  font-size: var(--text-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-primary);
  font-weight: 600;
}

.site-header h1 {
  font-size: var(--text-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.site-header p {
  font-size: var(--text-body);
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ============================================
   Navigation
   ============================================ */

.nav {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: var(--space-xxl);
}

.nav a {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: var(--text-label);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s ease;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
  background: rgba(20, 184, 166, 0.08);
  outline: none;
}

/* ============================================
   Section heading
   ============================================ */

.section-head {
  margin-bottom: var(--space-lg);
}

.section-head h2 {
  font-size: var(--text-title);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.section-head p {
  font-size: var(--text-body);
  color: var(--text-secondary);
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.card.featured {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

.card h2 {
  font-size: var(--text-title);
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.card p {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-md);
}

.card p:last-child {
  margin-bottom: 0;
}

/* ============================================
   Typography helpers
   ============================================ */

h1 { font-size: var(--text-headline); font-weight: 700; line-height: 1.2; margin-bottom: var(--space-lg); color: var(--text-primary); }
h2 { font-size: var(--text-title); font-weight: 700; line-height: 1.25; margin-bottom: var(--space-md); color: var(--text-primary); }
h3 { font-size: var(--text-body); font-weight: 600; line-height: 1.3; margin-bottom: var(--space-sm); color: var(--text-primary); }

p { font-size: var(--text-body); color: var(--text-secondary); line-height: 1.7; margin-bottom: var(--space-md); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

a:hover { color: var(--accent-secondary); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  color: var(--text-secondary);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-label);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
  background: rgba(20, 184, 166, 0.08);
  outline: none;
}

.btn.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-on-accent);
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: #9333ea;
  border-color: #9333ea;
  color: #fff;
}

/* ============================================
   Button row
   ============================================ */

.btn-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-lg);
}

/* ============================================
   Status pills
   ============================================ */

.status-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: var(--space-xl);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-label);
  color: var(--text-secondary);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
  margin-top: var(--space-xxxl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: var(--text-label);
  color: var(--text-hinting);
}

.site-footer p {
  margin-bottom: var(--space-xs);
}

.site-footer p:last-child {
  margin-bottom: 0;
  color: var(--text-hinting);
  font-size: var(--text-hinting);
}

/* ============================================
   Back link (about / stack pages)
   ============================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--accent-primary);
  text-decoration: none;
  font-size: var(--text-label);
  font-weight: 500;
  margin-bottom: var(--space-xl);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.back-link:hover {
  border-bottom-color: var(--accent-primary);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
  .wrapper {
    padding: var(--space-lg) var(--space-md);
  }

  .site-header {
    padding: var(--space-xl) 0 var(--space-lg);
  }

  .site-header h1 {
    font-size: var(--text-headline);
  }

  .nav {
    flex-direction: column;
    align-items: center;
  }

  .card {
    padding: var(--space-lg);
  }
}

/* ============================================
   Page: Stack — service cards grid
   ============================================ */

.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.service-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.service-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.service-card .icon.nginx { background: #009639; }
.service-card .icon.fastapi { background: #009688; }
.service-card .icon.pg { background: #336791; }

.service-card .name {
  font-size: var(--text-title);
  font-weight: 700;
  color: var(--text-primary);
}

.service-card .desc {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: 1.6;
}

.service-card .tech {
  font-size: var(--text-label);
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

/* ============================================
   Page: About — two-column grid
   ============================================ */

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.about-section {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
}

.about-section h2 {
  font-size: var(--text-title);
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.about-section p {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-md);
}

.about-section p:last-child {
  margin-bottom: 0;
}
