/* ─── TOKENS ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --border:    #1e1e1e;
  --border-hi: #2e2e2e;
  --text:      #6b6b6b;
  --muted:     #ffffff;
  --accent:    #c8a96e;
  --accent2:   #4a7c6f;
  --ff-display: 'Cormorant Garamond', Georgia, serif;
  --ff-mono:    'DM Mono', 'Courier New', monospace;
  --ff-body:    'Outfit', sans-serif;
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:    cubic-bezier(0.7, 0, 0.84, 0);
  --section-pad-x: clamp(1.25rem, 5vw, 4rem);
  --section-pad-y: clamp(3.5rem, 8vw, 7rem);
}

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

/* FIX 1: Lock overflow on BOTH html AND body — body alone is not enough */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  /* FIX 2: Contain width to viewport so nothing can push it wider */
  max-width: 100vw;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }
ul { list-style: none; }

/* FIX 3: Ensure every element respects the column it's in */
* { min-width: 0; }

/* ─── NOISE OVERLAY ───────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.025;
}

/* ─── SCROLLBAR ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

/* ════════════════════════════════════════════
   NAV
════════════════════════════════════════════ */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--section-pad-x);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
  min-height: 64px;
  /* FIX 4: Nav must never exceed viewport */
  width: 100%;
  max-width: 100vw;
}
nav.scrolled { border-bottom-color: var(--border); }

.nav-logo {
  font-family: var(--ff-display);
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 0.02em;
  color: var(--accent);
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  gap: 2.5rem;
  align-items: center;
}
.nav-links a {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
  /* FIX 5: Remove nowrap — allow wrapping if needed, or hide on mobile via media query */
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); }
.nav-cta {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent) !important;
  border: 1px solid var(--accent);
  padding: 0.5rem 1.2rem;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s !important;
  white-space: nowrap;
}
.nav-cta:hover { background: var(--accent); color: var(--bg) !important; }

/* ─── HAMBURGER ─────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  margin-right: -8px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}
.hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.mobile-menu {
  display: none;
  position: fixed;
  inset: 0;
  top: 64px;
  background: rgba(10,10,10,0.98);
  z-index: 800;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  font-family: var(--ff-display);
  font-size: clamp(1.6rem, 8vw, 2.5rem);
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.04em;
  padding: 0.5rem 1rem;
  transition: color 0.2s;
  text-align: center;
}
.mobile-menu a:hover { color: var(--accent); }

/* ════════════════════════════════════════════
   HERO
════════════════════════════════════════════ */
.hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  /* FIX 6: Contain hero — it holds the photo which can cause bleed */
  overflow: hidden;
  width: 100%;
}
.hero-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8rem var(--section-pad-x) 6rem;
  position: relative;
  z-index: 2;
  /* FIX 7: Prevent text content pushing layout */
  overflow: hidden;
}
.hero-eyebrow {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 0.2s forwards;
}
.hero-eyebrow::before {
  content: '';
  display: block;
  width: 2.5rem;
  height: 1px;
  background: var(--accent);
  flex-shrink: 0;
}
.hero-name {
  color: var(--muted);
  font-family: var(--ff-display);
  font-size: clamp(3rem, 5.5vw, 6rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: fadeUp 0.9s var(--ease-out) 0.35s forwards;
  /* FIX 8: Long names must wrap, not push width */
  word-break: break-word;
  overflow-wrap: break-word;
}
.hero-name em {
  font-style: italic;
  color: var(--accent);
}
.hero-title {
  font-family: var(--ff-display);
  font-size: clamp(1.1rem, 2.2vw, 2rem);
  font-weight: 300;
  color: var(--muted);
  margin-bottom: 2rem;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeUp 0.9s var(--ease-out) 0.5s forwards;
}
.hero-desc {
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  color: var(--muted);
  max-width: 42ch;
  line-height: 1.75;
  margin-bottom: 2.5rem;
  font-weight: 300;
  opacity: 0;
  animation: fadeUp 0.9s var(--ease-out) 0.65s forwards;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeUp 0.9s var(--ease-out) 0.8s forwards;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.85rem 1.75rem;
  border-radius: 2px;
  font-weight: 500;
  transition: background 0.2s, transform 0.15s;
  /* FIX 9: Allow wrapping on tiny screens rather than overflowing */
  white-space: normal;
  text-align: center;
}
.btn-primary:hover { background: #d9bb80; transform: translateY(-1px); }
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.85rem 1.75rem;
  border: 1px solid var(--border-hi);
  border-radius: 2px;
  transition: border-color 0.2s, color 0.2s;
  white-space: normal;
  text-align: center;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }

.hero-stats {
  margin-top: 3rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeUp 0.9s var(--ease-out) 1s forwards;
}
.stat-num {
  font-family: var(--ff-display);
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  display: block;
}
.stat-label {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.3rem;
  display: block;
}

/* Hero right — photo */
.hero-right {
  position: relative;
  overflow: hidden;
  background: #080c10;
}
.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  opacity: 0;
  animation: imgReveal 1.2s var(--ease-out) 0.4s forwards;
}
.hero-right::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--bg) 0%, transparent 35%),
              linear-gradient(to top, var(--bg) 0%, transparent 20%);
}
.hero::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--border-hi) 20%, var(--border-hi) 80%, transparent);
  z-index: 3;
}

