/*
 * v-call app styles.
 *
 * Monochrome product UI: hairline borders, a tight 4px spacing scale, and one
 * small radius. No third-party resources — Inter is self-hosted from /fonts.
 * Dark mode follows prefers-color-scheme only (no toggle, no localStorage).
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-latin-600.woff2') format('woff2');
}

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  --bg: #fafafa;
  --fg: #171717;
  --muted: #525252;
  --line: #e5e5e5;
  --fill: #f0f0f0;
  --fill-hover: #e7e7e7;

  --primary: #171717;
  --primary-fg: #fafafa;
  --primary-hover: #000000;

  --danger: #c62828;
  --danger-fg: #ffffff;
  --danger-hover: #b71c1c;
  --ok: #0f6b43;

  --ring: var(--fg);
  --overlay: #000000;

  --radius: 8px;
  --radius-sm: 6px;

  --font-sans:
    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  --control-h: 2.5rem;
  --page: 60rem;
  --cluster: 40rem;

  --ease: 140ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #f5f5f5;
    --muted: #a3a3a3;
    --line: #262626;
    --fill: #171717;
    --fill-hover: #262626;

    --primary: #f5f5f5;
    --primary-fg: #0a0a0a;
    --primary-hover: #ffffff;

    --danger: #ef5350;
    --danger-fg: #0a0a0a;
    --danger-hover: #e57373;
    --ok: #4ade80;

    --ring: var(--fg);
  }
}

/* ------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  margin: 0;
  padding: 0 var(--space-5);
  line-height: 1.5;
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection {
  background: var(--fg);
  color: var(--bg);
}
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-color: var(--fg);
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.cluster {
  width: min(var(--cluster), 100%);
  align-self: center;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--primary);
  color: var(--primary-fg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.875rem;
  transform: translateY(calc(-100% - var(--space-4)));
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.site-header-inner {
  width: min(var(--page), 100%);
  margin: 0 auto;
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--fg);
}
.brand:hover {
  color: var(--fg);
}
.brand-mark {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}
.brand-cutout {
  fill: var(--bg);
}
.brand-name {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}
.call-timer {
  display: inline-flex;
  align-items: center;
  color: var(--fg);
  font-size: 0.8125rem;
}
.call-timer:not([hidden]) + .health::before {
  content: '';
  width: 1px;
  height: 0.75rem;
  background: var(--line);
  margin-right: var(--space-3);
}
.health {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.health #connectionHealth {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot.ok {
  background: var(--fg);
}
.status-dot.warn {
  background: var(--muted);
  animation: pulse 1.6s ease-in-out infinite;
}
.status-dot.bad {
  background: var(--danger);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ------------------------------------------------------------------- main */

