/* Shared styles for every page. Moved out of index.html so the case-study pages match. */
/* Layout: one 1080px column. On wide screens each section reads like a drawing title block,
   its label in a narrow rail on the left and the content on the right. */
:root {
  --bg: #13110f;
  --panel: #1c1916;
  --line: #2e2a26;
  --text: #eeeae6;
  --soft: #cdc6bf;
  --muted: #9b928a;
  --forge: #e8642c;
  --cool: #3fb6c8;
  /* Heated metal: straw yellow through orange to cherry red. Used on primary buttons and the header edge. */
  --heat: linear-gradient(100deg, #f2b33d 0%, #ea7a2b 52%, #dc4f2a 100%);
  --on-heat: #1d0c04;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --gutter: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 17px/1.65 var(--sans); }
a { color: var(--text); text-decoration-color: var(--forge); text-underline-offset: 3px; }
a:hover { color: var(--forge); }
:focus-visible { outline: 2px solid var(--forge); outline-offset: 3px; border-radius: 3px; }
img { max-width: 100%; display: block; }

/* Logo glitch: FERRARO to IRON and back. Right-aligned in a fixed width so LABS doesn't move. */
.glitch { position: relative; display: inline-block; white-space: nowrap; text-align: right; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; left: 0; right: 0; top: 0; opacity: 0; pointer-events: none;
}
.glitch.on::before { opacity: .8; color: var(--forge); transform: translate(-2px, 0); clip-path: var(--c1); }
.glitch.on::after { opacity: .8; color: var(--cool); transform: translate(2px, 0); clip-path: var(--c2); }

/* Header */
header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: rgba(19, 17, 15, .9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--heat); opacity: .45; }
.bar {
  max-width: 1080px; margin: 0 auto; padding-block: 14px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.logo { font: 700 16px var(--mono); letter-spacing: .1em; text-decoration: none; }
.logo:hover { color: var(--text); }
nav { display: flex; gap: 22px; font: 500 13px var(--mono); letter-spacing: .04em; }
nav a { text-decoration: none; color: var(--muted); }
nav a:hover { color: var(--text); }

/* Sections */
main {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
section { padding-block: 88px; border-bottom: 1px solid var(--line); }
section:last-child { border-bottom: 0; }
.kicker { font: 500 12px var(--mono); letter-spacing: .18em; color: var(--forge); text-transform: uppercase; margin: 0 0 14px; }

h1, h2, h3 { font-family: var(--display); text-wrap: balance; }
h1 { font-size: clamp(44px, 8vw, 84px); font-weight: 800; font-stretch: 120%; line-height: 1; letter-spacing: -.01em; margin: 0 0 24px; }
h2 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; font-stretch: 112%; line-height: 1.15; margin: 0 0 32px; }
h3 { font-size: 20px; font-weight: 700; font-stretch: 112%; line-height: 1.25; margin: 0; }
.lede { font-size: 20px; color: var(--soft); max-width: 36em; margin: 0 0 32px; }
.meta { font: 500 13px var(--mono); color: var(--muted); margin: 6px 0 16px; }
.note { font-size: 14px; color: var(--muted); margin: 16px 0 0; }

.hero { padding-block: 104px 96px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 56px; align-items: center; }
/* Headshot in a slim heat-gradient frame */
.portrait { position: relative; width: 240px; align-self: start; }
/* LinkedIn-style header: one headline item per line, location under it */
.headline { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; font-size: 19px; line-height: 1.4; color: var(--soft); }
.headline li { display: flex; gap: 12px; align-items: baseline; }
.headline li::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 1px; background: var(--heat); transform: translateY(-2px); }
.where { font: 500 13px var(--mono); color: var(--muted); letter-spacing: .04em; margin: 0 0 30px; }
.about p { font-size: 18px; color: var(--soft); max-width: 40em; margin: 0 0 16px; }
.about p:first-child { margin-top: 6px; }
.about p:last-child { margin-bottom: 0; }
.frame { padding: 2px; border-radius: 8px; background: var(--heat); transform-origin: 12% 10%; }
.frame img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 4px solid var(--bg); }
/* Hover gag: the photo swings on a nail near its top-left corner and an arm lifts it level (see script) */
.fixer { position: absolute; left: 0; overflow: hidden; pointer-events: none; display: none; }

