/* ============================================================================
   Tesoro — paraguayhistory.net dark design system
   Canonical tokens + shared chrome components.
   Source of truth: design_handoff_tesoro/BRAND-SYSTEM.md
   Reproduce values exactly; route-specific layout lives in each template.
   ========================================================================== */

:root {
  /* Surfaces (dark) */
  --t-bg:          #16130f;  /* page background */
  --t-bg-deep:     #100E0C;  /* sidebars, alt sections, table headers */
  --t-panel:       #211c19;  /* cards, panels, inputs, ghost buttons */
  --t-panel-ops:   #1a1613;  /* dashboard (ops) cards */
  --t-well:        #0c0a08;  /* code blocks, scan backdrop */
  --t-border:      #3A332D;  /* default borders/dividers */
  --t-border-soft: #2A241F;  /* inner/secondary dividers */
  --t-border-gold: #4a3f2e;  /* gold-tinted border (active chips, callouts) */

  /* Text */
  --t-text:    #FDFBF7;  /* primary */
  --t-text-2:  #E8E1D5;  /* secondary */
  --t-text-3:  #D6CFC4;  /* body */
  --t-text-4:  #C9C1B4;  /* tertiary body */
  --t-muted:   #A8A29E;  /* muted labels */
  --t-muted-2: #8A7E6B;  /* fainter — IDs, captions */
  --t-faint:   #6F665C;  /* footer, fine print */
  --t-faint-2: #6B6258;

  /* Accent & semantic */
  --t-gold:        #F59E0B;  /* primary accent, CTAs, active states */
  --t-gold-bright: #FCD34D;  /* highlights, key numbers, Guaraní */
  --t-ink:         #1C1917;  /* text ON gold */
  --t-green:       #1F8A5B;
  --t-green-text:  #6FBF95;
  --t-red:         #D52B1E;
  --t-red-text:    #E8897B;

  /* Paraguay tricolor (always red · white · blue, in order) */
  --t-tri-red:   #D52B1E;
  --t-tri-white: #FFFFFF;
  --t-tri-blue:  #0038A8;

  /* Type */
  --t-font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --t-font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --t-font-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* Radius */
  --t-r-badge: 4px;
  --t-r-btn:   8px;
  --t-r-card:  12px;
  --t-r-pill:  100px;

  /* Shadow */
  --t-shadow-card:  0 24px 48px -22px rgba(0,0,0,0.85);
  --t-shadow-gold:  0 10px 30px -10px rgba(245,158,11,0.5);
  --t-shadow-figure:0 40px 80px -30px rgba(0,0,0,0.7);
}

/* ---- Reset / page base ------------------------------------------------- */
.t-reset *, .t-reset *::before, .t-reset *::after { box-sizing: border-box; }

body.t-page {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-text);
  font-family: var(--t-font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Generic full-height column scaffold (error/login centred layouts) */
.t-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Tricolor ribbon --------------------------------------------------- */
.t-ribbon {
  height: 5px;
  width: 100%;
  background: linear-gradient(90deg,
    var(--t-tri-red) 0 33.33%,
    var(--t-tri-white) 33.33% 66.66%,
    var(--t-tri-blue) 66.66% 100%);
}
.t-ribbon--vertical {
  width: 6px;
  height: auto;
  background: linear-gradient(180deg,
    var(--t-tri-red) 0 33.33%,
    var(--t-tri-white) 33.33% 66.66%,
    var(--t-tri-blue) 66.66% 100%);
}

/* ---- Wordmark ---------------------------------------------------------- */
.t-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--t-font-display);
  font-weight: 500;
  font-size: 21px;
  color: var(--t-text);
  text-decoration: none;
  width: max-content;
}
.t-wordmark .t-dot { color: var(--t-gold); }

/* ---- Sticky header ----------------------------------------------------- */
.t-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(22,19,15,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--t-border);
}
.t-header__row {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.t-header--wide .t-header__row { max-width: 1500px; }

/* minimal header (error pages) — wordmark only, not sticky */
.t-header--minimal {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 40px;
}

.t-nav {
  display: flex;
  align-items: center;
  gap: 36px;
}
.t-nav a {
  font-family: var(--t-font-body);
  font-size: 15px;
  color: var(--t-text-3);
  text-decoration: none;
  transition: color 0.18s;
}
.t-nav a:hover { color: var(--t-text); }
.t-nav a.is-active { color: var(--t-gold-bright); font-weight: 500; }
.t-nav a.t-nav__cta { color: var(--t-gold); font-weight: 500; }

/* Language toggle (ES | EN) */
.t-lang {
  background: transparent;
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-pill);
  padding: 4px 12px;
  font-family: var(--t-font-mono);
  font-size: 12px;
  color: var(--t-muted);
  cursor: pointer;
}
.t-lang [data-lang-seg] { cursor: pointer; }
.t-lang .t-lang__sep { opacity: 0.4; }

/* ---- Kicker / eyebrow -------------------------------------------------- */
.t-kicker {
  font-family: var(--t-font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--t-gold);
}

/* ---- Guaraní signature line ------------------------------------------- */
.t-guarani {
  font-family: var(--t-font-mono);
  font-size: 13px;
  color: var(--t-muted);
}
.t-guarani .t-guarani__phrase { color: var(--t-gold-bright); }

