/* Frame Judge — app-local layout only.
   Every color/radius/type value below MUST reference a var(--color-*) /
   var(--radius-*) / var(--text-*) / var(--spacing-*) role token from lh-ui.css.
   No raw hex — see ANTI-SLOP.md. */

#fj-nav-score {
  white-space: nowrap;
}

.fj-progress-row {
  justify-content: space-between;
}

/* ── The matchup card ────────────────────────────────────────────────────
   overscroll-behavior-x + touch-action guard a Chromebook trackpad two-finger
   horizontal swipe from being interpreted as browser back/forward navigation
   while the user is dragging a photo choice (pre-mortem adjustment). */
.fj-matchup {
  position: relative;
  touch-action: pan-y;
  overscroll-behavior-x: contain;
  user-select: none;
  -webkit-user-select: none;
}

.fj-photo {
  position: relative;
  aspect-ratio: 16 / 9; /* v2 content is generated 16:9; a 4:3 cover-crop tightened every frame */
  overflow: hidden;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
              background-color var(--duration-fast) var(--ease-standard);
}

.fj-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none; /* the whole tile is the drag/tap target, not the <img> */
}

/* Designed hover + focus states (Tier 0 App-UI floor: intentional, not default). */
.fj-photo:hover {
  border-color: var(--color-border-strong);
}
.fj-photo:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-color: var(--color-accent);
}

/* Applied by JS while a drag is in progress, to the side the drag is heading
   toward / away from. transform/opacity only — motion budget compliant. */
.fj-photo.is-leading {
  border-color: var(--color-accent);
}
.fj-photo.is-trailing {
  opacity: 0.7;
}

/* Correct / incorrect flash after a commit (JS toggles briefly before the
   feedback screen swaps in; skipped entirely under reduced-motion). */
.fj-photo.is-correct {
  border-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface-2));
}
.fj-photo.is-incorrect {
  border-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 12%, var(--color-surface-2));
}

.fj-controls {
  justify-content: center;
}

#fj-feedback-badge {
  width: fit-content;
}

/* ── Responsive ──────────────────────────────────────────────────────────
   lh-grid--2 already collapses to a single column at 720px (lh-ui.css), so
   the two photos stack full-width on a 375px phone instead of squeezing
   side by side. This just tunes spacing/height at each tested breakpoint. */
@media (max-width: 719px) {
  .fj-photo { aspect-ratio: 16 / 9; }
  .fj-controls { flex-direction: column; align-items: stretch; }
  .fj-controls .lh-btn { width: 100%; }
}

@media (min-width: 1024px) {
  .fj-photo { aspect-ratio: 16 / 9; }
}

@media (min-width: 1440px) {
  .fj-matchup { gap: var(--spacing-xl); }
}

/* ════════════════════════════════════════════════════════════════════════
   v3 additions — real photographs, four formats, review deck.
   Same rule as above: role tokens only, no raw hex, no shadows.
   ════════════════════════════════════════════════════════════════════════ */

/* Real photos come in every aspect ratio. Letterbox inside the 16:9 tile
   instead of cover-cropping: a cover crop would change the very composition
   (thirds, negative space, balance) the student is asked to judge. */
.fj-photo img {
  object-fit: contain;
}

.fj-side {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xs);
  min-width: 0;
}

/* Credit line: never truncated, wraps anywhere a long photographer name or
   URL-ish credit needs it to. */
.fj-credit {
  margin: 0;
  color: var(--color-fg-muted);
  overflow-wrap: anywhere;
}
.fj-credit__lead {
  color: var(--color-fg-subtle);
}
.fj-credit__pexels {
  display: block;
}

/* lh-cluster sets display:flex, which beats the UA [hidden] rule. */
.fj-progress-row[hidden] {
  display: none;
}

/* The question heading takes programmatic focus (tabindex=-1) so keyboard and
   screen-reader users land on the new question; it is not a control, so it
   gets no focus ring. */
.fj-question:focus,
.fj-question:focus-visible {
  outline: none;
}

