:root {
  --bg: #0c0b0b;
  --surface: #141212;
  --surface-alt: #1b1717;
  --stroke: #2b2424;
  --text: #f6f2f2;
  --muted: #b8aaaa;
  --accent: #d3152b;
  --accent-bright: #ff2f4b;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, .brand-text {
  font-family: "Fraunces", serif;
  letter-spacing: -0.02em;
}

a {
  color: var(--text);
}

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

.nav-shell {
  background: rgba(12, 11, 11, 0.9);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
}

.nav-link {
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

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

.nav-shell .form-select {
  width: auto;
  min-width: 7.5rem;
  white-space: nowrap;
}

.nav-shell .form-select option {
  white-space: nowrap;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.brand-badge {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--accent-bright);
}

.brand-text {
  color: var(--text);
}

.navbar-brand {
  color: var(--text);
}

.hero-card,
.section-card,
.panel-card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 1.8rem;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.section-card {
  padding: 1.5rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.section-card:hover {
  border-color: rgba(211, 21, 43, 0.4);
  box-shadow: 0 18px 35px rgba(211, 21, 43, 0.15);
  transform: translateY(-2px);
}

.pill {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent-bright);
}

.pill-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.text-muted {
  color: var(--muted) !important;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-accent:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  color: #fff;
  box-shadow: 0 8px 20px rgba(211, 21, 43, 0.3);
  transform: translateY(-1px);
}

.btn-outline-dark {
  border-color: var(--stroke);
  color: var(--text);
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn-outline-dark:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow: 0 8px 18px rgba(211, 21, 43, 0.18);
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.section-title {
  position: relative;
  display: inline-block;
  padding-bottom: 0.4rem;
}

.section-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 48px;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  animation: underlineGrow 0.8s ease forwards;
}

@keyframes underlineGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.bg-grid,
.bg-code,
.bg-noise,
.bg-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-grid {
  background-image:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 120px),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 120px);
  opacity: 0.05;
  z-index: 0;
}

.bg-code {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='520' height='320'><text x='20' y='50' fill='%23d3152b' fill-opacity='0.22' font-family='monospace' font-size='14'>const api = await fetch('/projects')</text><text x='20' y='90' fill='%23d3152b' fill-opacity='0.18' font-family='monospace' font-size='12'>SELECT * FROM skills ORDER BY level;</text><text x='20' y='130' fill='%23d3152b' fill-opacity='0.18' font-family='monospace' font-size='12'>docker build -t samuel/portfolio .</text><text x='20' y='170' fill='%23d3152b' fill-opacity='0.18' font-family='monospace' font-size='12'>git push origin main</text><text x='20' y='210' fill='%23d3152b' fill-opacity='0.18' font-family='monospace' font-size='12'>POST /api/testimonials</text><text x='20' y='250' fill='%23d3152b' fill-opacity='0.18' font-family='monospace' font-size='12'>runtime: python</text></svg>");
  opacity: 0.05;
  background-repeat: repeat;
  background-size: 520px 320px;
  z-index: 0;
}

.bg-noise {
  background-image: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 3px);
  opacity: 0.35;
  z-index: 0;
}

.bg-vignette {
  background: radial-gradient(circle at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.6) 100%),
    radial-gradient(circle at 10% 50%, rgba(211, 21, 43, 0.12), transparent 45%),
    radial-gradient(circle at 90% 50%, rgba(211, 21, 43, 0.12), transparent 45%);
  z-index: 0;
}

.edge-chips {
  position: fixed;
  top: 22vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1;
  pointer-events: auto;
}

.edge-left {
  left: clamp(12px, 2vw, 24px);
}

.edge-right {
  right: clamp(12px, 2vw, 24px);
}

.edge-chips .chip {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(20, 18, 18, 0.45);
}

.edge-chips .chip:hover {
  border-color: rgba(211, 21, 43, 0.45);
  color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 18px rgba(211, 21, 43, 0.18);
}

.ascii-corner {
  position: fixed;
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.1em;
  z-index: 1;
}

.ascii-top-left {
  top: 12px;
  left: 12px;
}

.ascii-bottom-right {
  bottom: 12px;
  right: 12px;
}

.content-wrap {
  position: relative;
  z-index: 2;
}

.footer-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-trigger {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--muted);
}

.footer-trigger:hover {
  color: var(--accent-bright);
}

.project-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: start;
}

.project-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--stroke);
}

.project-body {
  min-width: 0;
}

.stat-card {
  background: var(--surface-alt);
  border-color: rgba(255, 255, 255, 0.1);
  padding: 1.2rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-size: 1.05rem;
  margin-top: 0.35rem;
}

.terminal-card {
  background: #0f0f12;
  border: 1px solid rgba(255, 47, 75, 0.25);
  font-family: "Courier New", monospace;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.terminal-dots {
  display: flex;
  gap: 0.4rem;
}

.terminal-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.terminal-title {
  font-size: 0.85rem;
  color: var(--muted);
}

.terminal-content p {
  margin-bottom: 0.35rem;
}

.terminal-label {
  color: var(--accent-bright);
}

.terminal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 6, 0.7);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.2s ease;
}

.terminal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.terminal-modal {
  width: min(560px, 90vw);
  background: #0f0f12;
  border: 1px solid rgba(255, 47, 75, 0.35);
  border-radius: 14px;
  padding: 1.2rem;
  color: var(--text);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.terminal-modal .terminal-header {
  margin-bottom: 0.75rem;
}

.terminal-modal h2 {
  font-size: 1rem;
  margin: 0;
}

.terminal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}

.terminal-close:hover {
  color: var(--accent-bright);
}

.terminal-body {
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.75rem;
}

.terminal-line {
  margin-bottom: 0.35rem;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.6rem;
  font-family: "Courier New", monospace;
}

.terminal-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
}

.terminal-prompt {
  color: var(--accent-bright);
}

.fade-up {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.8s ease forwards;
}

.fade-delay-1 { animation-delay: 0.1s; }
.fade-delay-2 { animation-delay: 0.2s; }
.fade-delay-3 { animation-delay: 0.3s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 992px) {
  .edge-chips,
  .ascii-corner {
    display: none;
  }
}

@media (max-width: 768px) {
  .project-card {
    grid-template-columns: 1fr;
  }

  .project-thumb {
    height: 200px;
  }
}
