/* =============================================================================
   style.css — everything that isn't a token. Consumes src/css/tokens.css.
   Goal: match the old Squarespace look (proxima-nova, generous whitespace,
   clean blue links, gold accent) as a baseline.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* --- Layout helpers --------------------------------------------------------
   The old site centered a 1060px "canvas" with 50px padding and laid content
   out LEFT-aligned within it (not in a narrow centered column). .wrap and
   .wrap-wide both use that frame; long-form text is constrained with .measure. */
.wrap,
.wrap-wide {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap { max-width: var(--frame-width); }
.wrap-wide { max-width: var(--wide-width); }
/* A narrow readable measure for long-form text, left-aligned within the frame. */
.measure { max-width: var(--content-width); }

main { padding-block: var(--space-7); }

/* --- Typography ------------------------------------------------------------ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-heading);
  line-height: var(--leading-heading);
  margin: 0 0 var(--space-4);
  font-weight: var(--weight-light);   /* old site headings were thin/light */
}
/* The page/post title (h1) is large and thin, like the old .main h1
   (42px, weight 100 → Montserrat 300, no tracking). */
h1 { font-size: var(--text-h1); font-weight: var(--weight-light); letter-spacing: 0; }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
h4 { font-size: var(--text-h4); }
h5 { font-size: var(--text-h5); }
h6 { font-size: var(--text-h6); text-transform: uppercase; letter-spacing: 0.04em; }

p { margin: 0 0 var(--space-5); }

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

img { max-width: 100%; height: auto; display: block; }

hr { border: 0; border-top: 1px solid var(--color-rule); margin: var(--space-7) 0; }

/* --- Header / nav ----------------------------------------------------------
   Mirrors the old site: nav on the LEFT, site title on the RIGHT, both near the
   top. Title is 28px uppercase, letter-spaced, weight 400 (#2e2e2e). Nav is
   14px uppercase with .1em tracking. (Values pulled from export/css/site.css:
   .siteTitle h1 and .main-nav-font.) */
.site-header {
  padding-block: var(--space-7) 0;
}
.site-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.site-brand {
  order: 2;                       /* title block to the right */
  flex: 0 0 auto;                 /* keep its size; don't let it get squeezed */
  text-align: right;
}
.site-title {
  display: block;
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  line-height: 1;
  color: #2e2e2e;
}
.site-title:hover { text-decoration: none; color: #2e2e2e; }
/* "composer, musician, data scientist" — old .logo-subtitle: 15px, #999. */
.site-subtitle {
  margin: 0.75em 0 0;
  font-size: 15px;
  font-weight: 400;
  color: #999;
  line-height: 1;
}
.site-nav {
  order: 1;                       /* nav to the left */
  flex: 1 1 0;                    /* claim the remaining width so its OWN items
                                     wrap to a second line before the brand drops
                                     below (matching the old header behavior) */
  min-width: 0;
  padding-top: 6px;               /* optical align with the larger title */
}
.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
}
/* Nav links: grey by default, dark + underline when active — matching the old
   #nav anchors (#8a8a8a normal; active = #222 text with a #222 bottom border). */
