/*
 * Product media.
 *
 * Designed at 375 px, where the whole section is one column: the featured card
 * full width, then the secondary cards as a snap rail the thumb can flick. On
 * desktop the featured card takes two thirds and the rail becomes a column
 * beside it. Nothing is added or removed between the two.
 *
 * The stage is always 16:9 and always laid out before anything loads, so a
 * poster decoding, a plate painting, or a player opening never moves the page.
 */

.root {
  display: grid;
  /*
   * Explicit, and load-bearing. A grid track defaults to `min-width: auto`,
   * which means "never smaller than my content" — and the rail's content is a
   * row of fixed-width cards. Without this the track grows to the full
   * un-scrolled width of the rail and the page rocks sideways at 375 px.
   */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s6);
  /* Each card resolves its own module accent; this is the fallback. */
  --accent: var(--rule-strong);
}

.root [data-module="financa"] {
  --accent: var(--m-financa);
}

.root [data-module="materiale"] {
  --accent: var(--m-materiale);
}

.root [data-module="paga"] {
  --accent: var(--m-paga);
}

.root [data-module="bar-restorant"] {
  --accent: var(--m-bar-restorant);
}

/* ---- The card ----------------------------------------------------------- */

.card {
  display: grid;
  gap: var(--s4);
  align-content: start;
}

/*
 * The stage. A fixed aspect box with the plate behind it, so the card has its
 * final height from the first frame whether it ends up holding a poster, a
 * drawn plate or a player.
 */
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--navy);
  overflow: hidden;
}

.open {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

/*
 * <picture> is a wrapper with no intrinsic size, so the image inside it cannot
 * resolve a percentage height against it — without this the poster falls back
 * to its own aspect and leaves the stage showing above and below it.
 */
.open picture {
  display: block;
  width: 100%;
  height: 100%;
}

.poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /*
   * The frame is a 2020-era Windows application: light, blue-chromed and a
   * little loud next to this palette. A hair of desaturation settles it into
   * the page without touching what it shows, and it returns to full on hover
   * so the thing a reader is about to open looks like itself.
   */
  filter: saturate(0.82);
  transition:
    filter var(--t-base) var(--ease),
    transform var(--t-slow) var(--ease);
}

.open:hover .poster,
.open:focus-visible .poster {
  filter: saturate(1);
  transform: scale(1.012);
}

/* ---- The document plate ------------------------------------------------- */

/*
 * Where no cleared poster exists, the card draws the product's own document:
 * the ledger's rule pairs, the delivery note's numbered lines, the payslip's
 * grid, the table map's places, in the secondary blue at low strength, with
 * the product's name set large. Not a photograph of the software and not
 * pretending to be one; unmistakably a piece of media belonging to a named
 * part of Nexys. The mark's blades no longer appear here: the mark means the
 * opening now, and a plate is a document.
 *
 * The name sits at the top. The play cue owns the bottom-left corner and the
 * running time the bottom-right.
 */
.plate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  padding: var(--s5);
  background: var(--navy);
}

.plateArt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ruling {
  stroke: var(--blue-2);
  stroke-width: 3;
  opacity: 0.42;
}

.rulingStrong {
  stroke: #fff;
  stroke-width: 5;
  opacity: 0.55;
}

.rulingCell {
  fill: none;
  stroke: var(--blue-2);
  stroke-width: 3;
  opacity: 0.42;
}

.rulingCellOpen {
  fill: var(--green);
  stroke: var(--green);
  stroke-width: 3;
  opacity: 0.55;
}

.plateMark {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
  max-width: 11ch;
}

/* ---- Play cue and running time ------------------------------------------ */

/*
 * A square, not a circle, and no shadow: the site has no round corners and no
 * shadows anywhere else, and a glassy pill here would be the one piece of
 * borrowed interface on the whole page.
 */
