/* ==========================================================================
   Eamon McGleenan — shared portfolio styles
   Loaded by index.html and every project page (after each page's own
   <style>, so these rules win on shared components: nav, footer, headers,
   figures). Page-specific components stay in the page itself.
   ========================================================================== */

:root {
  /* colour */
  --ink: #15201c;
  --fg: #1d2622;
  --fg-secondary: #4f5a55;
  --fg-muted: #7d8681;
  --bg: #f7f6f2;
  --bg-card: #ffffff;
  --bg-sunken: #efede7;
  --accent: #1f5646;
  --accent-strong: #163f33;
  --accent-light: #e5eee9;
  --warm: #b8622f;
  --border: #e3e1d9;
  --border-strong: #cfccc2;

  /* type */
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* layout */
  --wide: 1120px;
  --space: 1.5rem;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(21, 32, 28, .05);
  --shadow: 0 1px 2px rgba(21, 32, 28, .04), 0 8px 24px -12px rgba(21, 32, 28, .14);
  --shadow-lg: 0 2px 4px rgba(21, 32, 28, .05), 0 22px 48px -20px rgba(21, 32, 28, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
::selection { background: #cfe2d9; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ── NAV (shared by every page) ─────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247, 246, 242, .82);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s, box-shadow .25s;
}
nav.scrolled { border-bottom-color: var(--border); box-shadow: 0 6px 20px -16px rgba(21,32,28,.35); }
nav .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: .8rem var(--space);
  display: flex; justify-content: space-between; align-items: center; gap: 1.5rem;
}
nav .name {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--serif); font-weight: 500; font-size: 1.08rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em; white-space: nowrap;
}
nav .name .mark {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: .72rem; font-weight: 500; letter-spacing: .04em;
}
nav ul { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; }
nav ul a {
  display: block; padding: .4rem .7rem; border-radius: 999px;
  color: var(--fg-secondary); font-size: .84rem; font-weight: 500;
  text-decoration: none; letter-spacing: .01em;
  transition: color .2s, background .2s;
}
nav ul a:hover { color: var(--ink); background: rgba(21,32,28,.05); }
nav ul a.active { color: var(--accent); background: var(--accent-light); }

@media (max-width: 860px) {
  nav .inner { flex-wrap: wrap; row-gap: .35rem; padding-bottom: .5rem; }
  nav ul {
    width: 100%; overflow-x: auto; scrollbar-width: none;
    margin: 0 calc(var(--space) * -1); padding: 0 var(--space);
    width: calc(100% + var(--space) * 2);
  }
  nav ul::-webkit-scrollbar { display: none; }
  /* fade the right edge so it's obvious the links scroll */
  nav ul.overflows {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent);
  }
  nav ul.overflows.at-end { -webkit-mask-image: none; mask-image: none; }
  nav ul a { white-space: nowrap; font-size: .8rem; padding: .35rem .6rem; }
}
@media (max-width: 600px) { :root { --space: 1rem; } }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .62rem 1.05rem; border-radius: 999px;
  font-family: var(--sans); font-size: .86rem; font-weight: 500; line-height: 1;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .12s ease-out;
  -webkit-tap-highlight-color: transparent;
}
/* feedback on press, not release (instant, small) */
.btn:active { transform: scale(.97); transition-duration: .08s; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--bg-card); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); }

/* quiet icon links (Scholar / GitHub / LinkedIn) */
.icon-links { display: flex; gap: .25rem; align-items: center; }
.icon-link {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--fg-secondary); transition: color .15s, background .15s, transform .12s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.icon-link svg { width: 19px; height: 19px; }
.icon-link:hover { color: var(--accent); background: var(--accent-light); }
.icon-link:active { transform: scale(.94); }

.link-arrow {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .85rem; font-weight: 500; color: var(--accent); text-decoration: none;
}
.link-arrow svg { width: 13px; height: 13px; transition: transform .2s var(--ease); }
@media (hover: hover) { .link-arrow:hover svg { transform: translateX(3px); } }

