/* Home (Work): opening statements and project cards. Rules: site-design-system.md §4, §8. */

/* ---------- Opening: one statement, centred, filling the first screen (§2 pacing, §4.1) ---------- */
.opening {
  position: relative;
  min-height: calc(100vh - var(--nav-h));
  min-height: calc(100svh - var(--nav-h));
  display: grid;
  align-items: center;
}
.opening__statement {
  position: relative;
  font-family: var(--font-display);
  font-size: var(--hero-size);
  line-height: var(--hero-lh);
  font-weight: 400;
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  text-align: center;
  text-wrap: balance;
}

/* Scroll hint: a faint small arrow at the bottom centre of the first screen.
   home.js shows it 2s after arrival (fades in while settling 8px down into place, on
   spring-enter) and hides it as soon
   as the page scrolls (200ms fade). Reduced motion: fade only. */
.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 32px;
  width: 20px; height: 20px;
  margin-left: -10px;
  overflow: visible;
  pointer-events: none;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translate3d(0, -8px, 0);
  transition: opacity 200ms ease, transform 200ms ease;
}
.scroll-hint.is-on {
  opacity: .5;
  transform: none;
  transition:
    opacity var(--spring-enter-dur) var(--spring-enter),
    transform var(--spring-enter-dur) var(--spring-enter);
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint, .scroll-hint.is-on { transform: none; transition: opacity 200ms ease; }
}

/* Split-flap board (built by /assets/js/flap.js). Every character is its own layer,
   drawn at the position the browser gives it in normal text. */
.flap { position: relative; display: block; width: 100%; }
.flap__g {
  position: absolute;
  top: 0; left: 0;
  display: block;
  height: calc(var(--hero-size) * var(--hero-lh));
  white-space: pre;
  transform-origin: 50% 50%;            /* the hinge runs through the middle of the line */
  backface-visibility: hidden;
  will-change: transform, opacity;
  pointer-events: none;
}
.flap__g--top    { clip-path: inset(-40% -30% 50% -30%); }
.flap__g--bottom { clip-path: inset(50% -30% -40% -30%); }

/* Hidden copy used only to measure where each character sits. */
.flap__measure {
  position: absolute;
  inset: 0 0 auto 0;
  visibility: hidden;
  pointer-events: none;
}
.flap__measure-statement { position: absolute; top: 0; left: 0; right: 0; display: block; }
.flap__measure-half { display: block; }

/* ---------- Project grid (§4.2): max 3 per row, all cards the same height ---------- */
.work { padding-bottom: var(--section-gap); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;                  /* every row as tall as the tallest card */
  gap: var(--grid-gap);
}
@media (max-width: 1023.98px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* One column: each card is as tall as its own content (step 7, Jack); the shared row height
   only applies where cards sit side by side. */
@media (max-width: 599.98px)  { .card-grid { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; } }

.card-cell { position: relative; display: flex; }

.card {
  --tint: var(--tint-light);
  position: relative;
  display: flex;
  flex: 1;
  color: var(--ink);
  border-radius: 16px;                  /* only for the native focus fallback; the ring is drawn on the squircle */
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] .card { --tint: var(--tint-dark); }
.card:focus-visible { outline: none; }

.card__lift {
  position: relative;
  display: flex;
  flex: 1;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* Tint, shadow and focus ring are drawn on the card's squircle (cards.js), in slices so the
   card can grow downward on hover. Only the shadow's opacity and the slices' transforms move. */
.card__shadow,
.card__bg,
.card__ring {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  max-width: none;
  overflow: visible;
  pointer-events: none;
}
.card__shadow {
  opacity: 0;
  filter: drop-shadow(0 18px 36px var(--card-shadow-far)) drop-shadow(0 3px 8px var(--card-shadow-near));
}
.card__shadow path,
.card__bg path { fill: var(--tint); transition: fill var(--theme-dur) var(--theme-ease); }
.card__ring { z-index: 2; opacity: 0; }
.card__ring path { fill: none; stroke: var(--accent); stroke-width: 2; }
.card:focus-visible .card__ring { opacity: 1; }

.card__body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 16px;                  /* replaced by the squircle clip once JS runs */
}

.card__cover {
  position: relative;
  flex: none;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--tint);
}
.card__img,
.card__video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.card__video { opacity: 0; transition: opacity 200ms ease; }
.card__video.is-on { opacity: 1; transition: none; }   /* appears at once: its first frame is the cover */