/* ── Single-photo formats (name / settings) ────────────────────────────── */
.fj-photo--solo {
  aspect-ratio: var(--ar, 16 / 9);
  width: 100%;
  max-height: 52vh;
  cursor: default;
}
.fj-photo--solo:hover,
.fj-photo--static:hover {
  border-color: var(--color-border);
}
.fj-photo--static {
  cursor: default;
}

.fj-options {
  gap: var(--spacing-sm);
}
.fj-option {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  transition: transform var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.fj-option:hover {
  transform: translateY(-1px);
}
.fj-option:active {
  transform: scale(0.97);
}
.fj-option__key {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-fg-subtle);
  min-width: 1ch;
}
.fj-option.is-correct {
  border-color: var(--color-success);
  color: var(--color-success);
}
.fj-option.is-incorrect {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ── Crop pair ─────────────────────────────────────────────────────────────
   Each tile is a size container; the crop view fits inside it with the crop's
   own aspect ratio (container-query units), the photo offset inside it. */
.fj-crop-tile {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xs);
  min-width: 0;
}
.fj-photo--crop {
  container-type: size;
  display: grid;
  place-items: center;
}
.fj-crop {
  position: relative;
  overflow: hidden;
  width: min(100cqw, calc(100cqh * var(--ar)));
  height: min(100cqh, calc(100cqw / var(--ar)));
}
.fj-photo .fj-crop img {
  position: absolute;
  max-width: none;
  object-fit: fill;
}
.fj-crop-label {
  margin: 0;
  color: var(--color-fg-muted);
}

/* ── Unit picker ───────────────────────────────────────────────────────── */
.fj-units {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--spacing-sm);
}
.fj-units legend {
  margin-bottom: var(--spacing-xs);
}
.fj-unit {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
}
.fj-unit input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.fj-unit:hover {
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}
.fj-unit:active {
  transform: scale(0.98);
}
.fj-unit:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-surface-2);
}
.fj-unit:has(input:checked) .fj-unit__name {
  color: var(--color-accent);
}
.fj-unit:has(input:focus-visible) {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}
.fj-unit:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
.fj-unit__name {
  font-weight: 600;
}

/* ── Explainer ─────────────────────────────────────────────────────────── */
.fj-example {
  border-left: 2px solid var(--color-rule);
  padding-left: var(--spacing-md);
}
.fj-example p {
  margin: 0;
}

/* ── Feedback extras ───────────────────────────────────────────────────── */
.fj-answer {
  font-weight: 600;
}
.fj-feedback-credits {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xs);
  padding-top: var(--spacing-xs);
  border-top: 1px solid var(--color-border);
}

.fj-unit-scores {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--spacing-2xs) var(--spacing-md);
  margin: 0;
}
.fj-unit-scores dd {
  margin: 0;
}

/* ── Review deck + grid ────────────────────────────────────────────────── */
.fj-review-card {
  touch-action: pan-y;
  overscroll-behavior-x: contain;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.fj-review-card.is-flag,
.fj-grid-card.is-flag {
  border-color: var(--color-danger);
}
.fj-review-card.is-keep {
  border-color: var(--color-success);
}
.fj-review-card .fj-photo--solo {
  max-height: 44vh;
}
.fj-meta {
  margin: 0;
}
.fj-id {
  font-family: var(--font-mono);
  color: var(--color-fg);
}
.fj-face-question {
  font-weight: 600;
  margin: 0;
}
.fj-note-label {
  font-weight: 600;
}
.fj-mark {
  width: fit-content;
}
.fj-flagged {
  font-family: var(--font-mono);
  width: 100%;
}

.fj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--spacing-md);
  align-items: start;
}
.fj-grid-card .fj-face-pair {
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-xs);
}
.fj-grid-card .fj-photo--solo {
  max-height: 240px;
}
.fj-flag-toggle[aria-pressed="true"] {
  color: var(--color-danger);
}

