/*
 * Fatoura — free simulators (public pages), on top of the design system and
 * of generators.css. Served by GET /generateurs/assets/gs.css (versioned,
 * cached for a year). One layout for every simulator: inputs on one side,
 * the answer (headline figures, part-to-whole bar, notes, tables) on the
 * other; the page prints as a clean statement.
 *
 * Part-to-whole bar: categorical colours in a fixed order (--gs-s1 … s5),
 * stepped separately for the light and the dark surface; values and labels
 * stay in text colours, the swatch carries the identity.
 */
.gs-page{
  --gs-s1:#2a78d6; --gs-s2:#eb6834; --gs-s3:#1baf7a; --gs-s4:#eda100; --gs-s5:#e87ba4;
}
[data-theme="dark"] .gs-page{
  --gs-s1:#3987e5; --gs-s2:#d95926; --gs-s3:#199e70; --gs-s4:#c98500; --gs-s5:#d55181;
}
.gs-hero .gen-hero-row > div:first-child{ min-width:0; }
.gs-h2{ font-size:15px; font-weight:700; display:flex; align-items:center; gap:8px; margin:0; }
.gs-h2 > i{ color:var(--muted); font-size:13px; }

/* layout: form | results */
.gs-layout{ display:grid; grid-template-columns:minmax(320px,400px) minmax(0,1fr); gap:16px; align-items:start; }
.gs-form{ position:sticky; top:82px; max-height:calc(100vh - 98px); display:flex; flex-direction:column; }
.gs-form > .card-b{ overflow:auto; scrollbar-width:thin; }
.gs-fields{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px 12px; }
.gs-field{ grid-column:1 / -1; }
.gs-field.gs-half{ grid-column:auto; }
/* Two fields side by side keep their inputs on one line whatever the length of a label in French, English or Arabic:
   each field lends its rows (label, control, extras, hint) to the form grid. */
@supports (grid-template-rows:subgrid){
  .gs-fields{ row-gap:0; margin-bottom:-14px; }
  .gs-field{ display:grid; grid-template-rows:subgrid; grid-row:span 4; row-gap:0; align-content:start; margin-bottom:14px; }
  .gs-field > * + *{ margin-top:5px; }
  .gs-field > label{ align-self:end; }
}
.gs-field .inp-add{ font-weight:600; font-size:12px; }
.gs-field .inp{ font-weight:600; }
.gs-field .seg{ display:flex; width:100%; }
.gs-field .seg button{ flex:1 1 0; justify-content:center; white-space:normal; text-align:center; line-height:1.25; padding:6px 8px; min-height:30px; }
.gs-field-toggle .switch{ align-items:flex-start; line-height:1.4; }
.gs-field-toggle .switch .track{ margin-top:1px; }
.gs-field-toggle .hint{ padding-inline-start:46px; }
.gs-chips .chip{ height:24px; font-size:11.5px; padding:0 9px; cursor:pointer; }
.gs-more-btn{ margin-top:14px; border:0; background:none; padding:6px 0; color:var(--accent); font-weight:600; font-size:12.5px; display:inline-flex; align-items:center; gap:7px; cursor:pointer; }
.gs-more-btn i{ font-size:10px; transition:transform .15s; }
.gs-more-btn i.gs-up{ transform:rotate(180deg); }
.gs-more{ margin-top:8px; padding-top:14px; border-top:1px dashed var(--border-2); }
.gs-fields + .gs-more-btn{ margin-top:22px; }
.gs-actions{ justify-content:flex-start; }
.gs-live{ display:none; }

