/* ============================================================
   Rent Affordability Calculator — style.css
   Mobile-first, zero external dependencies
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-dk: #1d4ed8;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --bg:         #f8fafc;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 800; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 700; margin-bottom: .75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
p  { margin-bottom: 1rem; }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
li { margin-bottom: .4rem; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 860px; margin: 0 auto; padding: 0 1rem; }
.container--wide { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

section { padding: 2.5rem 0; }
section + section { border-top: 1px solid var(--border); }

/* ── Header ───────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; max-width: 1100px; margin: 0 auto;
}
.logo { font-size: 1.1rem; font-weight: 800; color: var(--primary); text-decoration: none; }
.logo span { color: var(--text); }
nav { display: flex; align-items: center; gap: 0; }
nav ul { list-style: none; display: flex; gap: 1.25rem; padding: 0; margin: 0; align-items: center; }
nav a { font-size: .9rem; color: var(--muted); font-weight: 500; }
nav a:hover { color: var(--primary); text-decoration: none; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff; padding: 2.5rem 1rem 2rem;
  text-align: center;
}
.hero h1 { color: #fff; margin-bottom: .75rem; }
.hero p  { color: rgba(255,255,255,.85); max-width: 600px; margin: 0 auto 0; font-size: 1.05rem; }

/* ── Ad Slots ─────────────────────────────────────────────── */
.ad-slot {
  background: #f1f5f9; border: 1px dashed #cbd5e1;
  text-align: center; color: #94a3b8; font-size: .8rem;
  padding: .5rem; border-radius: 4px; overflow: hidden;
}
.ad-slot--leaderboard { height: 90px; max-width: 728px; margin: 1.5rem auto; }
.ad-slot--rectangle   { height: 250px; max-width: 300px; margin: 1.5rem auto; }
.ad-slot--article     { height: 90px; margin: 1.5rem 0; }

/* ── Calculator Card ──────────────────────────────────────── */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 680px;
  margin: -1.5rem auto 2rem;
}

