/*
 * The CISF cabin TV screen. One 3840 x 2160 TV (LG 43UA831C0LA), no touch, no
 * keyboard, no navigation: a single full-bleed page that fills the viewport.
 * Every size comes from tv-tokens.css (one set per breakpoint, from the
 * responsive standard, section 6); there is no vw, vh or clamp() in this file.
 */

/* No keyboard on this screen: no focus ring anywhere on it. */
.cisf-tv-root :focus,
.cisf-tv-root :focus-visible {
  outline: none;
  box-shadow: none;
}

.cisf-tv-root {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--color-bg-default);
}

/* The three rows: header, main, and the fixed-height bottom row, so the
   panels do not change size from one state of the screen to the next. */
.cisf-tv-shell {
  width: 100%;
  height: 100%;
  padding: var(--tv-outer);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) var(--tv-bottom-h);
  gap: var(--tv-gap);
  overflow: hidden;
}

/* Header */
.cisf-tv-header {
  background: var(--color-primary-dark);
  color: var(--color-on-primary);
  border: var(--tv-border) solid var(--color-primary-main);
  border-radius: var(--tv-radius-surface);
  padding: var(--tv-nav-pad) calc(var(--tv-nav-pad) * 2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-nav-gap);
  flex-wrap: nowrap;
  overflow: hidden;
}

.cisf-tv-header__brand {
  display: flex;
  align-items: center;
  gap: var(--tv-nav-gap);
  min-width: 0;
}

/* The logo box has a fixed height; the picture keeps its own proportions
   (254 x 330) inside it and never grows past it. */
.cisf-tv-header__logo {
  height: var(--tv-logo-h);
  aspect-ratio: 254 / 330;
  flex-shrink: 0;
  display: block;
}

.cisf-tv-header__logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cisf-tv-header__title {
  font-size: var(--tv-fs-title);
  line-height: var(--tv-lh-title);
  font-weight: 900;
  margin: 0;
  white-space: nowrap;
}

.cisf-tv-header__authority {
  font-size: var(--tv-fs-body2);
  line-height: var(--tv-lh-body2);
  color: var(--color-primary-light);
  font-weight: 700;
  white-space: nowrap;
  display: block;
}

.cisf-tv-header__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: var(--tv-nav-gap);
  min-width: 0;
}

/* Gate, direction, date and time: rounded rectangles of the interactive
   radius, as the badges on the TA and Admin portals. Never a full pill. */
.cisf-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--tv-pill-y) / 1.5);
  padding: var(--tv-pill-y) var(--tv-pill-x);
  border: var(--tv-border) solid var(--color-on-primary-muted);
  border-radius: var(--tv-radius-ctrl);
  background: var(--color-primary-main);
  color: var(--color-on-primary);
  white-space: nowrap;
  font-size: var(--tv-fs-pill);
  line-height: var(--tv-lh-pill);
  font-weight: 800;
}

.cisf-meta-pill .cisf-icon {
  width: var(--tv-icon-inline);
  height: var(--tv-icon-inline);
}

/* The direction badge sits inside its pill: text only, no second shape. */
.cisf-tv-header .cisf-direction-pill .cisf-direction-badge {
  border-radius: 0;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: 0.04em;
}

/* Main grid: the CGP panel and the images, side by side from 1536px. */
.cisf-tv-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--tv-gap);
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 1920px) and (min-height: 1000px) {
  .cisf-tv-main {
    grid-template-columns: minmax(0, 3fr) minmax(0, 7fr);
    grid-template-rows: minmax(0, 1fr);
  }
}

.cisf-panel {
  min-height: 0;
  padding: var(--tv-panel-pad);
  border-radius: var(--tv-radius-surface);
  border: var(--tv-border) solid var(--color-divider);
  background: var(--color-bg-paper);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* The same title in every panel: h3. The compact variant is gone. */
.cisf-panel__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-row-gap);
  margin-bottom: calc(var(--tv-row-gap) / 2);
}

