/* Aly Salem portfolio.
   Layout: a 1180px page column. Projects sit in a three-up card grid grouped by discipline;
   each project page opens on a media stage (3D model first, then photos) above a 72ch reading column.
   One deliberate light theme: CAD renders and FEA plots read best on near-white.
   Accent is layout-fluid blue, the dye machinists brush on stock before scribing lines. */

@font-face { font-family: "Libre Franklin"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/libre-franklin-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Libre Franklin"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/libre-franklin-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Libre Franklin"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/libre-franklin-latin-600-normal.woff2") format("woff2"); }

:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --inset: #f0f2f5;
  --ink: #15181c;
  --ink-2: #3b4047;
  --muted: #5d646e;
  --faint: #8a919b;
  --line: #e2e5e9;
  --line-2: #cdd2d8;
  --accent: #1d4f9c;        /* layout-fluid blue */
  --accent-ink: #163d79;
  --accent-soft: #e8eef8;
  --note-bg: #fff5df;
  --note-line: #d99a00;
  --note-ink: #5c4500;
  --stage: #eef0f3;

  --font: "Libre Franklin", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --page: 1180px;
  --prose: 70ch;
  --gut: max(20px, env(safe-area-inset-left, 0px));
  --gut-r: max(20px, env(safe-area-inset-right, 0px));
  --r: 10px;
  --shadow-lift: 0 10px 28px rgba(21, 24, 28, .08), 0 2px 6px rgba(21, 24, 28, .05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; letter-spacing: -0.015em; }
p { margin: 0; }
.wrap { max-width: var(--page); margin-inline: auto; padding-left: var(--gut); padding-right: var(--gut-r); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 10px; z-index: 20; background: var(--ink); color: var(--surface); padding: 8px 12px; }

/* ---------- header ---------- */
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: rgba(251, 251, 252, .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 11; background: var(--bg); }
.site-header .wrap { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 8px 28px; flex-wrap: wrap; padding-block: 8px; }
.brand { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.nav { display: flex; flex-wrap: wrap; gap: 2px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.nav a:hover { color: var(--ink); background: var(--inset); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- buttons, tags ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 600 15px/1.2 var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12.5px; line-height: 1.3; padding: 4px 9px; border-radius: 999px; background: var(--inset); color: var(--ink-2); white-space: nowrap; }
.tag-3d { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* ---------- draft notes and placeholders (hidden when draft is false) ---------- */
.todo { padding: 10px 14px; border-left: 3px solid var(--note-line); background: var(--note-bg); color: var(--note-ink); font-size: 14.5px; line-height: 1.5; border-radius: 0 6px 6px 0; }
.todo-i { display: inline; padding: 1px 7px; background: var(--note-bg); color: var(--note-ink); font-size: 13.5px; border-radius: 4px; }
.ph { display: grid; place-content: center; gap: 4px; text-align: center; padding: 16px; background: repeating-linear-gradient(135deg, var(--inset) 0 12px, #f5f6f8 12px 24px); color: var(--muted); font-size: 14px; }
.ph strong { color: var(--ink-2); font-weight: 600; }
.ph-quiet { background: var(--inset); color: var(--faint); font-weight: 600; font-size: 15px; }

/* ---------- home ---------- */
.hero { padding-block: clamp(40px, 7vw, 88px) clamp(40px, 6vw, 72px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.hero .kicker { color: var(--muted); font-size: 15.5px; }
.hero h1 { margin-top: 10px; font-size: clamp(2.8rem, 6.4vw, 4.6rem); font-weight: 600; line-height: 1.0; letter-spacing: -0.03em; }
.hero .lede { margin-top: 20px; font-size: clamp(1.08rem, 1.5vw, 1.22rem); color: var(--ink-2); max-width: 36em; }
.hero .actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.hero .reach { margin-top: 18px; color: var(--muted); font-size: 14.5px; }
.hero-media { position: relative; border-radius: 14px; overflow: hidden; background: var(--stage); border: 1px solid var(--line); aspect-ratio: 4 / 3; max-width: 100%; }
.hero-media img { width: 100%; height: 100%; object-fit: cover; }
.hero-media img.whole { object-fit: contain; background: #fff; }
.hero-media model-viewer { width: 100%; height: 100%; }
.hero-media .cap { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; pointer-events: none; }
.hero-media .cap a { pointer-events: auto; background: rgba(255,255,255,.92); color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); }

.band { padding-block: clamp(40px, 6vw, 72px); border-top: 1px solid var(--line); }
.band-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.band-head h2 { font-size: clamp(1.45rem, 2.4vw, 1.8rem); font-weight: 600; }
.band-head a { font-size: 15px; font-weight: 600; text-decoration: none; }

/* ---------- resume ---------- */
.page-head .actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 10px; }
.pdf-frame { margin: 28px 0 clamp(48px, 7vw, 80px); max-width: 920px; aspect-ratio: 8.5 / 11; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--stage); box-shadow: var(--shadow-lift); }
.pdf-frame object { display: block; width: 100%; height: 100%; }
.pdf-fallback { height: 100%; display: grid; place-content: center; gap: 14px; text-align: center; color: var(--muted); padding: 24px; }
.pdf-mobile { display: none; margin: 24px 0 56px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink-2); }
.pdf-mobile .actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: box-shadow .18s, transform .18s, border-color .18s; min-width: 0; }
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--line-2); }
.card-thumb { aspect-ratio: 16 / 10; background: var(--stage); border-bottom: 1px solid var(--line); overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card-thumb img { transform: scale(1.02); }
.card-thumb .ph { height: 100%; }
/* No photo yet: the key result set like a note on a drawing sheet */
.spec { height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; padding: 18px 20px;
  background-color: var(--accent-soft);
  background-image: linear-gradient(rgba(29,79,156,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(29,79,156,.07) 1px, transparent 1px);
  background-size: 20px 20px; background-position: -1px -1px; }
.spec-cat { font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.spec-hl { font-size: clamp(1.15rem, 1.9vw, 1.4rem); font-weight: 600; line-height: 1.25; color: var(--accent-ink); letter-spacing: -0.01em; max-width: 18em; }
.card-body { padding: 16px 18px 18px; display: grid; gap: 8px; align-content: start; flex: 1; }
.card-meta { font-size: 13.5px; color: var(--muted); }
.card h3 { font-size: 1.12rem; font-weight: 600; line-height: 1.3; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card p { color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.card .hl { font-size: 14px; color: var(--ink); font-weight: 500; padding-top: 8px; border-top: 1px solid var(--line); }
.card .tags { margin-top: 4px; }
.grid-2 .card h3 { font-size: 1.3rem; }
.grid-2 .card p { font-size: 15.5px; }

/* ---------- projects index ---------- */
.page-head { padding-block: clamp(36px, 6vw, 64px) 8px; }
.page-head h1 { font-size: clamp(2.2rem, 4.6vw, 3.1rem); font-weight: 600; }
.page-head .lede { margin-top: 14px; max-width: 62ch; color: var(--ink-2); font-size: 1.1rem; }
.group { padding-block: 32px 8px; }
.group-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.group-head h2 { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); white-space: nowrap; }
.group-head::before { content: ""; width: 22px; height: 3px; background: var(--accent); border-radius: 2px; flex: none; }
.group-head .rule { flex: 1; height: 1px; background: var(--line); }
.group-head .count { color: var(--faint); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- project page ---------- */
.crumb { padding-top: 28px; font-size: 15px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.p-head { padding-block: 18px 28px; display: grid; gap: 14px; max-width: 900px; }
.p-head .cat { color: var(--accent); font-weight: 600; font-size: 14.5px; }
.p-head h1 { font-size: clamp(2.1rem, 4.4vw, 3.2rem); font-weight: 600; line-height: 1.08; }
.p-head .lede { font-size: clamp(1.08rem, 1.5vw, 1.2rem); color: var(--ink-2); max-width: 62ch; }
.p-head .meta { display: flex; flex-wrap: wrap; gap: 4px 22px; color: var(--muted); font-size: 15px; }
.p-head .meta b { color: var(--ink); font-weight: 600; }

.stage { display: grid; gap: 12px; }
.stage-view { position: relative; aspect-ratio: 16 / 9; max-width: 100%; border-radius: 12px; overflow: hidden; background: var(--stage); border: 1px solid var(--line); }
.stage-view > img { width: 100%; height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; }
.stage-view > img.cover { object-fit: cover; }
.stage-view > img.tall { object-fit: contain; background: var(--stage); }
.stage-view > .ph { height: 100%; }
.stage-view model-viewer { width: 100%; height: 100%; --poster-color: transparent; background: radial-gradient(120% 90% at 50% 35%, #ffffff 0%, var(--stage) 70%); }
.stage-view:fullscreen { border-radius: 0; border: 0; }
.mv-bar { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.mv-bar button { font: 600 13px/1 var(--font); color: var(--ink); background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.mv-bar button:hover { border-color: var(--ink); }
.mv-bar button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.mv-hint { position: absolute; left: 12px; bottom: 12px; font-size: 13px; color: var(--muted); background: rgba(255,255,255,.9); padding: 5px 9px; border-radius: 6px; pointer-events: none; }
.mv-badge { position: absolute; top: 12px; left: 12px; font-size: 12.5px; font-weight: 600; color: var(--note-ink); background: var(--note-bg); border: 1px solid var(--note-line); padding: 4px 9px; border-radius: 999px; }
.mv-load { position: absolute; inset: auto 0 0 0; height: 3px; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.stage-cap { color: var(--muted); font-size: 14.5px; max-width: 80ch; min-height: 1.5em; }

.rail { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.rail button { flex: none; width: 112px; aspect-ratio: 4 / 3; padding: 0; border-radius: 7px; overflow: hidden; border: 2px solid transparent; background: var(--stage); cursor: pointer; position: relative; }
.rail button[aria-current="true"] { border-color: var(--accent); }
.rail button img { width: 100%; height: 100%; object-fit: cover; }
.rail button.whole img { object-fit: contain; background: #fff; }
.rail .r3d { display: grid; place-content: center; gap: 2px; font: 600 13px/1.2 var(--font); color: var(--accent-ink); background: var(--accent-soft); }
.rail .r3d svg { margin-inline: auto; }
.rail .ph { height: 100%; font-size: 11.5px; padding: 6px; }

.summary { margin-top: 36px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.summary.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary > div { padding: 18px 20px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary dt { font-size: 13px; font-weight: 600; color: var(--accent); }
.summary dd { margin: 0; font-size: 15.5px; color: var(--ink); }

.prose { max-width: var(--prose); padding-block: 12px 8px; }
.prose h2 { margin: 44px 0 12px; font-size: 1.4rem; font-weight: 600; }
.prose p { margin: 0 0 14px; color: var(--ink-2); }
.prose ul { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); }
.prose li { margin-bottom: 8px; }
.prose li strong, .prose p strong { color: var(--ink); font-weight: 600; }
.prose .todo { margin: 12px 0; }
.sec .prose { padding-block: 0; }
.part { margin: clamp(48px, 7vw, 80px) 0 4px; padding-top: 28px; border-top: 1px solid var(--line-2); max-width: var(--prose); }
.part h2 { font-size: clamp(1.45rem, 2.4vw, 1.8rem); font-weight: 600; letter-spacing: -0.01em; }
.part p { margin-top: 6px; color: var(--muted); }
.part-rule { display: block; width: 28px; height: 3px; border-radius: 2px; background: var(--accent); margin-bottom: 14px; }
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 18px 0 8px; }
.figs.one { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
.figs.one img { aspect-ratio: auto; max-height: 520px; }
.figs figure { margin: 0; display: grid; gap: 8px; align-content: start; }
.figs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--stage); cursor: zoom-in; }
.figs img.whole { object-fit: contain; background: #fff; }
.figs figcaption { color: var(--muted); font-size: 14px; line-height: 1.5; }

.files { margin-top: 36px; }
.files h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 12px; }
.files ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-width: var(--prose); }
.files a { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--ink); }
.files a:hover { border-color: var(--accent); }
.files .kind { color: var(--muted); font-size: 14px; white-space: nowrap; }

.pager { margin-top: 64px; padding-block: 24px 8px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pager a { text-decoration: none; color: var(--ink); display: grid; gap: 2px; }
.pager a span { color: var(--muted); font-size: 14px; }
.pager a strong { font-size: 1.15rem; font-weight: 600; }
.pager a:hover strong { color: var(--accent); }
.pager .nx { text-align: right; }

/* ---------- experience / about ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; padding-block: 20px; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; padding-top: 0; }
.timeline .org { font-weight: 600; font-size: 1.08rem; }
.timeline .ttl { color: var(--ink-2); }
.timeline .where { color: var(--muted); font-size: 14.5px; }
.timeline .when { color: var(--muted); font-size: 14.5px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline .desc { grid-column: 1 / -1; color: var(--ink-2); font-size: 15.5px; max-width: 74ch; }
.timeline .desc a { font-weight: 600; white-space: nowrap; }
.rows { margin: 0; display: grid; }
.rows > div { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 4px 24px; padding-block: 13px; border-top: 1px solid var(--line); }
.rows > div:first-child { border-top: 0; padding-top: 0; }
.rows dt { color: var(--muted); font-size: 15px; }
.rows dd { margin: 0; }
.about-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: clamp(28px, 5vw, 56px); align-items: start; }
.about-grid .portrait { aspect-ratio: 4 / 5; border-radius: 12px; overflow: hidden; background: var(--stage); }
.about-grid .portrait img { width: 100%; height: 100%; object-fit: cover; }
.about-grid .portrait .ph { height: 100%; }
.bio { display: grid; gap: 14px; max-width: 64ch; color: var(--ink-2); font-size: 1.05rem; }
.contact-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 0; }
.contact-list dt { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.contact-list dd { margin: 0; overflow-wrap: anywhere; font-size: 16px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; }
.site-footer .wrap { padding-block: 26px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; color: var(--muted); font-size: 14.5px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.site-footer a { color: var(--muted); }

/* ---------- lightbox ---------- */
dialog.lb { border: 0; padding: 0; max-width: none; max-height: none; width: 100vw; height: 100vh; height: 100dvh; background: rgba(13, 15, 18, .94); color: #e9ecef; }
dialog.lb::backdrop { background: rgba(13, 15, 18, .6); }
.lb-inner { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); gap: 10px; }
.lb-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: #aab1ba; }
.lb-top button, .lb-nav button { font: 600 14px/1 var(--font); color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 9px 12px; cursor: pointer; }
.lb-img { min-height: 0; display: grid; place-items: center; }
.lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 4px; }
.lb-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.lb-bottom p { color: #cfd4da; font-size: 14.5px; max-width: 80ch; }
.lb-nav { display: flex; gap: 8px; flex: none; }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .pdf-frame { display: none; }
  .pdf-mobile { display: block; }
  .nav a { padding: 6px 7px; font-size: 14.5px; }
  body { font-size: 16px; }
  .grid, .grid-2 { grid-template-columns: 1fr; }
  .summary, .summary.n2 { grid-template-columns: 1fr; }
  .summary > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .stage-view { aspect-ratio: 4 / 3; }
  .figs { grid-template-columns: 1fr; }
  .rows > div { grid-template-columns: 1fr; }
  .timeline > li { grid-template-columns: 1fr; }
  .timeline .when { text-align: left; }
  .about-grid { grid-template-columns: 1fr; }
  .about-grid .portrait { max-width: 220px; }
  .contact-list { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .nx { text-align: left; }
  .mv-hint { display: none; }
  .mv-badge { top: auto; bottom: 12px; }
  .mv-bar button { padding: 7px 8px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
