/* =====================================================================
   DOORWAY COMPONENTS  ·  shared by site, app (homeowner) and hub (pros)
   Every color comes from tokens.css. Class names are the component API;
   docs/components.md lists them with usage.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--stage);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-xs); }
img, svg { max-width: 100%; }
/* The dot grid belongs to the stage behind devices */
.dotgrid { background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 26px 26px; }

/* ---------- Type ---------- */
.display   { font-family: var(--font-display); font-weight: 600; letter-spacing: -.025em; line-height: 1.05; font-size: var(--fs-3xl); text-wrap: balance; }
.display-md{ font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; line-height: 1.1; font-size: var(--fs-2xl); text-wrap: balance; }
.h3        { font-family: var(--font-display); font-weight: 600; font-size: 16.5px; line-height: 1.25; letter-spacing: -.01em; }
.eyebrow   { font-family: var(--font-label); font-stretch: 125%; font-variation-settings: 'wdth' 125; font-size: 10px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow.accent { color: var(--primary); }
.sub       { color: var(--ink-2); font-size: var(--fs-md); line-height: 1.55; }
.fine      { color: var(--ink-3); font-size: var(--fs-xs); line-height: 1.5; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tnum      { font-variant-numeric: tabular-nums; }
.serial    { font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .09em; color: var(--ink-3); text-transform: uppercase; }
.muted     { color: var(--ink-2); }
.up   { color: var(--kept); }  .down { color: var(--breach); }  .warn { color: var(--watch); }
.link { color: var(--primary); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- Layout helpers ---------- */
.row   { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.row.start { justify-content: flex-start; }
.row.wrap  { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-2); }
.stack.lg { gap: var(--s-4); }
.stack.xl { gap: var(--s-6); }
.grid  { display: grid; gap: var(--s-4); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: minmax(0,1fr); } }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-4) 0; }
.spacer { flex: 1; }

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  padding: var(--s-4); box-shadow: var(--shadow-card); min-width: 0;
}
.card { border-color: var(--line); }
.card.quiet { background: var(--surface-2); box-shadow: none; border-color: transparent; }
.card.navy { background: var(--frame); color: var(--on-frame); border-color: var(--navy); }
.card.navy .sub, .card.navy .muted { color: var(--slate); }
.card.flat  { box-shadow: none; border-color: var(--line); }
.card.hero  { border: 2px solid var(--primary); }
.card.pad-lg { padding: var(--s-6); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.card-head .h3 { font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  background: var(--fill); color: var(--primary-ink); font-weight: 600; font-size: 15px;
  padding: 13px 18px; border-radius: 13px; white-space: nowrap; text-decoration: none;
  transition: transform 120ms var(--ease), filter 120ms ease;
}
.btn:hover  { filter: brightness(.96); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.block  { width: 100%; }
.btn.sm     { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn.ghost  { background: transparent; color: var(--ink); border: 1.5px solid var(--line-strong); }
.btn.ghost:hover { border-color: var(--ink-3); filter: none; }
.btn.quiet  { background: var(--surface-2); color: var(--ink); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--breach); color: #fff; }
.btn.dark   { background: var(--frame); color: var(--on-frame); }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Chips, stamps, pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip.blue   { background: var(--primary-soft); color: var(--navy); }
.chip.navy   { background: var(--frame); color: var(--on-frame); }
.chip.orange { background: var(--accent-soft); color: var(--navy); }
.chip.kept   { background: var(--kept-soft); color: var(--kept); }
.chip.teal   { background: var(--kept-soft); color: var(--kept); }
.chip.watch  { background: var(--watch-soft); color: var(--watch); }
.chip.breach { background: var(--breach-soft); color: var(--breach); }
.chip .dot   { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Stamp: the one-word state of a promise. Outlined, mono, uppercase. */
.stamp {
  display: inline-block; padding: 3px 8px; border: 1px solid currentColor; border-radius: 4px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: .11em;
  text-transform: uppercase; white-space: nowrap; color: var(--ink-2);
}
.stamp.tilt { transform: rotate(-1.6deg); border-width: 1.5px; }
.stamp.kept, .stamp.paid, .stamp.signed { color: var(--kept); }
.stamp.measured, .stamp.confirmed { color: var(--navy); }
.stamp.confirming { color: var(--ink-3); border-style: dashed; }
.stamp.backed, .stamp.saved { color: var(--navy); }
.stamp.watch, .stamp.provisional { color: var(--watch); }
.stamp.missed { color: var(--breach); }
.stamp.press { animation: dw-press 260ms cubic-bezier(.2,1.4,.4,1) both; }
@keyframes dw-press { 0% { transform: rotate(-6deg) scale(1.7); opacity: 0 } 100% { transform: rotate(-1.6deg) scale(1); opacity: 1 } }

/* Bracket: an arrival window. Always a range. */
.bracket {
  position: relative; display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap;
  padding: 7px 14px; font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; font-variant-numeric: tabular-nums;
}
.bracket::before, .bracket::after { content: ""; position: absolute; top: 0; bottom: 0; width: 8px; border: 2px solid var(--door-ink); }
.bracket::before { left: 0; border-right: 0; }
.bracket::after  { right: 0; border-left: 0; }
.bracket .d { font-size: 10px; letter-spacing: .1em; color: var(--ink-2); text-transform: uppercase; }
.bracket.lg { font-size: 17px; padding: 9px 16px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 12px;
}
.avatar.blue { background: var(--fill); color: var(--primary-ink); }
.avatar.ink  { background: var(--ink); color: var(--ground); }
.avatar.soft { background: var(--surface-2); color: var(--ink-2); }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .t { font-weight: 600; font-size: 14px; }
.list-row .d { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
button.list-row, a.list-row { width: 100%; text-align: left; color: inherit; text-decoration: none; }
button.list-row:hover, a.list-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-2); font-size: 13.5px; }
.kv .v { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Timeline ---------- */
.tl { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--kept); margin-top: 4px; position: relative; flex: 0 0 auto; }
.tl-dot.now { background: var(--primary); }
.tl-dot.next { background: transparent; border: 2px solid var(--ink-3); }
.tl-dot.now::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--primary); opacity: 0; animation: dw-ring 2s ease-out infinite; }
@keyframes dw-ring { 0% { transform: scale(.5); opacity: .7 } 70% { transform: scale(1.15); opacity: 0 } 100% { opacity: 0 } }
.tl-line { width: 2px; flex: 1; background: var(--line); margin: 4px 0; }
.tl-body { padding-bottom: 14px; }
.tl-body .t { font-size: 14px; font-weight: 600; }
.tl-body .d { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1.5px solid var(--line); border-radius: 11px;
  padding: 11px 13px; font-size: 14px; color: var(--ink); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 88px; resize: vertical; }
.otp { display: flex; gap: 8px; }
.otp span { flex: 1; aspect-ratio: 1 / 1.15; max-width: 52px; border: 1.5px solid var(--line); border-radius: 11px; display: grid; place-items: center; font-family: var(--font-mono); font-size: 22px; font-weight: 600; background: var(--surface); }
.otp span.on { border-color: var(--primary); }

/* Toggle switch: <button class="switch" aria-pressed="true"> */
.switch { width: 40px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; flex: 0 0 auto; transition: background 160ms ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 160ms var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch[aria-pressed="true"] { background: var(--primary); }
.switch[aria-pressed="true"]::after { transform: translateX(16px); }

/* Segmented control: <div class="seg"><button class="on">..</button></div> */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--ground); }

