/* Zerem v4 — the door.
 *
 * Built on the five rules from Roy Shavit's Hick's-law reel (docs/v4, PLAN.md):
 * show only what is relevant now; not everything is equally important;
 * advanced options only when needed; the primary button stands out; one
 * primary action per screen. So this sheet has exactly one filled button
 * style (.btn-primary), and the page uses it once per state.
 *
 * Light first, one accent. The accent is the Zerem bolt green and appears in
 * three places only: the mark, focus, and the price confirmation. Everything
 * else is ink on paper.
 */

:root {
  color-scheme: light;
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --sunken: #EFEFEC;
  --ink: #0F1115;
  --ink-2: #454B57;
  --ink-3: #6A707C;
  --line: #E4E4E0;
  --line-2: #D3D3CE;
  --brand: #1E8E4E;
  --brand-ink: #166B3B;
  --brand-tint: #E8F4EC;
  --danger: #C23B3B;
  --on-ink: #FFFFFF;
  --me: #ECEDEA;

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-full: 999px;
  --sh-1: 0 1px 2px rgba(15, 17, 21, .05);
  --sh-2: 0 1px 2px rgba(15, 17, 21, .04), 0 10px 30px rgba(15, 17, 21, .07);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: 180ms;
  --font: 'IBM Plex Sans Hebrew', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --measure: 680px;

  /* The shared list cards (assets/listcards.js) read --zlc-*. */
  --zlc-bg: var(--bg);
  --zlc-panel: var(--surface);
  --zlc-line: var(--line);
  --zlc-ink: var(--ink);
  --zlc-sub: var(--ink-2);
  --zlc-muted: var(--ink-3);
  --zlc-accent: var(--brand-ink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1013;
    --surface: #16191E;
    --sunken: #1C2026;
    --ink: #F3F4F6;
    --ink-2: #BAC0CA;
    --ink-3: #8E95A1;
    --line: #262A31;
    --line-2: #323843;
    --brand: #38C172;
    --brand-ink: #5FD392;
    --brand-tint: #14261B;
    --danger: #F07575;
    --on-ink: #0E1013;
    --me: #1F242B;
    --sh-1: none;
    --sh-2: 0 0 0 1px var(--line);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1013;
  --surface: #16191E;
  --sunken: #1C2026;
  --ink: #F3F4F6;
  --ink-2: #BAC0CA;
  --ink-3: #8E95A1;
  --line: #262A31;
  --line-2: #323843;
  --brand: #38C172;
  --brand-ink: #5FD392;
  --brand-tint: #14261B;
  --danger: #F07575;
  --on-ink: #0E1013;
  --me: #1F242B;
  --sh-1: none;
  --sh-2: 0 0 0 1px var(--line);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
/* A heading takes focus only so a screen reader starts there (a new screen, a
   sheet). It is no control, and on a screen opened with no tap (the door's
   hand-off) the ring drew a green box around the job's title. */
[tabindex="-1"]:focus { outline: none; }
.skip {
  position: absolute; inset-inline-start: 12px; top: -48px;
  background: var(--ink); color: var(--on-ink); padding: 10px 14px; border-radius: var(--r-s);
  z-index: 50; text-decoration: none;
}
.skip:focus { top: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t) var(--ease);
}
body.is-chatting .top, body.scrolled .top { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand); color: #0F1115;
}
.mark svg { width: 17px; height: 17px; }
.wordmark { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.top-end { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }

/* Quiet buttons: text only, a hover fill. Never compete with the primary. */
.btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--ink-2);
  font-size: 15px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.btn-quiet:hover { background: var(--sunken); color: var(--ink); }
.btn-quiet svg { width: 18px; height: 18px; }
#new-chat { display: none; }
body.is-chatting #new-chat { display: inline-flex; }

/* ---------- the one primary button ---------- */
/* Green, the bolt's colour (Stav, 6.10: "ולא הלבן, הצבעוני"; the approved
   pictures in general/zerem-options/final): dark text on it in both themes. */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 26px;
  border: 0; border-radius: var(--r-full);
  background: var(--brand); color: #0E1013;
  font-size: 17px; font-weight: 600; text-decoration: none;
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .35; cursor: default; transform: none; }

/* ---------- main column ---------- */
main { flex: 1; display: flex; flex-direction: column; }
.column {
  width: 100%; max-width: var(--measure); margin: 0 auto;
  padding: 0 16px;
}

/* ---------- hero (landing state) ---------- */
.hero { padding: clamp(40px, 9vh, 96px) 0 28px; }
.hero h1 {
  font-size: clamp(32px, 6.4vw, 52px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -.02em;
}
.hero .lede {
  margin-top: 14px;
  max-width: 34em;
  font-size: clamp(16px, 2.2vw, 18px);
  color: var(--ink-2);
}

/* ---------- composer ---------- */
.composer-wrap { padding-bottom: 12px; }
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 10px 10px 10px;
  padding-inline-start: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--sh-2);
  transition: border-color var(--t) var(--ease);
}
.composer:focus-within { border-color: var(--line-2); }
.composer textarea {
  flex: 1; min-height: 72px; max-height: 160px;
  padding: 10px 0; border: 0; outline: 0; resize: none; overflow-y: hidden;
  background: transparent; font-size: 17px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--ink-3); }