.cue {
  position: absolute;
  left: var(--s4);
  bottom: var(--s4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--paper);
  color: var(--ink);
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.open:hover .cue,
.open:focus-visible .cue {
  background: var(--accent);
  color: #fff;
}

.duration {
  position: absolute;
  right: var(--s4);
  bottom: var(--s4);
  padding: 2px var(--s2);
  background: rgb(9 23 52 / 0.82);
  color: #fff;
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  letter-spacing: 0.04em;
}

.player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- The text ----------------------------------------------------------- */

.body {
  display: grid;
  gap: var(--s2);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2);
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.kicker {
  color: var(--accent);
}

.sep {
  color: var(--rule-strong);
}

.lead {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  max-width: 46ch;
  text-wrap: pretty;
}

/*
 * The video's own title, verbatim and quiet — often Macedonian on an Albanian
 * page, because it is a quotation from the archive rather than interface copy.
 */
.title {
  margin: 0;
  font-size: var(--step-small);
  color: var(--ink-2);
  max-width: 46ch;
}

.action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
  margin: var(--s2) 0 0;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  margin-inline-start: calc(var(--s3) * -1);
  padding-inline: var(--s3);
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: var(--step-small);
  font-weight: 500;
  color: var(--ink);
  transition: color var(--t-colour) linear;
}

.cta:hover {
  color: var(--accent);
}

.arrow {
  font-weight: 400;
  display: inline-block;
  transition: transform var(--t-colour) var(--ease);
}

.cta:hover .arrow {
  transform: translateX(3px);
}

.away {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--muted);
}

.note {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--muted);
  max-width: 64ch;
}

/* ---- On the system's surface ------------------------------------------- */

[data-surface="ink"] .lead,
[data-surface="ink"] .cta {
  color: #fff;
}

[data-surface="ink"] .title {
  color: var(--mat);
}

[data-surface="ink"] .meta,
[data-surface="ink"] .note,
[data-surface="ink"] .away {
  color: var(--muted-2);
}

[data-surface="ink"] .kicker {
  color: var(--blue-2);
}

[data-surface="ink"] .sep {
  color: var(--rule-navy);
}

[data-surface="ink"] .cta:hover {
  color: var(--green);
}

[data-surface="ink"] .stage {
  outline: var(--hairline) solid var(--rule-navy);
}

[data-surface="ink"] .rail:focus-visible {
  outline-color: #fff;
}

/* ---- The secondary rail ------------------------------------------------- */

.rail {
  display: grid;
  gap: var(--s6);
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.cell {
  min-width: 0;
}

.rail:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/*
 * On a phone the secondary cards are a snap rail rather than a stack: three
 * full-width cards one under another turns a showcase into a scroll, and the
 * rail keeps the section to about a screen and a half while making it obvious
 * there is more than one.
 */
@media (max-width: 767px) {
  .root[data-variant="showcase"] .rail {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    gap: var(--s4);
    padding-bottom: var(--s3);
  }

  .root[data-variant="showcase"] .cell {
    flex: 0 0 min(78%, 20rem);
    scroll-snap-align: start;
  }
}

/* ---- Wider -------------------------------------------------------------- */

@media (min-width: 768px) {
  .rail {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }
}

@media (min-width: 1024px) {
  /*
   * On a product page the video sits beside its own description rather than
   * above it. A single 16:9 stage at the full container width is 1,200 px of
   * navy for one sentence — it reads as a banner dropped onto the page, which
   * is the opposite of belonging to it.
   */
  .root[data-variant="inline"] .card {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--s7);
    align-items: center;
  }

  .root[data-variant="inline"] .plateMark {
    font-size: 1.75rem;
  }

  /*
   * The featured card and its two companions side by side: one thing to look
   * at, two to notice. A three-up grid of equals would make none of them the
   * reason the section exists.
   */
  .root[data-variant="showcase"] {
    grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
    gap: var(--s7);
    align-items: start;
  }

  .root[data-variant="showcase"] .featured {
    grid-row: span 2;
  }

  .root[data-variant="showcase"] .rail {
    grid-auto-flow: row;
    gap: var(--s6);
  }

  .root[data-variant="showcase"] .note {
    grid-column: 1 / -1;
  }

  .card[data-size="small"] .plateMark {
    font-size: 1.375rem;
  }

  .card[data-size="small"] .cue {
    width: 40px;
    height: 40px;
    left: var(--s3);
    bottom: var(--s3);
  }

  .card[data-size="small"] .plate {
    padding: var(--s4);
  }
}