.site-nav a {
  color: #8a8a8a;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.site-nav a:hover { color: #222; text-decoration: none; }
.site-nav a[aria-current="page"] { color: #222; border-bottom-color: #222; }

/* --- Footer ---------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-rule);
  margin-top: var(--space-9);
  padding-block: var(--space-6);
  color: var(--color-muted);
  font-size: var(--text-small);
}
.site-footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.site-footer a { color: var(--color-muted); }
.site-footer a:hover { color: var(--color-link); }

/* --- Home ------------------------------------------------------------------ */
.hero { padding-block: var(--space-8) var(--space-7); }
.hero h1 { margin-bottom: var(--space-3); }
.hero .tagline { font-size: var(--text-h5); color: var(--color-muted); }

.home-section { margin-top: var(--space-8); }
.home-section h2 { font-size: var(--text-h3); }

/* --- Listings (writings index, work index) --------------------------------- */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li { padding-block: var(--space-5); border-bottom: 1px solid var(--color-rule); }
.entry-list h3 { margin-bottom: var(--space-1); }
.entry-list .post-meta { color: var(--color-muted); font-size: var(--text-small); margin: 0; }

/* --- Writings listing (index + tag/category filter pages) ------------------
   Two columns matching the old Squarespace blog: date on the left, the post
   title + excerpt + clickable tags/categories on the right, with a dark rule
   above each row. */
.writings-list { margin-top: var(--space-6); }
.writing-row {
  display: grid;
  grid-template-columns: 3fr 9fr;
  gap: var(--space-7);
  align-items: start;
  margin-top: var(--space-7);
}
/* Split rule: a separate hairline above each column, with the gutter between
   them left blank — matching the old Squarespace blog. */
.writing-meta,
.writing-body {
  border-top: 1px solid #888;
  padding-top: var(--space-5);
}
.writing-date { color: var(--color-ink); font-weight: var(--weight-medium); margin: 0; }
.writing-title { font-size: var(--text-h3); margin: 0 0 var(--space-4); }
.writing-excerpt { margin: 0 0 var(--space-4); }
.writing-readmore { margin: 0 0 var(--space-5); }
.writing-terms { margin: 0 0 var(--space-1); font-size: var(--text-small); color: var(--color-muted); }
.writing-terms:last-child { margin-bottom: 0; }
.writing-terms .terms-label { color: var(--color-muted); margin-right: var(--space-1); }
.writing-terms .term { color: var(--color-link); }

/* Filter-page banner (e.g. "Tagged Product · all writings"). */
.filter-note { color: var(--color-muted); margin: calc(-1 * var(--space-3)) 0 0; }
.filter-note .filter-term { color: var(--color-ink); font-weight: var(--weight-medium); }

@media (max-width: 700px) {
  /* Single column: collapse the split rule into one full-width rule above the
     stacked date + body. */
  .writing-row { grid-template-columns: 1fr; gap: var(--space-2); margin-top: var(--space-6); }
  .writing-body { border-top: 0; padding-top: 0; }
  .writing-meta { padding-top: var(--space-4); }
  .writing-title { font-size: var(--text-h4); }
}

/* --- Post ------------------------------------------------------------------ */
/* The post body gets a wider readable measure than other narrow content,
   matching the old Squarespace post column. */
.post { max-width: var(--post-width); }
.post-header { margin-bottom: var(--space-6); }
.post-title { margin-bottom: var(--space-2); }
.post-meta { color: var(--color-muted); font-size: var(--text-small); margin: 0; }
.post-body h2 { margin-top: var(--space-7); }
.post-body h3 { margin-top: var(--space-6); }
.post-body img { max-width: 100%; height: auto; margin-block: var(--space-5); }
/* Captioned images, converted from old [caption] shortcodes to <figure>. */
.post-body figure { margin: var(--space-6) 0; }
.post-body figure img { display: block; max-width: 100%; height: auto; margin: 0; }
.post-body figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-small);
  color: var(--color-muted);
  line-height: var(--leading-body);
}
.post-footer { margin-top: var(--space-8); padding-top: var(--space-5); border-top: 1px solid var(--color-rule); }

/* --- Content pages (about, code, publications) ----------------------------- */
/* Two-column layout matching the old About page: text ~58% left, sidebar ~25%
   right with a gutter between (old site used a 12-col grid: span-7 / span-3). */
.two-col {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: var(--space-8);
  align-items: start;
}
.two-col-main { max-width: var(--content-width); }
.two-col-side { padding-top: var(--space-2); }
.two-col-side h2 { font-size: var(--text-h4); }

.portrait {
  width: 100%;
  border-radius: var(--radius);
  margin: 0 0 var(--space-5);
}
/* Layout-rendered page title (Publications, Contact, Code). Matches the
   in-content h1: large + thin. */
.page-title { margin-bottom: var(--space-5); }
/* Thin rule directly under a page title, like the old Publications page. */
.title-rule {
  border: 0;
  border-top: 1px solid #888;
  margin: 0 0 var(--space-6);
}

/* Publications: two-column rows (year left ~17%, citations right) matching the
   old span-2 / span-10 grid. */