/* Fade band (§4.2.1): generated from the cover's bottom row, fading out onto the card tint, so
   there is no hard line between picture and text. The cover itself is never covered or faded. */
.card__fade {
  flex: none;
  display: block;
  width: 100%;
  height: 32px;
  max-width: none;
}

.card__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 24px;
}

/* Tags (§4.2.1): solid pills under the summary, so the cover is shown whole. They lift with the
   card; on hover they move down with it to make room for the hover lines (cards.js). */
.card__tags {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
}
.card__tag {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ink);                /* #242424 in light mode; inverted in dark (#E6E6E6) */
  color: var(--bg);                      /* #F5F3EF in light mode; #161514 in dark */
  box-shadow: 0 0 0 1px var(--tag-ring), 0 1px 2px var(--chip-shadow);
  font-size: 13px;
  line-height: 26px;
  font-weight: 500;
  letter-spacing: var(--tracking-small);
  white-space: nowrap;
}
.card__title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: var(--tracking-display-small);
  color: var(--ink);                    /* never changes on hover (§4.2) */
}
.card__copy {
  margin-top: 8px;
  font-size: var(--meta-size);
  line-height: var(--meta-lh);
  font-weight: var(--meta-weight);
  letter-spacing: var(--tracking-small);
  color: var(--ink-2);
}
/* At rest the card is sized for the name and summary only. The hover lines sit in the
   same spot, out of the flow; on hover the card grows down just far enough to make room
   for them (cards.js measures how far), so the cover is never covered. */
.card__copy { position: relative; }
.card__more {
  position: absolute;
  top: 0; left: 0; right: 0;
  opacity: 0;
}

/* Touch devices (no hover): the hover lines show directly; a tap opens the project. */
@media (hover: none), (pointer: coarse) {
  .card__summary { display: none; }
  .card__more { position: static; opacity: 1 !important; transform: none !important; }
}

/* ---------- Entrance: fade and rise in sequence, landing almost together ---------- */
.js .card-cell .card {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
}
.js .card-cell.is-in .card {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--spring-enter-dur) var(--spring-enter),
    transform var(--spring-enter-dur) var(--spring-enter);
  transition-delay: var(--delay, 0ms);
}

/* ---------- "View" magnifier cursor ---------- */
html.is-view-cursor, html.is-view-cursor * { cursor: none !important; }
.view-cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: 150;
  width: 0; height: 0;
  pointer-events: none;
  opacity: 0;
}
.view-cursor__glass {
  position: absolute;
  left: -32px; top: -32px;
  width: 64px; height: 64px;
  transform-origin: 32px 32px;          /* grows from the pointer */
  transform: scale(0);
}
.view-cursor__lens {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--button-size);
  line-height: var(--button-lh);
  font-weight: var(--button-weight);
  letter-spacing: var(--tracking-small);
}
.view-cursor__handle {
  position: absolute;
  left: 49.5px; top: 53px;               /* starts just inside the lens, at its bottom right */
  width: 7px; height: 22px;
  border-radius: 999px;
  background: var(--ink);
  transform: rotate(-45deg);
  transform-origin: 50% 0;
}
/* The magnifier sits on photos, light or dark, so it carries its own edge: a thin outline
   in the opposite tone plus a soft shadow, drawn around lens and handle as one shape. */
.view-cursor__glass {
  filter: drop-shadow(0 0 .6px var(--lens-outline)) drop-shadow(0 0 .6px var(--lens-outline)) drop-shadow(0 4px 10px var(--lens-shadow));
}
@media (hover: none), (pointer: coarse) { .view-cursor { display: none; } }

/* ---------- Reduce motion: opacity only ---------- */
@media (prefers-reduced-motion: reduce) {
  .js .card-cell .card { transform: none; }
  .js .card-cell.is-in .card { transition: opacity 200ms ease; transition-delay: 0ms; }
}
