/* IsraeliCar — live driver-monitor demo. Uses the site tokens (--th-*, --ic-*) + shared .th-btn / header / footer. */
.page-dm-demo {
  --dm-ok: #1a8a5f; --dm-ok-bg: #e8f5ef; --dm-ok-line: #bfe3d2;
  --dm-warn: #a86400; --dm-warn-bg: #fff4dc; --dm-warn-line: #f2d99a; --dm-warn-strong: #e0a020;
  --dm-bad: #c42b1c; --dm-bad-bg: #fdecea; --dm-bad-line: #f5c0ba; --dm-bad-strong: #e5484d;
  --dm-hdr: 69px;
  --dm-stage: #0a1a3d;
}
.dm-main { display: block; }
.dm-app { width: min(100% - 2rem, var(--th-rail-wide, 1100px)); margin-inline: auto; padding: 28px 0 44px; }
.dm-head { margin-bottom: 20px; }
.dm-eyebrow { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px; padding: 3px 10px 3px 12px; border-radius: 999px; background: #fff4dc; color: #8a5300; font-size: .8125rem; font-weight: 600; line-height: 1.5; border: 1px solid var(--dm-warn-line); }
.dm-eyebrow svg { width: 15px; height: 15px; flex: none; }
.dm-title { margin: 0 0 10px; font-size: clamp(1.5rem, .55rem + 2.4vw, 2.5rem); font-weight: 700; line-height: 1.2; color: var(--th-navy); text-wrap: balance; }
.dm-lead { margin: 0; max-width: 46rem; font-size: 1.0625rem; line-height: 1.6; color: var(--th-ink-soft); }

.dm-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 24px; align-items: start; }

/* ---------- stage ---------- */
.dm-stage-wrap { min-width: 0; }
.dm-stage { position: relative; aspect-ratio: 4 / 3; width: 100%; background: var(--dm-stage); border-radius: var(--th-radius-media, 16px); overflow: hidden; isolation: isolate; box-shadow: 0 0 0 1px var(--th-line) inset; }
.dm-stage::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5; border: 3px solid transparent; transition: border-color .25s var(--th-ease, ease); }
.dm-stage[data-level="ok"]::after { border-color: rgba(26,138,95,.75); }
.dm-stage[data-level="warn"]::after { border-color: var(--dm-warn-strong); }
.dm-stage[data-level="bad"]::after { border-color: var(--dm-bad-strong); animation: dmPulse 1s ease-in-out infinite; }
@keyframes dmPulse { 50% { border-color: rgba(229,72,77,.35); } }
.dm-stage video, .dm-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); }
.dm-stage video { object-fit: cover; background: var(--dm-stage); }
.dm-stage[data-state="idle"] video, .dm-stage[data-state="idle"] canvas, .dm-stage[data-state="loading"] canvas { visibility: hidden; }
.dm-stage[data-state="loading"] video { opacity: .55; }
.dm-stage canvas { pointer-events: none; z-index: 2; }