/* ── FOOTER (shared) ────────────────────────────────────────────────────── */
body > footer {
  max-width: none; margin: 0; padding: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  display: block; font-size: .84rem; color: var(--fg-muted);
}
body > footer .inner {
  max-width: var(--wide); margin: 0 auto; padding: 2.25rem var(--space);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
}
body > footer .links { display: flex; gap: 1.1rem; flex-wrap: wrap; }
body > footer a { color: var(--fg-secondary); text-decoration: none; font-weight: 500; }
body > footer a:hover { color: var(--accent); }

/* ── ARTICLE PAGES ──────────────────────────────────────────────────────── */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200;
  background: linear-gradient(90deg, var(--accent), #3f8a70);
  transform: scaleX(0); transform-origin: 0 50%; will-change: transform;
}
.article { padding-top: 2.5rem; }
.article-header { margin-bottom: 2rem; }
.article-header .eyebrow {
  display: inline-block; margin-bottom: .9rem;
  font-size: .72rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-light);
  padding: .3rem .65rem; border-radius: 999px;
}
.article-header h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2rem, 4.6vw, 2.9rem); line-height: 1.12; letter-spacing: -.025em;
  color: var(--ink); text-wrap: balance;
}
.article-header .subtitle { font-size: 1.05rem; line-height: 1.65; color: var(--fg-secondary); text-wrap: pretty; }
.breadcrumb a { color: var(--accent); }

.article-cover {
  margin: 0 0 2.75rem;
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.article-cover img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: top center; }
.article-cover figcaption {
  padding: .7rem 1rem; font-size: .8rem; color: var(--fg-muted);
  border-top: 1px solid var(--border); background: var(--bg-card);
}


.prose h2, .article h2 { letter-spacing: -.015em; color: var(--ink); }

/* screenshots and figures */
.screenshot, .article figure:not(.article-cover) {
  border-radius: var(--radius);
}
.screenshot img, .article figure:not(.article-cover) img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

/* callouts and tables: soften */
.callout { border-radius: 0 var(--radius) var(--radius) 0; }
.metric-table { border-radius: var(--radius-sm); overflow: hidden; }