main {
  width: min(var(--page), 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6) 0 var(--space-2);
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  width: min(32rem, 100%);
  align-self: center;
  padding: var(--space-2) 0 0;
}
.hero h1 {
  font-size: clamp(1.625rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.032em;
  line-height: 1.15;
  margin: 0;
  color: var(--fg);
}
.hero-sub {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 28rem;
  line-height: 1.55;
}

.identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
.identity-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.id-value {
  font-size: 0.875rem;
  color: var(--fg);
  user-select: all;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.id-value.is-pending {
  color: var(--muted);
}
@media (prefers-reduced-motion: no-preference) {
  .id-value.is-pending {
    animation: pulse 1.6s ease-in-out infinite;
  }
}
.identity-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    color var(--ease),
    opacity var(--ease);
}
.btn svg {
  width: 0.9375rem;
  height: 0.9375rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.btn.primary:disabled {
  opacity: 1;
  background: var(--fill);
  color: var(--muted);
}
.btn.primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn.primary:not(:disabled):hover {
  background: var(--primary-hover);
}
.btn.primary:not(:disabled):active {
  background: var(--fg);
}
.btn.ghost,
.btn.secondary {
  border-color: var(--line);
  background: var(--bg);
  color: var(--fg);
}
.btn.ghost:not(:disabled):hover,
.btn.secondary:not(:disabled):hover {
  background: var(--fill);
}
.btn.ghost:not(:disabled):active,
.btn.secondary:not(:disabled):active {
  background: var(--fill-hover);
}
.btn.quiet {
  color: var(--muted);
  padding: 0 var(--space-3);
}
.btn.quiet:not(:disabled):hover {
  color: var(--fg);
  background: var(--fill);
}
.btn.quiet:not(:disabled):active {
  background: var(--fill-hover);
}
.btn.sm {
  height: 2rem;
  padding: 0 var(--space-3);
  font-size: 0.75rem;
}
.btn.sm svg {
  width: 0.8125rem;
  height: 0.8125rem;
}

/* ----------------------------------------------------------------- dialer */

.dialer {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.dialer-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.dialer-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.dialer-field input {
  width: 100%;
  padding-right: 4.75rem;
}
.field-clear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  height: 2rem;
}
.dialer-field:has(input:placeholder-shown) .field-clear {
  visibility: hidden;
  pointer-events: none;
}
.privacy-note {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}
.privacy-note a {
  color: var(--muted);
}

/* ------------------------------------------------------------ form fields */

input,
select {
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  transition: border-color var(--ease);
}
input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--fg) 28%, var(--line));
}
input:focus,
select:focus {
  border-color: var(--fg);
}
input:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--fill);
}
input.mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}
input::placeholder {
  color: var(--muted);
}

/* -------------------------------------------------------- incoming banner */

.incoming-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
}
.incoming-banner.visible {
  display: flex;
}
.incoming-banner :focus-visible {
  outline-color: var(--bg);
}
.incoming-actions {
  display: flex;
  gap: var(--space-2);
}
.incoming-banner .btn.inverted {
  background: var(--bg);
  color: var(--fg);
}
.incoming-banner .btn.inverted:hover {
  background: var(--fill);
}
.incoming-banner .btn.inverted:active {
  background: var(--fill-hover);
}
.incoming-banner .btn.inverted-outline {
  background: transparent;
  color: var(--bg);
  border-color: color-mix(in srgb, var(--bg) 40%, transparent);
}
.incoming-banner .btn.inverted-outline:hover {
  border-color: var(--bg);
  background: color-mix(in srgb, var(--bg) 8%, transparent);
}

/* ------------------------------------------------------------ video stage */

.stage {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18.75rem), 1fr));
}
.video-card {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--overlay);
  contain: content;
}
.video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--overlay);
  object-fit: cover;
}
.video-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 2.75rem var(--space-3) var(--space-2);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
  color: #fff;
  font-size: 0.8125rem;
}
.video-meta strong {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.video-badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}
.video-empty {
  display: none;
  margin: 0;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: var(--space-4);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8125rem;
  text-align: center;
  pointer-events: none;
}
.video-card.no-media .video-empty {
  display: grid;
}
.video-card.no-media .video-meta {
  background: none;
  padding: var(--space-3);
}

/* ------------------------------------------------------------- control bar */