.dm-live { position: absolute; z-index: 6; inset-inline: 12px; top: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-inline: auto; width: fit-content; max-width: calc(100% - 24px); padding: 8px 16px; border-radius: 999px; background: rgba(255,255,255,.96); color: var(--th-navy); font-weight: 650; font-size: .975rem; line-height: 1.3; box-shadow: 0 6px 22px rgba(6,18,43,.28); transition: background .2s, color .2s; }
.dm-live__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dm-ok); flex: none; box-shadow: 0 0 0 4px rgba(26,138,95,.18); }
.dm-live__hint { font-weight: 500; font-size: .85rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-live__hint:empty { display: none; }
.dm-stage[data-level="warn"] .dm-live { background: #fff4dc; color: #7a4a00; }
.dm-stage[data-level="warn"] .dm-live__dot { background: var(--dm-warn-strong); box-shadow: 0 0 0 4px rgba(224,160,32,.25); }
.dm-stage[data-level="bad"] .dm-live { background: var(--dm-bad-strong); color: #fff; }
.dm-stage[data-level="bad"] .dm-live__dot { background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.3); }
.dm-stage[data-level="calib"] .dm-live { background: rgba(255,255,255,.96); }
.dm-stage[data-level="calib"] .dm-live__dot { background: var(--th-accent); box-shadow: 0 0 0 4px rgba(24,104,201,.18); }

.dm-tools { position: absolute; z-index: 6; inset-inline-start: 10px; bottom: 10px; display: flex; gap: 8px; }
.dm-tool { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(6,18,43,.62); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .2s; }
.dm-tool:hover { background: rgba(6,18,43,.85); }
.dm-tool svg { width: 20px; height: 20px; }
.dm-tool .s-on { display: none; }
.dm-tool[aria-pressed="true"] .s-on { display: block; }
.dm-tool[aria-pressed="true"] .s-off { display: none; }
.dm-tool:focus-visible, .dm-start:focus-visible { outline: 3px solid var(--th-accent-bright, #0081fc); outline-offset: 2px; }

.dm-calib { position: absolute; z-index: 4; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; padding-bottom: 14%; pointer-events: none; color: #fff; text-align: center; background: linear-gradient(to top, rgba(6,18,43,.55), rgba(6,18,43,0) 55%); }
.dm-ring { width: 74px; height: 74px; transform: rotate(-90deg); }
.dm-ring circle { fill: none; stroke-width: 7; }
.dm-ring .bg { stroke: rgba(255,255,255,.28); }
.dm-ring .fg { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .12s linear; }
.dm-calib__txt { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 8px rgba(6,18,43,.6); }
.dm-calib__txt b { font-size: 1.125rem; font-weight: 700; }
.dm-calib__txt span { font-size: .9rem; opacity: .95; }

.dm-intro { position: absolute; z-index: 7; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; color: #fff; background: radial-gradient(120% 90% at 50% 0%, #17336b 0%, #0a1a3d 62%, #06122b 100%); }
.dm-intro[hidden], .dm-load[hidden], .dm-calib[hidden], .dm-live[hidden], .dm-tools[hidden] { display: none; }
.dm-intro__icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); }
.dm-intro__icon svg { width: 34px; height: 34px; }
.dm-intro__title { margin: 0; font-size: clamp(1.15rem, .9rem + 1vw, 1.5rem); font-weight: 700; line-height: 1.3; color: #fff; max-width: 24rem; }
.dm-intro__priv { display: flex; align-items: flex-start; gap: 8px; margin: 0; max-width: 25rem; font-size: .9rem; line-height: 1.55; color: #d6e0f0; text-align: start; }
.dm-intro__priv svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: #7fdcb5; }
.dm-start { background: #fff; border-color: #fff; color: var(--th-navy); box-shadow: 0 10px 28px rgba(0,0,0,.28); }
.dm-start:hover { background: var(--th-navy-soft); border-color: var(--th-navy-soft); color: var(--th-navy); }
.dm-intro__msg { margin: 0; max-width: 26rem; padding: 10px 14px; border-radius: 10px; background: rgba(229,72,77,.16); border: 1px solid rgba(255,140,140,.5); color: #ffe1de; font-size: .9rem; line-height: 1.5; }
.dm-load { position: absolute; z-index: 6; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; font-weight: 600; background: rgba(6,18,43,.5); }
.dm-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; animation: dmSpin .8s linear infinite; }
@keyframes dmSpin { to { transform: rotate(360deg); } }

/* ---------- panel ---------- */
.dm-panel { min-width: 0; display: flex; flex-direction: column; gap: 16px; }


.dm-cta { display: flex; flex-direction: column; gap: 10px; }
.dm-cta__btn { width: 100%; }

/* ---------- explainer ---------- */
.dm-about { background: var(--th-bg-warm, #f6f8fb); border-block: 1px solid var(--th-line); padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.dm-about__inner { width: min(100% - 2rem, var(--th-rail-wide, 1100px)); margin-inline: auto; }
.dm-about h2 { margin: 0 0 12px; font-size: clamp(1.4rem, 1rem + 1.4vw, 2rem); color: var(--th-navy); font-weight: 700; }
.dm-about__lead { margin: 0 0 24px; max-width: 46rem; font-size: 1.0625rem; line-height: 1.7; color: var(--th-ink-soft); }
.dm-about__grid { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dm-about__grid li { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: #fff; border: 1px solid var(--th-line); border-radius: var(--th-radius-media, 16px); }
.dm-about__grid b { color: var(--th-navy); font-size: 1rem; font-weight: 650; }
.dm-about__grid span { color: var(--th-ink-soft); font-size: .9375rem; line-height: 1.6; }
.dm-about__foot { margin: 0; color: var(--th-ink-soft); }
.dm-about__foot a { color: var(--th-accent); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 980px) {
  .dm-grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 18px; }
  .dm-about__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- mobile: the whole live test fits ONE screen (header + app), footer below the fold ---------- */
@media (max-width: 760px) {
  .dm-app { width: min(100% - 1.5rem, 640px); height: calc(100vh - var(--dm-hdr)); height: calc(100svh - var(--dm-hdr)); min-height: 540px; padding: 8px 0 max(10px, env(safe-area-inset-bottom, 0px)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; box-sizing: border-box; }
  .dm-head { margin: 0; display: flex; align-items: center; gap: 10px; }
  .dm-head__text { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; }
  .dm-eyebrow { margin: 0; flex: none; padding: 2px 9px; font-size: .75rem; }
  .dm-eyebrow svg { width: 13px; height: 13px; }
  .dm-title { margin: 0; font-size: 1.0625rem; line-height: 1.25; font-weight: 700; min-width: 0; }
  .dm-lead { display: none; }
  .dm-grid { display: contents; }
  .dm-stage-wrap { min-height: 0; display: flex; }
  .dm-stage { aspect-ratio: auto; height: 100%; min-height: 220px; flex: 1; }
  .dm-panel { display: contents; }
  .dm-head { grid-row: 1; grid-column: 1; } .dm-stage-wrap { grid-row: 2; grid-column: 1; } .dm-cta { grid-row: 3; grid-column: 1; }
  .dm-cta__btn { width: 100%; min-height: 44px; padding: 8px 16px; font-size: .95rem; }
  .dm-live { top: 8px; padding: 6px 12px; font-size: .875rem; }
  .dm-live__hint { display: none; }
  .dm-intro { gap: 10px; padding: 14px; }
  .dm-intro__icon { width: 52px; height: 52px; border-radius: 15px; }
  .dm-intro__icon svg { width: 28px; height: 28px; }
  .dm-intro__priv { font-size: .8125rem; }
  .dm-tools { flex-direction: column; inset-inline-start: 10px; bottom: auto; top: 52px; gap: 8px; }
  .dm-tool { width: 38px; height: 38px; }
  .dm-calib { justify-content: center; padding-bottom: 0; }
  .dm-about__grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .dm-intro__icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dm-stage[data-level="bad"]::after { animation: none; }
  .dm-spin { animation-duration: 2s; }
}

/* ---------- results card (r7): flat white, rows with line-art icon + title/percent + thin bar. Only white / grays / navy. ---------- */
.dm-panel { gap: 14px; }
.md-card { --nv: var(--th-navy, #0a1a3d); position: relative; border: 1px solid #e8ecf2; border-radius: 18px; background: #fff; padding: 4px 18px; box-shadow: 0 1px 2px rgba(10,26,61,.04), 0 6px 18px rgba(10,26,61,.05); }
.md-card[hidden] { display: none; }
.md-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }
/* leading state line: placeholder "ממתין למצלמה" until the model outputs, then the predicted state */
.md-hero { display: block; padding: 12px 0 10px; border-bottom: 1px solid #edf0f5; }
.md-hero__ico { display: none; }
.md-state { font-size: .9375rem; font-weight: 500; line-height: 1.3; color: #8a95a8; min-height: 1.3em; }
.md-state .s { display: none; }
.md-card:not([data-lvl="idle"]) .md-state { color: var(--nv); font-weight: 700; }
.md-card[data-lvl="unsure"] .md-state { color: #5b6880; }
.md-bars { list-style: none; margin: 0; padding: 0; }
.md-bars li { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(90px, 38%); align-items: center; column-gap: 14px; padding-block: 13px; border-block-end: 1px solid #edf0f5; }
.md-bars li:last-child { border-block-end: 0; }
.md-bars .md-i { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #f1f3f7; color: #5b6880; }
.md-bars .md-i svg { width: 22px; height: 22px; }
.md-bars .md-body { display: grid; gap: 2px; min-width: 0; line-height: 1.3; }
.md-bars .md-n { font-size: .975rem; color: #2a3550; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-bars .md-n .s { display: none; }
.md-bars .md-p { font-size: .8125rem; color: #8a95a8; font-variant-numeric: tabular-nums; }
.md-bars .md-b { position: relative; height: 5px; border-radius: 999px; background: #e9edf3; overflow: hidden; direction: ltr; }
.md-bars .md-b i { position: absolute; inset-block: 0; left: 0; width: 0; border-radius: inherit; background: #b8c1cf; transition: width .2s linear; }
.md-bars li[data-top="1"] .md-n { color: var(--nv); font-weight: 700; }
.md-bars li[data-top="1"] .md-p { color: var(--nv); font-weight: 600; }
.md-bars li[data-top="1"] .md-i { color: var(--nv); background: #e6eaf1; }
.md-bars li[data-top="1"] .md-b i { background: var(--nv); }
.md-status { margin: 4px 0 8px; font-size: .8125rem; color: #5b6880; } .md-status:empty { display: none; }
.md-meta { padding: 4px 0 10px; }
.md-ver { margin: 0; font-size: .6875rem; color: #a3adbd; text-align: center; } .md-ver b { font-weight: 500; }
.dm-stage[data-model="1"] .dm-live::after { content: none; }
/* CTA: dark navy, full width, rounded */
.dm-cta__btn { border-radius: 16px; min-height: 52px; font-weight: 650; gap: 8px; background: var(--th-navy, #0a1a3d); border-color: var(--th-navy, #0a1a3d); color: #fff; }
.dm-cta__more { display: none; }
.dm-title .dm-t-m { display: none; }
.dm-cta__btn svg { width: 20px; height: 20px; flex: none; }

/* ---------- phones (r7b): STACKED, nothing overlays the camera. header / one-line title / camera (state pill + 2 small buttons) / compact rows / tiny version / navy CTA ---------- */
@media (max-width: 760px) {
  .page-dm-demo { --dm-card: 168px; --dm-cta: 52px; --dm-over: 392px; }
  .dm-app { width: calc(100% - 32px); max-width: 640px; height: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 0 10px; }
  .dm-head { flex: none; } .dm-head__text { justify-content: center; }
  .dm-title { font-size: 1.125rem; line-height: 1.3; text-align: center; white-space: nowrap; }
  .dm-title .dm-t-d { display: none; } .dm-title .dm-t-m { display: inline; }
  .dm-grid { display: contents; } .dm-panel { display: contents; }
  .dm-stage-wrap { flex: none; display: block; min-height: 0; }
  .dm-stage { aspect-ratio: auto; width: 100%; flex: none; min-height: 0; height: clamp(240px, calc(100svh - var(--dm-over)), 390px); border-radius: 18px; }
  .dm-app .md-card { order: 3; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; border-radius: 0; display: flex; flex-direction: column; gap: 4px; position: static; }
  .md-card[hidden] { display: flex; visibility: hidden; }
  .md-card::before { content: none; }
  .md-hero { display: none; }
  .md-bars { height: var(--dm-card); box-sizing: border-box; padding: 8px 14px; background: #fff; border: 1px solid #e5eaf2; border-radius: 16px; display: flex; flex-direction: column; justify-content: space-between; }
  .md-bars li { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 20px minmax(0, 1fr) 30% 38px; grid-template-areas: "i n b p"; align-items: center; column-gap: 10px; padding: 0; border: 0; }
  .md-bars .md-body { display: contents; }
  .md-bars .md-i { grid-area: i; width: 20px; height: 20px; border-radius: 0; background: none !important; box-shadow: none !important; color: #64748b; }
  .md-bars .md-i svg { width: 20px; height: 20px; }
  .md-bars .md-n { grid-area: n; font-size: .875rem; color: #64748b; font-weight: 500; } .md-bars .md-n .l { display: none; } .md-bars .md-n .s { display: inline; }
  .md-bars .md-p { grid-area: p; font-size: .875rem; font-weight: 600; color: #64748b; text-align: end; }
  .md-bars .md-b { grid-area: b; height: 3px; background: #edf0f5; }
  .md-bars .md-b i { background: #cbd3df; }
  .md-bars li[data-top="1"] .md-i, .md-bars li[data-top="1"] .md-n, .md-bars li[data-top="1"] .md-p { color: #1769d2; background: none; }
  .md-bars li[data-top="1"] .md-n { font-weight: 650; }
  .md-bars li[data-top="1"] .md-b i { background: #1769d2; }
  .md-bars li[data-c="normal"][data-top="1"] .md-i, .md-bars li[data-c="normal"][data-top="1"] .md-n, .md-bars li[data-c="normal"][data-top="1"] .md-p { color: #198754; }
  .md-bars li[data-c="normal"][data-top="1"] .md-b i { background: #198754; }
  .md-status { font-size: .6875rem; margin: 0; text-align: center; }
  .md-meta { padding: 0; }
  .md-ver { font-size: .6875rem; line-height: 1.2; color: #94a3b8; }
  .dm-cta { order: 5; flex: none; margin: 0; }
  .dm-cta__btn { min-height: var(--dm-cta); height: var(--dm-cta); border-radius: 14px; font-size: 1rem; padding: 0 16px; }
  .dm-cta__more { display: inline; }
  .dm-live { top: 8px; height: 36px; padding: 0 14px; font-size: 1rem; font-weight: 700; box-sizing: border-box; }
  .dm-live__txt { white-space: nowrap; }
  .dm-tools { flex-direction: column; inset-inline-start: 8px; bottom: auto; top: 8px; gap: 8px; }
  .dm-tool { width: 40px; height: 40px; border-radius: 12px; } .dm-tool svg { width: 20px; height: 20px; }
  #btnStop { display: none; }
  .dm-calib__txt span { font-size: .8rem; } .dm-calib__txt b { font-size: 1rem; } .dm-ring { width: 56px; height: 56px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .page-dm-demo { --dm-card: 128px; --dm-cta: 48px; --dm-over: 350px; }
  .dm-title { font-size: 1.0625rem; }
  .md-bars { padding: 5px 14px; }
}
