/* =========================================================================
   Portfolio — Landing
   Spec: harin.design lineage. Sidebar 1:1 with harin.
   Right column diverges: vertical list of 4 wide (16:10) cards.
   System fonts only. No build step. Mobile-aware.
   ========================================================================= */

:root {
  /* ---- Color: greys + ink ---- */
  --bg: #ffffff;
  --white: #ffffff;
  --cream: #ffffff;
  --g50: #f5f4f1;
  --g100: #ebeae5;
  --g200: #d8d6d0;
  --g400: #a8a59e;
  --g500: #8a877f;
  --g700: #4a4842;
  --ink: #161513;

  /* Aliases preserved for existing rules */
  --ink-1: var(--ink);
  --ink-2: var(--g500);
  --ink-3: var(--g400);
  --surface-sticker: var(--white);
  --surface-card: #f5f4f0;
  --halftone-dot: rgba(22, 21, 19, 0.4); /* full alpha; canvas opacity scales it down */

  /* ---- Hairline border (used everywhere) ---- */
  --hairline: 1px solid rgba(0, 0, 0, 0.05);

  /* ---- Success / Copied state ---- */
  --success-bg: rgb(225, 245, 238);
  --success-border: rgba(29, 158, 117, 0.15);
  --success-ink: rgb(29, 158, 117);

  /* ---- Type ---- */
  --font-sans: -apple-system, BlinkMacSystemFont, "system-ui", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --fs-display: 28px;
  --lh-display: 1.15;

  --fs-body: 12px;
  --lh-body: 1.55;

  --fs-eyebrow: 11px;
  --fs-pill: 13px;

  --fs-card-title: 16px;
  --lh-card-title: 1.3;

  --fs-card-meta: 12px;
  --fs-footer: 11px;

  --tracking-display: -0.035em;
  --tracking-card-title: -0.015em;
  --tracking-default: -0.01em;
  --tracking-eyebrow: 0.02em;

  /* ---- Layout ---- */
  /* Page-edge ladder aligned with case-study `--container-max` /
     `--container-pad` so clicking from home into a case study doesn't
     shift the outer gutters. Inner typography stays unchanged. */
  --page-max: 1440px;
  --page-pad-x: 96px;
  --col-gap: 64px;
  --sidebar-w: 408px;
  --content-w: 776px;
  --eyebrow-to-card: 40px;
  --row-gap-cards: 80px;

  /* ---- Cards ---- */
  --media-aspect: 2 / 1;
  --media-radius: 20px;
  --media-to-caption: 20px;
  --title-to-meta: 6px;

  /* ---- Radii ---- */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-pill: 100px;

  /* ---- Spacing scale (informational) ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 48px;
  --s-10: 56px;
  --s-11: 64px;
  --s-12: 72px;
  --s-13: 96px;

  /* ---- Motion ---- */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --island: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-card: 350ms;
}

/* -------------------------------------------------------------------------
   Base & resets
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink-1);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

ol,
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

::selection {
  background: var(--ink-1);
  color: var(--bg);
}

/* -------------------------------------------------------------------------
   Sticker primitive — every text "stand-off" pill on white page
   Every sticker gets the 1px hairline. Without it the page reads as flat.
   ------------------------------------------------------------------------- */
.sticker {
  display: inline-block;
  width: fit-content;
  background: var(--surface-sticker);
  border: var(--hairline);
  border-radius: var(--r-md);
  padding: 6px 12px;
}

/* -------------------------------------------------------------------------
   Page container
   ------------------------------------------------------------------------- */
.page {
  display: flex;
  flex-direction: row;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad-x);
  column-gap: var(--col-gap);
}

/* -------------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  /* Right padding moved onto .sidebar-top so the game can run full-bleed
     to the right divider. */
  padding: 72px 0 0 0;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  border-right: var(--hairline); /* vertical divider into content */
}

.sidebar-top {
  padding-right: 32px;
}

/* -------------------------------------------------------------------------
   Sidebar game (Tetris) — full-bleed bottom of the sidebar.
   Internal flex column: hint line above, canvas fills the rest.
   Canvas anchors flush to the bottom of the sidebar (= viewport bottom on
   sticky layout) so the playfield base never gets cut.
   ------------------------------------------------------------------------- */
.sidebar-game {
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  position: relative; /* anchor for the first-line-clear confetti burst */
}

