/* ============================================================================
   CarbonPulse — App styles  ·  DARK / GOLD brand skin
   Inherits the estimator's visual line: near-black canvas, warm gold accent,
   elegant serif italics for emphasis, a compliance top bar, the dandelion logo.
   ============================================================================ */

:root {
  --bg:        #0B0C0D;          /* near-black canvas */
  --bg-2:      #0F1112;
  --surface:   #15171A;          /* cards */
  --surface-2: #1B1E22;          /* inputs / raised */
  --line:      #2A2E34;          /* hairline borders */
  --line-soft: #20242A;
  --ink:       #F4F1E9;          /* warm off-white text */
  --ink-soft:  #CFCcC2;
  --muted:     #8E8B83;          /* secondary */
  --gold:      #C9A24B;          /* primary brand gold */
  --gold-2:    #E6C76E;          /* bright gold (hover / emphasis) */
  --gold-soft: rgba(201,162,75,.12);
  --green:     #4FAE8B;          /* scope-2 / success accent */
  --amber:     #D08A2C;          /* warning */
  --amber-soft:rgba(208,138,44,.12);
  --danger:    #D2675C;          /* blocking */
  --danger-soft:rgba(210,103,92,.12);
  --radius:    14px;
  --radius-sm: 10px;
  --maxw:      900px;
  --display: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif:   "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --body:    "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;
  --arabic:  "IBM Plex Sans Arabic", "Noto Sans Arabic", var(--body);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(201,162,75,.10), transparent 60%),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body[dir="rtl"] { font-family: var(--arabic); }

/* ---- compliance top bar (like the estimator) ---- */
.topbar {
  background: var(--gold);
  color: #1A1407;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 14px;
  font-weight: 500;
}
.topbar .sep { opacity: .55; margin: 0 8px; }

