/* ═══════════════════════════════════════════════════════════
   יועץ החוק הצה"לי — מערכת עיצוב v2
   בהשראת כל-זכות: נקי, נגיש, קריא — עם זהות צה"לית:
   זית, חאקי, וזהב-דרגות. RTL מלא, מובייל תחילה.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* זהות צבאית */
  --olive:        #4a5230;   /* ירוק זית — צבע היסוד */
  --olive-deep:   #353c22;
  --olive-dark:   #262b18;
  --olive-soft:   #eef0e4;   /* זית מדולל לרקעים */
  --olive-line:   #cdd2b8;
  --gold:         #a8863c;   /* זהב דרגות */
  --gold-bright:  #c9a75c;
  --gold-soft:    #f8f3e6;
  --gold-line:    #e3d5ae;

  /* בסיס */
  --bg:           #f6f5f0;   /* חול בהיר */
  --bg-2:         #edebe2;
  --surface:      #ffffff;
  --line:         #dcdacd;
  --line-soft:    #ecebe2;
  --text:         #23271b;
  --ink:          #191d10;
  --ink-2:        #3c422a;
  --muted:        #6b705c;
  --faint:        #979b8a;

  /* מצבים */
  --amber:        #8a5e08;
  --amber-bg:     #fdf7e9;
  --amber-line:   #e6d4ac;
  --danger:       #97281d;
  --danger-bg:    #fdf1ef;
  --danger-line:  #eac2ba;
  --ok:           #2f6a40;
  --ok-bg:        #edf5ee;

  --radius:       16px;
  --radius-sm:    10px;
  --shadow-sm:    0 1px 2px rgba(38,43,24,.05), 0 2px 6px rgba(38,43,24,.05);
  --shadow:       0 4px 14px rgba(38,43,24,.07), 0 14px 40px rgba(38,43,24,.06);
  --shadow-lg:    0 8px 30px rgba(38,43,24,.11), 0 24px 70px rgba(38,43,24,.09);
  --font: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Arial Hebrew", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16.5px; line-height: 1.7;
  direction: rtl; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ── כותרת עליונה ─────────────────────────────────── */
.masthead {
  background: linear-gradient(165deg, var(--olive-deep), var(--olive) 70%);
  color: #f2f3e9;
  position: relative;
}
.masthead::after {
  /* פס זהב-דרגות דק בתחתית */
  content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-bright) 18%, var(--gold-bright) 82%, transparent);
  opacity: .85;
}
.mast-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 17px; }
.brand { display: flex; align-items: center; gap: 14px; }
.crest {
  width: 52px; height: 52px; flex: none; border-radius: 13px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.22);
  display: grid; place-items: center; color: var(--gold-bright);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.crest svg { display: block; }