/* ---- Motion ------------------------------------------------------------- */

/*
 * The card's text follows the band's own entrance — provenance, then what it
 * is, then the way in — using the same three beats the archive records use, so
 * a page carrying both reads as one system rather than two.
 *
 * The stage itself never animates in. It is the largest object in the band and
 * a 16:9 plate sliding or fading would be exactly the carousel behaviour this
 * section exists to avoid.
 */
@media (prefers-reduced-motion: no-preference) {
  [data-enter="out"] .body > [data-enter-part] {
    opacity: 0;
  }

  [data-enter="in"] .body > [data-enter-part] {
    animation: media-in 300ms var(--ease-out) both;
  }

  [data-enter="in"] .body > [data-enter-part="meta"] {
    animation-delay: 40ms;
  }

  [data-enter="in"] .body > [data-enter-part="title"] {
    animation-delay: 110ms;
  }

  [data-enter="in"] .body > [data-enter-part="action"] {
    animation-delay: 180ms;
  }

  @keyframes media-in {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .poster,
  .cue,
  .arrow {
    transition: none;
  }

  .open:hover .poster,
  .open:focus-visible .poster {
    transform: none;
  }
}

/* ---- The feature: the recording as a chapter ---------------------------- */

/*
 * The featured recording at the full width of the chapter, its stage the
 * largest object on the page after the opening; beneath it the card's own
 * line and action, and beside those the day it shows — first step, last
 * step — in the product's own words. The other recordings follow as a row
 * of two, not a rail.
 */
.root[data-variant="feature"] .featured {
  display: grid;
  gap: var(--s5);
}

.root[data-variant="feature"] .featured .card {
  gap: var(--s5);
}

.frame {
  display: grid;
  gap: var(--s4);
  margin: 0;
  border-top: var(--hairline) solid var(--rule-navy);
  padding-top: var(--s4);
}

.frameStep {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s3);
  align-items: baseline;
}

.frameIndex {
  display: grid;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: var(--step-body);
  color: var(--green);
  min-width: 3ch;
}

.frameLabel {
  font-size: var(--step-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

.frameText {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.35;
  color: #fff;
  max-width: 34ch;
}

.rail[data-variant="feature"] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}

.rail[data-variant="feature"] .card[data-size="small"] .plateMark {
  font-size: 1.125rem;
}

.rail[data-variant="feature"] .card[data-size="small"] .cue {
  width: 40px;
  height: 40px;
  left: var(--s3);
  bottom: var(--s3);
}

.rail[data-variant="feature"] .card[data-size="small"] .plate {
  padding: var(--s3);
}

.rail[data-variant="feature"] .card[data-size="small"] .lead {
  font-size: var(--step-small);
}

@media (min-width: 768px) {
  .frame {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s6);
  }

  .rail[data-variant="feature"] {
    gap: var(--s6);
  }
}

@media (min-width: 1024px) {
  .root[data-variant="feature"] .featured .card {
    grid-template-columns: minmax(0, 1fr);
  }

  .root[data-variant="feature"] .featured .body {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--s6);
    align-items: start;
  }

  .root[data-variant="feature"] .featured .body .meta {
    grid-column: 1;
  }

  .root[data-variant="feature"] .featured .body .lead {
    grid-column: 1;
    max-width: 52ch;
    font-size: 1.25rem;
  }

  .root[data-variant="feature"] .featured .body .title {
    grid-column: 1;
  }

  .root[data-variant="feature"] .featured .body .action {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: end;
  }

  .root[data-variant="feature"] .rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s7);
  }

  .root[data-variant="feature"] .cell .card {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: var(--s5);
    align-items: center;
  }
}