/* -------------------------------------------------------------------------
   First-line-clear confetti — pops once per session the first time the
   player clears any number of lines. Anchored to .sidebar-game so the
   burst originates from the playfield region; the container is layered
   above the canvas and ignores pointer events. Bits are tiny rectangles
   that get keyframed outward + downward with gravity + spin + fade.
   ------------------------------------------------------------------------- */
.tetris-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.tetris-confetti-bit {
  position: absolute;
  left: 50%;
  top: 60%;
  width: 6px;
  height: 10px;
  border-radius: 1px;
  opacity: 0;
  will-change: transform, opacity;
  animation: tetris-confetti-pop 1100ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes tetris-confetti-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.6);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
      rotate(var(--rot, 540deg))
      scale(1);
  }
}

.game-hint {
  margin: 0 0 10px;
  padding: 0 16px 0 4px;
  font-weight: 400;
  letter-spacing: var(--tracking-default);
  user-select: none;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.game-hint-lead {
  font-size: 11px;
  font-weight: 500;
  color: var(--g500);
}

.game-hint-keys {
  font-size: 10px;
  color: var(--g400);
}

.game-hint-keys span {
  font-weight: 500;
  color: var(--g500);
}

/* Score readout — one row, two halves via flex space-between.
   Left half: `high <num> · <initials>`. Right half: `you <num>`.
   Lowercase labels match the calm register of .game-hint above it
   (avoids the arcade-machine feel that uppercase HIGH/YOU would
   stamp onto the page). Tabular numerals keep digits from shifting
   when the score updates. */
.game-score {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 12px;
  padding: 0 16px 0 4px;       /* match .game-hint padding so columns align */
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: var(--tracking-default);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  user-select: none;
}

.game-score-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.game-score-label {
  font-weight: 500;
  color: var(--g500);
}

.game-score-num {
  font-weight: 600;
  color: var(--ink);
}

/* Initials trail the high-score number, with a · separator that only
   renders when initials are actually present (avoids a dangling dot
   in the empty state). Lighter color than the number so they read as
   chrome, not a competing number. */
.game-score-initials {
  font-size: 10px;
  font-weight: 500;
  color: var(--g400);
  letter-spacing: 0.04em;
}

.game-score-initials:not(:empty)::before {
  content: "·";
  margin-right: 4px;
  color: var(--g400);
}

/* Two-mode toggle: .game-score holds either the default readout or
   the initials claim form. Both modes use the same parent height
   (~16px line-box) so toggling between them never reflows the canvas
   below. */
.game-score-default {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
}

.game-score.is-claiming .game-score-default {
  display: none;
}

/* Claim form — hidden at rest, shown when .is-claiming flips on.
   `border: 0` strips the default form border that some UA stylesheets
   apply. Matches the .game-score row's typography so the toggle
   doesn't feel like a different component slipping in. */
.game-score-claim {
  display: none;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.game-score.is-claiming .game-score-claim {
  display: flex;
}

.game-score-claim-label {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  /* Slightly bolder + inkier than the regular .game-score-label —
     this is the call-to-action moment, deserves visual weight. */
}

/* The input itself. Single line, 3 chars wide, ink-on-transparent
   so it reads as a text field embedded in the sidebar rather than
   a heavy form control. The bottom border carries the "you can
   type here" affordance without needing a full box outline. */
.game-score-claim-input {
  flex: 1 1 auto;
  font: inherit;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  /* Generous tracking so the three letters read as arcade-style
     separated glyphs rather than a single word. tabular-nums kept
     for consistency with the rest of the score row's monospaced
     digit feel (even though letters here, not numbers). */
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--ink);
  outline: none;
  padding: 2px 4px;
  /* Width sized to ~3 uppercase letters + the tracking; just enough
     for the placeholder "AAA" to show without scroll. */
  min-width: 0;
  width: 6ch;
  /* Disable iOS auto-zoom on focus by ensuring the rendered font
     size is >= 11px (Safari triggers zoom when input font is < 16
     CSS px, but the sidebar is desktop-only so this is academic;
     keeping for safety). */
}

.game-score-claim-input::placeholder {
  color: var(--g400);
  letter-spacing: 0.3em;
  opacity: 1;
}

.game-score-claim-input:focus {
  border-bottom-color: var(--ink);
}

/* Submit hint — the ↩ glyph signals "press Enter to submit". Sits
   on the right edge of the form, very muted so it reads as a
   keyboard hint rather than a clickable element. */
.game-score-claim-hint {
  font-size: 10px;
  color: var(--g400);
  font-weight: 500;
  user-select: none;
}

.game-canvas {
  display: block;
  flex: 1 1 auto;
  min-height: 0;       /* flex shrink past intrinsic */
  width: 100%;
  background: transparent;
  cursor: pointer;
  outline: none;
}

/* No visible focus ring — hover engages the game, focus is silent.
   Pure-keyboard users still tab in and play; we trade the visual signal
   for a cleaner sidebar surface. */
.game-canvas:focus,
.game-canvas:focus-visible {
  outline: none;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

/* Display heading — plain (no sticker treatment) */
.sidebar-name {
  margin: 0 0 24px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
  color: var(--ink-1);
}

.sidebar-name-line-1,
.sidebar-name-line-2 {
  display: block;
}

.sidebar-name em {
  font-style: italic;
  font-weight: 500;
}

/* Bio — three short blocks, plain (no sticker treatment) */
.sidebar-bio {
  margin: 0 0 32px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ink-2);
  font-size: var(--fs-body);
  line-height: 2.1;
  letter-spacing: var(--tracking-default);
  max-width: 376px;
}

.bio-block {
  display: block;
}

.bio-block + .bio-block {
  margin-top: 12px;
}

.bio-block--quiet {
  color: var(--ink-3);
}

/* Inline pill — the credibility lift (company chips inside bio).
   Fully rounded ends so the class lives up to its name; padding nudged
   a touch wider to balance the curved cap. */
.inline-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-sticker);
  color: var(--ink-1);
  font-weight: 500;
  letter-spacing: var(--tracking-default);
  padding: 1px 9px 2px;
  border: var(--hairline);
  border-radius: var(--r-pill);
  vertical-align: baseline;
}
.inline-pill-logo {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
  display: inline-block;
}

