/* On-site AI box v1: site styles on top of the shared ui.css (which provides the "!" hints,
   toasts, page transitions, phone tap targets and the reduced-motion switch). */

:root { accent-color: var(--accent); }

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}
.skip-link:focus { top: 8px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

main:focus { outline: none; }

/* The app name in the top bar links home but reads as a name. */
.topbar a.app-name { color: var(--text); text-decoration: none; }
.topbar a.app-name:hover { color: var(--accent); }

/* ---- Small shared pieces ---- */
.lead { font-size: 1.08rem; color: var(--text); max-width: 46rem; }
.section-title { margin-top: 8px; }
.with-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clean-list { list-style: none; padding: 0; margin: 0; }
.clean-list > li + li { margin-top: 10px; }
mark { background: var(--warn-weak); color: inherit; padding: 0 2px; border-radius: 3px; }
.details-body { margin-top: 12px; }
.field-note { color: var(--muted); font-size: 0.82rem; }
.table tbody th { position: static; background: none; color: var(--text); font-size: inherit; font-weight: 600; white-space: normal; }
.table tbody tr:last-child th { border-bottom: 0; }

/* Segmented control: radios that look like pills (keyboard: Tab in, arrows to choose).
   The chosen pill is tinted, not filled, so it doesn't look like a primary button. */
.segmented { display: flex; gap: 6px; flex-wrap: wrap; border: 0; padding: 0; margin: 0; min-width: 0; }
.segmented legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; padding: 0; }
.segmented label {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.segmented label:hover { border-color: var(--accent); }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.segmented label:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Entry animations (off for reduced motion at the bottom). */
@keyframes rise-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: none; } }
@keyframes flash-bg { from { background: var(--warn-weak); } to { background: var(--accent-weak); } }
@keyframes bump { 0% { scale: 1; } 40% { scale: 1.035; } 100% { scale: 1; } }
.anim-in { animation: rise-in 220ms ease-out both; animation-delay: calc(var(--i, 0) * 45ms); }

/* ---- Overview ---- */
.hero { padding: 8px 0 4px; }
.hero h1 { font-size: 2rem; max-width: 36rem; }
.hero .lead { margin: 0; }
.promise h3 { font-size: 1.05rem; display: flex; gap: 10px; align-items: center; }
.promise-num {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}
.promise p { margin: 0; color: var(--muted); }
.diagram-wrap { display: block; }
.diagram { width: 100%; height: auto; max-width: 380px; display: block; margin: 0 auto; }
.diagram .d-frame { fill: none; stroke: var(--muted); stroke-dasharray: 6 5; }
.diagram .d-box { fill: var(--surface-2); stroke: var(--border); }
.diagram .d-main { fill: var(--accent-weak); stroke: var(--accent); stroke-width: 2; }
.diagram .d-chip { fill: var(--surface); stroke: var(--accent); }
.diagram .d-sdi { fill: var(--surface); stroke: var(--border); }
.diagram .d-line { stroke: var(--muted); stroke-width: 2; fill: none; }
.diagram .d-tunnel { stroke: var(--good); stroke-width: 2.5; fill: none; stroke-dasharray: 7 5; animation: tunnel-flow 1.2s linear infinite; }
@keyframes tunnel-flow { to { stroke-dashoffset: -24; } }
.diagram .d-arrow { fill: var(--good); }
.diagram .d-arrow-muted { fill: var(--muted); }
.diagram text { fill: var(--text); font-family: var(--font); font-size: 13px; }
.diagram .t-small { font-size: 11.5px; fill: var(--muted); }
.diagram .t-strong { font-weight: 700; }
.diagram .t-accent { fill: var(--accent); font-weight: 700; }
.diagram .t-good { fill: var(--good); font-weight: 600; }
.diagram .t-note { fill: var(--text); font-weight: 600; }
.not-list li strong { display: block; }