/* ---- Buttons ----------------------------------------------------------- */
.t-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--t-font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 26px;
  border-radius: var(--t-r-btn);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.18s;
}
.t-btn--pill { border-radius: var(--t-r-pill); }
.t-btn--gold {
  background: var(--t-gold);
  color: var(--t-ink);
  border-color: var(--t-gold);
  box-shadow: var(--t-shadow-gold);
}
.t-btn--gold:hover { background: #FBB034; }
.t-btn--ghost {
  background: var(--t-panel);
  border-color: var(--t-border);
  color: var(--t-text);
  font-weight: 500;
}
.t-btn--ghost:hover { border-color: var(--t-gold); }
.t-btn svg { flex: none; }

/* ---- Form inputs ------------------------------------------------------- */
.t-label {
  display: block;
  font-family: var(--t-font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t-muted);
  margin-bottom: 8px;
}
.t-input {
  width: 100%;
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-btn);
  color: var(--t-text);
  font-family: var(--t-font-body);
  font-size: 15px;
  padding: 13px 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t-input::placeholder { color: var(--t-faint-2); }
.t-input:focus {
  outline: none;
  border-color: var(--t-gold);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.15);
}

/* ---- Divider with centered label (O / OR) ----------------------------- */
.t-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
}
.t-divider::before, .t-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--t-border);
}
.t-divider span {
  font-family: var(--t-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--t-faint-2);
}

/* ---- Flash / alert ----------------------------------------------------- */
.t-flash {
  padding: 11px 14px;
  border-radius: var(--t-r-btn);
  font-size: 14px;
  margin-bottom: 18px;
  color: var(--t-red-text);
  background: rgba(213,43,30,0.12);
  border: 1px solid rgba(213,43,30,0.4);
}

/* ---- Card / panel ------------------------------------------------------ */
.t-card {
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-card);
}
.t-card--interactive { transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; }
.t-card--interactive:hover {
  transform: translateY(-3px);
  border-color: var(--t-gold);
  box-shadow: var(--t-shadow-card);
}

/* ---- Feature figure (scan with provenance) ---------------------------- */
.t-figure {
  margin: 0;
  position: relative;
}
.t-figure__edge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -18px;
  width: 6px;
  background: linear-gradient(180deg,
    var(--t-tri-red) 0 33.33%,
    var(--t-tri-white) 33.33% 66.66%,
    var(--t-tri-blue) 66.66% 100%);
}
.t-figure__frame {
  background: var(--t-panel);
  padding: 12px;
  border: 1px solid var(--t-border);
  box-shadow: var(--t-shadow-figure);
  position: relative;
}
.t-figure__cap {
  position: absolute;
  background: var(--t-gold);
  color: var(--t-ink);
  font-family: var(--t-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 12px;
}

/* ---- Badges ------------------------------------------------------------ */
.t-badge {
  font-family: var(--t-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: var(--t-r-badge);
  border: 1px solid transparent;
}
.t-badge--image { color: var(--t-ink); background: var(--t-gold); }
.t-badge--text  {
  color: var(--t-green-text);
  background: rgba(31,138,91,0.16);
  border-color: rgba(31,138,91,0.4);
}

/* ---- Status pills (tables) -------------------------------------------- */
.t-pill {
  font-family: var(--t-font-mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--t-r-pill);
  border: 1px solid transparent;
}
.t-pill--green { color: var(--t-green-text); background: rgba(31,138,91,0.14); border-color: rgba(31,138,91,0.4); }
.t-pill--amber { color: var(--t-gold-bright); background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.4); }
.t-pill--red   { color: var(--t-red-text);   background: rgba(213,43,30,0.12);  border-color: rgba(213,43,30,0.4); }

/* ---- KPI card ---------------------------------------------------------- */
.t-kpi {
  position: relative;
  background: var(--t-panel);
  border: 1px solid var(--t-border);
  border-radius: var(--t-r-card);
  padding: 20px 22px 20px 26px;
}
.t-kpi__bar {
  position: absolute;
  left: 0; top: 18px; bottom: 18px;
  width: 3px;
  background: var(--t-gold);
  border-radius: 0 2px 2px 0;
}
.t-kpi__label { font-family: var(--t-font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--t-muted); }
.t-kpi__value { font-family: var(--t-font-display); font-weight: 600; font-size: 34px; color: var(--t-text); margin-top: 6px; }
.t-kpi__sub   { font-size: 12px; color: var(--t-muted-2); margin-top: 4px; }

/* ---- Table ------------------------------------------------------------- */
.t-table { width: 100%; border-collapse: collapse; }
.t-table thead th {
  background: var(--t-bg-deep);
  font-family: var(--t-font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t-muted-2);
  text-align: left;
  padding: 12px 14px;
}
.t-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--t-border-soft); color: var(--t-text-3); font-size: 14px; }
.t-table tbody tr:hover { background: #1b1714; }
.t-table .t-id { font-family: var(--t-font-mono); color: var(--t-gold-bright); }

/* ---- Footer ------------------------------------------------------------ */
.t-footer {
  border-top: 1px solid var(--t-border);
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.t-footer span { font-family: var(--t-font-mono); font-size: 12px; color: var(--t-faint-2); }

/* ---- Accessibility floor ---------------------------------------------- */
.t-page :focus-visible {
  outline: 2px solid var(--t-gold);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .t-page *, .t-page *::before, .t-page *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- Responsive: collapse header padding + nav on narrow ------------- */
@media (max-width: 760px) {
  .t-header__row { padding: 14px 20px; flex-wrap: wrap; }
  .t-header--minimal { padding: 16px 20px; }
  .t-nav { gap: 18px; }
  .t-footer { padding: 16px 20px; }
}
