/* Jay Rabe — portfolio.
   Calm, document-like, auto light/dark, no motion.
   Type: IBM Plex Sans (display + body) with IBM Plex Mono for labels and data,
   so the technical callouts read like annotations on an engineering drawing.
   Layout: justified-rows galleries, lead + support, hover captions. */

:root {
  --bg:        #fbfbf9;
  --surface:   #f3f2ee;
  --tile:      #eceae5;        /* gallery tile backing while images load */
  --text:      #17191e;
  --muted:     #63666d;
  --border:    #e3e1db;
  --accent:    #b8482b;        /* oxide rust; used sparingly */
  --maxw:      1080px;
  --measure:   64ch;           /* reading width for prose */
  --radius:    5px;
  --gap:       8px;            /* gallery gutter; justify() must match */
  --media-h:   360px;          /* normalized height for side-by-side media (bridge + control pair) */

  --font-display: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-body:    "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #111214;
    --surface: #191a1d;
    --tile:    #212327;
    --text:    #ececea;
    --muted:   #9a9ea6;
    --border:  #2a2c30;
    --accent:  #e07a52;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.6rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top nav ---- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.15rem; min-height: 3.25rem; }
.nav .brand { font-family: var(--font-mono); font-weight: 600; margin-right: auto; letter-spacing: 0.01em; }
.nav a { font-family: var(--font-mono); color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.nav a:hover { color: var(--text); text-decoration: none; }

/* ---- hero / thesis ---- */
.hero { padding: 5rem 0 3rem; border-bottom: 1px solid var(--border); }
.hero h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.2rem, 5.5vw, 3.4rem); line-height: 1.04; margin: 0 0 0.6rem; letter-spacing: -0.025em; }
.hero .role { font-size: 1.18rem; line-height: 1.45; margin: 0 0 2rem; max-width: var(--measure); color: var(--text); }
.hero .thesis { max-width: var(--measure); color: var(--muted); }
.hero .thesis p { margin: 0 0 1.1rem; }
.hero .thesis p:last-child { color: var(--text); font-weight: 500; }
.hero .contact { margin-top: 1.8rem; font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em; }
.hero .contact a { margin-right: 1.2rem; text-transform: uppercase; }
.hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 3rem; align-items: start; }
.headshot {
  width: 196px; height: 196px; border-radius: 50%;
  object-fit: cover; object-position: 50% 22%;   /* circle crop frames the face on the tighter headshot2 crop */
  border: 1px solid var(--border);
}
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; gap: 1.6rem; }
  .headshot { order: -1; width: 128px; height: 128px; }
}

/* ---- sections ---- */
section { padding: 4rem 0; border-bottom: 1px solid var(--border); }
.eyebrow {
  display: flex; align-items: center; gap: 0.65rem;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--accent); margin: 0 0 0.7rem;
}
.eyebrow::before { content: ""; width: 1.5rem; height: 1px; background: currentColor; opacity: 0.65; flex: 0 0 auto; }
section h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 0.6rem; letter-spacing: -0.018em; line-height: 1.12; }
.lede { color: var(--muted); max-width: var(--measure); margin: 0 0 2rem; font-size: 1.06rem; line-height: 1.55; }
.lede a { color: var(--accent); }

/* ---- bridge: stacked pieces, image beside caption, heights normalized ---- */
.bridge { display: grid; gap: 2.8rem; }
.bridge .piece { display: flex; gap: 30px; align-items: center; margin: 0; }
.bridge figcaption { flex: 1 1 0; font-size: 0.96rem; color: var(--muted); line-height: 1.62; margin: 0; }
.piece-media { display: block; padding: 0; }
.bridge .piece > .piece-media { flex: 0 0 auto; }
.piece-media.media { width: fit-content; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--tile); cursor: zoom-in; }
.piece-media.media img { position: static; display: block; height: var(--media-h); width: auto; max-width: 100%; }