.cisf-panel__title {
  font-size: var(--tv-fs-h3);
  line-height: var(--tv-lh-h3);
  font-weight: 900;
  color: var(--color-primary-dark);
  margin: 0;
}

/* Panel body wrappers the JS renders into: flex containers so a child can
   take the remaining height. */
#cisf-cgp-body,
#cisf-validation-body,
#cisf-purpose-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cisf-badge {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--tv-pill-y) / 2);
  padding: calc(var(--tv-pill-y) / 2) var(--tv-pill-x);
  border-radius: var(--tv-radius-ctrl);
  background: var(--color-primary-dark);
  color: var(--color-on-primary);
  font-size: var(--tv-fs-body2);
  line-height: var(--tv-lh-body2);
  font-weight: 700;
  white-space: nowrap;
}

.cisf-badge .cisf-icon {
  width: var(--tv-icon-inline);
  height: var(--tv-icon-inline);
  display: block;
}

/* The icon's wrapper is an inline box with its own line height, which sat the
   camera below the middle of the text line: make it a flex box so the icon is
   centred on the line. */
.cisf-badge > span {
  display: inline-flex;
  align-items: center;
}

/* No CGP / No details / empty value */
.cisf-no-cgp,
.cisf-no-details {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--tv-row-gap);
  text-align: center;
  border-radius: var(--tv-radius-surface);
}

.cisf-no-cgp {
  background: var(--color-error-light);
  border: var(--tv-border) dashed var(--status-danger);
}

.cisf-no-cgp__line {
  font-size: var(--tv-fs-h2);
  line-height: var(--tv-lh-h2);
  font-weight: 900;
  color: var(--status-danger);
}

.cisf-no-details {
  color: var(--color-text-secondary);
  background: var(--color-bg-default);
  border: var(--tv-border) solid var(--color-divider);
}

.cisf-no-details .cisf-icon {
  width: var(--tv-icon-large);
  height: var(--tv-icon-large);
}

.cisf-no-details span {
  font-size: var(--tv-fs-h3);
  line-height: var(--tv-lh-h3);
  font-weight: 700;
}

.cisf-dash-placeholder {
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.cisf-dash-placeholder span {
  font-size: var(--tv-fs-h2);
  line-height: var(--tv-lh-h2);
  font-weight: 800;
  color: var(--color-text-secondary);
}

/* CGP information: a strip of four across when the panel spans the screen
   (smaller screens), four rows one under another when it is the left column. */
.cisf-cgp-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: var(--tv-row-gap);
}

@media (min-width: 1920px) and (min-height: 1000px) {
  .cisf-cgp-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* No CGP with a read plate. In the strip the "No CGP" block takes the three
   columns beside the plate, its two lines side by side; in the left column it
   takes the three rows above the plate. */
.cisf-cgp-list > .cisf-no-cgp {
  grid-column: span 3;
  flex-direction: row;
  gap: var(--tv-row-pad);
}

@media (min-width: 1920px) and (min-height: 1000px) {
  .cisf-cgp-list > .cisf-no-cgp {
    grid-column: 1 / -1;
    grid-row: span 3;
    flex-direction: column;
    gap: var(--tv-row-gap);
  }
}

.cisf-cgp-row {
  min-height: 0;
  display: flex;
  align-items: center;
  gap: var(--tv-row-pad);
  padding: var(--tv-row-pad);
  background: var(--color-bg-default);
  border: var(--tv-border) solid var(--color-divider);
  border-radius: var(--tv-radius-surface);
}

/* The tile is as tall as the row's content box and square; the glyph is the
   Medium icon of the breakpoint (about 55% of the tile). */
.cisf-cgp-row__icon {
  height: 100%;
  max-height: calc(var(--tv-icon-medium) * 1.8);
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--tv-radius-ctrl);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.cisf-cgp-row__icon .cisf-icon {
  width: var(--tv-icon-medium);
  height: var(--tv-icon-medium);
}

.cisf-cgp-row > div:last-child {
  min-width: 0;
}

.cisf-cgp-row__label {
  font-weight: 800;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-size: var(--tv-fs-body2);
  line-height: var(--tv-lh-body2);
  display: block;
}

.cisf-cgp-row__value {
  font-weight: 900;
  color: var(--color-primary-dark);
  overflow-wrap: anywhere;
  font-size: var(--tv-fs-value);
  line-height: var(--tv-lh-value);
  display: block;
}

/* Captured images: six cards, in one row on smaller screens and three across
   in two rows when the panel is the wide right column. */
.cisf-capture-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: var(--tv-row-gap);
  flex: 1;
  min-height: 0;
}

