/* --- Fonts (served locally; there is a CSP and no remote font is reachable) */
@font-face {
  font-family: "Heebo";
  src: url("../vendor/fonts/heebo-hebrew.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0590-05FF, U+FB1D-FB4F, U+20AA;
}
@font-face {
  font-family: "Heebo";
  src: url("../vendor/fonts/heebo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}

/* --- Tokens
   One deep green ink, a paper biased very slightly toward it, and exactly one
   saturated colour (--warn) held in reserve. The design idea is that
   everything on screen is quiet except the one thing that can cost money. */
:root {
  --paper:     #F1F4F1;
  --card:      #FFFFFF;
  --sunk:      #E9EEEA;
  --ink:       #17211C;
  --ink-2:     #4C5C54;
  --ink-3:     #78877E;
  --rule:      #D5DED8;
  --rule-2:    #BFCBC3;
  --accent:    #2C6650;
  --accent-s:  #E2ECE6;
  --on-accent: #FFFFFF;
  --warn:      #A6391C;
  --warn-s:    #FBEDE7;
  --ok:        #2C6650;
  --shadow:    0 1px 2px rgba(23,33,28,.06), 0 8px 28px -12px rgba(23,33,28,.18);
  --radius:    4px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Heebo", "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; text-wrap: balance; }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.2; }
h2 { font-size: clamp(22px, 4vw, 30px); line-height: 1.25; }
h3 { font-size: 20px; }
h4 {
  font-size: 13px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
p { margin: 0; max-width: 64ch; }
a { color: var(--accent); }

/* --- Shell */

#app { min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  padding: 10px 22px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
#topbar .brand { font-weight: 700; font-size: 17px; }
#topbar .spacer { flex: 1; }
#topbar .ver { font-size: 12px; color: var(--ink-3); }

#stepBar { display: flex; flex-wrap: wrap; gap: 6px; }
#stepBar .step {
  font-size: 13px; color: var(--ink-3);
  padding: 3px 11px; border-radius: 100px; border: 1px solid transparent;
}
#stepBar .step-done { color: var(--accent); }
#stepBar .step-now {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
  font-weight: 600;
}

#screen {
  flex: 1;
  width: 100%; max-width: 940px; margin: 0 auto;
  padding: 34px 22px 90px;
  display: flex; flex-direction: column; gap: 28px;
}

/* --- Status line */

.status {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  padding: 13px 22px; font-size: 16px; cursor: pointer;
  border-top: 1px solid var(--rule);
}
.status-work    { background: var(--sunk);  color: var(--ink); }
.status-success { background: var(--accent-s); color: var(--accent); font-weight: 600; }
.status-error   { background: var(--warn-s); color: var(--warn); font-weight: 600; }

/* --- Buttons */

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 12px 24px; border-radius: var(--radius);
  border: 1px solid var(--rule-2); background: var(--card); color: var(--ink-2);
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
button.primary:hover:not(:disabled) { background: #245442; border-color: #245442; color: var(--on-accent); }
button.danger { color: var(--warn); border-color: var(--warn); }
button.big { font-size: 19px; padding: 15px 34px; }
button.small { font-size: 14px; padding: 7px 14px; }
button.plain { border-color: transparent; background: transparent; }

.btnrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btnrow.end { justify-content: flex-start; }

/* --- Cards and blocks */

.card {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 24px 26px;
  display: flex; flex-direction: column; gap: 16px;
}

.sec { display: flex; flex-direction: column; gap: 12px; }

.honest {
  background: var(--sunk); border-inline-start: 3px solid var(--rule-2);
  padding: 18px 20px; border-radius: 2px;
  display: flex; flex-direction: column; gap: 16px;
}
.honest strong { display: block; margin-bottom: 3px; }

.warn {
  background: var(--warn-s); border-inline-start: 3px solid var(--warn);
  padding: 18px 20px; border-radius: 2px;
}
.warn strong { color: var(--warn); display: block; margin-bottom: 3px; font-size: 18px; }

.quiet { color: var(--ink-2); font-size: 15px; }
.tiny  { color: var(--ink-3); font-size: 14px; }

ul.plain { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; max-width: 64ch; }
ul.plain li::marker { color: var(--ink-3); }

/* --- Forms */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-weight: 600; font-size: 15px; }
.field > .hint { font-size: 14px; color: var(--ink-3); }
input[type="text"], input[type="date"], input[type="tel"], textarea, select {
  font: inherit; padding: 11px 13px;
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  background: var(--card); color: var(--ink); width: 100%;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent-s); color: var(--accent);
  border-radius: 100px; padding: 5px 8px 5px 14px; font-size: 15px; font-weight: 600;
}
.chip button { padding: 0 4px; border: 0; background: transparent; color: var(--accent); font-size: 17px; line-height: 1; }