@media (max-width: 719px) {
  .fj-units { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fj-options { flex-direction: column; align-items: stretch; }
  .fj-options .lh-btn { width: 100%; justify-content: flex-start; }
  /* Crops stay side by side on phones: comparing two crops of ONE photo only
     works when they sit next to each other. */
  .fj-crops { grid-template-columns: 1fr 1fr; gap: var(--spacing-sm); }
  .fj-photo--crop { aspect-ratio: 1 / 1; }
}

@media (prefers-reduced-motion: reduce) {
  .fj-option, .fj-unit { transition: none; }
  .fj-option:hover, .fj-option:active, .fj-unit:hover, .fj-unit:active { transform: none; }
}

/* ── Phone fit: matchup + review deck (verify-app F1, F5) ──────────────────
   At phone width two stacked tiles, two credit lines, a wrapped question and
   the answer buttons do not fit a 390×844 screen at 16:9. While the matchup
   or a review card is showing, the page becomes exactly one viewport tall
   and the photo tiles give up height (letterboxed, never cropped) so the
   credits and the answer / Keep / Flag buttons stay on screen. Anything that
   still cannot fit scrolls inside <main> (matchup) or inside the card
   (review), never pushing the buttons off screen. The byline footer is
   hidden on those two phone screens only. Tablet and desktop keep
   the 16:9 tiles above. */
@media (max-width: 719px) {
  body:has(#screen-matchup:not([hidden])),
  body:has(#screen-review:not([hidden]) #fj-review-deal:not([hidden])) {
    height: 100svh;
    display: flex;
    flex-direction: column;
  }
  body:has(#screen-matchup:not([hidden])) > main,
  body:has(#screen-review:not([hidden]) #fj-review-deal:not([hidden])) > main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-block: var(--spacing-md);
    gap: var(--spacing-md);
    overflow-y: auto;
  }
  /* The one-line byline footer would eat the pinned viewport; it comes back
     on every other screen. */
  body:has(#screen-matchup:not([hidden])) > footer,
  body:has(#screen-review:not([hidden]) #fj-review-deal:not([hidden])) > footer {
    display: none;
  }
  main > #screen-matchup:not([hidden]),
  main > #screen-review:not([hidden]),
  #fj-review-deal:not([hidden]) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  main > #screen-matchup { --element-gap: var(--spacing-sm); }
  #screen-matchup .fj-question {
    font-size: var(--text-subheading);
    line-height: var(--leading-subheading);
    letter-spacing: var(--tracking-subheading);
  }

  /* Tiles: 16:9 of the column width when there is room, shorter when not. */
  #fj-matchup {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  #fj-matchup .fj-side {
    flex: 0 1 auto;
    min-height: 0;
    container-type: inline-size;
  }
  #fj-matchup .fj-photo {
    aspect-ratio: auto;
    height: 56.25cqw;
    flex: 0 1 auto;
    min-height: 96px;
  }
  #fj-matchup .fj-credit { flex: 0 0 auto; }

  /* Answer and Keep / Flag buttons: one row, not a stack. */
  #screen-matchup .fj-controls,
  #fj-review-deal .fj-controls {
    flex-direction: row;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  #screen-matchup .fj-controls .lh-btn,
  #fj-btn-flag,
  #fj-btn-keep {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    padding-inline: var(--spacing-xs);
    white-space: nowrap;
  }
  #fj-review-deal .fj-controls #fj-btn-review-back { width: auto; flex: 0 0 auto; }

  /* Review card: pair side by side like the grid, and a long judge note
     scrolls inside the card so Keep / Flag stay pinned below it. */
  .fj-review-card {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  .fj-review-card .fj-face-pair {
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-xs);
  }
  .fj-review-card .fj-photo--solo { max-height: 32svh; }
  #fj-review-deal > * { flex-shrink: 0; }
  #fj-review-deal > .fj-review-card { flex-shrink: 1; }
}

/* ── Short wide viewports (Chromebook 1366×657, landscape phones) — carried
   debt from verify-app F-a. Above 719px the phone-fit block does not apply,
   so on a short window the 16:9 tiles pushed the answer and Keep / Flag
   buttons below the fold. Clamp tile height to what the viewport leaves
   after the question, credits and controls; the image letterboxes
   (object-fit: contain), never crops. */
@media (min-width: 720px) and (max-height: 820px) {
  #fj-matchup .fj-photo { max-height: max(90px, calc(100svh - 330px)); }
  .fj-photo--solo { max-height: max(90px, calc(100svh - 360px)); }
  .fj-photo--crop { max-height: max(90px, calc(100svh - 400px)); }
  .fj-review-card .fj-photo--solo { max-height: max(90px, calc(100svh - 420px)); }
}