/* Pill links — round pills, white-on-black flip on hover with spring + icon rotate.
   Row layout so socials + Resume reclaim vertical space for the Tetris canvas
   below. Socials use the icon-only `--icon` modifier (universally recognised
   brand marks don't need a text label); Resume keeps its label (no canonical
   document-page icon, so the text affordance matters). */
.sidebar-links {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px 4px;
}

.sidebar-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--white);
  color: var(--ink);
  border: var(--hairline);
  border-radius: var(--r-pill);
  font-size: var(--fs-pill);
  font-weight: 500;
  letter-spacing: var(--tracking-default);
  transition: background-color 0.35s var(--spring),
              color 0.35s var(--spring),
              border-color 0.35s var(--spring),
              transform 0.35s var(--spring);
  will-change: transform;
}

/* Icon-only variant — fixed 36×36 circle. Same height as the labeled
   Resume pill so they baseline-align in the row. Slightly larger icon
   (16px vs the labeled pill's 14px) because the glyph is the only
   content and needs more visual weight to stand alone. */
.sidebar-link--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  gap: 0;
  justify-content: center;
}

.sidebar-link--icon .link-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.sidebar-link:hover {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
  transform: translateY(-2px);
}

.sidebar-link:hover .link-icon {
  transform: rotate(-8deg) scale(1.15);
}

.sidebar-link:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.1s;
}

.link-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: currentColor;
  transition: transform 0.35s var(--spring);
}

/* Email row — bottom-left email + animated copy button */
.sidebar-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 4px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: var(--fs-body);
  color: var(--g500);
  letter-spacing: var(--tracking-default);
}

.sidebar-email-text {
  display: inline-block;
  font-size: 12px;
  color: var(--g500);
}

/* Round 26×26 pill that morphs to a mint "Copied ✓" capsule on click */
.sidebar-email-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  background: var(--white);
  border: var(--hairline);
  border-radius: var(--r-pill);
  color: var(--g500);
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  transition: background-color 0.35s var(--spring),
              color 0.35s var(--spring),
              border-color 0.35s var(--spring),
              padding 0.35s var(--spring),
              transform 0.35s var(--spring);
}

.sidebar-email-copy:hover {
  background: var(--g50);
  color: var(--ink);
}

.sidebar-email-copy:active {
  transform: scale(0.95);
  transition-duration: 0.1s;
}

.sidebar-email-copy svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.sidebar-email-copy .copy-check {
  display: none;
}

/* Slide-in "Copied" text label */
.sidebar-email-copy .copy-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-default);
  max-width: 0;
  opacity: 0;
  margin-left: 0;
  overflow: hidden;
  transition: max-width 0.35s var(--spring),
              opacity 0.2s ease,
              margin 0.35s var(--spring);
}

/* Copied state — mint capsule, check icon, label slides in */
.sidebar-email-copy.copied {
  padding: 0 10px 0 6px;
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-ink);
}