.control-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-self: center;
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.btn.control {
  height: 2.5rem;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.btn.control:not(:disabled):hover {
  color: var(--fg);
  background: var(--fill);
}
.btn.control:not(:disabled):active {
  background: var(--fill-hover);
}
.btn.control.is-off {
  background: var(--fg);
  color: var(--bg);
}
.btn.control.is-off:not(:disabled):hover {
  background: var(--primary-hover);
  color: var(--primary-fg);
}
.btn.control.is-on {
  background: var(--fill);
  color: var(--fg);
}
.btn.control .icon-off {
  display: none;
}
.btn.control.is-off .icon-on {
  display: none;
}
.btn.control.is-off .icon-off {
  display: block;
}
.btn.control.danger {
  color: var(--danger);
}
.btn.control.danger:not(:disabled) {
  background: var(--danger);
  color: var(--danger-fg);
}
.btn.control.danger:not(:disabled):hover {
  background: var(--danger-hover);
  color: var(--danger-fg);
}
.control-sep {
  width: 1px;
  align-self: stretch;
  margin: var(--space-1) var(--space-1);
  background: var(--line);
}

/* ---------------------------------------------------------------- devices */

.devices {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
.devices-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.devices-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.device-select {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 11.25rem;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.device-select select {
  width: 100%;
  max-width: none;
  color: var(--fg);
}
.devices-row .btn {
  align-self: flex-end;
}

/* ------------------------------------------------------------------- chat */

.chat-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  font-size: 0.8125rem;
}
.chat-header strong {
  font-weight: 600;
}
.chat-panel:has(#chatLog[hidden]) .chat-empty {
  display: none;
}
.chat-empty {
  margin: 0;
  padding: var(--space-5) var(--space-4);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}
.chat-log {
  list-style: none;
  margin: 0;
  padding: var(--space-3);
  overflow-y: auto;
  max-height: 15rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-log:not([hidden]) {
  min-height: 0;
}
.chat-log:not([hidden]):not(:empty) {
  min-height: 3.5rem;
}
.chat-log li {
  margin: 0;
  max-width: 85%;
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--fill);
  align-self: flex-start;
}
.chat-log li .chat-sender {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  margin-bottom: 0.125rem;
}
.chat-log li.self {
  background: var(--fg);
  color: var(--bg);
  text-align: left;
  align-self: flex-end;
}
.chat-log li.self .chat-sender {
  color: color-mix(in srgb, var(--bg) 72%, var(--fg));
}
.chat-input-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--line);
}
.chat-input-row input {
  flex: 1;
  min-width: 0;
}

/* ----------------------------------------------------------------- status */

.status {
  width: min(var(--cluster), 100%);
  align-self: center;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted);
  padding: 0 0 var(--space-2);
  overflow-wrap: anywhere;
}
.status.error {
  color: var(--danger);
}
.status.success {
  color: var(--ok);
}

/* ----------------------------------------------------------------- footer */

.site-footer {
  margin-top: auto;
  width: min(var(--page), 100%);
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--line);
  padding: var(--space-5) 0 var(--space-8);
}
.site-footer nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
}
.site-footer nav a {
  color: var(--muted);
  text-decoration: none;
  margin: 0;
}
.site-footer nav a:hover {
  color: var(--fg);
  text-decoration: underline;
}
.site-footer nav span {
  color: var(--line);
}
.site-footer p {
  margin: var(--space-2) 0 0;
}

/* --------------------------------------------------------------- noscript */

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 100;
  background: var(--primary);
  color: var(--primary-fg);
  text-align: center;
  font-size: 0.875rem;
  padding: var(--space-3) var(--space-4);
}

/* ------------------------------------------------------------- responsive */

@media (pointer: coarse) {
  .btn,
  input,
  select {
    min-height: 2.75rem;
  }
  .btn.sm,
  .field-clear {
    min-height: 2.5rem;
  }
}

@media (max-width: 640px) {
  body {
    padding: 0 var(--space-4);
  }
  .site-header-inner {
    height: 3rem;
  }
  main {
    padding-top: var(--space-4);
    gap: var(--space-4);
  }
  .identity {
    flex-direction: column;
    gap: var(--space-2);
  }
  .identity-actions {
    width: 100%;
  }
  .identity-actions .btn {
    flex: 1 1 auto;
  }
  .dialer-row {
    flex-direction: column;
    align-items: stretch;
  }
  .dialer-row > .btn {
    width: 100%;
  }
  .devices-row {
    flex-direction: column;
    align-items: stretch;
  }
  .devices-row .btn {
    width: 100%;
  }
  .control-bar {
    width: 100%;
    padding: var(--space-2);
  }
  .btn.control {
    flex: 1 1 calc(50% - var(--space-2));
  }
  #toggleScreen,
  .btn.control.danger {
    flex: 1 1 100%;
  }
  .control-sep {
    display: none;
  }
  .incoming-actions {
    width: 100%;
  }
  .incoming-actions .btn {
    flex: 1 1 auto;
  }
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