/* Floating cert badge */
.badge-floating {
  position: absolute;
  bottom: 2rem;
  /* FIX 10: Use left+right so badge stays inside container on all screen sizes */
  left: 1rem;
  right: 1rem;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 1.2s forwards;
  /* Sit at right edge on large screens */
  max-width: fit-content;
  margin-left: auto;
}
.badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 8px #4caf5088;
  flex-shrink: 0;
}
.badge-text {
  font-family: var(--ff-mono);
  font-size: clamp(0.6rem, 1.2vw, 0.7rem);
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1.4;
}
.badge-text strong { color: var(--accent); }

/* ════════════════════════════════════════════
   SECTION SHARED
════════════════════════════════════════════ */
section {
  padding: var(--section-pad-y) var(--section-pad-x);
  /* FIX 11: Every section is capped to viewport */
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.section-label {
  font-family: var(--ff-mono);
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}
.section-label::before {
  content: '';
  display: block;
  width: 2rem;
  height: 1px;
  background: var(--accent);
  flex-shrink: 0;
}
.section-title {
  color: var(--muted);
  font-family: var(--ff-display);
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
  /* FIX 12: Prevent huge display text from overflowing */
  word-break: break-word;
  overflow-wrap: break-word;
}
.section-title em { font-style: italic; color: var(--accent); }

/* ════════════════════════════════════════════
   SERVICES
════════════════════════════════════════════ */
#services { background: var(--bg); border-top: 1px solid var(--border); }
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
  background: var(--border);
  border: 1.5px solid var(--border);
  margin-top: 3rem;
  /* FIX 13: Grid must not exceed its parent */
  width: 100%;
}
.service-card {
  background: var(--surface);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  position: relative;
  overflow: hidden;
  transition: background 0.3s;
  /* FIX 14: Cards respect column width */
  min-width: 0;
  word-break: break-word;
}
.service-card:hover { background: #161616; }
.service-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-out);
}
.service-card:hover::after { transform: scaleX(1); }
.service-icon {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  display: block;
  color: var(--muted);
}
.service-name {
  color: var(--muted);
  font-family: var(--ff-display);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 400;
  margin-bottom: 0.65rem;
  letter-spacing: 0.01em;
}
.service-desc {
  font-size: clamp(0.82rem, 1.4vw, 0.9rem);
  color: var(--muted);
  line-height: 1.7;
  font-weight: 300;
}
.service-tags {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tag {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--border);
  padding: 0.22rem 0.55rem;
  border-radius: 1px;
}

