/* ==========================================================================
   piece.css — the portfolio piece detail template.
   Written for reuse: every piece page shares this file, so nothing here
   names a specific project.

   Layout follows the Traverse Town reference (stacked display title,
   label/value meta strip, then Overview, Summary, Breakdown, Gallery).
   Styling follows Pofo: very large Montserrat display type, small muted
   body copy, uppercase letter-spaced micro-labels, full-bleed media, fade-in.
   ========================================================================== */

/* The scroll-in fade lives in css/components/reveal.css, shared with the
   landing page. Every piece page links that file before this one. */

/* --- Hero ----------------------------------------------------------------- */
.piece-hero {
  /* Was 9vw up to 6rem on top. The title is display-sized and the sticky
     header already sets it off, so the extra lead-in only pushed the video
     below the fold. */
  padding-block: clamp(var(--space-6), 5vw, var(--space-8)) var(--space-5);
}

.piece-hero__kicker {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-accent);
}

/* The Pofo signature: display type as large as the viewport will bear.
   Each line is its own block so the title stacks, as TRAVERSE over TOWN. */
.piece-title {
  margin-top: var(--space-4);
  font-family: var(--font-display-alt);
  font-size: clamp(2.6rem, 8.4vw, 7.5rem);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-wrap: balance;
}
/* Long titles wrap to three or four lines at the full size, which pushes the
   trailer off screen entirely. Apply --long past roughly 35 characters. */
.piece-title--long {
  font-size: clamp(2.1rem, 5.4vw, 4.4rem);
  line-height: 0.98;
}
/* One step further down, for a single line past roughly 30 characters — at
   --long it overruns the container and wraps mid-phrase. */
.piece-title--xlong {
  font-size: clamp(1.8rem, 4.3vw, 3.5rem);
  line-height: 1.02;
}

.piece-title__line { display: block; }
/* Second line sits lighter, so the stack has hierarchy. */
.piece-title__line--soft { color: var(--color-text-muted); }

/* --- Meta strip: label above value, in a row that wraps -------------------- */
.piece-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5) var(--space-7);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  list-style: none;
}

.piece-meta__label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-subtle);
}
.piece-meta__value {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-base);
  font-weight: 500;
}

/* --- Media ---------------------------------------------------------------- */

/* Wider than the text container, but still gutter-safe on small screens. */
.piece-media--bleed {
  width: 100%;
  margin-inline: auto;
  max-width: min(112rem, 100%);
  padding-inline: var(--gutter);
}

.piece-video,
.piece-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--ink-950);
  box-shadow: var(--shadow-lg);
}
.piece-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* YouTube embeds. Sized by the wrapper's aspect-ratio, so no padding hack. */
.piece-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.piece-media__caption {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* --- Sections: label column on the left, content on the right -------------
   Pofo and the Traverse Town reference both anchor a small uppercase label
   beside a wide content column. Collapses to one column on narrow screens.
   -------------------------------------------------------------------------- */
.piece-section {
  padding-block: var(--section-y);
  border-top: 1px solid var(--color-border);
}
.piece-section--sunken { background-color: var(--color-bg-sunken); }

.piece-section__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
@media (min-width: 56rem) {
  .piece-section__grid {
    grid-template-columns: minmax(9rem, 1fr) minmax(0, 3fr);
    gap: var(--space-7);
  }
}

/* A section with no label (the briefs' summary sections have none) leaves a
   single child, which would otherwise land in the narrow label column and read
   as a squashed strip on wide screens. Let it span the whole grid and use the
   full measure — the point of these sections is one short, prominent statement. */
.piece-section__grid > :only-child { grid-column: 1 / -1; }
.piece-section__grid > :only-child .piece-section__body { max-width: none; }

.piece-section__label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.piece-section__heading {
  font-family: var(--font-display-alt);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.piece-section__body {
  margin-top: var(--space-4);
  max-width: var(--width-text);
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}
.piece-section__body > * + * { margin-top: var(--space-4); }

/* Lead paragraph — the line that should land hardest. */
.piece-lede {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  color: var(--color-text);
}

/* --- Credit list, em-dash marked (Traverse Town idiom) -------------------- */
.piece-list {
  margin-top: var(--space-4);
  list-style: none;
  padding: 0;
  columns: 2;
  column-gap: var(--space-6);
}
@media (max-width: 40rem) { .piece-list { columns: 1; } }

.piece-list li {
  break-inside: avoid;
  padding-block: var(--space-2);
  color: var(--color-text-muted);
}
.piece-list li::before {
  content: "―";
  margin-right: var(--space-2);
  color: var(--color-accent);
}

/* --- Gallery -------------------------------------------------------------- */
.piece-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr));
  gap: var(--space-4);
  margin-top: var(--space-5);
}
.piece-gallery img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
  background-color: var(--color-bg-sunken);
}

/* --- Placeholder ----------------------------------------------------------
   Deliberately loud. Anything wearing this class is unfinished content that
   must never reach production — grep for "placeholder" before deploying.
   -------------------------------------------------------------------------- */
.placeholder {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  min-height: 9rem;
  padding: var(--space-5);
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background-color: var(--color-bg-sunken);
  color: var(--color-text-subtle);
  text-align: center;
}
.placeholder::before {
  content: "Placeholder";
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-accent);
}
.placeholder p { font-size: var(--text-sm); margin: 0; }
.placeholder--media { aspect-ratio: 16 / 9; min-height: 0; }

/* --- Related work --------------------------------------------------------
   Moved out on 2026-08-28. The block is now css/components/related-work.css,
   built by js/modules/relatedWork.js from js/data/pieces.js — .piece-nav and
   its slug -> thumbnail map are gone, along with the per-page hand-editing
   they cost. Piece pages carry a <section data-related-work> placeholder.
   -------------------------------------------------------------------------- */

/* --- Looping clips (the GIF replacement) ----------------------------------
   A short, silent, autoplaying loop. It reads as a moving still rather than a
   player, so there is no controls chrome until js/modules/loopVideo.js has to
   fall back — see .piece-video--loop video[controls] below.

   The masters are 1920x1080, so the 16:9 of .piece-video is right; these sit
   two-up on a wide screen and stack on a narrow one.
   -------------------------------------------------------------------------- */
.piece-loops {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}
/* .piece-section__label carries no bottom margin — it is built to sit in the
   narrow left column of .piece-section__grid. Used as a heading above this
   grid it needs the gap put back. */
.piece-section__label + .piece-loops { margin-top: var(--space-4); }
@media (min-width: 48rem) {
  .piece-loops { grid-template-columns: 1fr 1fr; }
}

/* --dense: for a run of short title cards rather than a pair of gameplay
   clips. Eight of them two-up is four rows and about 1200px of page for
   content that is a single word each; auto-fit off a 17rem minimum puts three
   or four across on a desktop and still collapses to one on a phone. The
   clips are 1920x1080 masters, so they hold up at a third of the width.

   It has to stay BELOW the 48rem block above: both selectors are one class, so
   the media query buys no specificity and only source order decides which
   grid-template-columns wins. Move this up and the two-up rule takes it back. */
.piece-loops--dense {
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
  gap: var(--space-4);
}

.piece-video--loop {
  aspect-ratio: 16 / 9;
}
.piece-video--loop video {
  display: block;
  cursor: default;
}
/* When autoplay was refused the visitor gets controls back, and with them the
   pointer affordance that says the clip is theirs to start. */
.piece-video--loop video[controls] {
  cursor: pointer;
}