/* ---- Ask ---- */
.ask { display: grid; gap: 12px; }
.ask-field { position: relative; }
.ask-field input[type="search"] { font-size: 1.05rem; padding: 12px 44px 12px 14px; border-radius: var(--radius); }
.ask-field input[type="search"]:focus { border-color: var(--accent); }
.kbd-hint {
  position: absolute; right: 12px; top: 50%; translate: 0 -50%;
  min-width: 22px; padding: 1px 6px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  color: var(--muted); font: 600 0.78rem/1.4 var(--mono); text-align: center;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.ask-field input:focus + .kbd-hint, .ask-field input:not(:placeholder-shown) + .kbd-hint { opacity: 0; }
@media (hover: none) { .kbd-hint { display: none; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit;
  font-size: 0.86rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.weak-note { color: var(--warn); font-weight: 600; margin-bottom: 6px; }
.passage { padding: 6px 0; }
.passage + .passage { border-top: 1px solid var(--border); }
.passage-body { padding: 4px 0 8px 26px; }
.passage-body > p { margin: 0 0 8px; }
.passage-body.doc-enter, .doc-inline.doc-enter { animation: rise-in 220ms ease-out both; }
/* Header and "Whole document" toggles: a chevron on the left that turns when open (shared look with Knowledge capture). */
.toggle {
  display: flex; align-items: baseline; gap: 8px;
  width: 100%;
  padding: 8px 0;
  border: 0; background: none;
  font: inherit; color: var(--text); text-align: left;
  cursor: pointer;
}
.toggle:hover { color: var(--accent); }
.toggle .chev { flex: none; width: 18px; font-size: 1.15em; line-height: 1; color: var(--muted); transition: rotate 150ms ease; display: inline-block; text-align: center; }
.toggle[aria-expanded="true"] .chev { rotate: 90deg; color: var(--accent); }
.passage-toggle { font-weight: 600; }
.passage-toggle .muted { font-weight: 400; }
.doc-toggle { width: auto; padding: 4px 0; color: var(--accent); font-size: 0.9rem; font-weight: 600; }
.doc-inline { margin-top: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.doc-inline.doc-enter { animation: rise-in 240ms ease-out both; }
.doc-meta { color: var(--muted); font-size: 0.84rem; margin: 2px 0 10px; }
.doc-section { padding: 8px 10px; border-left: 3px solid transparent; border-radius: 4px; margin: 0 -10px; }
.doc-section h4 { margin: 0 0 4px; font-size: 0.95rem; }
.doc-section p { margin: 0; }
.doc-section.is-cited { background: var(--accent-weak); border-left-color: var(--accent); }
.doc-section.flash { animation: flash-bg 900ms ease-out; }
.doc-section .cited-label { font-size: 0.78rem; font-weight: 700; color: var(--accent); margin-left: 6px; }

/* ---- Hardware ---- */
.tier { display: flex; flex-direction: column; gap: 10px; }
.tier h2, .tier p { margin: 0; }
.spec { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.spec dt { color: var(--muted); font-size: 0.88rem; }
.spec dd { margin: 0; }
.yes { color: var(--good); font-weight: 600; }
.part { color: var(--warn); font-weight: 600; }
.no { color: var(--bad); font-weight: 600; }

/* ---- Security setup ---- */
.setup-groups { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; }
.setup-group h2 { font-size: 1.05rem; }
.setup-list { list-style: none; padding: 0; margin: 0; }
.setup-list li { position: relative; padding: 8px 0 8px 30px; border-top: 1px solid var(--border); }
.setup-list li:first-child { border-top: 0; }
.setup-list li::before {
  content: "\2713";
  position: absolute; left: 0; top: 9px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--good-weak); color: var(--good);
  font-size: 0.75rem; font-weight: 700;
}
.setup-list strong { display: block; }
.setup-list .why { display: block; color: var(--muted); font-size: 0.88rem; }
.print-only { display: none; }

/* ---- Pricing ---- */
.calc { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.users-row { display: grid; grid-template-columns: 1fr 90px; gap: 12px; align-items: center; }
.users-row input[type="range"] { width: 100%; margin: 0; }
.users-row input[type="text"] { text-align: right; font-variant-numeric: tabular-nums; }
.result-kpis { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: end; }
.result-kpis .kpi-value { font-size: 1.6rem; display: block; font-variant-numeric: tabular-nums; transform-origin: left center; }
.result-kpis .kpi-value.bump { animation: bump 300ms ease-out; }
.result-kpis .kpi.total { grid-column: 1 / -1; padding-top: 14px; border-top: 1px solid var(--border); }
.result-kpis .kpi.total .kpi-value { font-size: 2rem; color: var(--accent); }
.per-user { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; color: var(--muted); font-size: 0.88rem; }
.per-user strong { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }
.calc-note { color: var(--warn); font-weight: 600; margin: 0; }
.breakdown td.num { white-space: nowrap; }
.sticky-total { display: none; }

/* ---- Install ---- */
.cmd { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-2); }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 0.86rem; }
.cmd + .cmd-note { margin: 4px 0 12px; color: var(--muted); font-size: 0.86rem; }
.cmd-gap { margin-top: 8px; }
.hash code { word-break: break-all; white-space: normal; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 10px 0 10px 40px; border-top: 1px solid var(--border); }
.steps li:first-child { border-top: 0; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 10px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-weak); color: var(--accent);
  font-weight: 700; font-size: 0.85rem;
}
.steps h3 { margin: 0 0 2px; }
.steps p { margin: 0; color: var(--muted); }
.script-pre { max-height: 520px; overflow: auto; font-size: 0.8rem; line-height: 1.45; white-space: pre; margin-top: 12px; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .spec { grid-template-columns: 1fr; gap: 0; }
  .spec dd { margin-bottom: 8px; }
  /* Tap targets of at least 40px */
  .chip, .segmented label, .toggle { min-height: 40px; }
  .chip { display: inline-flex; align-items: center; }
  .toggle { align-items: center; }
  details > summary { min-height: 40px; padding-block: 9px; }
  .col-note { display: none; }
  /* A one-line total pinned to the bottom while the cost tiles are out of view */
  .sticky-total.is-away {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
    min-height: 44px; padding: 8px 14px;
    border: 1px solid var(--accent); border-radius: var(--radius);
    background: var(--surface); color: var(--text); text-decoration: none;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
    animation: rise-in 180ms ease-out;
  }
  .sticky-total strong { font-variant-numeric: tabular-nums; }
  body:has(.sticky-total) .container { padding-bottom: 84px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .anim-in, .doc-inline.doc-enter, .passage-body.doc-enter, .doc-section.flash, .result-kpis .kpi-value.bump, .sticky-total.is-away { animation: none; }
  .diagram .d-tunnel { animation: none; }
}

/* ---- Print (security checklist): empty boxes to tick by hand ---- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #333; --border: #999; color-scheme: light; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .no-print, .footer, .skip-link, .toast-stack, .hint, .sticky-total { display: none !important; }
  .print-only { display: block; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .setup-groups { display: block; }
  .setup-group + .setup-group { margin-top: 12px; }
  .setup-list li::before { content: ""; border: 1.5px solid #000; border-radius: 3px; background: #fff; width: 14px; height: 14px; top: 11px; }
  a { color: #000; }
}