/* video + still pair inside the positioner piece, matched to the same height */
.bridge .stack { display: flex; gap: var(--gap); height: var(--media-h); }
.bridge .stack .media { height: 100%; width: auto; }
.media {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: var(--tile); border: 1px solid var(--border); display: block; width: 100%;
  padding: 0; cursor: zoom-in;
}
.media > img, .media > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stack .media.video { aspect-ratio: 9 / 16; cursor: default; }
.stack .media.still { aspect-ratio: 3 / 4; }

@media (max-width: 760px) {
  .bridge .piece { flex-direction: column; align-items: stretch; gap: 0.9rem; }
  .piece-media.media img { height: auto; width: 100%; }
  .bridge .stack { height: auto; }
  .bridge .stack .media { height: auto; width: auto; flex: 1; }
}

/* ---- lead element: one larger piece carries the substantive caption ---- */
.lead { display: grid; grid-template-columns: 1.5fr 1fr; gap: 26px; align-items: center; margin-bottom: var(--gap); }
@media (max-width: 760px) { .lead { grid-template-columns: 1fr; } }
.lead .media { aspect-ratio: auto; }
.lead .media img { position: static; height: auto; }
.lead .caption b {
  display: block; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 0.55rem; font-weight: 500;
}
.lead .caption p { margin: 0; font-size: 0.98rem; color: var(--text); line-height: 1.6; }

/* ---- two-up pair (machine control): equal heights, flexible width ---- */
.pair { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.pair figure { margin: 0; flex: 0 1 auto; }
.pair .piece-media.media img { height: var(--media-h); width: auto; max-width: 100%; }
.pair figcaption { color: var(--muted); font-size: 0.94rem; line-height: 1.6; margin-top: 0.75rem; max-width: 42ch; }
.pair figcaption b { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); font-weight: 500; display: inline-block; margin-bottom: 0.2rem; }
@media (max-width: 760px) {
  .pair { display: block; }
  .pair figure { margin-bottom: 1.8rem; }
  .pair .piece-media.media img { height: auto; width: 100%; }
}

/* ---- prose section (the team) ---- */
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.15rem; color: var(--muted); }
.prose p:first-child { font-size: 1.08rem; color: var(--text); }

/* ---- justified support gallery ---- */
.gallery { display: flex; flex-wrap: wrap; gap: var(--gap); }
.tile {
  position: relative; background: var(--tile); border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: flex-end; cursor: zoom-in;
  border: 1px solid var(--border); padding: 0; text-align: left;
  /* width/height set by justify() in JS */
}
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cap {
  position: relative; width: 100%; padding: 1.5rem 0.75rem 0.7rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.74));
  color: #fff; font-size: 0.78rem; line-height: 1.42;
  opacity: 0; transform: translateY(6px); transition: 0.2s ease;
}
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; transform: none; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .tile .cap { opacity: 1; transform: none; } }  /* touch: always show */

/* ---- closing / contact ---- */
.closing .cta { max-width: var(--measure); font-size: 1.2rem; line-height: 1.5; margin: 0 0 1.3rem; }
.closing .contact-line { color: var(--muted); margin: 0 0 1.5rem; }
.cta-buttons { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.btn {
  display: inline-block; padding: 0.75rem 1.3rem;
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.07em;
  border: 1px solid var(--accent); border-radius: var(--radius); color: var(--accent);
}
.btn:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }

/* ---- footer ---- */
footer { padding: 3rem 0 4rem; color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.03em; }
footer a { margin-right: 1.2rem; text-transform: uppercase; }

/* ---- lightbox (brief fade only) ---- */
.lb { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.92); padding: 2rem; cursor: zoom-out; opacity: 0; transition: opacity 0.12s ease; }
.lb.open { display: flex; opacity: 1; }
.lb img { max-width: 100%; max-height: 100%; border-radius: var(--radius); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tile .cap, .lb { transition: none; }
}
