/* EconGenesis site styles.
   Colours and fonts are set once here, in :root. Change them here to restyle the whole site.
   Layout uses "logical" properties (inline-start/end) so an Arabic, right-to-left version works later. */

:root {
  --brand: #0f5c63;        /* main colour: deep teal */
  --brand-dark: #0a3f44;
  --accent: #c9822b;       /* warm accent: dates / sand */
  --ink: #1c2430;          /* main text */
  --muted: #5b6573;        /* secondary text */
  --line: #dfe3e8;         /* borders */
  --soft: #f4f6f8;         /* light backgrounds */
  --white: #ffffff;
  --good: #2e7d4f;
  --bad: #b3423a;
  --radius: 10px;
  --max: 1120px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--white);
  line-height: 1.6;
  font-size: 17px;
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.25; color: var(--ink); }
h1 { font-size: 2.2rem; margin: 0 0 0.5em; }
h2 { font-size: 1.55rem; margin: 1.6em 0 0.5em; }
h3 { font-size: 1.2rem; margin: 1.3em 0 0.4em; }
p { margin: 0 0 1em; }

.container { max-width: var(--max); margin-inline: auto; padding-inline: 20px; }
.narrow { max-width: 780px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.96);
  border-block-end: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.2rem; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-size: 0.95rem; font-weight: 800;
}
.logo small { display: block; font-weight: 400; font-size: 0.72rem; color: var(--muted); margin-top: -2px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 8px; font-size: 0.95rem;
}
.nav a:hover { background: var(--soft); }
.nav a.active { color: var(--brand); font-weight: 600; background: #e8f1f2; }
.menu-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 1rem; cursor: pointer; }

@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .nav { display: none; position: absolute; inset-inline: 0; top: 64px; background: #fff; flex-direction: column; padding: 10px 20px 16px; border-block-end: 1px solid var(--line); }
  .nav.open { display: flex; }
}

/* ---------- Hero and sections ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff; padding: 72px 0 64px;
}
.hero h1 { color: #fff; font-size: 2.6rem; max-width: 760px; }
.hero p { font-size: 1.15rem; max-width: 680px; opacity: 0.95; }
.page-head { background: var(--soft); border-block-end: 1px solid var(--line); padding: 40px 0 28px; }
.page-head p { color: var(--muted); max-width: 720px; margin: 0; }
.section { padding: 48px 0; }
.section.alt { background: var(--soft); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.hero .eyebrow { color: #f3c98e; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 8px; padding: 10px 18px;
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
  background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.secondary:hover { background: #e8f1f2; color: var(--brand-dark); }
.btn.light { background: #fff; color: var(--brand-dark); }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.7); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Cards and grids ---------- */
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.card h3 { margin: 0 0 4px; font-size: 1.12rem; }
.card p { color: var(--muted); margin: 0; font-size: 0.95rem; }
.card .meta { font-size: 0.82rem; color: var(--muted); }
.card .card-links { margin-top: auto; padding-top: 12px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.92rem; font-weight: 600; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #e8f1f2; color: var(--brand-dark); margin-inline-end: 6px; }
.icon-badge { width: 42px; height: 42px; border-radius: 10px; background: #e8f1f2; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }

.steps { counter-reset: step; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.step { border-inline-start: 3px solid var(--brand); padding: 4px 14px; }
.step strong { display: block; }
.step span { color: var(--muted); font-size: 0.92rem; }

/* ---------- Article (markdown pages) ---------- */
.article { padding: 36px 0 56px; }
.article table { border-collapse: collapse; width: 100%; margin: 1em 0 1.4em; font-size: 0.93rem; display: block; overflow-x: auto; }
.article th, .article td { border: 1px solid var(--line); padding: 8px 10px; text-align: start; vertical-align: top; }
.article th { background: var(--soft); }
.article blockquote { margin: 1em 0; padding: 10px 18px; border-inline-start: 4px solid var(--accent); background: #fbf6ef; color: var(--ink); }
.article code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.article pre { background: var(--soft); padding: 14px; border-radius: 8px; overflow-x: auto; }
.article img { border-radius: 8px; }
.article .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 0.92rem; }

/* ---------- Model pages ---------- */
.model-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.model-layout > * { min-width: 0; }
@media (max-width: 900px) { .model-layout { grid-template-columns: 1fr; } .controls { position: static; } }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h3 { margin-top: 0; font-size: 1rem; }
.controls { position: sticky; top: 84px; }
.control { margin-bottom: 16px; }
.control label { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; gap: 8px; }
.control label output { font-weight: 700; color: var(--brand); }
.control .help { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }
.control input[type=range] { width: 100%; accent-color: var(--brand); }
.control select { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--line); font: inherit; font-size: 0.92rem; background: #fff; }
.control-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.control-buttons .btn { padding: 8px 14px; font-size: 0.88rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--soft); border-radius: 8px; padding: 12px 14px; }
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.45rem; font-weight: 700; }
.stat .sub { font-size: 0.78rem; color: var(--muted); }
.stat.good .value { color: var(--good); }
.stat.bad .value { color: var(--bad); }

.chart-box { margin-bottom: 22px; }
.chart-box h4 { margin: 0 0 4px; font-size: 1rem; }
.chart-box .caption { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }
.chart-box svg { width: 100%; height: auto; display: block; background: #fff; }
.chart-box svg text { font-family: var(--font); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; display: inline-block; border-radius: 2px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { border-block-end: 1px solid var(--line); padding: 6px 8px; text-align: end; }
.data-table th:first-child, .data-table td:first-child { text-align: start; }
.data-table th { background: var(--soft); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.explain { background: #fbf6ef; border-inline-start: 4px solid var(--accent); padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 0.95rem; }
.tabs { display: flex; gap: 6px; border-block-end: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-block-end: 3px solid transparent; padding: 8px 12px; font: inherit; font-size: 0.92rem; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--brand); border-block-end-color: var(--brand); font-weight: 600; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; max-width: 620px; }
.form label { font-weight: 600; font-size: 0.92rem; display: block; margin-bottom: 4px; }
.form input, .form textarea, .form select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.form textarea { min-height: 140px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #c9d1db; padding: 36px 0 24px; font-size: 0.9rem; margin-top: 40px; }
.site-footer a { color: #fff; }
.footer-grid { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.footer-note { margin-top: 18px; font-size: 0.8rem; color: #8f99a6; }

.empty { color: var(--muted); font-style: italic; }
.loading { color: var(--muted); }
.hidden { display: none !important; }