/* Tabs: <div class="tabs"><button class="on">..</button></div> */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--primary); }

/* Selectable option (slot, plan, filter): add .sel */
.option { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; transition: border-color 120ms ease, transform 120ms ease; }
.option:hover { border-color: var(--ink-3); }
.option:active { transform: scale(.98); }
.option.sel { border: 2px solid var(--primary); padding: 10.5px 13.5px; }
.option.sel .w { color: var(--primary); }

/* ---------- Metrics ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.kpi .delta.up { color: var(--kept); } .kpi .delta.down { color: var(--breach); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.meter.orange > i { background: var(--ochre); }
.meter.kept > i { background: var(--kept); }
.meter.watch > i { background: var(--watch); }
.meter.breach > i { background: var(--breach); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-family: var(--font-mono); font-size: 9.5px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.n, .table th.n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); color: var(--ink); font-size: 13.5px; }
.callout.kept { background: var(--kept-soft); }
.callout.watch { background: var(--watch-soft); }
.callout.breach { background: var(--breach-soft); }
.callout .ic { flex: 0 0 auto; margin-top: 2px; color: var(--primary); }
.callout.kept .ic { color: var(--kept); } .callout.watch .ic { color: var(--watch); } .callout.breach .ic { color: var(--breach); }
/* AI suggestion: the agent proposes, a person approves */
.suggest { border: 1.5px dashed var(--navy); border-radius: 14px; padding: 14px; background: var(--surface); }
.suggest .eyebrow { color: var(--navy); }
/* Needs you: the one attention colour. Door-orange tint, navy border, navy words. Max three per screen. */
.needs { background: var(--door-soft); border: 2px solid var(--navy); border-radius: 14px; padding: 14px; }
.pill-needs { display: inline-flex; align-items: center; gap: 6px; background: var(--door); color: var(--navy); font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; }
/* Status label on every figure that isn't real: Modeled · sample data */
.label-modeled { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; color: var(--ink-3); white-space: nowrap; }
.label-modeled::before { content: 'Modeled · sample data'; }