/* ---- layout ---- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.screen { display: none; padding: 30px 0 70px; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ---- header ---- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11,12,13,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.app-header .wrap { display: flex; align-items: center; gap: 14px; height: 84px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); }
.logo-tile {
  width: 66px; height: 66px; border-radius: 16px; flex: 0 0 auto;
  background: #fff; display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06), 0 6px 16px rgba(0,0,0,.35);
}
.logo-tile img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.logo-tile .fallback { font-family: var(--serif); font-style: italic; font-weight: 600; color: #0B0C0D; font-size: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.brand-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-top: 3px; }
.header-spacer { flex: 1; }
.brand-tagline { display: flex; flex-direction: column; line-height: 1.15; padding-inline-start: 4px; border-inline-start: 1px solid var(--line); padding-inline-start: 14px; margin-inline-start: 4px; }
.brand-tagline .tl-main { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--ink); }
.brand-tagline .tl-main em { font-family: var(--serif); font-style: italic; font-weight: 600; color: var(--gold-2); font-size: 16px; }
.brand-tagline .tl-sub { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; color: var(--muted); margin-top: 3px; }
@media (max-width: 860px){ .brand-tagline { display: none; } }
.header-actions { display: flex; align-items: center; gap: 10px; }
.who { font-size: 12px; color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* language toggle — gold pill EN | عربي */
.lang-toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; background: var(--surface); font-size: 13px;
}
.lang-toggle button { border: 0; background: transparent; padding: 6px 13px; cursor: pointer; color: var(--muted); font: inherit; }
.lang-toggle button.on { background: var(--gold); color: #1A1407; font-weight: 600; }

/* ---- type ---- */
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; color: var(--ink); margin: 0 0 .4em; }
h1 { font-size: 30px; font-weight: 700; line-height: 1.1; }
h1 .accent { font-family: var(--serif); font-style: italic; font-weight: 600; color: var(--gold-2); letter-spacing: 0; }
h2 { font-size: 21px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.lede { color: var(--ink-soft); font-size: 15px; max-width: 58ch; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.muted { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 16px 0; }
.card.tight { padding: 16px; }
.stack > * + * { margin-top: 14px; }

/* ---- forms ---- */
.field { display: block; margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
input::placeholder { color: #6C6A64; }
select option { background: var(--surface-2); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px){ .row { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; background: var(--surface-2); user-select: none; }
.chip input { width: auto; margin: 0; accent-color: var(--gold); }
.chip.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-2); }
.flagprev { font-size: 20px; margin-inline-start: 4px; vertical-align: middle; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); padding: 11px 18px; border: 1px solid transparent; text-decoration: none; }
.btn-primary { background: var(--gold); color: #1A1407; }
.btn-primary:hover { background: var(--gold-2); }
.btn-ghost { background: transparent; color: var(--gold-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---- pills / status ---- */
.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; display: inline-block; }
.pill.scope1 { background: rgba(201,162,75,.16); color: var(--gold-2); }
.pill.scope2 { background: rgba(79,174,139,.16); color: var(--green); }
.pill.draft  { background: #23262B; color: var(--muted); }
.pill.calculated { background: rgba(79,174,139,.16); color: var(--green); }

/* ---- lists ---- */
.list { display: flex; flex-direction: column; gap: 10px; }
.line { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.line .grow { flex: 1; min-width: 160px; }
.line .src { font-weight: 600; }
.line .meta { font-size: 12px; color: var(--muted); }
.line .val { font-family: var(--mono); font-weight: 600; color: var(--gold-2); }

/* ---- readiness pulse meter ---- */
.readiness { margin: 4px 0 2px; }
.readiness .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.readiness .score { font-family: var(--mono); font-size: 30px; font-weight: 600; color: var(--gold-2); }
.readiness .score small { font-size: 14px; color: var(--muted); }
.pulse-track { position: relative; height: 40px; border-radius: 10px; background: linear-gradient(90deg, var(--danger-soft), var(--amber-soft) 45%, rgba(79,174,139,.14)); overflow: hidden; border: 1px solid var(--line); }
.pulse-line { position: absolute; inset: 0; width: 100%; }
.pulse-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0%; border-right: 2px solid var(--gold); background: linear-gradient(90deg, rgba(201,162,75,.18), rgba(201,162,75,.06)); transition: width .9s cubic-bezier(.2,.7,.2,1); }
body[dir="rtl"] .pulse-fill { left: auto; right: 0; border-right: 0; border-left: 2px solid var(--gold); }

/* ---- totals ---- */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.total-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.total-card .k { font-size: 12px; color: var(--muted); }
.total-card .v { font-family: var(--mono); font-size: 24px; font-weight: 600; color: var(--ink); }
.total-card .u { font-size: 12px; color: var(--muted); }

/* ---- flags ---- */
.flag { border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px; border: 1px solid; display: flex; gap: 9px; align-items: flex-start; }
.flag.blocking { background: var(--danger-soft); border-color: rgba(210,103,92,.4); color: #E7A79F; }
.flag.warning  { background: var(--amber-soft); border-color: rgba(208,138,44,.4); color: #E6BC7E; }
.flag.review   { background: #1B1E22; border-color: var(--line); color: var(--ink-soft); }

/* ---- caveat / honest-claims banner ---- */
.caveat { border-inline-start: 3px solid var(--amber); background: var(--amber-soft); padding: 12px 14px; border-radius: 8px; font-size: 13px; color: #E6BC7E; }
.caveat.clean { border-inline-start-color: var(--green); background: rgba(79,174,139,.10); color: #93D6BC; }

/* ---- toast ---- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: #000; border: 1px solid var(--line); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--danger); color: #E7A79F; }

/* ---- misc ---- */
.center { text-align: center; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }
.back { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 999px; margin-bottom: 16px; display: inline-flex; align-items: center; gap: 6px; }
.back:hover { color: var(--gold-2); border-color: var(--gold); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.35); border-top-color: #1A1407; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--ink-soft); padding: 34px 18px; border: 1px solid var(--gold-soft); border-radius: var(--radius); background: linear-gradient(180deg, var(--gold-soft), transparent); position: relative; }
.empty::before { content: "✦"; display: block; color: var(--gold); font-size: 20px; margin-bottom: 8px; }
.footer-links { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.footer-links a { color: var(--muted); text-decoration: underline; cursor: pointer; }
.footer-links a:hover { color: var(--gold-2); }

/* ---- privacy page ---- */
.legal { max-width: 760px; }
.legal h2 { margin-top: 26px; font-size: 18px; color: var(--gold-2); }
.legal h3 { margin-top: 18px; }
.legal p, .legal li { color: var(--ink-soft); font-size: 14px; }
.legal ul { padding-inline-start: 20px; }
.legal .meta { font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .pulse-fill, #toast { transition: none; } .spinner { animation: none; } }

/* country flag images (flagcdn) */
.cflag { width: 21px; height: 14px; border-radius: 2px; vertical-align: -2px; margin-inline-end: 5px; box-shadow: 0 0 0 1px rgba(255,255,255,.12); display: inline-block; }
.flagprev .cflag { width: 24px; height: 16px; }

/* custom country dropdown (native selects can't show flag images) */
.cselect { position: relative; }
.cselect-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink); text-align: start; }
.cselect-btn:hover { border-color: var(--gold); }
.cselect-btn .cname { flex: 1; }
.cselect-btn .carrow { color: var(--muted); transition: transform .15s; }
.cselect.open .cselect-btn .carrow { transform: rotate(180deg); }
.cselect-list { position: absolute; z-index: 40; top: calc(100% + 5px); left: 0; right: 0; max-height: 280px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 14px 34px rgba(0,0,0,.55); padding: 5px; display: none; }
.cselect.open .cselect-list { display: block; }
.cselect-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.cselect-item:hover { background: var(--gold-soft); }
.cselect-item.sel { background: var(--gold-soft); color: var(--gold-2); font-weight: 600; }
.cselect-group { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); padding: 9px 10px 4px; }
