/* Dark only: it's a remote for a car screen and a phone at the gate.
   Accents are rgb channel triplets so they work with rgb(... / alpha) on older
   Chromium (the Tesla browser), without color-mix(). */
:root {
  --bg: #0b0f14;
  --panel: #121820;
  --line: #243041;
  --text: #e6edf5;
  --muted: #8a99ab;
  --gate: 245 158 11;
  --garage: 56 189 248;
  --ok: 34 197 94;
  --bad: 239 68 68;
  --radius: 28px;
  --gap: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button { font: inherit; color: inherit; }

/* ---- header ---------------------------------------------------------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--gap);
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.02em;
}
.brand b { color: var(--text); font-weight: 600; }

.link {
  background: none;
  border: 0;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.link:hover { color: var(--text); }

/* ---- the two buttons ------------------------------------------------- */
.pad {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
  min-height: 0;
}
@media (min-aspect-ratio: 1/1) {
  .pad { grid-template-columns: 1fr 1fr; grid-auto-rows: auto; }
}

.opener {
  --accent: var(--gate);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vmin;
  min-height: 0;
  padding: 3vmin 16px;
  border: 2px solid rgb(var(--accent) / 0.35);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% 0%, rgb(var(--accent) / 0.14) 0%, rgb(var(--accent) / 0) 65%),
    var(--panel);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.12s ease, border-color 0.2s ease, background-color 0.2s ease;
}
#garage { --accent: var(--garage); }

.opener:active { transform: scale(0.98); background-color: #18202a; }
.opener:focus-visible { outline: 3px solid rgb(var(--accent) / 0.8); outline-offset: 3px; }

.icon {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(72px, 22vmin, 190px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: rgb(var(--accent));
  background: rgb(var(--accent) / 0.1);
}
.icon svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgb(var(--accent) / 0.45));
}

.label {
  font-size: clamp(32px, 8vmin, 76px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.status {
  min-height: 1.3em;
  font-size: clamp(16px, 3.2vmin, 28px);
  color: var(--muted);
  text-align: center;
}

/* ---- phases ---------------------------------------------------------- */
.opener[data-phase="sending"],
.opener[data-phase="dialing"],
.opener[data-phase="queued"],
.opener[data-phase="calling"] {
  border-color: rgb(var(--accent) / 0.9);
}
.opener[data-phase="sending"] .status,
.opener[data-phase="dialing"] .status,
.opener[data-phase="queued"] .status,
.opener[data-phase="calling"] .status { color: rgb(var(--accent)); }

.opener[data-phase="sending"] .icon::after,
.opener[data-phase="dialing"] .icon::after,
.opener[data-phase="queued"] .icon::after,
.opener[data-phase="calling"] .icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgb(var(--accent));
  animation: ring 1.2s ease-out infinite;
}
.opener[data-phase="queued"] .icon::after { animation-duration: 2.4s; }

@keyframes ring {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(1.45); opacity: 0; }
}

.opener[data-phase="done"] { border-color: rgb(var(--ok) / 0.9); }
.opener[data-phase="done"] .status { color: rgb(var(--ok)); }
.opener[data-phase="done"] .status::before { content: "✓ "; }

.opener[data-phase="failed"] { border-color: rgb(var(--bad) / 0.9); }
.opener[data-phase="failed"] .status { color: rgb(var(--bad)); }
.opener[data-phase="failed"] .status::before { content: "✕ "; }

@media (prefers-reduced-motion: reduce) {
  .opener[data-phase] .icon::after { animation: none; opacity: 0.6; }
}

/* ---- login ----------------------------------------------------------- */
body.login {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.card img { align-self: center; border-radius: 18px; }
.card h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 22px;
  font-weight: 400;
  color: var(--muted);
}
.card h1 b { color: var(--text); font-weight: 600; }
.card label { font-size: 15px; color: var(--muted); }

.card input {
  height: 56px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font-size: 22px;
}
.card input:focus { outline: none; border-color: rgb(var(--gate)); }

.primary {
  height: 56px;
  margin-top: 4px;
  border: 0;
  border-radius: 14px;
  background: rgb(var(--gate));
  color: #1a1204;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.primary:disabled { opacity: 0.6; }

.error { min-height: 1.3em; margin: 0; color: rgb(var(--bad)); font-size: 16px; text-align: center; }
.hint { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }
