/* Kannaka TV — the gallery monitor.
   The programme lives inside a framed raster. Everything outside the frame is engineering
   furniture: tally, timecode, signal, rundown. Colours are SMPTE bar colours and each has
   exactly one job. */

:root {
  --video-black: #0a1012;   /* lifted video black — never #000; a real raster is not off */
  --rack: #141c1f;          /* the furniture around the monitor */
  --rack-line: #26343a;
  --bone: #e8e6df;          /* broadcast white, warm enough to be a sibling of the record label */
  --dim: #7d8e94;
  --cyan: #49c5d6;          /* data */
  --yellow: #d8c04a;        /* attention */
  --magenta: #b0568f;       /* carriage, and nothing else */
  --tally: #e04b3a;         /* on air, and nothing else */

  --narrow: "Arial Narrow", "Liberation Sans Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;

  --gutter: clamp(12px, 2.2vw, 28px);
  --safe: clamp(16px, 3.4vw, 48px); /* the title-safe margin inside the raster */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--rack);
  color: var(--bone);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  overflow: hidden;
}

a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the rack */

.rack {
  display: flex;
  align-items: center;
  gap: var(--gutter);
  padding: 10px var(--gutter);
  background: var(--rack);
  font-family: var(--narrow);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.rack--top { border-bottom: 1px solid var(--rack-line); }
.rack--bottom {
  border-top: 1px solid var(--rack-line);
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
}

.rack__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--gutter);
}

/* The tally lamp. Red means this is going out right now — the one thing red is for. */
.tally { display: flex; align-items: center; gap: 8px; }
.tally__lamp {
  width: 11px; height: 11px; border-radius: 50%;
  background: #3a2622;
  box-shadow: inset 0 0 0 1px #000;
}
.tally[data-state="on"] .tally__lamp {
  background: var(--tally);
  box-shadow: 0 0 12px rgba(224, 75, 58, 0.85), inset 0 0 0 1px #000;
}
.tally__word { color: var(--dim); font-weight: 700; }
.tally[data-state="on"] .tally__word { color: var(--tally); }

.ident {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(17px, 2vw, 22px);
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.ident__tv {
  color: var(--video-black);
  background: var(--bone);
  padding: 0 5px;
  margin-left: 5px;
}

.timecode {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--bone);
}

.signal { display: flex; align-items: center; gap: 7px; }
.signal__label { color: var(--dim); font-weight: 700; font-size: 12px; }
.signal__meter {
  display: flex;
  gap: 2px;
}
.signal__meter i {
  width: 4px; height: 13px;
  background: #26343a;
}
.signal__meter i.lit { background: var(--cyan); }

/* ------------------------------------------------------------- the monitor */

.gallery {
  display: grid;
  place-items: center;
  padding: var(--gutter);
  min-height: 0;
}