/* Guarantee line: triangle bullet + two lines */
.guar { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.guar svg { flex: 0 0 auto; margin-top: 3px; color: var(--kept); }
.guar .t { font-size: 13.5px; font-weight: 600; }
.guar .d { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

/* ---------- Brand mark ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.wordmark { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.02em; color: var(--crimson); line-height: 1; white-space: nowrap; }
.wordmark .dw-wordmark { display: inline-block; vertical-align: -.22em; }
.dw-mark, .dw-lockup { display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.wordmark i { font-style: normal; color: var(--door-ink); font-size: .55em; margin-left: .25em; vertical-align: .55em; letter-spacing: .06em; }

/* QR badge: the tech's badge, how homeowners first meet Doorway */
.qr-badge { background: var(--frame); color: var(--on-frame); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.qr-badge .qr { background: #fff; border-radius: 8px; padding: 8px; width: 120px; }

/* ---------- Overlays ---------- */
.dw-toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--frame); color: var(--on-frame); padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms var(--ease); z-index: 1000; max-width: calc(100vw - 32px);
}
.dw-toast.show { opacity: 1; transform: translate(-50%, 0); }
.dw-modal-back { position: fixed; inset: 0; background: rgba(42,26,21,.45); display: grid; place-items: center; padding: 16px; z-index: 900; }
.dw-modal-back[hidden] { display: none !important; }
.dw-modal { background: var(--surface); color: var(--ink); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: var(--s-6); }
.dw-drawer-back { position: fixed; inset: 0; background: rgba(42,26,21,.35); z-index: 900; }
.dw-drawer-back[hidden] { display: none !important; }
.dw-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); box-shadow: var(--shadow-pop); overflow: auto; padding: var(--s-6); }

/* ---------- Prototype bar (not product UI) ---------- */
.proto-bar {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 950;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px;
  background: var(--frame); color: var(--slate); box-shadow: var(--shadow-pop); font-size: 12px; font-weight: 600;
}
.proto-bar a, .proto-bar button { color: var(--slate); padding: 7px 11px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
.proto-bar a:hover, .proto-bar button:hover { background: var(--frame-2); color: var(--on-frame); text-decoration: none; }
.proto-bar a.on { background: var(--fill); color: var(--on-fill); }
.proto-bar .lbl { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--slate-2); padding: 0 8px 0 10px; }
@media (max-width: 640px) { .proto-bar .lbl { display: none; } .proto-bar { right: 8px; left: 8px; justify-content: center; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); } }
.proto-bar.hide-mobile { }

/* ---------- Motion ---------- */
.rise > * { animation: dw-rise 340ms var(--ease) both; }
.rise > *:nth-child(2) { animation-delay: 25ms } .rise > *:nth-child(3) { animation-delay: 50ms }
.rise > *:nth-child(4) { animation-delay: 75ms } .rise > *:nth-child(5) { animation-delay: 95ms }
.rise > *:nth-child(n+6) { animation-delay: 115ms }
@keyframes dw-rise { from { opacity: 0; transform: translateY(7px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