.sidebar-email-copy.copied .copy-icon {
  display: none;
}

.sidebar-email-copy.copied .copy-check {
  display: block;
}

.sidebar-email-copy.copied .copy-label {
  max-width: 50px;
  opacity: 1;
  margin-left: 4px;
}

/* Footer copyright — plain (no sticker treatment) */
.sidebar-bottom {
  align-self: flex-start;
  width: fit-content;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--g400);
  font-size: var(--fs-footer);
  letter-spacing: var(--tracking-default);
}

/* -------------------------------------------------------------------------
   Content (right column)
   ------------------------------------------------------------------------- */
.content {
  width: var(--content-w);
  flex: 0 0 var(--content-w);
  padding: 72px 0 64px;
  min-width: 0;
}

/* "Selected Works" eyebrow — plain text label, aligns flush to grid */
.content-label {
  display: inline-block;
  width: fit-content;
  margin: 0 0 28px 0;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--g500);
}

/* -------------------------------------------------------------------------
   Work list
   ------------------------------------------------------------------------- */
.work-list {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap-cards);
}

.work-row {
  display: block;
  width: 100%;
  outline: none;
}

.work-row:focus-visible .work-media {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}

/* Card media — 16:10 wide hero. Hairline rim like harin's phone-frame stroke. */
.work-media {
  width: 100%;
  aspect-ratio: var(--media-aspect);
  background: var(--surface-card);
  border: var(--hairline);
  border-radius: var(--media-radius);
  overflow: hidden;
  position: relative;
  transition: transform var(--dur-card) var(--ease);
  will-change: transform;
}

/* Subtle gradient inside placeholder so cards don't read as flat dead surfaces */
.work-media::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(22, 21, 19, 0.04), transparent 60%),
    radial-gradient(120% 80% at 0% 100%, rgba(22, 21, 19, 0.03), transparent 55%);
}

/* Placeholder slug label — visible only while real art isn't dropped in */
.work-media::after {
  content: "[" attr(data-slug) "]";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--g400);
}

/* Card hover: gentle lift, matches harin's translateY(-3px) on .card-media */
.work-row:hover .work-media {
  transform: translateY(-3px);
}

/* When a real image is dropped in (via .work-media--has-image), hide
   the placeholder slug text and inset the image so the cream frame +
   subtle gradient still show as breathing room around it. This reads
   as "screenshot pinned in a frame" rather than full-bleed cover —
   the cream rim signals that what you're seeing is a deliberate
   composition, not an edge-clipped raster.

   ::before (the subtle radial gradient) is left enabled so the cream
   border has texture; the image sits ABOVE it via position: relative
   so the gradient only shows in the inset band, not through the
   image itself. */
.work-media--has-image::after {
  display: none;
}

.work-media--has-image {
  /* 32px padding gives contained media (1.7-1.78:1 sources in the card's
     2:1 box) a hairline of cream breathing room while keeping the image
     as large as possible. This is the Chrome baseline — do not tweak
     for Safari. Any Safari-specific fix lives in the @supports block
     near the bottom of the file. */
  padding: 32px;
  box-sizing: border-box;
  /* Override the cream var(--surface-card) — these cards match the
     same #fafafa neutral near-white treatment used by
     .case-figure-frame inside the case studies, so the homepage
     tile and the in-article figure share one surface vocabulary. */
  background: #fafafa;
  /* Canonical 'whisper of shadow' from the slider hero / figure-frame
     family. Card lifts off the page as one unit; inner image stays
     anchored without a competing shadow of its own. */
  box-shadow: 0 6px 24px -6px rgba(15, 23, 42, 0.06);
}

/* Work-in-progress cards — case study isn't fully shipped yet
   (figures inside still on placeholders, cover image pending).
   Dashed border visually signals 'draft state'; the bracketed
   [SLUG] placeholder text gets replaced with a 'Coming soon'
   pill that doesn't overclaim about story completeness.

   Earlier copy was "Story shipped · cover incoming" — dropped
   because grep'ing each case-study HTML showed 1–15 figure
   placeholders still in each one. The story isn't shipped; only
   the writing is. "Coming soon" is the honest framing. */
.work-media--wip {
  border-style: dashed;
  border-color: rgba(0, 0, 0, 0.12);
}