.frame {
  width: 100%;
  max-width: min(100%, calc((100dvh - 150px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: var(--video-black);
  box-shadow: 0 0 0 1px var(--rack-line), 0 24px 60px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

.raster {
  position: absolute;
  inset: 0;
  display: grid;
}

.raster > * { grid-area: 1 / 1; }

/* -------------------------------------------------------------- the slate */

.slate {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--video-black);
  z-index: 30;
}

.bars {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.bars i { background: var(--c); opacity: 0.9; }

.slate__plate {
  position: relative;
  text-align: center;
  background: rgba(10, 16, 18, 0.93);
  padding: clamp(20px, 4vw, 44px) clamp(24px, 6vw, 64px);
  max-width: 88%;
}

.slate__name {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(34px, 7vw, 84px);
  line-height: 0.92;
  margin: 0;
  letter-spacing: -0.01em;
}

.slate__line {
  font-family: var(--mono);
  font-size: clamp(11px, 1.3vw, 14px);
  color: var(--cyan);
  margin: 14px 0 22px;
}

.tune {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(15px, 1.8vw, 19px);
  letter-spacing: 0.06em;
  color: var(--video-black);
  background: var(--bone);
  border: 0;
  padding: 12px 32px;
  cursor: pointer;
}
.tune:hover { background: var(--cyan); }

.slate__note {
  font-size: 12px;
  color: var(--dim);
  margin: 18px 0 0;
  max-width: 34ch;
  margin-inline: auto;
  line-height: 1.5;
}

/* ---------------------------------------------------------- the programme */

.programme {
  position: relative;
  padding: var(--safe);
  padding-bottom: calc(var(--safe) + 74px); /* clear of the lower third */
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

/* The cut. A vision mixer cuts; it does not fade. Three frames of white and you are elsewhere. */
.raster.cutting::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bone);
  z-index: 40;
  animation: cut 120ms steps(2, end) forwards;
  pointer-events: none;
}
@keyframes cut { from { opacity: 0.9; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .raster.cutting::after { animation: none; opacity: 0; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Programme typography. Big, confident, unboxed — broadcast graphics, not cards. */
.p-kicker {
  font-family: var(--mono);
  font-size: clamp(10px, 1.1vw, 13px);
  color: var(--cyan);
  margin: 0 0 clamp(10px, 1.6vw, 18px);
}
.p-lead {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(24px, 4.4vw, 62px);
  line-height: 1.02;
  margin: 0;
  max-width: 20ch;
  text-wrap: balance;
}
.p-body {
  font-size: clamp(13px, 1.4vw, 17px);
  line-height: 1.55;
  color: var(--bone);
  max-width: 56ch;
  margin: clamp(12px, 1.6vw, 20px) 0 0;
}
.p-dim { color: var(--dim); }

/* Readings: the vital signs, set as a row of figures with the leading one enormous. */
.readings { display: flex; align-items: baseline; gap: clamp(18px, 3.4vw, 56px); flex-wrap: wrap; }
.reading { display: flex; flex-direction: column; gap: 4px; }
.reading__sym {
  font-family: var(--mono);
  font-size: clamp(10px, 1.1vw, 12px);
  color: var(--dim);
}
.reading__val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 2.6vw, 36px);
  line-height: 1;
}
.reading--lead .reading__val { font-size: clamp(44px, 9vw, 124px); color: var(--cyan); }
.reading__label { font-size: 11px; color: var(--dim); }
.trend { font-family: var(--narrow); font-weight: 700; font-size: 13px; }
.trend[data-d="rising"] { color: var(--cyan); }
.trend[data-d="falling"] { color: var(--yellow); }

/* Rows: the open board, a tracklist, a carriage list. Rules, not boxes. */
.rows { list-style: none; margin: clamp(14px, 2vw, 22px) 0 0; padding: 0; }
.rows li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px solid var(--rack-line);
  font-size: clamp(12px, 1.25vw, 15px);
}
.rows li:last-child { border-bottom: 1px solid var(--rack-line); }
.rows .r-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .r-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--yellow);
  white-space: nowrap;
}
.rows .r-note { color: var(--dim); font-size: 0.86em; white-space: nowrap; }
.rows li[data-playing="true"] .r-main { color: var(--cyan); }

/* The tower, drawn as an elevation. Ten storeys; the lit ones are let. */
.elevation { display: flex; gap: 18px; align-items: flex-end; margin-top: clamp(12px, 2vw, 20px); }
.storeys { display: flex; flex-direction: column-reverse; gap: 2px; }
.storey {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--dim);
}
.storey__box { width: 44px; height: 12px; background: #1c272b; }
.storey[data-let="true"] .storey__box { background: var(--yellow); }
.storey[data-let="true"] { color: var(--bone); }
.storey[data-us="true"] .storey__box { background: var(--cyan); }

/* A record sleeve, with its tracklist beside it. */
.sleeve { display: flex; gap: clamp(16px, 3vw, 38px); align-items: flex-start; min-height: 0; }
.sleeve img {
  width: clamp(110px, 20vw, 240px);
  aspect-ratio: 1;
  object-fit: cover;
  background: #1c272b;
  flex: none;
}
.sleeve__side { min-width: 0; flex: 1; }

/* A carried programme is magenta-keyed so you always know whose it is. */
.programme[data-carriage="true"] .p-kicker { color: var(--magenta); }
.carriage-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--magenta);
  margin-top: 14px;
}

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

/* The field: the overnight visual. It breathes at Φ and does nothing else. */
.field { position: absolute; inset: 0; overflow: hidden; }
.field span {
  position: absolute;
  left: 50%; top: 50%;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.16;
  animation: breathe var(--dur, 9s) ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { width: 12vmin; height: 12vmin; opacity: 0.24; }
  50%      { width: 88vmin; height: 88vmin; opacity: 0.03; }
}

/* ------------------------------------------------------------ lower third */

.lower-third {
  align-self: end;
  justify-self: start;
  margin: 0 0 var(--safe) 0;
  padding: 10px var(--safe);
  max-width: calc(100% - var(--safe));
  background: linear-gradient(90deg, rgba(10, 16, 18, 0.94) 72%, rgba(10, 16, 18, 0));
  border-left: 4px solid var(--cyan);
  display: grid;
  gap: 2px;
  z-index: 20;
  pointer-events: none;
}
.programme[data-carriage="true"] ~ .lower-third { border-left-color: var(--magenta); }

.lower-third__format {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}
.lower-third__title {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(17px, 2.3vw, 30px);
  line-height: 1.05;
}
.lower-third__sub {
  font-size: clamp(11px, 1.2vw, 14px);
  color: var(--bone);
  max-width: 58ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  align-self: start;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 25;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--cyan);
}

/* --------------------------------------------------------------- rundown */

.rundown { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.rundown__label { color: var(--dim); font-weight: 700; flex: none; }
.rundown__list {
  list-style: none;
  display: flex;
  gap: 22px;
  margin: 0; padding: 0;
  min-width: 0;
  overflow: hidden;
}
.rundown__list li { display: flex; gap: 8px; align-items: baseline; white-space: nowrap; }
.rundown__list .t {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--yellow);
  font-size: 12px;
}
.rundown__list .n { overflow: hidden; text-overflow: ellipsis; }

.rack__nav { display: flex; align-items: center; gap: 18px; flex: none; }
.rack__nav a, .mute {
  color: var(--dim);
  text-decoration: none;
  font-family: var(--narrow);
  font-size: 14px;
  letter-spacing: 0.04em;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.rack__nav a:hover, .mute:hover { color: var(--bone); }
.mute[aria-pressed="true"] { color: var(--yellow); }

/* ----------------------------------------------------------------- small */

@media (max-width: 720px) {
  body { overflow: auto; }
  .frame { max-width: 100%; box-shadow: none; }
  .rack--top { flex-wrap: wrap; }
  .signal { display: none; }
  .rundown__list li:nth-child(n + 2) { display: none; }
  .programme { padding-bottom: calc(var(--safe) + 62px); }
}

/* ------------------------------------------------------ guide + carriage */

.page {
  grid-row: 2;
  overflow: auto;
  padding: clamp(24px, 5vw, 56px) var(--gutter);
  background: var(--video-black);
}
.page__inner { max-width: 900px; margin: 0 auto; }
.page h1 {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: clamp(30px, 5vw, 54px);
  margin: 0 0 6px;
  line-height: 1;
}
.page .standfirst { color: var(--dim); max-width: 60ch; line-height: 1.6; margin: 0 0 36px; }
.page h2 {
  font-family: var(--narrow);
  font-size: clamp(17px, 2vw, 22px);
  margin: 40px 0 10px;
  letter-spacing: 0.03em;
}

.grid-guide { list-style: none; margin: 0; padding: 0; }
.grid-guide li {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding: 11px 0;
  border-top: 1px solid var(--rack-line);
}
.grid-guide li:last-child { border-bottom: 1px solid var(--rack-line); }
.grid-guide .g-time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--yellow); font-size: 13px; }
.grid-guide .g-title { font-family: var(--narrow); font-weight: 700; font-size: 17px; }
.grid-guide .g-sub { display: block; color: var(--dim); font-size: 13px; font-weight: 400; font-family: var(--sans); margin-top: 2px; }
.grid-guide .g-dur { font-family: var(--mono); color: var(--dim); font-size: 12px; }
.grid-guide li[data-onair="true"] { background: rgba(224, 75, 58, 0.07); }
.grid-guide li[data-onair="true"] .g-time { color: var(--tally); }
.grid-guide li[data-carriage="true"] .g-title { color: var(--magenta); }

.daypart-head {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  padding: 22px 0 6px;
}

.form-field { display: grid; gap: 6px; margin: 0 0 18px; max-width: 560px; }
.form-field label { font-family: var(--narrow); font-size: 15px; letter-spacing: 0.03em; }
.form-field .hint { color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.form-field input, .form-field select, .form-field textarea {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--bone);
  background: var(--rack);
  border: 1px solid var(--rack-line);
  padding: 10px 12px;
  width: 100%;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--cyan); outline: none; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: flex; gap: 7px; align-items: center; font-family: var(--sans); font-size: 14px; }

.btn {
  font-family: var(--narrow);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--video-black);
  background: var(--bone);
  border: 0;
  padding: 11px 26px;
  cursor: pointer;
}
.btn:hover { background: var(--cyan); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.notice { border-left: 3px solid var(--cyan); padding: 10px 14px; margin: 18px 0; font-size: 14px; line-height: 1.6; background: rgba(73, 197, 214, 0.06); }
.notice[data-kind="bad"] { border-left-color: var(--tally); background: rgba(224, 75, 58, 0.07); }
.notice[data-kind="good"] { border-left-color: var(--yellow); background: rgba(216, 192, 74, 0.07); }

code, .mono { font-family: var(--mono); font-size: 0.92em; }
