/* =====================================================================
   Simulateur CFC — charte graphique Crédit Foncier du Cameroun
   Bordeaux #782e18 · Or #ffa51c · police de marque Futura.
   Vanilla CSS, zéro dépendance. Light mode, accessible (AA), imprimable.
   ===================================================================== */

@font-face {
  font-family: "Futura CFC";
  src: url("../assets/fonts/futura-book.ttf") format("truetype");
  font-weight: 400 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Futura CFC";
  src: url("../assets/fonts/futura-extrabold.ttf") format("truetype");
  font-weight: 700 900; font-style: normal; font-display: swap;
}

:root {
  --brand: #782e18;
  --brand-2: #5e2412;
  --brand-tint: #f6ece8;
  --gold: #ffa51c;
  --gold-2: #e58a00;
  --gold-tint: #fff4e2;

  --bg: #f7f3f0;
  --surface: #ffffff;
  --surface-2: #fbf7f4;
  --ink: #1f1a17;
  --ink-2: #6b5f57;
  --ink-3: #9a8d83;
  --line: #ece4de;
  --line-2: #ddd2c9;

  --danger: #c8311c;
  --danger-bg: #fcebe7;
  --danger-ink: #8f2114;

  --r: 14px;
  --r-sm: 10px;
  --r-pill: 999px;
  --ring: 0 0 0 3px rgba(120, 46, 24, .22);
  --shadow-sm: 0 1px 2px rgba(64, 30, 16, .06);
  --shadow-md: 0 10px 30px -12px rgba(64, 30, 16, .18);
  --shadow-lg: 0 24px 60px -24px rgba(64, 30, 16, .28);

  --font-brand: "Futura CFC", "Helvetica Neue", Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-brand); font-weight: 800; letter-spacing: -.01em; margin: 0; }
a { color: var(--brand); }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar-in {
  max-width: 1080px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: inline-flex; }
.brand img { height: 44px; width: auto; display: block; }
.appbar-tag {
  margin-left: auto; font-family: var(--font-brand); font-weight: 700;
  font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-tint);
  padding: 7px 14px; border-radius: var(--r-pill);
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 165, 28, .16), transparent 55%),
    linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
}
.hero-in {
  max-width: 1080px; margin: 0 auto; padding: 56px 24px 64px;
  display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center;
}
.eyebrow {
  margin: 0 0 14px; font-family: var(--font-brand); font-weight: 700;
  font-size: 13px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold);
}
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.05; margin: 0 0 16px; max-width: 16ch; }
.lead { margin: 0; font-size: clamp(1rem, 1.6vw, 1.15rem); color: rgba(255, 255, 255, .88); max-width: 56ch; line-height: 1.6; }
.trust { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 26px 0 0; padding: 0; }
.trust li { display: inline-flex; align-items: center; gap: 9px; font-size: .95rem; font-weight: 500; color: rgba(255, 255, 255, .95); }
.trust svg { width: 18px; height: 18px; color: var(--gold); }
.hero-mark { width: 168px; height: 168px; }
.hero-mark svg { width: 100%; height: 100%; }
.hero-mark .house { fill: rgba(255, 255, 255, .06); stroke: rgba(255, 255, 255, .5); stroke-width: 3; }
.hero-mark .door { fill: var(--gold); stroke: none; }

/* ---------- Layout ---------- */
.wrap { max-width: 1080px; width: 100%; margin: -36px auto 0; padding: 0 24px 72px; position: relative; }

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; gap: 4px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); box-shadow: var(--shadow-md); margin-bottom: 22px;
}
.tab {
  appearance: none; border: 0; cursor: pointer; font-family: var(--font-brand);
  font-weight: 700; font-size: 15px; color: var(--ink-2);
  padding: 11px 24px; border-radius: var(--r-pill); background: transparent;
  transition: color .2s, background .2s;
}
.tab:hover { color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; }

.subtabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; }
.subtab {
  appearance: none; background: transparent; border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 14.5px; color: var(--ink-2);
  padding: 9px 16px; border-radius: var(--r-sm); transition: all .18s;
}
.subtab:hover { color: var(--brand); background: var(--brand-tint); }
.subtab.active { color: var(--brand); background: var(--gold-tint); border-color: #f4d9a8; }

.panel { display: none; }
.panel.active { display: block; }
.form-panel { display: none; }
.form-panel.active { display: block; animation: fade .3s ease; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-md);
  padding: clamp(20px, 3vw, 34px);
}

/* ---------- Section heading ---------- */
.sec {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.05rem; color: var(--ink); margin: 4px 0 18px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.sec:not(:first-child) { margin-top: 34px; }
.sec-ico {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); border-radius: 8px;
  font-family: var(--font-brand); font-weight: 800; font-size: 14px;
}

/* ---------- Form grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.auto-tag {
  font-family: var(--font-body); font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold-2); background: var(--gold-tint);
  padding: 2px 7px; border-radius: var(--r-pill);
}
.dur-eq {
  align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--gold-2);
  background: var(--gold-tint); border: 1px solid #f4d9a8; padding: 3px 11px;
  border-radius: var(--r-pill); margin-top: 1px;
}
.dur-eq:empty { display: none; }

input, select {
  width: 100%; font-family: var(--font-body); font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 11px 13px; transition: border-color .18s, box-shadow .18s; min-width: 0;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select {
  appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b5f57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input::placeholder { color: var(--ink-3); }
input[readonly] {
  background: var(--surface-2); color: var(--ink-2); border-style: dashed;
  cursor: not-allowed; font-weight: 600;
}

/* Input with trailing unit */
.input-money { position: relative; display: flex; align-items: center; }
.input-money input { padding-right: 56px; }
.input-money span {
  position: absolute; right: 13px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-3); pointer-events: none; letter-spacing: .02em;
}