.work-media--wip::after {
  /* Two-clause pill: state + invitation. 'Visuals pending'
     names what's missing (cover image + some in-article figures);
     'Read + listen' invites the click and signals that the
     written stories + audio overviews ARE live. Dot separator
     keeps the two halves visually balanced. */
  content: "Visuals pending · Read + listen";
  /* Override the inset:0 + flex centring from the base
     .work-media::after. We position the pill absolutely in the
     centre of the card so ::after itself becomes the pill shape,
     not a full-bleed centred-text layer. */
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.045);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g500);
  white-space: nowrap;
}

.work-media--has-image > img,
.work-media--has-image > video {
  display: block;
  /* Fill the padded inner box explicitly — `<video width: auto>` collapses
     to 0×0 in Safari until metadata loads, so we must give it real
     dimensions. The aspect-ratio hint on `<video>` (further down this
     file) gives Safari the ratio info `object-fit: contain` needs to
     letterbox correctly pre-metadata. */
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  position: relative;
}

/* `.work-media--cover` — fills the card edge-to-edge with no cream
   padding. Used for cards whose source media has heavy internal
   whitespace around the focal element (e.g. Quick Command's palette
   video, where the palette is small in a mostly white frame). Cover
   crops the whitespace + drops the cream rim so the focal UI fills
   the entire card and reads as a polished, full-bleed composition.
   Border-radius is inherited from the parent .work-media via overflow:
   hidden, so we don't need to round the media itself. */
.work-media--cover {
  padding: 0;
}
.work-media--cover > img,
.work-media--cover > video {
  /* Absolute-positioned, inset:0 cover is the most reliable cross-
     browser cover pattern. Identical layout in Chrome + Safari +
     Firefox regardless of when media metadata loads, because the
     element is sized by positioning rather than by intrinsic
     dimensions. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 0; /* parent .work-media handles the corner clip */
}

/* Safari needs an explicit aspect-ratio on `<video>` to size correctly
   before metadata loads — without it, WebKit defaults to 300×150 and
   `object-fit` cannot letterbox sensibly. The landing page doesn't
   include portfolio-shared.css (which already has this rule for the
   case studies), so we set it here too. `auto` keeps the door open for
   the rare non-16:9 source (Quick Command @ 1.94:1) to take over once
   its metadata arrives. */
video {
  aspect-ratio: auto 16 / 9;
}

/* ─── Safari-scoped fixes ────────────────────────────────────────────
   Safari has long-standing quirks with `object-fit` on `<video>` —
   the video element can render at its intrinsic size (or WebKit's
   300×150 default) and ignore the `width: 100%; height: 100%`
   constraint until metadata loads. The `@supports (-webkit-hyphens:
   none)` query targets WebKit-based browsers (Safari + iOS Safari);
   the rules inside only apply there, so Chrome's behaviour stays
   exactly as it was before this engineering work. */
@supports (-webkit-hyphens: none) {
  /* Force the contained media to fill its padded box explicitly,
     even pre-metadata. Combined with the `aspect-ratio: auto 16/9`
     on `<video>` above, this gives Safari enough layout information
     to compute the contain letterbox correctly on first paint. */
  .work-media--has-image > img,
  .work-media--has-image > video {
    width: 100% !important;
    height: 100% !important;
  }
}

.work-caption {
  margin-top: var(--media-to-caption);
  display: flex;
  flex-direction: column;
  gap: var(--title-to-meta);
}

.work-title {
  margin: 0;
  font-size: var(--fs-card-title);
  font-weight: 500;
  line-height: var(--lh-card-title);
  letter-spacing: var(--tracking-card-title);
  color: var(--ink-1);
  transition: font-weight 160ms var(--ease-out);
}

.work-row:hover .work-title {
  font-weight: 600;
}

