/* 2houses — ניתוח פיננסי. Light theme, RTL. Palette per the validated dataviz reference. */

:root {
  color-scheme: light;
  --page:       #f9f9f7;
  --surface:    #fcfcfb;
  --ink:        #0b0b0b;
  --ink-2:      #52514e;
  --muted:      #898781;
  --grid:       #e1e0d9;
  --baseline:   #c3c2b7;
  --border:     rgba(11, 11, 11, 0.10);
  --good:       #006300;
  --bad:        #d03b3b;

  /* series colors follow the scenario (entity), everywhere */
  --c-build:    #2a78d6;   /* בנייה והשכרה */
  --c-sell:     #1baf7a;   /* מכירה והשקעה */
  --c-hold:     #eda100;   /* החזקת הקרקע */
  --c-neg:      #e34948;   /* diverging: negative pole */
  --c-neutral:  #f0efec;   /* diverging midpoint */

  --radius: 10px;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

/* ---------- header & nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(252, 252, 251, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .bar {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 19px; white-space: nowrap; }
.brand small { color: var(--muted); font-weight: 400; margin-inline-start: 8px; font-size: 15px; }
nav.toc { display: flex; gap: 4px; flex-wrap: wrap; }
nav.toc a {
  color: var(--ink-2); text-decoration: none; font-size: 16px;
  padding: 6px 13px; border-radius: 999px;
}
nav.toc a:hover { background: var(--c-neutral); color: var(--ink); }

main { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 80px; }

section { margin-top: 44px; }
section > h2 {
  font-size: 24px; margin: 0 0 6px;
  padding-top: 8px;
}
section > .lede { color: var(--ink-2); margin: 0 0 18px; max-width: 70ch; }

.hero-title { font-size: 32px; margin: 18px 0 20px; }

/* ---------- info tooltip (ⓘ next to titles) ---------- */
.info-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--c-build); color: var(--c-build);
  font-size: 13px; font-weight: 600; font-style: normal;
  vertical-align: middle; margin-inline-start: 10px;
  cursor: help; user-select: none;
}
.info-tip .tip-body {
  visibility: hidden; opacity: 0; transition: opacity 0.12s;
  position: absolute; top: calc(100% + 10px); inset-inline-start: -10px;
  z-index: 60; width: min(440px, 82vw);
  background: var(--ink); color: #fff;
  border-radius: 10px; padding: 12px 16px;
  font-size: 14px; font-weight: 400; line-height: 1.7;
  text-align: right; box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}
.info-tip:hover .tip-body, .info-tip:focus .tip-body, .info-tip:focus-within .tip-body {
  visibility: visible; opacity: 1;
}

/* ---------- cards & tiles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile { position: relative; }
.tile .tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-2); font-weight: 600;
}
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.build { background: var(--c-build); }
.dot.sell  { background: var(--c-sell); }
.dot.hold  { background: var(--c-hold); }
.tile .value { font-size: 30px; font-weight: 700; margin-top: 4px; direction: ltr; text-align: right; }
.tile .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile .delta { font-size: 13.5px; margin-top: 6px; font-weight: 600; }
.delta.pos { color: var(--good); }
.delta.neg { color: var(--bad); }

.verdict { margin-top: 16px; border-inline-start: 4px solid var(--c-build); }
.verdict .headline { font-size: 18px; font-weight: 700; }
.verdict p { margin: 6px 0 0; color: var(--ink-2); }

/* ---------- parameters ---------- */
.param-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.param-group h3 { margin: 0 0 10px; font-size: 15.5px; }
.param {
  display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center;
  padding: 7px 0; border-bottom: 1px dashed var(--grid);
}
.param:last-child { border-bottom: none; }
.param label { font-size: 14px; color: var(--ink-2); }
.param label b { color: var(--ink); font-weight: 600; }
.param .ctl { display: flex; align-items: center; gap: 6px; direction: ltr; }
.param input, .param select {
  width: 100%; direction: ltr; text-align: right;
  font: inherit; font-size: 14.5px;
  padding: 6px 9px;
  border: 1px solid var(--baseline); border-radius: 7px;
  background: #fff; color: var(--ink);
}
.param input:focus, .param select:focus { outline: 2px solid var(--c-build); outline-offset: 0; border-color: transparent; }
.param .unit { font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 34px; }
.derived-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.param-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--baseline); background: var(--surface); color: var(--ink);
}
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--c-build); border-color: var(--c-build); color: #fff; }
button.primary:hover { filter: brightness(0.94); }
.copied-flash { font-size: 13px; color: var(--good); align-self: center; }

/* ---------- scenario cards ---------- */
.scenarios { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.scenario { border-top: 4px solid var(--grid); }
.scenario.build { border-top-color: var(--c-build); }
.scenario.sell  { border-top-color: var(--c-sell); }
.scenario.hold  { border-top-color: var(--c-hold); }
.scenario h3 { margin: 0; font-size: 17px; }
.scenario .story { font-size: 14px; color: var(--ink-2); min-height: 66px; margin: 8px 0 10px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--grid); font-size: 14.5px; }
.kv:last-of-type { border-bottom: none; }
.kv .k { color: var(--ink-2); }
.kv .v { font-weight: 600; direction: ltr; }