.masthead h1 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: -.3px; color: #fff; }
.masthead .sub { margin: 2px 0 0; font-size: 13px; color: #cfd3ba; font-weight: 500; }
.badge {
  margin-inline-start: auto; font-size: 12.5px; color: #dfe2cc;
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.2);
  padding: 6px 13px; border-radius: 100px; white-space: nowrap;
}
.badge b { color: #fff; font-weight: 700; }

/* ── גיבור ────────────────────────────────────────── */
.hero {
  background:
    radial-gradient(900px 420px at 85% -20%, rgba(201,167,92,.14), transparent 60%),
    linear-gradient(165deg, var(--olive-deep), var(--olive) 75%);
  color: #f2f3e9;
  padding: 46px 0 40px;
  position: relative; overflow: hidden;
}
.hero::before {
  /* שברוני דרגה מרומזים ברקע */
  content: ""; position: absolute; inset-block: 0; left: -40px; width: 340px;
  background-image: repeating-linear-gradient(
    -45deg, transparent 0 26px, rgba(255,255,255,.045) 26px 40px);
  pointer-events: none;
}
.hero-title {
  margin: 0 0 14px; font-size: clamp(26px, 4.6vw, 38px); font-weight: 900;
  line-height: 1.28; letter-spacing: -.5px; color: #fff;
}
.hero-title em { font-style: normal; color: var(--gold-bright); }
.hero-sub {
  margin: 0 0 24px; font-size: 16.5px; line-height: 1.75; color: #dfe2cc;
  max-width: 620px;
}
.hero-cta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 30px; }
.hero-note { font-size: 13.5px; color: #cfd3ba; font-weight: 500; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  border-top: 1px solid rgba(255,255,255,.16); padding-top: 22px;
}
.stat { text-align: center; }
.stat b {
  display: block; font-size: clamp(20px, 3vw, 27px); font-weight: 900;
  color: var(--gold-bright); font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.stat span { font-size: 12.5px; color: #cfd3ba; }
@media (max-width: 640px) {
  .hero { padding: 34px 0 28px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 16px 10px; }
}

/* ── איך זה עובד ──────────────────────────────────── */
.how { background: var(--surface); border-bottom: 1px solid var(--line); padding: 30px 0; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.how-step { position: relative; padding-inline-start: 44px; }
.how-n {
  position: absolute; inset-inline-start: 0; top: 1px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--olive-soft); color: var(--olive);
  border: 1.5px solid var(--olive-line);
  display: grid; place-items: center; font-weight: 900; font-size: 15px;
}
.how-step b { display: block; font-size: 15.5px; color: var(--ink); margin-bottom: 3px; }
.how-step p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
@media (max-width: 700px) { .how-grid { grid-template-columns: 1fr; gap: 18px; } }

/* ── כרטיסים ──────────────────────────────────────── */
main { padding: 34px 0 80px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px;
  overflow: hidden; scroll-margin-top: 20px;
}
.card > h2 {
  margin: 0; padding: 17px 24px 15px; font-size: 16px; font-weight: 700;
  color: var(--ink); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 11px; letter-spacing: -.15px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--olive-soft) 45%, var(--surface)), var(--surface));
}
.card > h2 .n {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: linear-gradient(155deg, var(--olive), var(--olive-deep));
  color: #fff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 900;
  box-shadow: 0 1px 3px rgba(38,43,24,.3);
}
.card-body { padding: 22px 24px 24px; }
.hint { font-size: 13.5px; color: var(--muted); margin: -2px 0 20px; line-height: 1.65; }

/* ── טופס ─────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 20px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.field .why { font-size: 12px; color: var(--faint); line-height: 1.5; }
.full { grid-column: 1 / -1; }

select, input[type="text"], input[type="date"], textarea {
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; width: 100%;
  box-shadow: inset 0 1px 2px rgba(38,43,24,.04);
  transition: border-color .15s, box-shadow .15s;
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 84px; line-height: 1.65; }
select {
  appearance: none;
  padding-left: 40px; padding-right: 13px;   /* החץ בשמאל ב-RTL */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%236b705c' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: left 15px center; background-repeat: no-repeat;
}
select:hover, input:hover, textarea:hover { border-color: color-mix(in srgb, var(--olive) 38%, var(--line)); }
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--olive);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--olive) 15%, transparent),
              inset 0 1px 2px rgba(38,43,24,.03);
}
::placeholder { color: var(--faint); }

.privacy-note {
  margin: 16px 0 0; font-size: 13px; color: var(--muted);
  background: var(--olive-soft); border: 1px solid var(--olive-line);
  border-radius: var(--radius-sm); padding: 9px 13px;
}