.pubs { margin-top: var(--space-6); }
.pub-row {
  display: grid;
  grid-template-columns: 2fr 10fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.pub-year { color: var(--color-text); }
.pub-entries p { margin-bottom: var(--space-4); }
.pub-entries p:last-child { margin-bottom: 0; }
@media (max-width: 700px) {
  .pub-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .pub-year { font-weight: var(--weight-medium); }
}

/* Code: project rows — title + year stacked on the left, description + link on
   the right, with a dark rule between rows (matching the old Code page). */
.code-row {
  display: grid;
  grid-template-columns: 4fr 6fr;
  gap: var(--space-7);
  align-items: start;
  padding-block: var(--space-7);
  border-bottom: 1px solid #888;
}
.code-row:first-child { padding-top: 0; }
.code-title { margin-bottom: var(--space-2); }
.code-year { color: var(--color-muted); font-size: var(--text-small); margin: 0; }
.code-body p { margin-bottom: var(--space-4); }
.code-body p:last-child { margin-bottom: 0; }
@media (max-width: 700px) {
  .code-row { grid-template-columns: 1fr; gap: var(--space-4); padding-block: var(--space-6); }
}

/* --- Work index (gallery of items) -----------------------------------------
   Row-major masonry matching the old Squarespace index: the newest items sit
   across the top, then each item drops into whichever column is currently
   shortest, so tiles tile seamlessly by image ratio. CSS `columns` fills
   column-major (one column top-to-bottom before the next), so work-grid.js does
   the placement into this CSS grid. Each tile keeps an always-visible bottom
   caption that, on hover, gives way to a dark overlay (title + "— view —")
   while the image zooms — the old behavior. */
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
@media (max-width: 900px) { .work-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .work-grid { grid-template-columns: 1fr; } }
/* Masonry mode: work-grid.js sizes the grid in fine row units (keep in sync with
   ROW in that file) and pins each tile to a column + row span. Until it runs (or
   with JS off), tiles fall back to a plain grid at natural image height. */
.work-grid.is-masonry { grid-auto-rows: 4px; }

.work-tile {
  position: relative;
  display: block;
  overflow: hidden;       /* clip the zoomed image + scaled overlay */
}
.work-thumb {
  display: block;
  width: 100%;
  height: auto;           /* natural ratio in the pre-masonry fallback */
  transform: scale(1);
  transition: transform var(--transition);
}
/* In masonry mode the tile's height is fixed by its grid row-span, so the image
   fills the tile and is cropped to fit (at most a few px of rounding). */
.work-grid.is-masonry .work-tile { height: 100%; }
.work-grid.is-masonry .work-thumb { height: 100%; object-fit: cover; }
.work-tile:hover .work-thumb { transform: scale(1.5); }

/* Always-visible bottom caption (medium-gray bar, like the old mobile view). */
.work-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: var(--space-3) var(--space-4);
  background: rgba(15, 15, 15, 0.6);
  color: #fff;
  font-size: var(--text-small);
  font-weight: var(--weight-light);
  line-height: 1.3;
  transition: opacity var(--transition);
}
.work-tile:hover .work-caption { opacity: 0; }   /* give way to the hover overlay */

/* Centered hover overlay (dark fill + title + "— view —"), like the old index. */
.work-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5);
  text-align: center;
  background: rgba(15, 15, 15, 0.7);
  opacity: 0;
  transform: scale(1.3);
  transition: opacity var(--transition), transform var(--transition);
}
.work-tile:hover .work-overlay { opacity: 1; transform: scale(1); }
.work-overlay-title {
  color: #fff;
  font-size: var(--text-h3);
  font-weight: var(--weight-light);
  line-height: 1.2;
}
.work-overlay-view {
  color: #fff;
  font-style: italic;
  font-size: var(--text-h6);
  letter-spacing: 0.05em;
}

/* Touch devices have no hover: keep the bottom caption, skip the overlay. */
@media (hover: none) {
  .work-tile:hover .work-thumb { transform: none; }
  .work-tile:hover .work-caption { opacity: 1; }
  .work-overlay { display: none; }
}

/* --- Work item (single project page) --------------------------------------- */
/* Top intro: lead image left, title + description right (old span-6/span-6). */
.work-intro {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
  margin-bottom: var(--space-8);
}
.work-lead { margin: 0; }
.work-lead img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}
.work-title { margin-bottom: var(--space-2); }
.work-year {
  color: var(--color-muted);
  font-size: var(--text-small);
  margin: 0 0 var(--space-5);
}
.work-body p { margin-bottom: var(--space-4); }
.work-body p:last-child { margin-bottom: 0; }
.work-links { margin-top: var(--space-5); }
.work-links a { margin-right: var(--space-5); }

/* Remaining shots: natural-aspect grid (images keep their real proportions). */
.work-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
  align-items: start;
}
.work-shot { margin: 0; }
.work-shot img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}
.work-shot figcaption { font-size: var(--text-small); color: var(--color-muted); margin-top: var(--space-2); }

