/* Companion dialer — a natural extension of the Nexiloq product surface.
   Brand system mirrored from static/style.css: warm off-white ground, teal
   primary, orange accent used sparingly, Georgia serif for display, Inter for
   body, and a monospace treatment for the number itself (it is data). Light
   first, with a sober dark variant for phones used at night. */
:root {
  --bg: #f3f6f1;
  --bg-accent: #dfe9e0;
  --surface: #fffefa;
  --surface-2: #eef4ef;
  --border: #d7dfd5;
  --border-strong: #aab9ac;
  --text: #17201d;
  --text-muted: #5b6961;
  --text-faint: #8a978e;
  --primary: #0f6f68;
  --primary-strong: #084f4a;
  --primary-soft: #e2f1ed;
  --accent: #b86f32;
  --on-primary: #ffffff;
  --shadow: 0 1px 2px rgba(23, 32, 29, 0.05), 0 12px 32px rgba(23, 32, 29, 0.08);
  --shadow-lg: 0 20px 54px rgba(23, 32, 29, 0.16), 0 2px 8px rgba(23, 32, 29, 0.06);
  --focus-ring: 0 0 0 3px rgba(15, 111, 104, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --display-font: Georgia, "Times New Roman", serif;
  --body-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --data-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101714;
    --bg-accent: #16211d;
    --surface: #18211e;
    --surface-2: #1e2925;
    --border: #2a352f;
    --border-strong: #3a4740;
    --text: #eef4ef;
    --text-muted: #a6b3ab;
    --text-faint: #7d8a82;
    --primary: #2f9d92;
    --primary-strong: #248076;
    --primary-soft: rgba(47, 157, 146, 0.14);
    --accent: #d08a4c;
    --on-primary: #04201d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 54px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    --focus-ring: 0 0 0 3px rgba(47, 157, 146, 0.4);
  }
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win over the display rules below (equal
   specificity would otherwise let a later `display:flex` show a hidden panel). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(820px 380px at 20% -6%, rgba(15, 111, 104, 0.10), transparent 62%),
    radial-gradient(760px 440px at 92% 2%, rgba(184, 111, 50, 0.08), transparent 66%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.dialer {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 460px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* ---------- top bar: wordmark + connection status ---------- */
.dialer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 4px;
}

.dialer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.dialer-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: block;
}

.dialer-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 0.32rem 0.7rem 0.32rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.dialer-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s ease;
}
body[data-live="1"] .dialer-status {
  color: var(--primary-strong);
  border-color: var(--primary-soft);
}
body[data-live="1"] .dialer-status::before {
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- body: centers whichever panel is active ---------- */
.dialer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 0;
}
.call-panel {
  display: flex;
  flex-direction: column;
}

/* ---------- shared card surface ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.panel-icon,
.idle-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}
.panel-icon svg,
.idle-icon svg { width: 26px; height: 26px; }

/* ---------- unpaired state ---------- */
.link-panel {
  text-align: center;
  padding: 34px 26px 30px;
}
.link-panel h1 {
  font-family: var(--display-font);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 1rem 0 0.6rem;
}
.link-panel p {
  color: var(--text-muted);
  margin: 0.5rem 0;
  font-size: 0.98rem;
}
.link-panel strong { color: var(--text); font-weight: 600; }
.panel-hint {
  margin-top: 1.1rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem !important;
  color: var(--text-faint) !important;
}

/* ---------- incoming number (the primary moment) ---------- */
.incoming {
  text-align: center;
  padding: 30px 24px 26px;
  margin-bottom: 20px;
  animation: rise 0.3s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.incoming-label {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.incoming-number {
  margin: 0 0 22px;
  font-family: var(--data-font);
  font-size: clamp(1.5rem, 6.6vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
  color: var(--text);
  word-break: break-word;
}

/* ---------- the one clear action ---------- */
.call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--primary);
  color: var(--on-primary);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: 0 12px 28px rgba(15, 111, 104, 0.26);
  transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
.call-btn:hover { background: var(--primary-strong); }
.call-btn:active { transform: translateY(1px) scale(0.995); box-shadow: 0 6px 16px rgba(15, 111, 104, 0.24); }
.call-glyph { display: inline-flex; }
.call-glyph svg { width: 22px; height: 22px; }
.call-hint {
  margin: 14px 0 0;
  color: var(--text-faint);
  font-size: 0.82rem;
}

/* ---------- linked / waiting ---------- */
.idle {
  text-align: center;
  padding: 34px 26px 30px;
}
.idle-title {
  font-family: var(--display-font);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 1rem 0 0.5rem;
}
.idle-sub {
  color: var(--text-muted);
  margin: 0 auto;
  max-width: 320px;
  font-size: 0.98rem;
}
.idle-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.4rem;
}
.idle-note {
  margin: 1rem 0 0;
  color: var(--text-faint);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* ---------- buttons (secondary actions) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1.3rem;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
  font-weight: 600;
}
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- recent numbers ---------- */
.recent { margin-top: 26px; }
.recent h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin: 0 0 10px;
  padding-left: 2px;
}
.recent ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.recent-meta { min-width: 0; }
.recent-number {
  font-family: var(--data-font);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  word-break: break-word;
}
.recent-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-call {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-pill);
  transition: background 0.15s ease;
}
.recent-call svg { width: 15px; height: 15px; }
.recent-call:hover { background: #d3e8e2; }

/* ---------- focus visibility (accessibility) ---------- */
.call-btn:focus-visible,
.btn:focus-visible,
.recent-call:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.dialer-status:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .incoming { animation: none; }
  * { transition: none !important; }
}

/* ---------- small phones ---------- */
@media (max-width: 360px) {
  .incoming, .idle, .link-panel { padding-left: 18px; padding-right: 18px; }
}
