/* JustStreamIt: control-room look. One family (Archivo) whose width axis
   does the work: condensed for broadcast-style display text, normal for body. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --panel: #23262c;
  --panel-raised: #2e323a;
  --panel-sunk: #1a1c21;
  --line: #3c414b;
  --ink: #ecebe8;
  --muted: #a4aab4;
  --tally: #e8382c;
  --tally-glow: rgb(232 56 44 / 0.5);
  --cue: #efbf3a;
  --focus: #8ab8ff;
  --font: "Archivo", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

a {
  color: inherit;
}

/* ------------------------------------------------------------------ tally */

.tally {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-stretch: 75%;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
  white-space: nowrap;
}

.lamp {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4a4f58;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.5);
  flex: none;
}

.tally[data-state="standby"] {
  color: var(--ink);
}
.tally[data-state="standby"] .lamp {
  background: var(--cue);
}

.tally[data-state="live"] {
  color: #fff;
  border-color: var(--tally);
  background: rgb(232 56 44 / 0.16);
}
.tally[data-state="live"] .lamp {
  background: var(--tally);
  animation: glow 2.4s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--tally-glow); }
  50% { box-shadow: 0 0 0 5px rgb(232 56 44 / 0); }
}

@media (prefers-reduced-motion: reduce) {
  .tally[data-state="live"] .lamp {
    animation: none;
    box-shadow: 0 0 0 3px var(--tally-glow);
  }
}

/* ------------------------------------------------------------ color bars */
/* Test card shown whenever there is no picture. */

.bars {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 67fr 8fr 25fr;
  filter: saturate(0.8) brightness(0.62);
}
.bars > div {
  display: grid;
}
.bars .b1 { grid-template-columns: repeat(7, 1fr); }
.bars .b2 { grid-template-columns: repeat(7, 1fr); }
.bars .b3 { grid-template-columns: 5fr 5fr 5fr 5fr 4fr 1.33fr 1.33fr 1.34fr 4fr; }
.bars span { display: block; }

