/* ==========================================================
   David Dwyer — Engineering Portfolio
   Bold dark theme. Edit the tokens below to restyle the site.
   ========================================================== */
:root {
  --bg: #0a0b0d;
  --bg-2: #111317;
  --surface: #16191e;
  --surface-2: #1d2127;
  --line: #2a2f37;
  --text: #eeece8;
  --muted: #9ba1a9;
  --faint: #6b717a;
  --accent: #ff5533;        /* signal red-orange */
  --accent-soft: rgba(255, 85, 51, 0.12);
  --plate: #ffffff;         /* light backdrop for white-background CAD shots */
  --radius: 14px;
  --maxw: 1200px;
  --font-display: "Archivo", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, video { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--accent); color: #fff; }

.wrap { width: min(var(--maxw), 100% - 32px); margin-inline: auto; }

/* ---------- Type ---------- */
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.6rem, 7vw, 5.4rem); font-weight: 800; }
h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; }
h3 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.eyebrow { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--accent); }
.lead { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--muted); max-width: 62ch; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 11, 13, 0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { text-decoration: none; color: var(--muted); font-size: 0.95rem; transition: color .2s; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px;
  font-weight: 600; font-size: 0.96rem; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: transform .15s, background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-1px); border-color: #3a414b; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff6a4d; border-color: #ff6a4d; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 72px 0 40px; overflow: hidden; }