.toggle-group {
  display: flex; border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; width: fit-content; margin-bottom: 1rem;
}
.toggle-group button {
  padding: .4rem 1rem; border: none; background: transparent;
  cursor: pointer; font-size: .9rem; color: var(--muted); font-family: var(--font);
  transition: background .15s, color .15s;
}
.toggle-group button.active {
  background: var(--primary); color: #fff;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-group input, .form-group select {
  width: 100%; padding: .65rem .9rem;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 1rem; font-family: var(--font); color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group .hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

.calc-btn {
  width: 100%; padding: .85rem;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px;
  font-size: 1.1rem; font-weight: 700; font-family: var(--font);
  cursor: pointer; transition: background .15s;
}
.calc-btn:hover { background: var(--primary-dk); }

/* ── Results ──────────────────────────────────────────────── */
#results { display: none; margin-top: 1.75rem; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.result-box {
  border-radius: 8px; padding: 1rem; text-align: center;
  border: 2px solid transparent;
}
.result-box.green  { background: #f0fdf4; border-color: #86efac; }
.result-box.yellow { background: #fffbeb; border-color: #fcd34d; }
.result-box.red    { background: #fef2f2; border-color: #fca5a5; }

.result-box .label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
.result-box .amount { font-size: 1.6rem; font-weight: 800; }
.result-box.green  .amount { color: var(--success); }
.result-box.yellow .amount { color: var(--warning); }
.result-box.red    .amount { color: var(--danger); }
.result-box .sub   { font-size: .78rem; color: var(--muted); margin-top: .15rem; }

.verdict {
  padding: 1rem 1.25rem; border-radius: 8px; font-weight: 600;
  margin-bottom: 1.5rem; font-size: .95rem;
}
.verdict.good   { background: #f0fdf4; color: #166534; border-left: 4px solid #16a34a; }
.verdict.caution{ background: #fffbeb; color: #92400e; border-left: 4px solid #d97706; }
.verdict.risk   { background: #fef2f2; color: #991b1b; border-left: 4px solid #dc2626; }

/* Budget breakdown */
.budget-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.budget-table th, .budget-table td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.budget-table th { background: #f8fafc; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.budget-table tr:last-child td { border-bottom: none; }

.disclaimer {
  font-size: .78rem; color: var(--muted); margin-top: 1.25rem;
  padding-top: .75rem; border-top: 1px solid var(--border);
}

/* ── Salary Table ─────────────────────────────────────────── */
.salary-table-wrap { overflow-x: auto; }
.salary-table {
  width: 100%; border-collapse: collapse; font-size: .88rem;
}
.salary-table th, .salary-table td { padding: .55rem .75rem; text-align: right; border-bottom: 1px solid var(--border); }
.salary-table th { background: #1e3a8a; color: #fff; text-align: center; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.salary-table td:first-child { text-align: left; font-weight: 600; }
.salary-table tr:nth-child(even) td { background: #f8fafc; }
.salary-table tr:hover td { background: #eff6ff; }

/* ── FAQ ──────────────────────────────────────────────────── */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-question {
  width: 100%; text-align: left; background: none; border: none;
  padding: 1rem 0; font-size: 1rem; font-weight: 600; font-family: var(--font);
  color: var(--text); cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.faq-question::after { content: "+"; font-size: 1.3rem; color: var(--primary); }
.faq-question.open::after { content: "−"; }
.faq-answer { display: none; padding: 0 0 1rem; color: var(--muted); font-size: .93rem; }
.faq-answer.open { display: block; }

/* ── Tips ─────────────────────────────────────────────────── */
.tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; }
.tip-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.tip-card .icon { font-size: 1.5rem; margin-bottom: .5rem; }

/* ── Info Boxes ───────────────────────────────────────────── */
.info-box {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin: 1.5rem 0;
}
.info-box h3 { color: var(--primary-dk); margin-bottom: .5rem; }

/* ── Footer ───────────────────────────────────────────────── */
footer {
  background: #1e293b; color: #94a3b8; font-size: .85rem;
  padding: 2rem 1rem; text-align: center;
}
footer a { color: #93c5fd; }
footer a:hover { color: #fff; }
.footer-links { display: flex; gap: 1.5rem; justify-content: center; margin-top: .75rem; flex-wrap: wrap; }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb { font-size: .82rem; color: var(--muted); padding: .75rem 0; }
.breadcrumb a { color: var(--muted); }
.breadcrumb span { margin: 0 .35rem; }

/* ── Article ──────────────────────────────────────────────── */
.article-body h2 { margin-top: 2rem; }
.article-body h3 { margin-top: 1.5rem; }

/* ── Forms (contact) ──────────────────────────────────────── */
.form-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; max-width: 560px; box-shadow: var(--shadow);
}
.form-card textarea { resize: vertical; min-height: 120px; }
.submit-btn {
  padding: .75rem 2rem; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-size: 1rem; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: background .15s;
}
.submit-btn:hover { background: var(--primary-dk); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .calc-card { padding: 1.25rem; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  nav ul { display: none; } /* simplify nav on mobile */
  .tips-grid { grid-template-columns: 1fr; }
}

/* ── Language Dropdown ─────────────────────────────────────── */
.lang-dropdown-wrap {
  position: relative;
  margin-left: 1rem;
  display: flex;
  align-items: center;
}

.lang-dropdown-wrap::before {
  content: '';
  display: block;
  width: 1px;
  height: 18px;
  background: var(--border);
  margin-right: 1rem;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .75rem;
  font-size: .85rem;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.lang-btn::after {
  content: '▾';
  font-size: .7rem;
  opacity: .6;
}
.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  list-style: none;
  padding: .4rem 0;
  margin: 0;
  min-width: 170px;
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
}
.lang-menu.open { display: block; }

.lang-option {
  padding: .45rem 1rem;
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}
.lang-option:hover  { background: #f1f5f9; }
.lang-option.active { color: var(--primary); font-weight: 600; background: #eff6ff; }

/* RTL support */
[dir="rtl"] .lang-menu { right: auto; left: 0; }
[dir="rtl"] .nav-inner { flex-direction: row-reverse; }
[dir="rtl"] nav ul { flex-direction: row-reverse; }
[dir="rtl"] .lang-dropdown-wrap { margin-left: 0; margin-right: 1.25rem; }

@media (max-width: 640px) {
  .lang-btn { font-size: .78rem; padding: .3rem .55rem; }
  .lang-menu { min-width: 150px; }
  .lang-dropdown-wrap::before { display: none; }
  .lang-dropdown-wrap { margin-left: 0; }
}