.send {
  flex-shrink: 0;
  width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: var(--r-full);
  display: grid; place-items: center;
  /* The door's main action: green, like every primary (Stav, 6.10: "הצבעוני"). */
  background: var(--brand); color: #0E1013;
  transition: transform var(--t) var(--ease), opacity var(--t) var(--ease);
}
.send:hover { transform: translateY(-1px); }
.send:active { transform: scale(.96); }
.send:disabled { opacity: .35; cursor: default; transform: none; }
.send svg { width: 20px; height: 20px; }
.fineprint {
  margin-top: 10px;
  font-size: 13px; color: var(--ink-3); text-align: center;
}

/* ---------- examples ---------- */
.examples { margin-top: 22px; }
.examples-label { font-size: 14px; color: var(--ink-3); margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px;
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); color: var(--ink);
  font-size: 15px;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.chip:hover { border-color: var(--line-2); background: var(--sunken); }

.trust {
  margin-top: 28px;
  font-size: 14px; color: var(--ink-3);
}
.trust b { color: var(--ink-2); font-weight: 600; }

/* ---------- how it works (landing state only) ---------- */
.how {
  margin-top: clamp(48px, 10vh, 96px);
  padding: 32px 0 8px;
  border-top: 1px solid var(--line);
}
.how h2 { font-size: 20px; font-weight: 600; margin-bottom: 18px; }
.steps { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 28px; } }
.step h3 { font-size: 16px; font-weight: 600; }
.step p { margin-top: 4px; font-size: 15px; color: var(--ink-2); }

/* ---------- footer ---------- */
.foot {
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  font-size: 13px; color: var(--ink-3); text-align: center;
}
.foot nav { margin-top: 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ---------- chat state ---------- */
#feed { display: none; }
body.is-chatting .hero,
body.is-chatting .examples,
body.is-chatting .trust,
body.is-chatting .how,
body.is-chatting .foot { display: none; }
body.is-chatting #feed { display: block; flex: 1; padding: 20px 0 8px; }
body.is-chatting .composer textarea { min-height: 46px; }
body.is-chatting .composer-wrap {
  position: sticky; bottom: 0; z-index: 5;
  padding-top: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

#wrap { display: flex; flex-direction: column; gap: 14px; }

.msg { max-width: 100%; white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.7; }
.msg.me {
  align-self: flex-end;
  max-width: 86%;
  padding: 10px 16px;
  background: var(--me);
  border-radius: 18px;
  border-end-start-radius: 6px;
}
.msg.ai { align-self: stretch; color: var(--ink); }
.msg.ai b { font-weight: 600; }

/* The number every visitor came for: big and calm, the conditions small. */
.price-line {
  display: block;
  font-size: clamp(26px, 5vw, 32px);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.price-note { display: block; margin-top: 4px; font-size: 15px; color: var(--ink-2); }

/* cards the answer can carry */
.qbox, .calcbox, .openbox {
  align-self: stretch;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--sh-1);
}
.qbox.done { opacity: .55; pointer-events: none; }
.qgroup + .qgroup { margin-top: 14px; }
.q-label { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.q-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.q-opt {
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); font-size: 15px;
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.q-opt:hover { border-color: var(--line-2); }
.q-opt.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.q-free {
  min-height: 44px; width: 120px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); font-size: 15px;
}
.q-free:focus { border-color: var(--line-2); }
.q-hint { margin-top: 14px; font-size: 14px; color: var(--ink-3); }
.q-go {
  margin-top: 12px;
  min-height: 48px; padding: 0 20px;
  border: 0; border-radius: var(--r-full);
  background: var(--ink); color: var(--on-ink);
  font-size: 16px; font-weight: 600;
}
.q-go:disabled { opacity: .35; cursor: default; }

.calc-price { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-vat { font-size: 15px; font-weight: 400; color: var(--ink-2); }
.calcbox input[type="range"] { width: 100%; margin: 14px 0 6px; accent-color: var(--brand-ink); min-height: 44px; }
.calc-label { display: flex; justify-content: space-between; font-size: 15px; color: var(--ink-2); }
.calc-label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.calc-note { margin-top: 6px; font-size: 13px; color: var(--ink-3); }

.open-head { font-size: 15px; font-weight: 600; }
.open-sub { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.open-list { margin: 6px 0 0; padding-inline-start: 18px; font-size: 15px; color: var(--ink-2); }
.open-list li + li { margin-top: 2px; }

/* actions under an answer: quiet, small, never a second primary */
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-act {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 500;
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease), background var(--t) var(--ease);
}
.msg-act svg { width: 16px; height: 16px; flex: none; }
.msg-act:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.msg-act:disabled { opacity: .4; cursor: default; pointer-events: none; }
.msg-actions.followups .msg-act { color: var(--ink); }

.typing { align-self: flex-start; font-size: 15px; color: var(--ink-3); }
.typing .dots::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* the one honest line about saving, after the first answer */
.save-note {
  align-self: stretch;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 12px 16px;
  border-radius: var(--r-m);
  background: var(--sunken);
  font-size: 14px; color: var(--ink-2);
}
.save-note .btn-quiet { min-height: 40px; padding: 0 10px; color: var(--ink); font-weight: 600; }

/* toast */
.ask-toast {
  position: fixed; inset-inline: 0; bottom: calc(96px + env(safe-area-inset-bottom));
  width: fit-content; max-width: calc(100% - 32px); margin: 0 auto;
  padding: 9px 14px; border-radius: var(--r-s);
  background: var(--ink); color: var(--on-ink); font-size: 14px; text-align: center;
  box-shadow: 0 6px 20px rgba(15, 17, 21, .18);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
  z-index: 40;
}
.ask-toast.show { opacity: 1; transform: none; }
#toast.ok::before { content: '✓  '; color: var(--brand); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