/* results */
.gs-out{ display:flex; flex-direction:column; gap:14px; min-width:0; transition:opacity .15s; }
.gs-out.gs-stale .gs-figures,.gs-out.gs-stale .gs-table,.gs-out.gs-stale .gs-bar-card{ opacity:.55; }
.gs-figures{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.gs-figure{ display:flex; flex-direction:column; gap:3px; padding:14px 16px; border:1px solid var(--border); border-radius:var(--radius-lg); background:var(--surface); min-width:0; }
.gs-figure-l{ font-size:12px; font-weight:600; color:var(--text-2); }
.gs-figure-v{ font-size:21px; font-weight:700; letter-spacing:-.02em; line-height:1.2; color:var(--text); overflow-wrap:anywhere; }
.gs-figure-v small{ font-size:11.5px; font-weight:600; color:var(--muted); letter-spacing:0; margin-inline-start:5px; }
.gs-figure-s{ font-size:11.5px; color:var(--muted); }
.gs-hero-figure{ grid-column:1 / -1; padding:20px 22px; border-color:color-mix(in srgb,var(--accent) 35%,var(--border)); background:radial-gradient(520px 180px at 100% 0%,rgba(var(--accent-rgb),.13),transparent 70%),var(--surface); }
.gs-hero-figure .gs-figure-l{ font-size:13px; }
.gs-hero-figure .gs-figure-v{ font-size:48px; font-weight:800; letter-spacing:-.035em; line-height:1.1; }
.gs-hero-figure .gs-figure-v small{ font-size:16px; font-weight:700; margin-inline-start:8px; }
.gs-hero-figure .gs-figure-s{ font-size:13px; color:var(--text-2); }
[dir="rtl"] .gs-figure-v,[dir="rtl"] .gs-hero-figure .gs-figure-v{ letter-spacing:0; }
.gs-figure.gs-bad .gs-figure-v{ color:var(--danger-fg); }
.gs-figure.gs-good .gs-figure-v{ color:var(--success-fg); }

/* part-to-whole bar */
.gs-bar-t{ font-size:13px; font-weight:600; color:var(--text-2); margin:0 0 10px; }
.gs-bar{ display:flex; gap:2px; height:18px; }
.gs-bar-p{ flex:1 1 0; min-width:4px; height:100%; }
.gs-bar-p:first-child{ border-start-start-radius:4px; border-end-start-radius:4px; }
.gs-bar-p:last-child{ border-start-end-radius:4px; border-end-end-radius:4px; }
.gs-s1{ background:var(--gs-s1); } .gs-s2{ background:var(--gs-s2); } .gs-s3{ background:var(--gs-s3); } .gs-s4{ background:var(--gs-s4); } .gs-s5{ background:var(--gs-s5); }
.gs-legend{ list-style:none; margin:12px 0 0; padding:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px 24px; font-size:12.5px; }
.gs-legend li{ display:flex; align-items:center; gap:8px; min-width:0; }
.gs-sw{ width:10px; height:10px; border-radius:3px; flex-shrink:0; }
.gs-legend-l{ flex:1; min-width:0; color:var(--text-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.gs-legend b{ font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; }
.gs-legend-p{ width:52px; text-align:end; color:var(--muted); font-variant-numeric:tabular-nums; flex-shrink:0; }

.gs-notes{ display:flex; flex-direction:column; gap:8px; }
.gs-error{ margin:0; }

/* tables */
.gs-table .card-h{ padding:11px 16px; }
.gs-tbl{ width:100%; border-collapse:collapse; font-size:13px; }
.gs-tbl th{ position:static; }
.gs-tbl th.r,.gs-tbl td.r{ text-align:end; }
.gs-tbl td{ padding:8px 12px; }
.gs-tbl td.r{ white-space:nowrap; }
.gs-tbl td:first-child,.gs-tbl th:first-child{ padding-inline-start:16px; }
.gs-tbl td:last-child,.gs-tbl th:last-child{ padding-inline-end:16px; }
.gs-tbl td.gs-neg{ color:var(--danger-fg); }
.gs-tbl tr.gs-r-sub td{ font-weight:700; background:var(--surface-2); }
.gs-tbl tr.gs-r-total td{ font-weight:800; font-size:13.5px; background:color-mix(in srgb,var(--accent) 7%,var(--surface)); border-top:2px solid color-mix(in srgb,var(--accent) 40%,var(--border)); }
.gs-tbl tr.gs-r-total td.gs-neg,.gs-tbl tr.gs-r-sub td.gs-neg{ color:var(--danger-fg); }
.gs-tbl tr.gs-r-hl td{ background:color-mix(in srgb,var(--accent) 9%,var(--surface)); font-weight:600; }
.gs-tbl tr.gs-r-hl td:first-child{ box-shadow:inset 3px 0 0 var(--accent); }
[dir="rtl"] .gs-tbl tr.gs-r-hl td:first-child{ box-shadow:inset -3px 0 0 var(--accent); }
.gs-tbl tr.gs-r-muted td{ color:var(--muted); font-style:italic; }
.gs-tbl tr.gs-fold{ display:none; }
.gs-table-f{ justify-content:center; }

.gs-disclaimer{ margin:2px 0 0; font-size:12px; line-height:1.6; color:var(--muted); display:flex; flex-wrap:wrap; gap:4px 8px; align-items:baseline; }
.gs-disclaimer .badge{ align-self:center; }
.gs-source{ color:var(--text-2); }

/* explanation, call to action, related */
.gs-explain{ display:grid; grid-template-columns:minmax(0,3fr) minmax(0,2fr); gap:16px; margin-top:28px; align-items:start; }
.gs-rules{ margin:0; padding-inline-start:20px; display:flex; flex-direction:column; gap:10px; font-size:13.5px; line-height:1.65; color:var(--text-2); }
.gs-rules li::marker{ color:var(--accent); font-weight:700; }
.gs-refs{ margin-top:16px; padding-top:14px; border-top:1px solid var(--border); font-size:12.5px; color:var(--muted); }
.gs-refs b{ color:var(--text-2); font-weight:600; }
.gs-refs ul{ margin:6px 0 0; padding-inline-start:18px; display:flex; flex-direction:column; gap:3px; }
.gs-params{ margin:0; display:flex; flex-direction:column; }
.gs-params > div{ display:grid; grid-template-columns:minmax(0,5fr) minmax(0,6fr); gap:12px; padding:9px 0; border-bottom:1px solid var(--border); font-size:12.5px; }
.gs-params > div:last-child{ border-bottom:0; }
.gs-params dt{ color:var(--muted); } .gs-params dd{ margin:0; font-weight:600; color:var(--text); overflow-wrap:anywhere; }
.gs-params-n{ margin:12px 0 0; }
.gs-cta{ margin-top:20px; display:flex; align-items:center; gap:14px; padding:14px 18px; border:1px solid color-mix(in srgb,var(--accent) 28%,var(--border)); border-radius:var(--radius-lg); background:color-mix(in srgb,var(--accent) 5%,var(--surface)); }
.gs-cta > div{ flex:1; min-width:0; } .gs-cta b{ display:block; font-size:14px; } .gs-cta p{ margin:2px 0 0; font-size:13px; color:var(--text-2); }
.gs-related-h{ margin-top:22px; font-size:15px; display:flex; align-items:center; gap:8px; }
.gs-related-h i{ color:var(--muted); font-size:13px; }
.gs-links{ display:flex; flex-wrap:wrap; gap:8px; }
.gs-links .chip{ height:32px; text-decoration:none; }

.gs-print-only{ display:none; }

/* tablet and phone: one column, the form first */
@media (max-width:1080px){
  .gs-layout{ grid-template-columns:minmax(0,1fr); }
  .gs-form{ position:static; max-height:none; }
  .gs-form > .card-b{ overflow:visible; }
  .gs-explain{ grid-template-columns:minmax(0,1fr); }
  /* the answer follows the visitor down the form */
  .gs-actions{ position:sticky; bottom:0; z-index:5; background:var(--surface); border-radius:0 0 var(--radius) var(--radius); box-shadow:0 -6px 16px -10px rgba(15,27,61,.35); }
  .gs-live{ display:flex; flex:1 1 100%; align-items:baseline; justify-content:space-between; gap:10px; color:var(--text); text-decoration:none !important; padding-inline-end:64px; min-width:0; }
  .gs-live span{ font-size:12px; font-weight:600; color:var(--text-2); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .gs-live b{ font-size:17px; font-weight:800; white-space:nowrap; }
  .gs-live small{ font-size:11px; font-weight:600; color:var(--muted); }
  .gs-live.gs-stale b{ opacity:.5; }
  #gs-result{ scroll-margin-top:84px; }
}
@media (max-width:1280px){
  .gs-figures{ grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:640px){
  .gs-hero-figure{ padding:16px; }
  .gs-hero-figure .gs-figure-v{ font-size:34px; }
  .gs-hero-figure .gs-figure-v small{ font-size:13px; }
  .gs-figure{ padding:12px; }
  .gs-figure-v{ font-size:17px; }
  .gs-legend{ grid-template-columns:minmax(0,1fr); }
  .gs-tbl{ font-size:12.5px; }
  .gs-tbl td,.gs-tbl th{ padding-inline:8px; }
  .gs-tbl td:first-child,.gs-tbl th:first-child{ padding-inline-start:12px; }
  .gs-tbl td:last-child,.gs-tbl th:last-child{ padding-inline-end:12px; }
  .gs-table .card-h{ padding:10px 12px; }
  .gs-table-actions > span{ display:none; }
  .gs-cta{ flex-direction:column; align-items:flex-start; }
  .gs-cta .btn{ width:100%; justify-content:center; }
  .gs-params > div{ grid-template-columns:minmax(0,1fr); gap:2px; }
  .gs-trust{ display:none; }
}

/* print: a statement of the inputs and the answer (the design system hides everything by visibility) */
@media print{
  @page{ size:A4; margin:14mm 12mm; }
  .gs-page,.gs-page *{ visibility:visible !important; }
  .gs-page{ padding:0 !important; max-width:none !important; }
  .gs-page .pp-crumbs,.gs-page .gs-trust,.gs-page .lp-glow,.gs-page .lp-eyebrow,.gs-form,.gs-cta,.gs-related,.gs-table-actions,.gs-table-f,.gs-error,.gs-params-n{ display:none !important; }
  .gs-hero{ border:0 !important; background:none !important; padding:0 0 8px !important; margin:0 0 8px !important; }
  .gs-hero .pp-h1{ font-size:20px !important; }
  .gs-hero .lp-lead{ font-size:11px !important; margin-top:4px !important; }
  .gs-layout{ display:block !important; }
  .gs-print-only{ display:block !important; }
  .gs-inputs .kv{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px 24px; font-size:11px; }
  .gs-kv{ display:flex; justify-content:space-between; gap:12px; border-bottom:1px dotted #C9CFDC; padding:2px 0; }
  .gs-kv dd{ margin:0; font-weight:600; }
  .gs-out{ gap:10px !important; opacity:1 !important; }
  .gs-out.gs-stale *{ opacity:1 !important; }
  .gs-page .card,.gs-figure{ box-shadow:none !important; border-color:#C9CFDC !important; background:#fff !important; break-inside:avoid; }
  .gs-table{ break-inside:auto !important; }
  .gs-tbl tr{ break-inside:avoid; }
  .gs-tbl tr.gs-fold{ display:table-row !important; }
  .gs-tbl thead{ display:table-header-group; }
  .gs-figures{ grid-template-columns:repeat(4,minmax(0,1fr)) !important; gap:6px !important; }
  .gs-figure{ padding:8px 10px !important; }
  .gs-figure-v{ font-size:14px !important; }
  .gs-hero-figure .gs-figure-v{ font-size:26px !important; }
  .gs-tbl{ font-size:10.5px !important; }
  .gs-tbl td,.gs-tbl th{ padding:4px 8px !important; }
  .gs-bar-p,.gs-sw,.gs-tbl tr.gs-r-total td,.gs-tbl tr.gs-r-sub td,.gs-tbl tr.gs-r-hl td{ -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  .gs-explain{ display:block !important; margin-top:10px !important; }
  .gs-explain .card{ margin-bottom:8px; }
  .gs-rules{ font-size:10.5px !important; gap:4px !important; }
  .gs-params > div{ font-size:10.5px !important; padding:4px 0 !important; }
  .gs-disclaimer{ font-size:10px !important; }
}