/* ════════════════════════════════════════════
   RESULTS / METRICS
════════════════════════════════════════════ */
#results {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.results-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  width: 100%;
}
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  width: 100%;
}
.metric-card {
  background: var(--bg);
  padding: clamp(1.25rem, 2.5vw, 2rem);
  min-width: 0;
}
.metric-card--wide {
  grid-column: span 2;
}
.metric-num {
  font-family: var(--ff-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
  display: block;
  margin-bottom: 0.5rem;
}
.metric-label {
  font-size: clamp(0.75rem, 1.3vw, 0.85rem);
  color: var(--muted);
  font-weight: 300;
}
.results-text p {
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  color: var(--muted);
  line-height: 1.85;
  font-weight: 300;
  margin-bottom: 1.25rem;
}
.results-text p:last-child { margin-bottom: 0; }
.cert-list {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.cert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-family: var(--ff-mono);
  font-size: clamp(0.65rem, 1.2vw, 0.72rem);
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.5;
}
.cert-item::before {
  content: '✓';
  color: var(--accent);
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

/* ════════════════════════════════════════════
   PORTFOLIO
════════════════════════════════════════════ */
#portfolio { background: var(--bg); border-top: 1px solid var(--border); }
.portfolio-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1.25rem;
  width: 100%;
}
/* FIX 15: The 12-column grid is the biggest overflow offender on mobile.
   Use auto-sizing columns that collapse naturally. On desktop we use
   the :nth-child span overrides below. */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5px;
  background: var(--border);
  width: 100%;
}
.project-card {
  background: var(--surface);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  min-width: 0;
}
.project-card:nth-child(1) { grid-column: span 7; }
.project-card:nth-child(2) { grid-column: span 5; }
.project-card:nth-child(3) { grid-column: span 6; }
.project-card:nth-child(4) { grid-column: span 6; }
.project-card:nth-child(5) { grid-column: span 3; }
.project-img {
  width: 100%;
  height: clamp(160px, 22vw, 300px);
  object-fit: cover;
  transition: transform 0.6s var(--ease-out), filter 0.4s;
  filter: grayscale(20%);
  display: block;
}
.project-card:first-child .project-img { height: clamp(200px, 26vw, 340px); }
.project-card:hover .project-img {
  transform: scale(1.04);
  filter: grayscale(0%);
}
.project-info {
  padding: clamp(0.85rem, 2vw, 1.5rem);
  border-top: 1px solid var(--border);
}
.project-cat {
  font-family: var(--ff-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.project-name {
  font-family: var(--ff-display);
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-bottom: 0.25rem;
  word-break: break-word;
}
.project-desc {
  font-size: clamp(0.72rem, 1.2vw, 0.82rem);
  color: var(--muted);
  font-weight: 300;
  word-break: break-word;
}
.project-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,10,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}
.project-card:hover .project-overlay { opacity: 1; }
.overlay-link {
  font-family: var(--ff-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.6rem 1.4rem;
  border-radius: 2px;
  transition: background 0.2s;
}
.overlay-link:hover { background: var(--accent); color: var(--bg); }

/* ════════════════════════════════════════════
   SKILLS
════════════════════════════════════════════ */
#skills {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.skills-layout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  margin-top: 2.5rem;
  width: 100%;
}
.skill-group-title {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-hi);
}
.skill-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.skill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.skill-name {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 400;
}
.skill-level {
  font-family: var(--ff-mono);
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.skill-bar {
  height: 2px;
  background: var(--border-hi);
  border-radius: 1px;
  overflow: hidden;
}
.skill-fill {
  height: 100%;
  background: linear-gradient(to right, var(--accent2), var(--accent));
  border-radius: 1px;
  transform-origin: left;
  animation: barGrow 1s var(--ease-out) forwards;
}
@keyframes barGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ════════════════════════════════════════════
   EXPERIENCE TIMELINE
════════════════════════════════════════════ */
#experience { background: var(--bg); border-top: 1px solid var(--border); }
.timeline {
  margin-top: 3.5rem;
  position: relative;
  width: 100%;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 8px; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--accent), transparent);
}
.timeline-item {
  padding-left: 3rem;
  margin-bottom: 3rem;
  position: relative;
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: 0;
  top: 8px;
  width: 21px; height: 21px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.timeline-dot::after {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-meta {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.timeline-date {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  /* FIX 16: Remove nowrap from timeline date — can wrap on mobile */
  white-space: normal;
}
.timeline-company {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1.4;
  /* FIX 17: Company names must wrap */
  word-break: break-word;
}
.timeline-role {
  font-family: var(--ff-display);
  color: var(--muted);
  font-size: clamp(1.1rem, 2.5vw, 1.7rem);
  font-weight: 400;
  margin-bottom: 0.85rem;
  word-break: break-word;
}
.timeline-bullets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.timeline-bullet {
  gap: 0.65rem;
  font-size: clamp(0.82rem, 1.5vw, 0.9rem);
  color: var(--muted);
  font-weight: 300;
  line-height: 1.65;
  /* FIX 18: Bullet text must wrap, not overflow */
  word-break: break-word;
  overflow-wrap: break-word;
}
.timeline-bullet::before {
  content: '→';
  color: var(--accent);
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}
strong.highlight { color: var(--accent); font-weight: 500; }

/* ════════════════════════════════════════════
   AI EDGE
════════════════════════════════════════════ */
#ai-edge {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ai-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
  width: 100%;
}
/* FIX 19: The terminal is the #1 horizontal overflow culprit.
   The &nbsp; spaces + long unbreakable strings escape the container.
   Force it to stay inside with overflow-x: auto on the block itself,
   and word-break on text content. */
.ai-terminal {
  background: #0d1117;
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  font-family: var(--ff-mono);
  font-size: clamp(0.65rem, 1.2vw, 0.78rem);
  line-height: 1.8;
  color: #7ee787;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  /* Use padding on a wrapper div via ::before trick */
  display: flex;
  flex-direction: column;
}
.ai-terminal::before {
  content: '● ● ●';
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  padding-bottom: 0;
}
pre.ai-terminal {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  padding-top: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.ai-terminal .comment { color: var(--muted); }
.ai-terminal .keyword { color: #ff7b72; }
.ai-terminal .string { color: #a5d6ff; }
.ai-terminal .value { color: var(--accent); }
.ai-card {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  padding: 1.1rem 1.25rem;
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
}
.ai-card-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 0.1rem; }
.ai-card-text {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  /* FIX 20: Card text must not overflow */
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}
.ai-card-text strong { color: var(--text); display: block; font-size: 0.9rem; margin-bottom: 0.2rem; }

/* ════════════════════════════════════════════
   CONTACT
════════════════════════════════════════════ */
#contact {
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  width: 100%;
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label {
  font-family: var(--ff-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-group input,
.form-group textarea,
.form-group select {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 16px; /* always 16px — prevents iOS zoom */
  padding: 0.75rem 1rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
  /* FIX 21: Inputs must never escape their container */
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 120px; }
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b6b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.form-group select option { background: var(--surface); }

.contact-info { display: flex; flex-direction: column; gap: 2rem; min-width: 0; }
.contact-info-intro {
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  color: var(--muted);
  line-height: 1.85;
  font-weight: 300;
}
.contact-links { display: flex; flex-direction: column; gap: 0.85rem; }
.contact-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  transition: color 0.2s;
  padding: 0.2rem 0;
  min-height: 44px;
  /* FIX 22: Long email/URLs must wrap */
  word-break: break-all;
  overflow-wrap: break-word;
}
.contact-link:hover { color: var(--accent); }
.contact-link-icon {
  width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--border-hi);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.form-success {
  display: none;
  background: rgba(74, 124, 111, 0.15);
  border: 1px solid var(--accent2);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  font-family: var(--ff-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: #7ecfc0;
}

/* ════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════ */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem var(--section-pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}
.footer-logo {
  font-family: var(--ff-display);
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--accent);
}
.footer-copy {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  /* FIX 23: Long copyright text must wrap */
  word-break: break-word;
}
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a {
  font-family: var(--ff-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
  padding: 0.3rem 0;
}
.footer-links a:hover { color: var(--accent); }

/* ════════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes imgReveal {
  from { opacity: 0; clip-path: inset(0 100% 0 0); }
  to   { opacity: 1; clip-path: inset(0 0% 0 0); }
}

/* Scroll-reveal */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }

/* ════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .hero-left {
    padding: 7rem 1.75rem 3rem;
    order: 2;
  }
  .hero-right {
    order: 1;
    height: 55vw;
    min-height: 280px;
    max-height: 480px;
  }
  .hero-right::after {
    background: linear-gradient(to top, var(--bg) 0%, transparent 35%),
                linear-gradient(to bottom, var(--bg) 0%, transparent 15%);
  }
  .hero::before { display: none; }

  .services-grid { grid-template-columns: 1fr 1fr; }
  .results-layout { grid-template-columns: 1fr; gap: 2.5rem; }

  /* Portfolio: switch to simple 2-col; kill the 12-col span system */
  .portfolio-grid { grid-template-columns: 1fr 1fr; }
  .project-card { grid-column: span 1 !important; }
  .project-img,
  .project-card:first-child .project-img { height: 200px; }

  .skills-layout { grid-template-columns: 1fr 1fr; gap: 2rem; }
  .ai-layout,
  .contact-layout { grid-template-columns: 1fr; gap: 2.5rem; }

  footer { gap: 0.5rem; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — LARGE MOBILE (≤ 768px)
════════════════════════════════════════════ */
@media (max-width: 768px) {
  .hero-right {
    height: 70vw;
    min-height: 240px;
  }
  .hero-stats { gap: 1.5rem; }

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

  .portfolio-grid { grid-template-columns: 1fr; }
  .project-img,
  .project-card:first-child .project-img { height: 220px; }

  .skills-layout { grid-template-columns: 1fr; }

  .contact-layout { grid-template-columns: 1fr; }
  .contact-layout > div:first-child { order: 2; }
  .contact-layout > div:last-child  { order: 1; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 480px)
════════════════════════════════════════════ */
@media (max-width: 480px) {
  .hero-left { padding-top: 6rem; padding-left: 1.25rem; padding-right: 1.25rem; }
  .hero-right { height: 80vw; min-height: 220px; }
  .hero-right::after {
    background: linear-gradient(to top, var(--bg) 0%, transparent 45%),
                linear-gradient(to bottom, var(--bg) 0%, transparent 12%);
  }

  /* Buttons full-width and stacked */
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .btn-primary,
  .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .hero-stats { gap: 1rem; }
  .stat-num { font-size: 1.6rem; }

  /* Badge: full-width bottom strip */
  .badge-floating {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 1rem;
    max-width: calc(100% - 1.5rem);
    margin-left: 0;
  }

  /* Tighten section padding on tiny screens */
  section { padding-left: 1.25rem; padding-right: 1.25rem; }

  .section-label::before { width: 1.2rem; }

  /* Single-column metrics on very small phones */
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card--wide { grid-column: span 1; }
  .metric-card--wide { grid-column: span 1; }

  /* Timeline: less indent */
  .timeline-item { padding-left: 2.25rem; margin-bottom: 2rem; }

  /* AI terminal: smaller text, still contained */
  .ai-terminal { font-size: 0.62rem; padding: 0.85rem; }

  /* Footer stacked */
  footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .footer-links { justify-content: center; }
  .footer-copy { text-align: center; }
}

/* ════════════════════════════════════════════
   REDUCED MOTION
════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero-eyebrow,
  .hero-name,
  .hero-title,
  .hero-desc,
  .hero-actions,
  .hero-stats,
  .hero-img,
  .badge-floating { opacity: 1; }
  .reveal { opacity: 1; transform: none; }
}