.work-meta {
  margin: 0;
  font-size: var(--fs-card-meta);
  font-weight: 400;
  letter-spacing: var(--tracking-default);
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.work-meta .dot {
  color: var(--ink-3);
}

/* -------------------------------------------------------------------------
   Sub-card variant — landing-page nested rows.
   - Indented 48px from the left (signals "child of the row above")
   - Width capped at ~80% so the card visually steps in
   - Smaller title + ↳ glyph prefix for clear hierarchy
   - Pulled UP closer to its parent (24px gap, not 80px)
   ------------------------------------------------------------------------- */
.work-list > .work-item--sub {
  margin-top: -56px;            /* offsets the parent 80px gap to net 24px */
  padding-left: 48px;            /* left indent does the "I'm a child" work */
  /* No width cap — right edge stays aligned with main cards for a consistent
     vertical column down the page. */
}

.work-row--sub .work-media {
  /* Same 2:1 aspect, smaller frame is achieved by parent width capping */
  border-radius: 16px;           /* slightly tighter than main 20px */
}

.work-title--sub {
  font-size: 14px;               /* down from 16px */
  font-weight: 500;
  letter-spacing: var(--tracking-card-title);
}

/* The ↳ glyph signals continuation. Rendered as pseudo-element so it can
   be styled (color, weight) without polluting the title text. */
.work-title--sub::before {
  content: "↳ ";
  color: var(--g500);
  font-weight: 400;
  margin-right: 2px;
}

/* -------------------------------------------------------------------------
   Field Notes — horizontal photo strip variant
   Replaces the .work-media with a flex row of varied-aspect placeholders.
   Image-dump aesthetic: not a polished gallery, just candid shots.
   ------------------------------------------------------------------------- */
.work-row--strip .field-strip {
  display: flex;
  flex-direction: row;
  gap: 12px;
  height: 168px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;          /* Firefox */
  border-radius: 16px;
}

.work-row--strip .field-strip::-webkit-scrollbar {
  display: none;                  /* WebKit */
}

.field-photo {
  height: 100%;
  flex: 0 0 auto;
  background: var(--surface-card);
  border: var(--hairline);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
}

.field-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(22, 21, 19, 0.04), transparent 60%),
    radial-gradient(120% 80% at 0% 100%, rgba(22, 21, 19, 0.03), transparent 55%);
}

.field-photo::after {
  content: "[" attr(data-slug) "]";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--g400);
}

/* Aspect-driven widths: photos vary in shape so the strip feels candid */
.field-photo--4x3 { aspect-ratio: 4 / 3; }
.field-photo--1x1 { aspect-ratio: 1 / 1; }
.field-photo--3x4 { aspect-ratio: 3 / 4; }

/* Strip variant doesn't need the regular media radius — it's its own thing */
.work-row--strip .work-caption {
  margin-top: 16px;
}

/* -------------------------------------------------------------------------
   Page-edge ladder — matches case-study `--container-pad` at the same
   breakpoints so clicking from home → case study doesn't shift gutters.
   ------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  :root { --page-pad-x: 64px; }
}

/* -------------------------------------------------------------------------
   Tablet / mobile (≤768px)
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root { --page-pad-x: 32px; }

  .page {
    flex-direction: column;
    column-gap: 0;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: calc(40px + env(safe-area-inset-top)) 0 32px;
    border-right: none;          /* desktop's vertical divider has no place at mobile */
  }

  .sidebar-top {
    padding-right: 0;            /* recover 48px of bio width on small viewports */
  }

  .sidebar-halftone {
    display: none;
  }

  .sidebar-bio {
    max-width: none;
  }

  .sidebar-links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  /* Email row: pill that gracefully wraps if the address is longer than viewport */
  .sidebar-email {
    flex-wrap: wrap;
    max-width: 100%;
  }
  .sidebar-email-text {
    overflow-wrap: anywhere;     /* allow break inside the address itself, not just at @ */
    min-width: 0;
  }

  /* Tetris is a hover/keyboard-only interaction. It has no value on touch
     and at narrow widths the canvas + key hint look cramped. Hide it. */
  .sidebar-game {
    display: none;
  }

  .content {
    width: 100%;
    flex: 1 1 auto;
    padding: 16px 0 calc(56px + env(safe-area-inset-bottom));
  }

  .content-label {
    margin-left: 0;
  }

  .work-list {
    gap: 64px;
  }

  /* Sub-card spacing on mobile.
     - Desktop: gap 80, margin-top -56 → 24px effective gap.
     - Tablet:  gap 64, margin-top -40 → 24px effective gap (preserves intent).
     - Indent reduces from 48px to 24px so the sub-card doesn't lose half the viewport. */
  .work-list > .work-item--sub {
    margin-top: -40px;
    padding-left: 24px;
  }
}

/* -------------------------------------------------------------------------
   Phone (≤480px)
   ------------------------------------------------------------------------- */
@media (max-width: 480px) {
  :root { --page-pad-x: 24px; }

  .work-list {
    gap: 48px;
  }

  .sidebar-name {
    font-size: 24px;
  }

  /* Phone: gap 48, margin-top -24 → 24px effective gap. Indent 16px. */
  .work-list > .work-item--sub {
    margin-top: -24px;
    padding-left: 16px;
  }

  /* Slightly smaller email font on phone — typical address fits one line */
  .sidebar-email-text {
    font-size: 11px;
  }
}

/* -------------------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .work-row:hover .work-media {
    transform: none;
  }
}