/* Buttons */
.buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block; padding: 11px 20px; border: 1px solid var(--line); border-radius: 4px;
  font: 500 14px var(--mono); letter-spacing: .04em; text-decoration: none; color: var(--text);
  transition: border-color .2s, box-shadow .3s, filter .3s;
}
.btn:hover { border-color: var(--forge); color: var(--text); }
.btn.primary { background: var(--heat); border-color: transparent; color: var(--on-heat); }
.btn.primary:hover { color: var(--on-heat); filter: brightness(1.06); box-shadow: 0 6px 24px -8px rgba(232, 100, 44, .65); }

/* Experience */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 28px 30px; }
.role { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.dates { font: 500 13px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.card ul { margin: 0; padding-left: 20px; color: var(--soft); }
.card li { margin-bottom: 8px; }
.card li::marker { color: var(--forge); }

/* Projects */
.project { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; padding-block: 44px; border-top: 1px solid var(--line); }
.project:first-of-type { border-top: 0; padding-top: 0; }
.project:last-of-type { padding-bottom: 0; }
.project p { margin: 0 0 12px; color: var(--soft); }
.project .meta { color: var(--muted); }
figure { margin: 0 0 18px; }
figure:last-child { margin-bottom: 0; }
figure img { border-radius: 4px; border: 1px solid var(--line); background: #fff; }
figcaption { font: 500 12px var(--mono); color: var(--muted); margin-top: 8px; letter-spacing: .02em; }
/* Live 3D arm (arm.js). The static render shows until the canvas is ready, and stays if WebGL fails. */
.arm-stage {
  position: relative; aspect-ratio: 4 / 3; max-width: 100%; overflow: hidden; border-radius: 4px; border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 35%, #2a241f 0%, var(--panel) 55%, var(--bg) 100%);
}
.arm-stage img { width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; background: none; }
.arm-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .6s; touch-action: none; }
.arm-stage.live .arm-canvas { opacity: 1; }
.arm-stage.live img { visibility: hidden; }
figcaption a { color: var(--muted); }
.placeholder {
  aspect-ratio: 4 / 3; max-width: 100%; border: 1px dashed #4a433d; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  font: 500 13px var(--mono); color: var(--muted);
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tags span { font: 500 12px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 28px 32px; }
.skills > div { border-top: 1px solid var(--line); padding-top: 18px; }
.skills h3 { font: 500 12px var(--mono); color: var(--forge); letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px; }
.skills p { margin: 0; color: var(--soft); }

footer {
  max-width: 1080px; margin: 0 auto; padding-block: 32px 48px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  font: 500 12px var(--mono); color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--line);
}
footer .fine { flex-basis: 100%; margin: 4px 0 0; font: 400 12px/1.6 var(--sans); max-width: 70em; }
footer .fine a { color: var(--muted); }
footer .fine strong { color: var(--soft); font-weight: 500; }
footer .fine + .fine { margin-top: 0;
}

/* Title-block rail on wide screens */
@media (min-width: 900px) {
  .rail { display: grid; grid-template-columns: 150px minmax(0, 1fr); column-gap: 48px; }
  .rail > .kicker { margin-top: 12px; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  section { padding-block: 60px; }
  .hero { padding-block: 56px 60px; grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .portrait { width: 132px; order: -1; margin-top: 0; }
  .lede { font-size: 18px; }
  .project { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  nav { gap: 16px; }
  .card { padding: 22px 20px; }
}
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .bar { flex-direction: column; align-items: stretch; gap: 10px; padding-block: 12px; }
  /* Phones: nothing short should break onto a second line. */
  nav { flex-wrap: nowrap; justify-content: space-between; gap: 6px; font-size: 12px; letter-spacing: 0; }
  .buttons { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .btn { text-align: center; overflow-wrap: anywhere; }
  h1 { font-size: 8.4vw; }
  h2 { font-size: 22px; font-stretch: 106%; }
  h3 { font-size: 17px; font-stretch: 104%; }
  .card h3 { font-size: min(16px, 4.25vw); font-stretch: 100%; }
  footer .line { font-size: min(12px, 3.6vw); }
  .headline { font-size: 16px; }
  .meta .sep { display: none; }
  .meta > span, footer .line { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
}

/* Case-study pages */
.case-hero { padding-block: 72px 56px; }
.crumb { display: inline-block; font: 500 13px var(--mono); color: var(--muted); text-decoration: none; margin-bottom: 26px; }
.crumb:hover { color: var(--forge); }
.case-title { font-size: clamp(38px, 6vw, 64px); }
.prose { min-width: 0; }
.prose h2 { margin-bottom: 18px; }
.prose h3 { margin: 28px 0 10px; }
.prose p, .prose li { font-size: 18px; color: var(--soft); max-width: 40em; }
.prose p { margin: 0 0 16px; }
.prose ul { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 10px; }
.prose li::marker { color: var(--forge); }
.prose strong { color: var(--text); font-weight: 500; }
.prose figure { margin: 26px 0; max-width: 44em; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; max-width: 44em; }
.fig-grid figure { margin: 0; }
.prose .back { margin-top: 36px; }
.more { display: inline-block; margin-top: 16px; font: 500 13px var(--mono); letter-spacing: .04em; color: var(--forge); text-decoration: none; }
.more:hover { text-decoration: underline; }

/* Outside of engineering */
.personal-intro { font-size: 18px; color: var(--soft); max-width: 40em; margin: 0 0 28px; }.prose figure.narrow { max-width: 30em; }

/* Lines that must wrap split evenly, never leaving one word alone on the last line. */
.headline li, figcaption, .meta, .note { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* Phone size for the case-study title. Kept last so it beats .case-title above. */
@media (max-width: 560px) {
  .case-title { font-size: 7vw; }
}

/* Joint sliders under the case-study arm (built by arm.js in slider mode) */
.arm-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 28px; margin-top: 14px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.arm-controls[hidden] { display: none; }
.ctl { display: grid; grid-template-columns: 96px minmax(0, 1fr) 46px; align-items: center; gap: 12px; }
.ctl label { font: 500 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ctl input[type="range"] { width: 100%; margin: 0; accent-color: var(--forge); cursor: pointer; }
.ctl output { font: 500 13px var(--mono); color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.arm-controls .btn { grid-column: 1 / -1; justify-self: start; margin-top: 4px; }
.arm-stage[data-mode="sliders"] .arm-canvas { touch-action: auto; }
@media (max-width: 560px) {
  .arm-controls { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .arm-controls .btn { justify-self: stretch; }
}
/* Case-study CAD figures: hub and socket stacked on the left, the assembly larger on the right,
   spanning both. Every render sits centered on white in its own frame. */
.cad-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.75fr); grid-template-rows: auto auto; gap: 18px; max-width: 44em; margin: 26px 0; }
.prose .cad-grid figure { margin: 0; display: flex; flex-direction: column; min-width: 0; }
.cad-hub { grid-column: 1; grid-row: 1; }
.cad-socket { grid-column: 1; grid-row: 2; }
.cad-asm { grid-column: 2; grid-row: 1 / span 2; }
.cad-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; object-position: center; background: #fff; }
.cad-asm img { flex: 1 1 auto; min-height: 0; height: 100%; aspect-ratio: auto; }
@media (max-width: 560px) {
  .cad-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  .cad-hub { grid-column: 1; grid-row: 1; }
  .cad-socket { grid-column: 2; grid-row: 1; }
  .cad-asm { grid-column: 1 / span 2; grid-row: 2; }
  .cad-asm img { height: auto; aspect-ratio: 4 / 3; }
  .cad-grid figcaption { font-size: 11px; }
}