.hero::before { /* faint engineering grid */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; opacity: 0.35;
  mask-image: radial-gradient(ellipse 80% 70% at 70% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 70% 40%, #000 30%, transparent 75%);
}
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.hero h1 .accent { display: block; }
.hero .lead { margin: 22px 0 30px; }
.hero-viewer { position: relative; aspect-ratio: 1 / 1; }
.hero-viewer model-viewer { width: 100%; height: 100%; --poster-color: transparent; }
.viewer-hint { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; color: var(--faint); pointer-events: none; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 28px 22px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-family: var(--font-display); font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 800; line-height: 1; margin-bottom: 8px; }
.stat span { color: var(--muted); font-size: 0.92rem; }

/* ---------- Sections ---------- */
section { padding: 96px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 44px; flex-wrap: wrap; }
.section-head p { max-width: 48ch; margin: 0; }

/* ---------- Project cards ---------- */
.projects { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; transition: border-color .25s, transform .25s;
}
.card:hover { border-color: #3d444f; transform: translateY(-3px); }
.card:hover .card-media img { transform: scale(1.035); }
.card-media { aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-2); }
.card-media.plate { background: var(--plate); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card-media.plate img { object-fit: contain; padding: 18px; }
.card-body { padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body p { color: var(--muted); margin: 0; font-size: 0.97rem; }
.card-meta { color: var(--accent); }
.card-arrow { margin-top: auto; padding-top: 8px; font-weight: 600; font-size: 0.93rem; }
.card-arrow::after { content: " →"; transition: margin .2s; }
.card:hover .card-arrow::after { margin-left: 4px; }
.span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.skill { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.skill h3 { margin-bottom: 14px; }
.skill ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; color: var(--muted); }
.skill li::before { content: "▸ "; color: var(--accent); }

/* ---------- Timeline / honors ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: grid; grid-template-columns: 110px 1fr; gap: 18px; padding: 18px 0; border-top: 1px solid var(--line); }
.list-rows li:last-child { border-bottom: 1px solid var(--line); }
.list-rows .when { color: var(--faint); font-family: var(--font-mono); font-size: 0.8rem; padding-top: 3px; }
.list-rows b { display: block; font-weight: 600; }
.list-rows span { color: var(--muted); font-size: 0.95rem; }

/* ---------- Contact ---------- */
.contact { text-align: center; background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%); border-top: 1px solid var(--line); }
.contact h2 { font-size: clamp(2.2rem, 6vw, 4.2rem); margin-bottom: 18px; }
.contact .lead { margin: 0 auto 30px; }
.contact .btn-row { justify-content: center; }

footer { padding: 28px 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.88rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ==========================================================
   Case-study pages
   ========================================================== */
.cs-hero { padding: 64px 0 36px; }
.back { display: table; color: var(--muted); text-decoration: none; margin-bottom: 26px; font-size: 0.95rem; }
.back:hover { color: var(--text); }
.cs-hero h1 { font-size: clamp(2.4rem, 6vw, 4.6rem); }
.cs-hero .lead { margin-top: 18px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 40px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { padding: 18px 20px 18px 0; }
.facts div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.facts dt { color: var(--faint); margin-bottom: 6px; }
.facts dd { margin: 0; font-weight: 500; }

.viewer-frame {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #232830 0%, #121418 70%);
}
.viewer-frame model-viewer { width: 100%; height: clamp(360px, 62vh, 640px); --poster-color: transparent; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); flex-wrap: wrap; }
.viewer-tabs { display: flex; gap: 8px; }
.viewer-tabs button { font: 600 0.85rem var(--font-body); color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.viewer-tabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.cs-section { padding: 72px 0; border-top: 1px solid var(--line); }
.cs-grid { display: grid; grid-template-columns: 300px 1fr; gap: 56px; }
.cs-grid > header h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.cs-grid > header .mono { color: var(--accent); display: block; margin-bottom: 12px; }
.prose { max-width: 70ch; }
.prose p, .prose li { color: #cfd2d6; }
.prose ul { padding-left: 1.1em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--text); }

.callouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 30px 0 8px; }
.callout { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.callout b { font-family: var(--font-display); font-size: 1.9rem; display: block; line-height: 1; margin-bottom: 8px; }
.callout span { color: var(--muted); font-size: 0.92rem; }

/* Iteration table */
.iter { width: 100%; border-collapse: collapse; margin: 18px 0 8px; font-size: 0.95rem; }
.iter th, .iter td { text-align: left; padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.iter th { color: var(--faint); font-weight: 500; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.iter td:first-child { font-weight: 600; white-space: nowrap; color: var(--text); }
.iter td { color: #cfd2d6; }
.table-scroll { overflow-x: auto; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-top: 34px; }
.gallery figure { margin: 0; grid-column: span 4; }
.gallery figure.w6 { grid-column: span 6; }
.gallery figure.w8 { grid-column: span 8; }
.gallery figure.w12 { grid-column: span 12; }
.gallery .shot { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); cursor: zoom-in; padding: 0; }
.gallery .shot.tall { aspect-ratio: 3 / 4; }
.gallery .shot.wide { aspect-ratio: 16 / 9; }
.gallery .shot.plate { background: var(--plate); }
.gallery .shot img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.gallery .shot.plate img { object-fit: contain; padding: 14px; }
.gallery .shot:hover img { transform: scale(1.03); }
.gallery figcaption { color: var(--muted); font-size: 0.88rem; padding: 10px 2px 0; line-height: 1.45; }

.video-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; }
.video-frame video { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; }
.video-frame.portrait video { aspect-ratio: auto; }
.video-frame.portrait { max-width: 380px; }
.media-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; align-items: start; }
.media-row figure { margin: 0; }
.media-row figcaption { color: var(--muted); font-size: 0.88rem; padding-top: 10px; }

.next-project { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 44px 0; border-top: 1px solid var(--line); text-decoration: none; }
.next-project h3 { font-size: clamp(1.6rem, 4vw, 2.6rem); }
.next-project:hover h3 { color: var(--accent); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(5, 6, 8, 0.94); display: none; align-items: center; justify-content: center; padding: 24px; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.lightbox .lb-cap { position: absolute; left: 24px; right: 24px; bottom: 22px; text-align: center; color: var(--muted); font-size: 0.92rem; }
.lightbox button { position: absolute; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 999px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-viewer { max-width: 560px; width: 100%; margin: 0 auto; }
  .span-7, .span-5, .span-6, .span-4 { grid-column: span 12; }
  .skills { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 40px; }
  .cs-grid { grid-template-columns: 1fr; gap: 22px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .callouts { grid-template-columns: 1fr; }
  .gallery figure, .gallery figure.w6, .gallery figure.w8 { grid-column: span 6; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  section { padding: 68px 0; }
  .cs-section { padding: 56px 0; }
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: flex-start; gap: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 0; width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .gallery figure, .gallery figure.w6, .gallery figure.w8 { grid-column: span 12; }
  .media-row { grid-template-columns: 1fr; }
  .list-rows li { grid-template-columns: 1fr; gap: 4px; }
  .lb-prev, .lb-next { top: auto; bottom: 64px; transform: none; }
}
@media (max-width: 720px) { .hero-viewer { aspect-ratio: 4 / 3; } .hero { padding-top: 48px; } }