/* bug fixes on existing components */
.file-tree { white-space: pre; }
a.clone-btn, .prose a.clone-btn, .article a.clone-btn { color: #fff !important; border-bottom: none !important; }
a.clone-btn:hover { color: #fff !important; }

/* more projects (end of each article) */
.more {
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}
.more .inner { max-width: var(--wide); margin: 0 auto; padding: 3.25rem var(--space) 3.5rem; }
.more h2 {
  font-family: var(--serif); font-weight: 400; font-size: 1.6rem; letter-spacing: -.015em;
  color: var(--ink); margin-bottom: 1.5rem;
}
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
@media (max-width: 860px) { .more-grid { grid-template-columns: 1fr; } }

/* ── PROJECT CARD (home + "more projects") ─────────────────────────────── */
.card {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: inherit; text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
  .card:hover .card-media img { transform: scale(1.035); }
}
.card:active { transform: scale(.985); transition-duration: .1s; }
.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-sunken); border-bottom: 1px solid var(--border); }
.card-media img {
  width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block;
  transition: transform .6s var(--ease);
}
.card-media .badge {
  position: absolute; top: .75rem; left: .75rem;
  font-size: .68rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(255,255,255,.94); color: var(--accent);
  padding: .3rem .6rem; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.card-body { padding: 1.25rem 1.35rem 1.4rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.card-body h3 {
  font-family: var(--serif); font-weight: 500; font-size: 1.22rem; line-height: 1.3;
  letter-spacing: -.01em; color: var(--ink); text-wrap: balance;
}
.card-body h3 a { color: inherit; text-decoration: none; }
.card-body h3 a::after { content: ""; position: absolute; inset: 0; }
.card-body p { font-size: .9rem; line-height: 1.65; color: var(--fg-secondary); }
.card-body .stat-line {
  font-size: .84rem; color: var(--ink); background: var(--accent-light);
  border-radius: var(--radius-sm); padding: .55rem .75rem; line-height: 1.5;
}
.card-body .stat-line strong { color: var(--accent); }
.card-body .thanks { font-size: .8rem; color: var(--fg-muted); font-style: italic; line-height: 1.55; }
.card-foot { margin-top: auto; padding-top: .5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.card-foot .actions { display: flex; gap: 1rem; flex-wrap: wrap; position: relative; z-index: 2; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; }
.tags span {
  font-size: .7rem; font-weight: 500; letter-spacing: .02em;
  padding: .2rem .55rem; border-radius: 999px;
  background: var(--bg-sunken); color: var(--fg-secondary);
}
.card { position: relative; }
.card.compact .card-body h3 { font-size: 1.08rem; }
.card.compact .card-body p { font-size: .85rem; }

/* ── LIGHTBOX ───────────────────────────────────────────────────────────────
   Opens out of the thumbnail and closes back into it. Positions are driven by
   springs in site.js; drag the image down to dismiss. */
.lightbox { position: fixed; inset: 0; z-index: 500; display: none; touch-action: none; }
.lightbox.open { display: block; }
.lightbox .scrim { position: absolute; inset: 0; background: rgb(10, 15, 13); opacity: 0; }
.lightbox .lb-img {
  position: fixed; left: 0; top: 0; margin: 0;
  transform-origin: 0 0; will-change: transform, opacity;
  border-radius: var(--radius-sm); box-shadow: 0 30px 80px rgba(0,0,0,.45);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
}
.lightbox .lb-img.dragging { cursor: grabbing; }
.lightbox .lb-cap {
  position: fixed; left: 50%; bottom: max(1.25rem, env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(70ch, calc(100% - 2rem));
  color: #d8ddd9; font-size: .88rem; text-align: center; line-height: 1.5; opacity: 0;
}
.lightbox .lb-close {
  position: fixed; top: max(.75rem, env(safe-area-inset-top)); right: .75rem;
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 0; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; opacity: 0;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  transition: background .15s, transform .1s ease-out;
}
.lightbox .lb-close svg { width: 18px; height: 18px; }
.lightbox .lb-close:hover { background: rgba(255,255,255,.24); }
.lightbox .lb-close:active { transform: scale(.94); }
.lightbox .lb-close:focus-visible { outline-color: #fff; }

/* ── REVEAL ───────────────────────────────────────────────────────────────
   Only hidden once JS has marked the page (html.js), so content never stays
   invisible if the script fails. */
.js .reveal { opacity: 0; transform: translateY(10px); transition: opacity .45s var(--ease), transform .45s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* Reduced motion: keep gentle opacity changes, drop movement */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { transform: none; transition: opacity .2s linear; }
  .btn:active, .card:active, .icon-link:active, .clone-btn:active { transform: none; }
  .card, .card-media img { transition: box-shadow .2s, border-color .2s; }
  .card:hover, .card:hover .card-media img { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  nav { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom-color: var(--border); }
  .lightbox .lb-close { -webkit-backdrop-filter: none; backdrop-filter: none; background: #2b322f; }
}
@media (prefers-contrast: more) {
  nav { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 1px solid var(--fg-muted); }
  .prose a { text-decoration-color: currentColor; }
}
@media print {
  nav, .progress, .more, .lightbox { display: none !important; }
}

/* keep the PFv tool's outline buttons (the shared .btn rule loads later) */
.btn.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.btn-outline:hover { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* phones: wide tables and the clone box scroll inside themselves, not the page */
@media (max-width: 600px) {
  .metric-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .clone-url { max-width: 100%; overflow-x: auto; }
  .clone-url code, .clone-url span { min-width: 0; }
}

/* keyboard focus for zoomable images */
[data-zoomable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* published-paper banner at the top of a research write-up */
.paper-banner {
  margin-top: 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 1.15rem 1.35rem; box-shadow: var(--shadow-sm);
}
.paper-banner .label {
  display: block; font-size: .7rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .35rem;
}
.paper-banner .title { font-family: var(--serif); font-size: 1.02rem; line-height: 1.4; color: var(--ink); margin: 0; }
.paper-banner .journal { font-size: .8rem; color: var(--fg-muted); margin: .35rem 0 0; }
.paper-banner .btn { flex-shrink: 0; color: #fff; }
@media (max-width: 700px) {
  .paper-banner { flex-direction: column; align-items: flex-start; }
}
