/* ============================================================
   WhitSentry interactive demo: the phone frame and app screens.
   Typography inside the frame is the system stack on purpose,
   so it reads as a real app, distinct from the editorial page.
   Spec: docs/site-plan/demo-spec.md
   ============================================================ */

.phone {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 380px; margin: 0 auto;
  background: var(--night-900);
  border: 1px solid var(--night-500);
  border-radius: 28px;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5), 0 0 0 6px rgba(22, 38, 63, 0.55);
  padding: 0.9rem 1.1rem 1.3rem;
  min-height: 640px;
  position: relative;
  display: flex; flex-direction: column;
}
.phone-topbar {
  width: 86px; height: 5px; border-radius: 3px;
  background: var(--night-500); margin: 0.2rem auto 1rem;
}

.screen { display: flex; flex-direction: column; gap: 0.75rem; flex-grow: 1; }
.screen[hidden] { display: none; }

.screen-h { font-size: 1.5rem; line-height: 1.3; font-weight: 600; font-family: inherit; letter-spacing: 0; color: var(--text); outline: none; }
.screen-sub { font-size: 1rem; line-height: 1.5; color: var(--text-dim); }
.screen-note { font-size: 0.8125rem; line-height: 1.5; color: var(--text-dim); }

/* ---------- App buttons ---------- */
.app-btn {
  font-family: inherit; font-size: 0.9375rem; font-weight: 600;
  background: var(--amber-400); color: var(--night-900);
  border: 0; border-radius: 12px; padding: 0.85rem 1.1rem;
  cursor: pointer; width: 100%; margin-top: auto;
  transition: background 0.2s, opacity 0.2s;
}
.app-btn:hover:not(:disabled) { background: var(--amber-300); }
.app-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.app-btn:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; }
.app-btn-secondary { background: var(--night-500); color: var(--text); margin-top: 0; }
.app-btn-secondary:hover:not(:disabled) { background: var(--night-700); }

/* ---------- Screen 1 ---------- */
.s1-form { display: flex; flex-direction: column; gap: 0.65rem; flex-grow: 1; }
.s1-form label, .s3-form label {
  font-size: 0.8125rem; font-weight: 600; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 0.3rem;
}
.s1-form input, .s3-form input, .s3-form select {
  font-family: inherit; font-size: 1rem; font-weight: 400;
  background: var(--night-700); color: var(--text);
  border: 1px solid var(--night-500); border-radius: 10px; padding: 0.65rem 0.8rem;
  width: 100%;
}
.s1-form input:focus, .s3-form input:focus, .s3-form select:focus {
  outline: 2px solid var(--amber-400); outline-offset: 0; border-color: transparent;
}
.s1-disclaimer {
  font-size: 0.8125rem; line-height: 1.5; color: var(--text-dim);
  border: 1px solid var(--night-500); border-radius: 10px; padding: 0.75rem 0.85rem;
  background: var(--night-700);
}
.s1-check { flex-direction: row !important; align-items: center; gap: 0.55rem !important; font-size: 0.9375rem !important; color: var(--text) !important; }
.s1-check input { width: 18px; height: 18px; accent-color: var(--amber-400); }
.s1-reason { font-size: 0.8125rem; color: var(--amber-300); }
.s1-success { display: flex; flex-direction: column; gap: 0.8rem; flex-grow: 1; justify-content: center; text-align: center; }
.s1-welcome { font-size: 1.3rem; font-weight: 600; color: var(--text); line-height: 1.35; }

/* ---------- Screen 2 ---------- */
.s2-skip {
  align-self: flex-end; background: none; border: 0; color: var(--amber-300);
  font-family: inherit; font-size: 0.8125rem; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; padding: 0.2rem;
}
.device-list { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; min-height: 260px; }
.device-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--night-700); border: 1px solid var(--night-500);
  border-radius: 12px; padding: 0.7rem 0.85rem;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}
.device-row.in { opacity: 1; transform: none; }
.device-glyph { color: var(--amber-400); flex-shrink: 0; }
.device-label { font-size: 0.9375rem; color: var(--text); }
.device-room { font-size: 0.9375rem; color: var(--amber-300); font-weight: 600; margin-left: auto; }
.device-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--night-500);
  margin-left: 0.5rem; flex-shrink: 0; transition: background 0.5s;
}
.device-dot.on { background: var(--amber-400); }
.device-status { font-size: 0.8125rem; color: var(--text-dim); margin-left: auto; opacity: 0; transition: opacity 0.5s; }
.device-status.in { opacity: 1; }