/* ════════════════════════════════════════════════════════════════════════
   Design track — Photography | Design tabs, diagrams on reference cards.
   Same rule: role tokens only, no raw hex, no shadows.
   ════════════════════════════════════════════════════════════════════════ */

/* A design URL: index.html marks <html> before first paint and app.js clears
   it once the Design copy is in, so the Photography markup never flashes. */
html[data-fj-pending="design"] #screen-start {
  visibility: hidden;
}

/* Flat segmented control: one bordered well on surface-2; the selected tab
   steps up to surface with an ink border and heavier type. Equal columns, so
   the weight change never shifts the other tab. */
.fj-tracks {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--spacing-2xs);
  width: fit-content;
  padding: var(--spacing-2xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-button);
  background: var(--color-surface-2);
}
.fj-track {
  min-height: 44px;
  padding: var(--spacing-xs) var(--spacing-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--color-fg-muted);
  font: inherit;
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.fj-track:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}
.fj-track:active {
  transform: scale(0.97);
}
.fj-track:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}
.fj-track[aria-selected="true"] {
  background: var(--color-surface);
  border-color: var(--color-fg);
  color: var(--color-fg);
  font-weight: var(--weight-strong);
  cursor: default;
}
.fj-track[aria-selected="true"]:hover {
  transform: none;
}

/* Reference-card diagram (design explainers): smaller than a drill tile so
   the definition, the example and "Got it" stay on screen. */
.fj-explainer .fj-photo--solo {
  max-height: 34vh;
}
/* On a wide screen the card with a diagram goes two-column: the words on the
   left, the diagram beside them. A longer definition then grows the text
   column instead of pushing "Got it" below a 657px Chromebook fold. Photo
   cards (no diagram) keep the single measured column. */
@media (min-width: 1024px) {
  #screen-explainer:has(#fj-explainer-media:not([hidden])) {
    max-width: 60rem;
  }
  .fj-explainer:has(#fj-explainer-media:not([hidden])) > .lh-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "eyebrow media"
      "title   media"
      "body    media"
      "example media";
    column-gap: var(--spacing-xl);
    row-gap: var(--element-gap);
    align-items: start;
  }
  .fj-explainer:has(#fj-explainer-media:not([hidden])) > .lh-stack > * {
    margin-top: 0;
  }
  #fj-explainer-eyebrow { grid-area: eyebrow; }
  #fj-explainer-title { grid-area: title; }
  #fj-explainer-body { grid-area: body; }
  #fj-explainer-media { grid-area: media; align-self: center; }
  .fj-explainer .fj-example { grid-area: example; }
  /* Beside the text the diagram has the height it needs: no letterbox. */
  .fj-explainer .fj-photo--solo { max-height: 56vh; }
}

@media (max-width: 719px) {
  .fj-tracks { width: 100%; }
}

/* The tab bar takes the place of the section's top air: on a short screen
   the start screen's top padding shrinks by about the bar's height, so
   "Start practicing" stays above the fold (1366×657 Chromebook, 390×844
   phone) as it was before the tabs. Tall screens keep the full air. */
@media (max-height: 900px) {
  body:has(#screen-start:not([hidden])) > main { padding-top: var(--spacing-lg); }
}
@media (max-height: 900px) and (max-width: 719px) {
  body:has(#screen-start:not([hidden])) > main { padding-top: var(--spacing-md); }
}

/* Stacked card on a short tablet-width screen: the diagram gives up height. */
@media (min-width: 720px) and (max-width: 1023px) and (max-height: 820px) {
  .fj-explainer .fj-photo--solo { max-height: max(90px, calc(100svh - 470px)); }
}
/* Phone: a card with a diagram starts right under the nav (as the start
   screen does), so a longer definition still leaves "Got it" on screen. */
@media (max-width: 719px) {
  body:has(#fj-explainer-media:not([hidden])) > main { padding-top: var(--spacing-md); }
}

@media (prefers-reduced-motion: reduce) {
  .fj-track { transition: none; }
  .fj-track:hover, .fj-track:active { transform: none; }
}