/* Video-based items: responsive 16:9 embeds, one per row, full width. */
.work-embeds { display: grid; gap: var(--space-6); }
.work-embed { margin: 0; }
.embed-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--color-rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.embed-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.work-embed figcaption { font-size: var(--text-small); color: var(--color-muted); margin-top: var(--space-2); }

/* Audio-based (music) items: native HTML5 player with a small title/author label. */
.work-audio { margin-top: var(--space-5); }
.audio-track { margin: 0 0 var(--space-5); }
.audio-track:last-child { margin-bottom: 0; }
.audio-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.audio-title { font-weight: var(--weight-medium); color: var(--color-ink); }
.audio-author { font-size: var(--text-small); color: var(--color-muted); }
.work-audio audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius);
}

.work-footer { margin-top: var(--space-8); }

@media (max-width: 700px) {
  .work-intro { grid-template-columns: 1fr; gap: var(--space-5); }
}

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; gap: var(--space-6); }
}

@media (max-width: 600px) {
  :root { --text-h1: 32px; --text-h2: 28px; --text-h3: 24px; --gutter: 24px; }
  .site-header-inner { flex-direction: column-reverse; align-items: flex-start; gap: var(--space-3); }
  .site-title { text-align: left; max-width: 100%; }
}

/* --- Music landing page (/music/) ------------------------------------------
   A curated, listen-first view of the music items (see src/music/index.njk +
   src/_data/music.js). Flat list of cards: cover/poster left, story + listen
   affordances right. Audio plays through one shared sticky player; videos load
   on click. Reuses the .embed-frame and .audio-* patterns above. */
.music-intro { margin-bottom: var(--space-7); color: var(--color-text); }

.music-list {
  display: grid;
  gap: var(--space-7);
  padding-bottom: var(--space-8); /* breathing room above the sticky player */
}

.music-card {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: var(--space-6);
  align-items: start;
}

/* Cover slot — a plain link for audio/album cards, a click-to-play poster
   (.embed-facade) for video cards. Both share this sizing. */
.music-cover {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
}
.music-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* Video poster: cover image as background + a centered play badge; on click the
   script swaps in the same .embed-frame iframe the Work page uses. */
.embed-facade {
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  aspect-ratio: 16 / 10;
}
.embed-facade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  transition: background var(--transition);
}
.embed-facade:hover::after { background: rgba(0, 0, 0, 0.36); }
.embed-facade-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  padding-left: 4px; /* optically center the ► glyph */
}

.music-content { display: flex; flex-direction: column; }
.music-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.music-head h2 { margin: 0; font-size: var(--text-h4); }
.music-year { color: var(--color-muted); font-size: var(--text-small); }
.music-blurb { margin: var(--space-3) 0 var(--space-4); color: var(--color-text); }

.music-listen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
/* Play (inline audio) = outline pill; stream (album) = filled pill to read as
   the primary "listen now" CTA. */
.music-play,
.music-stream-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  border: 1px solid var(--color-link);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.music-play { background: transparent; color: var(--color-link); }
.music-play:hover,
.music-play.is-playing { background: var(--color-link); color: #fff; }
.music-stream-btn { background: var(--color-link); color: #fff; }
.music-stream-btn:hover { background: var(--color-link-hover); border-color: var(--color-link-hover); }

.music-more { margin-top: auto; font-size: var(--text-small); }

/* Shared, persistent player — one <audio> for the whole page. */
.music-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: #fff;
  border-top: 1px solid #e6e6e6;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}
.music-player[hidden] { display: none; }
.music-player-title { font-weight: var(--weight-medium); color: var(--color-ink); white-space: nowrap; }
.music-player-author { font-size: var(--text-small); color: var(--color-muted); white-space: nowrap; }
.music-player-audio { flex: 1; min-width: 0; height: 40px; }
.music-player-close {
  flex: none;
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--color-muted);
  padding: var(--space-1) var(--space-2);
}
.music-player-close:hover { color: var(--color-ink); }

@media (max-width: 640px) {
  .music-card { grid-template-columns: 1fr; gap: var(--space-4); }
  .music-cover img,
  .embed-facade { aspect-ratio: 16 / 9; }
  .music-more { margin-top: 0; }
}
@media (max-width: 600px) {
  .music-player { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
  .music-player-audio { order: 3; flex-basis: 100%; }
}