@media (min-width: 1920px) and (min-height: 1000px) {
  .cisf-capture-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tv-gap);
  }
}

.cisf-capture-card {
  container-type: inline-size;
  min-height: 0;
  overflow: hidden;
  border: var(--tv-border) solid var(--color-divider);
  border-radius: var(--tv-radius-surface);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--color-bg-paper);
}

.cisf-capture-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-row-gap);
  padding: calc(var(--tv-pill-y) / 2) var(--tv-pill-x);
  color: var(--color-on-primary);
  font-size: var(--tv-fs-body1);
  line-height: var(--tv-lh-body1);
  font-weight: 900;
}

.cisf-capture-card__time {
  font-weight: 700;
  font-size: var(--tv-fs-caption);
  line-height: var(--tv-lh-caption);
  white-space: nowrap;
}

/* A narrow card (six across on a smaller screen) drops what does not fit: the
   time (the header clock shows it) and the registered photo. */
@container (max-width: 260px) {
  .cisf-capture-card__time {
    display: none;
  }

  .cisf-driver-licence__photo {
    display: none;
  }
}

/* The dark, text-safe shades the portals use for text on a status colour. */
.cisf-capture-card__head.is-failed {
  background: var(--status-danger);
}

.cisf-capture-card__head.is-passed {
  background: var(--status-success);
}

.cisf-capture-card__head.is-detecting {
  background: var(--color-primary-main);
}

.cisf-capture-card__body {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.cisf-capture-card__body img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}

/* The five camera pictures (ANPR front and back, driver and helper liveness,
   vehicle top view) are shown whole: the picture fits inside the card and any
   spare space stays blank, nothing is cropped. The driver's registered photo
   (inside the Driver License card) keeps its own frame. */
.cisf-capture-card__body:not(.cisf-driver-licence) {
  background: var(--color-neutral-bg);
}

.cisf-capture-card__body:not(.cisf-driver-licence) img {
  object-fit: contain;
}

.cisf-capture-card__body.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-default);
}

/* An <img> hidden while it retries (the script sets `hidden`). */
.cisf-capture-card__body [hidden] {
  display: none !important;
}

.cisf-capture-card__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--tv-row-gap) / 2);
  color: var(--color-text-secondary);
  text-align: center;
}

.cisf-capture-card__placeholder .cisf-icon {
  width: var(--tv-icon-large);
  height: var(--tv-icon-large);
}

.cisf-capture-card__placeholder span {
  font-size: var(--tv-fs-body1);
  line-height: var(--tv-lh-body1);
  font-weight: 700;
}

/* No helper image: a person with a red cross through its centre. */
.cisf-capture-card__no-image {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--tv-icon-large) * 1.5);
  height: calc(var(--tv-icon-large) * 1.5);
}

.cisf-capture-card__placeholder .cisf-capture-card__no-image .cisf-icon {
  width: 100%;
  height: 100%;
}

.cisf-capture-card__no-image::before,
.cisf-capture-card__no-image::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  height: calc(var(--tv-icon-large) / 8);
  border-radius: calc(var(--tv-icon-large) / 16);
  background: var(--status-danger);
}