/* ---------- details/formula disclosure ---------- */
details.how {
  margin-top: 12px; border-top: 1px solid var(--grid); padding-top: 10px;
}
details.how summary {
  cursor: pointer; font-size: 13.5px; color: var(--c-build); font-weight: 600;
  list-style-position: inside;
}
details.how[open] summary { margin-bottom: 8px; }

.formula {
  direction: ltr; text-align: left;
  background: var(--page);
  border: 1px solid var(--grid); border-radius: 8px;
  padding: 10px 14px; margin: 8px 0;
  font-size: 14.5px; line-height: 2;
  overflow-x: auto;
}
.formula var { font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.formula .op { color: var(--muted); padding: 0 2px; }
.formula .num { font-variant-numeric: tabular-nums; }
.formula .res { font-weight: 700; }
.formula-note { font-size: 13px; color: var(--muted); direction: rtl; text-align: right; }

/* ---------- charts ---------- */
.chart-card { margin-top: 16px; }
.chart-card h3 { margin: 0 0 2px; font-size: 16.5px; }
.chart-card .chart-sub { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chart-wrap { direction: ltr; position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 2px 0; font-size: 13px; color: var(--ink-2); direction: rtl; }
.legend .item { display: inline-flex; align-items: center; gap: 7px; }

.viz-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--ink); color: #fff;
  border-radius: 8px; padding: 8px 12px;
  font-size: 12.5px; line-height: 1.55;
  direction: rtl; text-align: right;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  opacity: 0; transition: opacity 0.08s;
  max-width: 260px; white-space: nowrap;
}
.viz-tooltip.on { opacity: 1; }
.viz-tooltip .t-title { font-weight: 700; margin-bottom: 3px; }
.viz-tooltip .t-row { display: flex; align-items: center; gap: 6px; }
.viz-tooltip .t-row .val { direction: ltr; margin-inline-start: auto; padding-inline-start: 12px; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data {
  border-collapse: collapse; width: 100%; font-size: 13.5px;
  min-width: 720px;
}
table.data th, table.data td {
  padding: 7px 12px; border-bottom: 1px solid var(--grid);
  text-align: center; white-space: nowrap;
}
table.data td { direction: ltr; font-variant-numeric: tabular-nums; }
table.data thead th {
  background: var(--page); color: var(--ink-2); font-weight: 600;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: #f4f6fa; }
table.data .neg { color: var(--bad); }
table.data tr.milestone { background: #f2f7ff; }

table.sens { min-width: 560px; }
table.sens td { font-weight: 600; }
table.sens th.corner { font-weight: 700; color: var(--ink); }
.sens-caption { font-size: 13px; color: var(--muted); margin-top: 8px; }
.sens-legend { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; direction: ltr; justify-content: flex-end; }
.sens-legend .swatch { width: 60px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }

/* ---------- caveats ---------- */
ul.caveats { padding-inline-start: 22px; }
ul.caveats li { margin: 9px 0; color: var(--ink-2); }
ul.caveats li b { color: var(--ink); }

.sources { font-size: 13.5px; color: var(--ink-2); }
.sources a { color: var(--c-build); }

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px; padding: 18px 20px 40px;
  text-align: center; font-size: 13px; color: var(--muted);
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  /* header: brand on its own line, menu becomes a swipeable pill row */
  .site-header .bar { padding: 8px 12px 6px; gap: 4px; }
  .brand { font-size: 16px; }
  .brand small { display: none; }
  nav.toc {
    flex: 1 1 100%;
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-inline: -12px; padding: 2px 12px 6px;
  }
  nav.toc::-webkit-scrollbar { display: none; }
  nav.toc a { white-space: nowrap; font-size: 15px; padding: 6px 11px; }

  /* charts: keep them legible and let them scroll sideways instead */
  .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-wrap svg { min-width: 620px; }

  /* info tooltips: pin to the viewport so they never overflow the screen */
  .info-tip .tip-body {
    position: fixed; inset-inline: 12px; top: 76px; width: auto;
  }
}

@media (max-width: 640px) {
  main { padding: 18px 12px 60px; }
  section { margin-top: 34px; }
  section > h2 { font-size: 21px; }
  .card { padding: 14px; }
  .param { grid-template-columns: 1fr 142px; }
  .param input, .param select { font-size: 13.5px; padding: 6px 7px; }
  .param .unit { min-width: 22px; font-size: 11.5px; }
  .hero-title { font-size: 24px; margin-bottom: 14px; }
  .tile .value { font-size: 23px; }
  .scenario .story { min-height: 0; }
  .param-actions button { flex: 1 1 46%; }
  .formula { font-size: 13px; line-height: 1.9; }
  .kv { font-size: 13.5px; }
}

@media print {
  .site-header, .param-actions, .viz-tooltip { display: none; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}