/* ---------- Actions / buttons ---------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 26px; }
.actions .muted { font-size: 13px; color: var(--ink-2); }
.btn {
  appearance: none; cursor: pointer; font-family: var(--font-brand); font-weight: 700;
  font-size: 15px; border-radius: var(--r-sm); border: 1px solid transparent;
  padding: 13px 24px; display: inline-flex; align-items: center; gap: 9px;
  transition: transform .12s, background .2s, box-shadow .2s, color .2s;
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px -8px rgba(120, 46, 24, .7); }
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--surface); color: var(--brand); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--brand-tint); border-color: var(--brand); }
.btn-ghost:active { transform: translateY(1px); }

/* ---------- Error ---------- */
.err {
  display: none; margin-top: 16px; padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--danger-bg); color: var(--danger-ink); border: 1px solid #f3c6bd;
  font-size: 14px; font-weight: 500;
}

/* ---------- Result ---------- */
.result { display: none; margin-top: 30px; padding-top: 30px; border-top: 2px dashed var(--line); }
.result.show { display: block; animation: fadeUp .4s ease; }
.result .sec { margin-top: 0; }
.badge {
  font-family: var(--font-body); font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold-2); background: var(--gold-tint);
  border: 1px solid #f4d9a8; padding: 3px 10px; border-radius: var(--r-pill); margin-left: 4px;
}

.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.kpi .lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.kpi .val { font-family: var(--font-brand); font-weight: 800; font-size: 1.4rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi.hl {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%);
  border-color: var(--brand-2); position: relative; overflow: hidden;
}
.kpi.hl::after { content: ""; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--gold); }
.kpi.hl .lbl { color: rgba(255, 255, 255, .8); }
.kpi.hl .val { color: #fff; }

/* Fiche de simulation (caractéristiques + modalités) */
.fiche { display: flex; flex-direction: column; gap: 18px; margin-bottom: 22px; }
.fiche-block { position: relative; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px 16px; }
.fiche-legend { font-family: var(--font-brand); font-weight: 800; font-size: .98rem; color: var(--brand); margin: 0 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.fiche-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 28px; }
.fiche-list:last-child { margin-bottom: 0; }
.fiche-list li { position: relative; padding-left: 15px; font-size: 14px; line-height: 1.45; }
.fiche-list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.fl { font-weight: 600; color: var(--ink-2); }
.fsep { color: var(--ink-3); margin: 0 5px; }
.fv { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.nb { font-size: 12.5px; line-height: 1.55; color: var(--ink-2); background: var(--gold-tint); border: 1px solid #f4d9a8; border-radius: var(--r-sm); padding: 12px 15px; margin: 0 0 22px; }
.nb strong { color: var(--brand); }

/* Detail + amortization tables */
table.detail, table.amort { width: 100%; border-collapse: collapse; font-size: 14px; }
table.detail { margin-bottom: 8px; }
table.detail td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.detail tr td:first-child { color: var(--ink-2); width: 52%; }
table.detail tr td:last-child { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
table.detail tr:last-child td { border-bottom: 0; }

.amort-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 6px; }
table.amort th, table.amort td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.amort th:first-child, table.amort td:first-child,
table.amort th:nth-child(2), table.amort td:nth-child(2) { text-align: left; }
table.amort thead th {
  position: sticky; top: 0; background: var(--brand); color: #fff; font-family: var(--font-brand);
  font-weight: 700; font-size: 12.5px; letter-spacing: .02em; z-index: 1;
}
table.amort tbody tr:nth-child(even) { background: var(--surface-2); }
table.amort tbody tr.differe td { background: var(--gold-tint); }
table.amort tbody tr:hover td { background: var(--brand-tint); }

/* ---------- Footer ---------- */
.site-footer { background: var(--brand-2); color: rgba(255, 255, 255, .85); margin-top: auto; }
.footer-in { max-width: 1080px; margin: 0 auto; padding: 40px 24px; text-align: center; }
.footer-in img { height: 42px; width: auto; margin-bottom: 12px; }
.footer-in .tagline { font-family: var(--font-brand); font-style: italic; color: var(--gold); margin: 0 0 16px; font-size: 1.05rem; }
.footer-in .legal { font-size: 12.5px; line-height: 1.6; max-width: 70ch; margin: 0 auto; color: rgba(255, 255, 255, .7); }

/* ---------- Animations ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid, .res-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-in { grid-template-columns: 1fr; }
  .hero-mark { display: none; }
}
@media (max-width: 560px) {
  .appbar-in, .hero-in, .wrap, .footer-in { padding-left: 16px; padding-right: 16px; }
  .grid, .res-grid, .fiche-list { grid-template-columns: 1fr; }
  .hero-in { padding-top: 40px; padding-bottom: 48px; }
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1; padding: 11px 12px; text-align: center; }
  .appbar-tag { display: none; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Print ---------- */
@media print {
  .appbar, .hero, .tabs, .subtabs, form, .no-print, .site-footer { display: none !important; }
  body { background: #fff; }
  .wrap { margin: 0; padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .result { display: block !important; border-top: 0; margin: 0; padding: 0; }
  .amort-wrap { max-height: none; overflow: visible; border: 0; }
  table.amort thead th { position: static; }
  .kpi { break-inside: avoid; }
}