/* --- Drop zone */

.drop {
  border: 2px dashed var(--rule-2); border-radius: 6px;
  padding: 44px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--card);
}
.drop.over { border-color: var(--accent); background: var(--accent-s); }

/* --- The redaction ledger */

.ledger { border-top: 1px solid var(--rule); }
.ledger .row {
  display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--rule);
}
.ledger .what { flex: 1; min-width: 170px; }
.ledger .num  { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 15px; white-space: nowrap; }
.ledger .note { flex-basis: 100%; color: var(--ink-3); font-size: 14px; }

/* --- Facts row */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.fact { border-top: 2px solid var(--accent); padding-top: 8px; }
.fact .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; line-height: 1.25; }
.fact .l { font-size: 14px; color: var(--ink-2); }

/* --- Page grid (the review screen) */

.pagegrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pagecard {
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--card); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; padding: 0; text-align: start;
}
.pagecard:hover { border-color: var(--accent); }
.pagecard canvas, .pagecard img { width: 100%; height: auto; display: block; background: #fff; }
.pagecard .cap {
  font-size: 13px; padding: 7px 9px; color: var(--ink-2);
  border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 8px;
}
.pagecard .cap .badge { color: var(--accent); font-weight: 700; }
.pagecard.clean .cap .badge { color: var(--ink-3); font-weight: 400; }

/* --- Page viewer */

.viewer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15,22,18,.72);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.viewer .inner {
  background: var(--card); border-radius: 6px; max-width: 1100px; width: 100%;
  max-height: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.viewer .head {
  padding: 12px 18px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.viewer .head .spacer { flex: 1; }
.viewer .stage { overflow: auto; padding: 16px; background: var(--sunk); flex: 1; }
.viewer canvas { max-width: 100%; height: auto; display: block; margin: 0 auto; background: #fff; box-shadow: var(--shadow); cursor: crosshair; }
.viewer .foot { padding: 11px 18px; border-top: 1px solid var(--rule); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* --- The code */

.codebox {
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(24px, 6vw, 40px); font-weight: 700; letter-spacing: .06em;
  direction: ltr; text-align: center;
  background: var(--sunk); border: 1px dashed var(--rule-2); border-radius: 6px;
  padding: 24px 12px; font-variant-numeric: tabular-nums; overflow-x: auto;
}

/* --- Explainer */

.explain-stage {
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
}
.explain-stage svg { width: 100%; height: auto; display: block; }
.explain-caption { font-size: 18px; min-height: 3.4em; }
.explain-caption b { color: var(--accent); }
.explain-dots { display: flex; gap: 7px; }
.explain-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--rule-2); }
.explain-dots span.on { background: var(--accent); }

/* --- Closed-for-capacity */

.closed { text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.closed .big { font-size: 22px; font-weight: 700; }

/* --- Progress */

.bar { height: 8px; background: var(--sunk); border-radius: 100px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.bar.waiting > i {
  width: 100% !important;
  background: repeating-linear-gradient(115deg, var(--accent) 0 14px, var(--accent-s) 14px 28px);
  animation: slide 1s linear infinite;
}
@keyframes slide { to { background-position: 28px 0; } }
@media (prefers-reduced-motion: reduce) {
  .bar.waiting > i { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* --- Panic exit */

#panic {
  position: fixed; inset-block-end: 16px; inset-inline-start: 16px; z-index: 30;
  border-color: var(--rule-2); background: var(--card);
  box-shadow: var(--shadow); font-size: 14px; padding: 9px 16px;
}

/* --- Details/summary explainers */

details.explain {
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--card); padding: 0;
}
details.explain > summary {
  cursor: pointer; padding: 13px 18px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.explain > summary::-webkit-details-marker { display: none; }
details.explain > summary::before { content: "▸"; color: var(--accent); }
details.explain[open] > summary::before { content: "▾"; }
details.explain > div { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 620px) {
  body { font-size: 16px; }
  #screen { padding: 24px 15px 90px; gap: 22px; }
  .card { padding: 18px 16px; }
  #topbar { padding: 9px 15px; }
}