/* ---------- Screen 3 ---------- */
.s3-subprogress {
  display: flex; gap: 0.6rem; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.s3-tab { color: var(--text-dim); padding-bottom: 0.3rem; border-bottom: 2px solid transparent; }
.s3-tab.active { color: var(--amber-400); border-bottom-color: var(--amber-400); }
.cal-list { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.cal-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--night-700); border: 1px solid var(--night-500);
  border-radius: 12px; padding: 0.7rem 0.85rem; min-height: 58px;
}
.cal-room { font-size: 1rem; font-weight: 600; color: var(--text); }
.cal-state { font-size: 0.8125rem; color: var(--text-dim); margin-left: auto; text-align: right; }
.cal-row.done .cal-state { color: var(--amber-300); }
.cal-ringwrap { width: 40px; height: 40px; position: relative; flex-shrink: 0; }
.cal-ringwrap svg { transform: rotate(-90deg); }
.cal-ringwrap circle { fill: none; stroke-width: 3; }
.cal-ringwrap .ring-bg { stroke: var(--night-500); }
.cal-ringwrap .ring-fg { stroke: var(--amber-400); }
.cal-count {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 600; color: var(--amber-300);
}
.cal-progress { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; margin-left: auto; flex-shrink: 0; }
.cal-settle { color: var(--amber-300); opacity: 0.85; line-height: 0; }
.people-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.person-row {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--night-700); border: 1px solid var(--night-500);
  border-radius: 12px; padding: 0.65rem 0.85rem;
  font-size: 0.9375rem; color: var(--text);
}
.pod-tag, .demo-badge {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--amber-300); border: 1px solid rgba(242, 178, 78, 0.45);
  border-radius: 6px; padding: 0.1rem 0.45rem;
}
.s3-form { display: flex; flex-direction: column; gap: 0.65rem; }
.s3-podnote { color: var(--amber-300) !important; }

/* ---------- Screen 4 ---------- */
.s4-headerrow { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.s4-time { font-size: 0.8125rem; color: var(--text-dim); }
.s4-simtag { flex-shrink: 0; }

.s4-summary { display: flex; align-items: center; gap: 0.55rem; font-size: 1.0625rem; font-weight: 500; color: var(--text); }
.s4-summary-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--amber-300);
  box-shadow: 0 0 0 5px var(--amber-glow); flex-shrink: 0;
}
.s4-summary.is-calibrating { color: var(--text-dim); }
.s4-summary.is-calibrating .s4-summary-dot { background: var(--text-dim); box-shadow: none; opacity: 0.7; }
.s4-summary.is-alert .s4-summary-dot { background: var(--amber-400); box-shadow: 0 0 0 5px var(--amber-glow); }

.s4-hub { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--text-dim); }
.s4-hub .device-dot { margin-left: 0; }

.s4-scene {
  display: flex; gap: 0.5rem;
}
.s4-scenebtn {
  font-family: inherit; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--night-700); color: var(--text-dim);
  border: 1px solid var(--night-500); border-radius: 999px;
  padding: 0.35rem 0.85rem; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.s4-scenebtn:hover:not([aria-pressed="true"]):not(:disabled) { color: var(--text); }
.s4-scenebtn:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; }
.s4-scenebtn[aria-pressed="true"] { color: var(--night-900); background: var(--amber-400); border-color: var(--amber-400); }
.s4-scenebtn:disabled { opacity: 0.45; cursor: not-allowed; }

.room-cards { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; align-items: start; }
.room-card {
  background: var(--night-700); border: 1px solid var(--night-500);
  border-radius: 12px; padding: 0.6rem 0.65rem;
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name chip" "status status";
  gap: 0.2rem 0.5rem; position: relative;
  transition: border-color 0.3s ease-out, background 0.3s ease-out, box-shadow 0.3s ease-out, opacity 0.25s ease-out;
}
.room-name { grid-area: name; font-size: 0.875rem; font-weight: 600; color: var(--text); }
.person-chip {
  grid-area: chip; font-size: 0.7rem; font-weight: 600; color: var(--night-900);
  background: var(--amber-400); border-radius: 999px; padding: 0.1rem 0.5rem;
  justify-self: end; align-self: center;
}
.chip-group {
  grid-area: chip; justify-self: end; align-self: center;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.25rem;
}
.room-status { grid-area: status; font-size: 0.8125rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.4rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--night-500); position: relative; flex-shrink: 0; }
.status-dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  background: var(--amber-glow); opacity: 0; transform: scale(1);
}
.room-card[data-state="occupied"] .status-dot { background: var(--amber-400); }
.room-card[data-state="occupied"] .status-dot::after { animation: pulse-halo 4.2s cubic-bezier(0.37, 0, 0.63, 1) infinite; animation-delay: var(--pulse-delay, 0s); }
.room-card[data-state="calibrating"] .status-dot { background: var(--text-dim); opacity: 0.7; }
@keyframes pulse-halo {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  45% { opacity: 0.85; transform: scale(1.06); }
}

