/*
 * Alpireum brand palette: logo red #C50707 on white (6.2:1 contrast, so it is
 * safe for text and for white text on red buttons). The UI is light to match
 * the logo; only the video stage stays black so the picture stands out.
 */
:root {
  --brand: #c50707;
  --brand-hover: #a30505;
  --brand-ring: rgba(197, 7, 7, 0.2);
  --focus-ring: rgba(28, 28, 33, 0.12);
  --bg: #f4f4f6;
  --surface: #ffffff;
  --border: #e2e2e7;
  --border-strong: #c9c9d0;
  --text: #1c1c21;
  --muted: #6b6b75;
  --warn: #b45309;
  --warn-dot: #d97706;
  --stage: #000000;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* Brand */

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin: 0;
  font-size: inherit;
}

.brand-logo {
  display: block;
  flex: none;
  width: auto;
  height: 22px;
}

.brand-divider {
  flex: none;
  width: 1px;
  height: 22px;
  background: var(--border-strong);
}

/* Product line set like the logo's wordmark: tracked capitals. */
.brand-product {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
}

.brand-model {
  color: var(--muted);
}

.brand--stacked {
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}

.brand--stacked .brand-logo {
  height: 36px;
}

/* Buttons */

.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-primary {
  width: 100%;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted);
  padding: 6px 12px;
  font-size: 14px;
}

.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
}

/* Square icon button, same height as .btn-ghost. */
.btn-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  background: transparent;
  border-color: var(--border-strong);
  color: var(--muted);
}

.btn-icon:hover,
.btn-icon[aria-expanded="true"] {
  border-color: var(--text);
  color: var(--text);
}

/* Login */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px 16px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 55%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(28, 28, 33, 0.08);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.login-form input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

/* Focus is neutral so that red keeps meaning "error" on this field. */
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.login-form input[aria-invalid="true"],
.login-form input[aria-invalid="true"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.form-error {
  margin: 0;
  font-size: 14px;
  color: var(--brand);
}

.login-form .btn-primary {
  margin-top: 8px;
}

/* Player */

.player-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Keeps the info panel above the video stage. */
  position: relative;
  z-index: 10;
}

.topbar-actions {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Anchored to the right edge of the actions group, so it never runs off a
   narrow screen. */
.info-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 264px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(28, 28, 33, 0.14);
}

.info-panel p {
  margin: 0;
}

.info-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.info-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.info-panel .info-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions form {
  margin: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.status[data-state="live"] {
  color: var(--text);
  font-weight: 600;
}

.status[data-state="live"] .status-dot {
  background: var(--brand);
  animation: pulse 2s infinite;
}

.status[data-state="connecting"] .status-dot,
.status[data-state="reconnecting"] .status-dot,
.status[data-state="stalled"] .status-dot {
  background: var(--warn-dot);
}

.status[data-state="stalled"],
.status[data-state="reconnecting"] {
  color: var(--warn);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(197, 7, 7, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(197, 7, 7, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(197, 7, 7, 0);
  }
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--stage);
}

.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--stage);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  text-align: center;
  color: #f2f2f4;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.overlay p {
  margin: 0;
  font-size: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fullscreen-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fff;
  background: rgba(20, 20, 24, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.stage:hover .fullscreen-btn,
.fullscreen-btn:focus-visible {
  opacity: 1;
}

.fullscreen-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Touch screens have no hover: keep the button visible. */
@media (hover: none) {
  .fullscreen-btn {
    opacity: 1;
  }
}

/* Phones: drop the product line from the top bar to keep it on one row. */
@media (max-width: 560px) {
  .topbar .brand-divider,
  .topbar .brand-product {
    display: none;
  }
}

@media (max-width: 380px) {
  .topbar .brand-logo {
    height: 18px;
  }

  .btn-ghost {
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .status[data-state="live"] .status-dot {
    animation: none;
  }
}