/* ── כפתורים ──────────────────────────────────────── */
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
button, .btn-primary, .btn-ghost {
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm); padding: 12px 26px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  text-decoration: none; display: inline-block; text-align: center;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(160deg, var(--olive), var(--olive-deep));
  color: #fff;
  border-color: var(--olive-dark);
  box-shadow: 0 1px 2px rgba(38,43,24,.25),
              0 4px 14px color-mix(in srgb, var(--olive) 30%, transparent),
              inset 0 1px 0 rgba(255,255,255,.14);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(160deg, var(--olive-deep), var(--olive-dark));
  box-shadow: 0 2px 4px rgba(38,43,24,.3),
              0 8px 22px color-mix(in srgb, var(--olive) 36%, transparent);
}
.btn-lg { font-size: 16.5px; padding: 14px 34px; }
.btn-ghost { background: var(--surface); color: var(--muted); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover:not(:disabled) { color: var(--olive); border-color: var(--olive); }

/* ── התקדמות ──────────────────────────────────────── */
#progress .card-body { padding-top: 14px; }
.pmeta {
  display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
  font-size: 13.5px; color: var(--muted); padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft); margin-bottom: 14px;
}
.pmeta b { color: var(--olive); font-variant-numeric: tabular-nums; font-weight: 700; }
.steps { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; }
.steps li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0; font-size: 14.5px; color: var(--muted);
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.steps li:last-child { color: var(--text); font-weight: 500; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 9px;
  background: var(--line); border: 1px solid var(--line);
}
.steps li:last-child .dot {
  background: var(--olive); border-color: var(--olive);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--olive) 55%, transparent);
  animation: pulse 1.7s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--olive) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.k-law .dot, .k-order .dot { background: var(--olive); border-color: var(--olive); }
.k-ruling .dot, .k-stats .dot { background: var(--ok); border-color: var(--ok); }
.k-live .dot { background: var(--gold); border-color: var(--gold); }
.k-warn { color: var(--amber) !important; }

/* ── שאלות הבהרה ──────────────────────────────────── */
.followup { border-color: var(--gold-line); }
.followup > h2 { color: var(--gold); border-bottom-color: var(--gold-line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold-soft) 65%, var(--surface)), var(--surface)); }
.followup > h2 .n { background: linear-gradient(155deg, var(--gold-bright), var(--gold)); }

/* ── תשובה ────────────────────────────────────────── */
.urgent {
  background: linear-gradient(135deg, var(--danger-bg), color-mix(in srgb, var(--danger-bg) 55%, var(--surface)));
  border: 1px solid var(--danger-line);
  border-inline-start: 5px solid var(--danger);
  border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.urgent h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--danger); }
.urgent p { margin: 0; font-size: 14px; color: var(--text); }
.urgent .contacts { margin-top: 10px; font-size: 13.5px; display: flex; gap: 16px; flex-wrap: wrap; }
.urgent .contacts span { color: var(--muted); }
.urgent .contacts b { color: var(--text); font-variant-numeric: tabular-nums; }