/* Vitals (wellness view, occupied cards only) */
.vitals { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.2rem; }
.vitals-person { display: flex; flex-direction: column; gap: 0.2rem; }
.vitals-line { font-size: 0.7rem; line-height: 1.4; color: var(--text-dim); }
.vitals-pause { font-size: 0.7rem; line-height: 1.4; color: var(--text-dim); }
.vitals-wave {
  width: 100%; height: 24px; overflow: hidden; margin-bottom: 0.15rem;
  filter: drop-shadow(0 0 4px var(--amber-glow));
}
.vitals-wave-svg { display: block; height: 24px; width: 100%; }
.vitals-wave-anim {
  width: 200%;
  animation: vitals-wave-scroll var(--breath) linear infinite;
  animation-delay: calc(-1 * var(--pulse-delay, 0s));
}
@keyframes vitals-wave-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.vitals-signal { display: flex; align-items: center; gap: 0.4rem; font-size: 0.7rem; color: var(--text-dim); }
.vitals-signal-track {
  flex-grow: 1; height: 2px; border-radius: 2px; background: var(--night-500); overflow: hidden;
}
.vitals-signal-fill { display: block; height: 100%; background: var(--amber-400); }

.s4-wellness { display: flex; flex-direction: column; gap: 0.35rem; }
.s4-wellness-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.s4-wellness-label { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.s4-switch {
  width: 42px; height: 24px; border-radius: 999px; padding: 0;
  background: var(--night-500); border: 1px solid var(--night-500);
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.s4-switch[aria-checked="true"] { background: var(--amber-400); border-color: var(--amber-400); }
.s4-switch[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.s4-switch-knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text); transition: transform 0.2s, background 0.2s;
}
.s4-switch[aria-checked="true"] .s4-switch-knob { transform: translateX(18px); background: var(--night-900); }
.s4-switch:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; }

/* Alert state */
.room-card[data-state="alert"] {
  grid-column: 1 / -1;
  border-color: var(--amber-400);
  background: #1E2438;
  box-shadow: 0 0 0 1px var(--amber-400), 0 8px 30px rgba(242, 178, 78, 0.18);
}
.alert-tag {
  position: absolute; top: -0.6rem; right: 0.7rem;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--amber-400); color: var(--night-900);
  border-radius: 6px; padding: 0.12rem 0.5rem;
}
.room-card[data-state="alert"] .room-status { color: var(--amber-300); font-weight: 600; }
.alert-body { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.4rem; }
.alert-copy { font-size: 0.875rem; line-height: 1.5; color: var(--text); }
.alert-countdown { display: flex; align-items: baseline; gap: 0.55rem; }
.alert-count { font-size: 1.9rem; font-weight: 600; color: var(--amber-300); font-variant-numeric: tabular-nums; }
.alert-count-label { font-size: 0.8125rem; color: var(--text-dim); }
.imfine-btn {
  font-family: inherit; font-size: 1.05rem; font-weight: 600;
  background: var(--amber-400); color: var(--night-900);
  border: 0; border-radius: 12px; padding: 0.95rem; cursor: pointer; width: 100%;
}
.imfine-btn:hover { background: var(--amber-300); }
.imfine-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.s4-alertrow { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.3rem; }
.s4-alertrow .app-btn-secondary { flex-grow: 1; }
.s4-close { margin-top: 0.2rem; }
.demo-toast {
  position: absolute; left: 1rem; right: 1rem; bottom: 1rem;
  background: var(--night-500); color: var(--text);
  font-size: 0.875rem; border-radius: 12px; padding: 0.8rem 1rem;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
}
.demo-toast.in { opacity: 1; transform: none; }

/* ---------- Stepper (lives outside the frame) ---------- */
.stepper { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.8rem; padding: 0; }
.stepper button {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--night-700); color: var(--text-dim);
  border: 1px solid var(--night-500); border-radius: 999px;
  padding: 0.5rem 1rem 0.5rem 0.55rem; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.stepper button:hover { color: var(--text); }
.stepper button:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; }
.stepper button[aria-current="step"] { color: var(--night-900); background: var(--amber-400); border-color: var(--amber-400); }
.stepper button[aria-current="step"] .step-n { background: var(--night-900); color: var(--amber-300); }
.step-n {
  width: 22px; height: 22px; border-radius: 50%; background: var(--night-500); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem;
}
.stepper button.done .step-n::after { content: "✓"; }
.stepper button.done .step-n { font-size: 0.65rem; }
.stepper button.done .step-n span { display: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .device-row { opacity: 1; transform: none; transition: opacity 0.15s; }
  .room-card[data-state="occupied"] .status-dot::after { animation: none; opacity: 0.65; }
  .demo-toast { transition: none; }
  .room-card { transition: none; }
  .vitals-wave-anim { animation: none; width: 100%; }
  .s4-switch-knob { transition: none; }
}