.cisf-capture-card__no-image::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.cisf-capture-card__no-image::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Driving Licence card: the registered photo, then Driver Name and Licence No. */
.cisf-capture-card__body.cisf-driver-licence {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  /* The photo sits vertically centred, shorter than the card. */
  align-items: center;
  gap: var(--tv-row-pad);
  padding: var(--tv-row-pad);
  background: var(--color-bg-default);
}

@container (max-width: 260px) {
  .cisf-capture-card__body.cisf-driver-licence {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cisf-driver-licence__photo {
  position: relative;
  height: 70%;
  /* A passport-style portrait at every card size, never cropped to landscape. */
  aspect-ratio: 3 / 4;
  justify-self: start;
  min-height: 0;
  overflow: hidden;
  border: var(--tv-border) solid var(--color-divider);
  border-radius: var(--tv-radius-ctrl);
  background: var(--color-bg-paper);
}

.cisf-driver-licence__photo.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cisf-driver-licence__facts {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(var(--tv-row-gap) / 2);
}

.cisf-driver-licence__field dt {
  font-weight: 800;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  font-size: var(--tv-fs-caption);
  line-height: var(--tv-lh-caption);
}

.cisf-driver-licence__field dd {
  margin: 0;
  font-weight: 900;
  color: var(--color-primary-dark);
  overflow-wrap: anywhere;
  font-size: var(--tv-fs-body2);
  line-height: var(--tv-lh-body2);
}

/* Bottom row: validation results and purpose of work. */
.cisf-tv-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--tv-gap);
  min-height: 0;
  overflow: hidden;
}

.cisf-validation-grid {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.35fr);
  gap: var(--tv-row-gap);
  align-items: stretch;
  min-height: 0;
}

.cisf-decision-banner {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--tv-row-pad);
  border: var(--tv-border) solid currentColor;
  border-radius: var(--tv-radius-surface);
}

/* With no check results to show (awaiting a decision, or data unavailable) the
   banner takes the whole width, so a long message does not wrap into a corner. */
.cisf-validation-grid:not(:has(.cisf-check-grid > *)) .cisf-decision-banner {
  grid-column: 1 / -1;
}

/* The text-safe dark shades on their tints (the portals' pairing). */
.cisf-decision-banner.is-approved {
  background: var(--color-success-light);
  color: var(--status-success);
}

.cisf-decision-banner.is-rejected {
  background: var(--color-error-light);
  color: var(--status-danger);
}

/* Neither state below is a decision, so neither borrows the approved or
   rejected colours. */
.cisf-decision-banner.is-awaiting {
  background: var(--color-neutral-bg);
  color: var(--color-text-secondary);
}

.cisf-decision-banner.is-unavailable {
  background: var(--color-neutral-bg);
  color: var(--color-text-secondary);
}

/* A long message (data unavailable) is not spaced out like APPROVED. */
.cisf-decision-banner.is-unavailable .cisf-decision-banner__label,
.cisf-decision-banner.is-awaiting .cisf-decision-banner__label {
  letter-spacing: 0.02em;
}

.cisf-decision-banner .cisf-icon {
  width: var(--tv-icon-large);
  height: var(--tv-icon-large);
}

.cisf-decision-banner__label {
  font-size: var(--tv-fs-h3);
  line-height: var(--tv-lh-h3);
  font-weight: 900;
  letter-spacing: 0.06em;
}

.cisf-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: calc(var(--tv-row-gap) / 2);
}

.cisf-check {
  display: flex;
  align-items: center;
  gap: calc(var(--tv-row-pad) / 2);
  min-width: 0;
  padding: 0 var(--tv-row-pad);
  border-radius: var(--tv-radius-ctrl);
  border: var(--tv-border) solid;
}

.cisf-check.is-passed {
  background: var(--color-success-light);
  color: var(--status-success);
  border-color: var(--status-success);
}

.cisf-check.is-failed {
  background: var(--color-error-light);
  color: var(--status-danger);
  border-color: var(--status-danger);
}

.cisf-check.is-unavailable {
  background: var(--color-neutral-bg);
  color: var(--color-text-secondary);
  border-color: var(--color-divider);
}