.c-gray { background: #c0c0c0; }
.c-yellow { background: #c0c000; }
.c-cyan { background: #00c0c0; }
.c-green { background: #00c000; }
.c-magenta { background: #c000c0; }
.c-red { background: #c00000; }
.c-blue { background: #0000c0; }
.c-black { background: #131313; }
.c-i { background: #00214c; }
.c-white { background: #ffffff; }
.c-q { background: #32006a; }
.c-sub { background: #090909; }
.c-sup { background: #1d1d1d; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-raised);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  border-color: #59606c;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  min-height: 52px;
  background: var(--ink);
  border-color: var(--ink);
  color: #17191d;
  font-size: 18px;
  font-stretch: 85%;
  font-weight: 700;
}
.btn-primary:hover {
  background: #fff;
  border-color: #fff;
}

.btn-stop {
  min-height: 52px;
  background: transparent;
  border-color: var(--tally);
  color: #ff8a80;
  font-size: 18px;
  font-stretch: 85%;
  font-weight: 700;
}
.btn-stop:hover {
  background: rgb(232 56 44 / 0.14);
  border-color: var(--tally);
}

.btn-quiet {
  min-height: 32px;
  padding: 4px 10px;
  background: transparent;
  font-size: 14px;
}

/* =================================================================== HOST */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px;
}

.wordmark {
  font-size: 24px;
  font-stretch: 62%;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px 48px;
  align-items: start;
}

.monitor {
  min-width: 0;
}

.bezel {
  padding: 10px;
  background: var(--panel-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 3px;
  background: #000;
}

.screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.screen-note {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  margin: 0;
  max-width: 80%;
  padding: 12px 18px;
  border-radius: 6px;
  background: rgb(26 28 33 / 0.88);
  text-align: center;
  font-stretch: 85%;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.35;
}

.link-strip {
  margin-top: 20px;
}

.link-strip label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 14px;
}

.link-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.link-field {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  font-size: clamp(22px, 3.1vw, 38px);
  font-stretch: 68%;
  font-weight: 650;
  line-height: 1.15;
  text-overflow: ellipsis;
}
.link-field:focus-visible {
  outline: none;
  border-bottom-color: var(--focus);
}

.link-row .btn {
  align-self: end;
  min-width: 108px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 68ch;
}

.controls {
  display: grid;
  gap: 20px;
}

.controls form {
  display: grid;
  gap: 18px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 12px;
}

legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 21px;
  font-stretch: 75%;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 4px;
}

.field > label,
.field > .label {
  color: var(--muted);
  font-size: 14px;
}

select,
input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-sunk);
}

select:disabled {
  opacity: 0.6;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-sunk);
  padding: 3px;
  gap: 3px;
}
.segmented label {
  flex: 1;
  position: relative;
}
.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.segmented span {
  display: block;
  padding: 5px 8px;
  border-radius: 4px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}
.segmented input:checked + span {
  background: var(--panel-raised);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line);
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.segmented input:disabled + span {
  opacity: 0.6;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--ink);
  flex: none;
}
.check small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--tally);
  background: rgb(232 56 44 / 0.1);
  font-size: 15px;
}

.notice {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--cue);
  background: rgb(239 191 58 / 0.08);
  font-size: 15px;
}

.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 40px;
  margin: 24px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.readout dt {
  color: var(--muted);
  font-size: 14px;
}
.readout dd {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.readout .big {
  font-size: 40px;
  font-stretch: 68%;
  font-weight: 700;
  line-height: 1;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  font-stretch: 85%;
  font-size: 17px;
}
details[open] summary {
  margin-bottom: 12px;
}
details .stack {
  display: grid;
  gap: 12px;
}
details p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.copy-row {
  display: flex;
  gap: 8px;
}
.copy-row input {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

@media (max-width: 900px) {
  .studio {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px 40px;
  }
  .topbar {
    padding: 12px 16px;
  }
}

@media (max-width: 520px) {
  .link-row {
    flex-direction: column;
  }
  .link-row .btn {
    align-self: stretch;
  }
  .screen-note {
    font-size: 15px;
  }
}

/* ================================================================== WATCH */

body.watch {
  background: #000;
  overflow: hidden;
}

.stage {
  position: fixed;
  inset: 0;
  background: #000;
  cursor: default;
}
.stage.idle {
  cursor: none;
}

.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.slate {
  position: absolute;
  left: 50%;
  top: 46%;
  translate: -50% -50%;
  width: min(560px, calc(100% - 32px));
  padding: 24px 28px;
  border-radius: 8px;
  background: rgb(26 28 33 / 0.92);
  border: 1px solid var(--line);
}
.slate h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 5vw, 48px);
  font-stretch: 65%;
  font-weight: 750;
  line-height: 1.05;
}
.slate p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  max-width: 52ch;
}
.slate .btn {
  margin-top: 16px;
}

.unmute {
  position: absolute;
  left: 50%;
  bottom: 96px;
  translate: -50% 0;
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #17191d;
  font-weight: 700;
  font-stretch: 85%;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.45);
}
.unmute svg {
  vertical-align: -4px;
  margin-right: 6px;
}

.hud {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 12px;
  border-radius: 10px;
  background: rgb(26 28 33 / 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.25s ease;
}
.stage.idle .hud {
  opacity: 0;
  pointer-events: none;
}
.hud .tally {
  border-color: transparent;
}
.hud .viewers {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}
.hud .spacer {
  flex: 1;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover,
.icon-btn[aria-pressed="true"] {
  background: rgb(255 255 255 / 0.1);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.volume {
  width: 96px;
  accent-color: var(--ink);
}

.stats {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgb(26 28 33 / 0.84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 14px;
}
.stats dt {
  color: var(--muted);
}
.stats dd {
  margin: 0;
}

@media (max-width: 560px) {
  .hud {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 4px;
  }
  .volume,
  .hud .viewers-label {
    display: none;
  }
}