.answer { font-size: 16.5px; line-height: 1.8; }
.answer > *:first-child { margin-top: 0; }
.answer h1, .answer h2, .answer h3 {
  color: var(--ink); line-height: 1.4; margin: 28px 0 10px; font-weight: 700;
  letter-spacing: -.25px;
}
.answer h1 { font-size: 20px; }
.answer h2 { font-size: 18.5px; padding-bottom: 9px; border-bottom: 2px solid var(--olive-soft); }
.answer h3 { font-size: 16px; color: var(--ink-2); }
.answer p { margin: 0 0 13px; }
.answer ul, .answer ol { margin: 0 0 14px; padding-inline-start: 22px; }
.answer li { margin-bottom: 6px; }
.answer strong { color: var(--ink); font-weight: 700; }
.answer a { color: var(--olive); text-underline-offset: 2px; }
.answer code {
  font-family: var(--mono); font-size: .88em; background: var(--gold-soft);
  color: var(--gold); border: 1px solid var(--gold-line);
  padding: 1.5px 5px; border-radius: 4px; direction: ltr; display: inline-block;
}
.answer blockquote {
  margin: 0 0 15px; padding: 14px 18px;
  background: linear-gradient(90deg, var(--olive-soft), color-mix(in srgb, var(--olive-soft) 45%, var(--surface)));
  border-inline-start: 4px solid var(--olive); border-radius: var(--radius-sm);
  color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.answer blockquote p:last-child { margin-bottom: 0; }
.answer table {
  width: 100%; margin: 0 0 16px; font-size: 14px;
  display: table; border-collapse: separate; border-spacing: 0;
  box-shadow: var(--shadow-sm); border-radius: var(--radius-sm); overflow: hidden;
}
.answer th, .answer td { padding: 8px 11px; border: 1px solid var(--line); text-align: start; }
.answer table th:first-child, .answer table td:first-child { border-inline-start: 1px solid var(--line); }
.answer th {
  background: linear-gradient(180deg, var(--olive-soft), color-mix(in srgb, var(--olive-soft) 60%, var(--surface)));
  font-weight: 700; color: var(--ink);
}
.answer .tbl-scroll { overflow-x: auto; margin: 0 0 16px; }
.answer .tbl-scroll table { margin: 0; }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* ── מקורות ───────────────────────────────────────── */
.src-title { font-size: 14.5px; margin: 28px 0 8px; color: var(--ink); font-weight: 700; }
.sources { list-style: none; margin: 0; padding: 0; }
.sources li {
  display: flex; gap: 10px; align-items: baseline; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 14.5px;
}
.sources li:last-child { border-bottom: 0; }
.tag {
  font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 100px;
  flex: none; border: 1px solid transparent; white-space: nowrap;
}
.tag.corpus { background: var(--olive-soft); color: var(--olive); border-color: var(--olive-line); }
.tag.live { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-line); }
.sources .meta { margin-inline-start: auto; font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.sources a { color: var(--text); text-decoration: none; }
.sources a:hover { color: var(--olive); text-decoration: underline; }

/* ── שיחת המשך ────────────────────────────────────── */
.thread { margin-top: 8px; }
.thread:empty { display: none; }
.turn { border-top: 1px solid var(--line-soft); padding-top: 16px; margin-top: 16px; }
.turn-q {
  background: var(--olive-soft); border: 1px solid var(--olive-line);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 14.5px;
  font-weight: 600; color: var(--ink); white-space: pre-wrap;
}
.turn-a { margin-top: 13px; }
.turn-a:empty { display: none; }
.turn-a .urgent { margin-bottom: 14px; }
.turn-a > .card { margin: 0; box-shadow: none; }
.sources.compact { margin-top: 12px; padding-top: 4px; border-top: 1px dashed var(--line); }
.sources.compact li { padding: 6px 0; font-size: 13px; border-bottom: 0; }

.chat { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.chat label { font-size: 14px; font-weight: 700; color: var(--ink-2); display: block; }
.chat .why { font-size: 12px; color: var(--faint); display: block; margin-bottom: 7px; }
.chat-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-row textarea { min-height: 60px; }
.chat-row button { flex: none; }
.chat-hint { font-size: 11.5px; color: var(--faint); margin-top: 6px; }
@media (max-width: 640px) {
  .chat-row { flex-direction: column; align-items: stretch; }
  .chat-hint { display: none; }
}

.disclaimer {
  margin-top: 22px; padding: 15px 18px; border: 1px solid var(--gold-line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--gold-soft), color-mix(in srgb, var(--gold-soft) 40%, var(--surface)));
  font-size: 13px; color: var(--muted); line-height: 1.65;
}
.disclaimer b { color: var(--text); }

.err {
  background: var(--danger-bg); border: 1px solid var(--danger-line);
  color: var(--danger); padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px;
}

/* ── תחתית ────────────────────────────────────────── */
footer {
  background: var(--olive-dark); color: #b9bda6;
  padding: 26px 0 38px; font-size: 13px; line-height: 1.7;
}
.foot-inner { display: flex; flex-direction: column; gap: 12px; }
.foot-legal { margin: 0; max-width: 640px; }
.foot-legal b { color: #e8eadb; }
.foot-meta {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: 12px; color: #8b9077;
  border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px;
}
.foot-meta .grow { margin-inline-start: auto; }
.foot-meta code { font-family: var(--mono); font-size: 11px; }

/* ── מובייל ───────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .card-body { padding: 18px 17px 20px; }
  .card > h2 { padding: 15px 17px 13px; }
  .mast-row { padding-top: 13px; padding-bottom: 14px; }
  .masthead h1 { font-size: 18px; }
  .crest { width: 44px; height: 44px; border-radius: 11px; }
  .crest svg { width: 36px; height: 36px; }
  .badge { display: none; }
  button, .btn-primary, .btn-ghost { width: 100%; }
  .hero-cta .btn-primary { width: 100%; }
  .actions { flex-direction: column; align-items: stretch; }
  main { padding: 24px 0 60px; }
}