.cisf-check .cisf-icon {
  width: var(--tv-icon-standard);
  height: var(--tv-icon-standard);
  flex-shrink: 0;
}

.cisf-check__label {
  font-size: var(--tv-fs-body2);
  line-height: var(--tv-lh-body2);
  font-weight: 800;
  color: var(--color-text-primary);
}

.cisf-purpose {
  display: flex;
  align-items: center;
  gap: var(--tv-row-pad);
  flex: 1;
  min-height: 0;
  padding: var(--tv-row-pad);
  background-color: var(--color-success-light);
  border: var(--tv-border) solid var(--status-success);
  border-radius: var(--tv-radius-surface);
}

.cisf-purpose__icon {
  height: 100%;
  max-height: calc(var(--tv-icon-large) * 1.8);
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--status-success);
  color: var(--color-on-primary);
  border-radius: var(--tv-radius-ctrl);
}

.cisf-purpose__icon .cisf-icon {
  width: var(--tv-icon-large);
  height: var(--tv-icon-large);
}

.cisf-purpose > div:last-child {
  min-width: 0;
}

.cisf-purpose__category {
  font-size: var(--tv-fs-caption);
  line-height: var(--tv-lh-caption);
  font-weight: 800;
  color: var(--status-success);
  text-transform: uppercase;
  display: block;
}

/* A sentence, not a value: body1, so a long purpose wraps on two lines. */
.cisf-purpose__description {
  font-size: var(--tv-fs-body1);
  line-height: var(--tv-lh-body1);
  font-weight: 900;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

/* The provisional "vehicle at the lane" line, between the plate read and the
   recorded decision. Plain text over the top of the header row, never a verdict. */
.cisf-cgp-pending {
  position: fixed;
  left: var(--tv-outer);
  right: var(--tv-outer);
  bottom: var(--tv-outer);
  z-index: 9000;
  margin: 0;
  padding: var(--tv-pill-y) var(--tv-pill-x);
  border: var(--tv-border) solid var(--color-info-main);
  border-radius: var(--tv-radius-ctrl);
  background: var(--color-bg-paper);
  color: var(--color-text-primary);
  font-size: var(--tv-fs-body1);
  line-height: var(--tv-lh-body1);
  font-weight: 800;
  text-align: center;
}

.cisf-cgp-pending[hidden] {
  display: none;
}

/* The "lane held" banner (shared with the tablet): on this screen it follows
   the same type scale. */
.cisf-tv-root .cisf-link-banner {
  padding: var(--tv-pill-y) var(--tv-outer);
  background: var(--status-danger);
  box-shadow: none;
}

.cisf-tv-root .cisf-link-banner__title {
  font-size: var(--tv-fs-h3);
  line-height: var(--tv-lh-h3);
}

.cisf-tv-root .cisf-link-banner__body {
  margin-top: 0;
  font-size: var(--tv-fs-body1);
  line-height: var(--tv-lh-body1);
}

/* Under Maintenance: takes the rows the main and decision panels occupy, so the
   gate pill and the clock stay. The wording is the one Port Admin configured. */
.cisf-maintenance-panel {
  grid-row: 2 / -1;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  padding: var(--tv-panel-pad);
  border-radius: var(--tv-radius-surface);
  border: var(--tv-border) solid var(--color-divider);
  background: var(--status-warning-light);
  text-align: center;
}

.cisf-maintenance-panel[hidden] {
  display: none;
}

/* Both carry `display: grid`, which outranks the browser's own rule for
   `hidden`; without this the script could not put them away. */
.cisf-tv-main[hidden],
.cisf-tv-bottom[hidden] {
  display: none;
}

.cisf-maintenance-panel__body {
  margin: 0;
  color: var(--status-warning);
  font-size: var(--tv-fs-h2);
  line-height: var(--tv-lh-h2);
  font-weight: 700;
  overflow-wrap: anywhere;
}
