/* ============================================================
   H Heuristics — Signature Visual Elements
   The anti-AI-aesthetic layer. These patterns make H Heuristics
   sites feel bespoke, not template-generated.

   Requires: hheuristics-tokens.css
   ============================================================ */

/* ============================================================
   1. THE GOLD RULE — Signature Section Divider
   A thin gold line that fades at both ends. The H Heuristics
   equivalent of The Economist's red rule, but warmer.
   Used between major content sections.
   ============================================================ */
.gold-rule {
  width: 100%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--color-accent) 15%,
    var(--color-accent) 85%,
    transparent 100%
  );
  margin: var(--space-20) 0;
}

.gold-rule--left {
  background: linear-gradient(
    to right,
    var(--color-accent) 0%,
    var(--color-accent) 80px,
    var(--border-subtle) 80px,
    transparent 100%
  );
}

.gold-rule--short {
  width: 60px;
  height: 2px;
  background: var(--color-accent);
  margin: var(--space-6) 0;
}

/* ============================================================
   2. THE OFFSET BORDER — Signature Card Accent
   Cards and panels with a 3px gold left-border. No generic
   rounded-card-with-shadow here. The gold edge telegraphs
   "this is H Heuristics content."
   ============================================================ */
.card-accent {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-left: var(--border-width-accent) solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}

.card-accent:hover {
  border-color: var(--border-default);
  border-left-color: var(--color-accent);
  box-shadow: var(--shadow-elevated);
}

.card-accent--dark {
  background: var(--surface-dark-card);
  border-color: var(--border-subtle);
  border-left-color: var(--color-accent);
}

/* ── Card without the accent border (for variety) ── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--duration-base) var(--ease-out),
              border-color var(--duration-base) var(--ease-out);
}

.card:hover {
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-default);
}

/* ============================================================
   3. SERIF KPI — Oversized Data-Forward Stat Cards
   Large Cormorant Garamond numbers with small Source Sans labels.
   The size contrast (serif number vs. sans label) is distinctive
   and telegraphs confidence in the data.
   ============================================================ */
.kpi-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}

.kpi-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-elevated);
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-brand);
  line-height: 1.1;
  letter-spacing: var(--tracking-tight);
}

.kpi-card__label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  margin-top: var(--space-2);
}

.kpi-card__trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  margin-top: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.kpi-card__trend--up {
  color: var(--hh-success);
  background: var(--hh-success-soft);
}

.kpi-card__trend--down {
  color: var(--hh-danger);
  background: var(--hh-danger-soft);
}

.kpi-card__trend--neutral {
  color: var(--text-muted);
  background: var(--hh-navy-50);
}

/* ── KPI Row (grid of KPI cards) ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

/* ============================================================
   4. THE GRADIENT HEADING — Brand Typography Flourish
   Select hero headings get a subtle navy-to-gold gradient.
   Use ONCE per page — it's a signature, not a gimmick.
   ============================================================ */
.gradient-heading {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-5xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  background: linear-gradient(
    135deg,
    var(--color-brand) 0%,
    var(--color-brand) 50%,
    var(--color-accent) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* For dark backgrounds */
.gradient-heading--light {
  background: linear-gradient(
    135deg,
    var(--text-inverse) 0%,
    var(--text-inverse) 50%,
    var(--color-accent) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   5. THE H WATERMARK — Subtle Brand Texture
   A faint, oversized "H" mark as a background texture on
   dark hero sections. Adds depth without distraction.
   ============================================================ */
.h-watermark {
  position: relative;
}

.h-watermark::after {
  content: 'H';
  position: absolute;
  top: 50%;
  right: -5%;
  transform: translateY(-50%);
  font-family: var(--font-display);
  font-size: 40vw;
  font-weight: var(--weight-bold);
  color: var(--hh-navy-800);
  opacity: 0.06;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
}

.h-watermark > * {
  position: relative;
  z-index: 1;
}

/* ============================================================
   6. BRANDED SECTION HEADER
   Small gold label + serif heading. Consistent across all
   sections — the H Heuristics way to open a content block.
   ============================================================ */
.section-header {
  margin-bottom: var(--space-10);
}

.section-header__label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-mono);
  margin-bottom: var(--space-3);
}

.section-header__heading {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  color: var(--color-brand);
  line-height: var(--leading-tight);
}

.section-header__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-top: var(--space-3);
  max-width: 36rem;
}

/* ============================================================
   7. DATA TABLE — H Heuristics Style
   Clean, editorial data tables. Minimal borders, accent on
   hover, monospace numbers, serif country names.
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.data-table thead th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-muted);
  border-bottom: 2px solid var(--color-brand);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  white-space: nowrap;
}

.data-table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tbody tr:hover td {
  background-color: var(--color-accent-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: 2px solid var(--border-subtle);
}

.data-table .cell--numeric {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .cell--rank {
  font-family: var(--font-body);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  text-align: center;
}

.data-table .cell--name {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
}

.data-table .cell--positive { color: var(--hh-success); }
.data-table .cell--negative { color: var(--hh-danger); }

/* ============================================================
   8. TAGS & BADGES
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 1.6;
}

.tag--brand {
  background: var(--color-accent-soft);
  color: var(--text-accent);
  border: 1px solid var(--color-accent);
}

.tag--navy {
  background: var(--hh-navy-50);
  color: var(--color-brand);
  border: 1px solid var(--border-default);
}

.tag--success {
  background: var(--hh-success-soft);
  color: var(--hh-success);
}

.tag--warning {
  background: var(--hh-warning-soft);
  color: var(--hh-warning);
}

.tag--danger {
  background: var(--hh-danger-soft);
  color: var(--hh-danger);
}

.tag--info {
  background: var(--hh-info-soft);
  color: var(--hh-info);
}

/* ============================================================
   9. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  line-height: 1.4;
}

.btn--primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}
.btn--primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: var(--shadow-elevated);
}

.btn--secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border-color: var(--btn-secondary-border);
}
.btn--secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--color-brand);
}

.btn--accent {
  background: var(--btn-accent-bg);
  color: var(--btn-accent-text);
}
.btn--accent:hover {
  background: var(--btn-accent-hover);
  box-shadow: var(--shadow-glow-gold);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--hh-navy-50);
}

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
}

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

/* ============================================================
   10. PANEL — Content Container
   ============================================================ */
.panel {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-card);
}

.panel__header {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--color-brand);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

/* ============================================================
   11. CALLOUT — Editorial Pull Quote
   ============================================================ */
.callout {
  padding: var(--space-6) var(--space-8);
  border-left: var(--border-width-accent) solid var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.callout__text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  color: var(--color-brand);
  line-height: var(--leading-snug);
  font-style: italic;
}

.callout__attribution {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

/* ============================================================
   12. HERO SECTION — Dark Navy with Brand Flourish
   ============================================================ */
.hero-dark {
  background: var(--surface-dark);
  color: var(--text-inverse);
  padding: var(--space-32) 0;
  position: relative;
  overflow: hidden;
}

.hero-dark::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 70% 50%, oklch(0.25 0.04 82 / 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 30% 80%, oklch(0.20 0.02 258 / 0.3) 0%, transparent 50%);
  pointer-events: none;
}

.hero-dark__heading {
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  font-weight: var(--weight-bold);
  color: var(--text-inverse);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  position: relative;
  z-index: 1;
}

.hero-dark__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--hh-navy-100);
  margin-top: var(--space-6);
  max-width: 36rem;
  position: relative;
  z-index: 1;
  line-height: var(--leading-relaxed);
}

/* ============================================================
   13. BRANDED CHART CONTAINER
   Consistent chrome for all data visualizations.
   ============================================================ */
.chart-panel {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.chart-panel__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-brand);
}

.chart-panel__badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--hh-navy-50);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  letter-spacing: var(--tracking-label);
}

.chart-panel__body {
  padding: var(--space-6);
}

/* ============================================================
   14. NUMBER HIGHLIGHT — Inline Stat
   For emphasizing a number in flowing text.
   ============================================================ */
.number-highlight {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  line-height: 1;
}

/* ============================================================
   15. FOOTER — Dark, Authoritative
   ============================================================ */
.footer-brand {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: var(--space-16) 0 var(--space-8);
  font-size: var(--text-sm);
}

.footer-brand a {
  color: var(--footer-text);
  text-decoration: none;
}

.footer-brand a:hover {
  color: var(--color-accent);
}

.footer-brand__logo {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--text-inverse);
  margin-bottom: var(--space-4);
}

.footer-brand__tagline {
  color: var(--footer-text-muted);
  font-size: var(--text-sm);
  max-width: 280px;
}

.footer-brand__heading {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--hh-navy-400);
  margin-bottom: var(--space-4);
}

.footer-brand__bottom {
  border-top: 1px solid var(--hh-navy-800);
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  font-size: var(--text-xs);
  color: var(--footer-text-muted);
}

/* ============================================================
   16. SKELETON LOADING — Branded, Not Boring
   Uses the gold accent tint instead of generic gray.
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-subtle) 0%,
    var(--color-accent-soft) 50%,
    var(--border-subtle) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   17. ANIMATIONS — Subtle, Professional
   ============================================================ */
@keyframes hh-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hh-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fade-up {
  animation: hh-fade-up var(--duration-slow) var(--ease-out) forwards;
}

.animate-fade-in {
  animation: hh-fade-in var(--duration-base) var(--ease-out) forwards;
}

/* ── Stagger children ── */
.stagger-fade-up > * {
  opacity: 0;
  animation: hh-fade-up var(--duration-slow) var(--ease-out) forwards;
}

.stagger-fade-up > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-fade-up > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-fade-up > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-fade-up > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-fade-up > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-fade-up > *:nth-child(6)  { animation-delay: 0.30s; }
.stagger-fade-up > *:nth-child(7)  { animation-delay: 0.35s; }
.stagger-fade-up > *:nth-child(8)  { animation-delay: 0.40s; }

/* ============================================================
   18. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton { animation: none; }
}

/* ============================================================
   19. PRINT STYLESHEET
   ============================================================ */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .card, .card-accent, .panel, .kpi-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  .card-accent {
    border-left: 3px solid #999;
  }
  .btn {
    border: 1px solid #999;
    background: none !important;
    color: #000 !important;
  }
  .hero-dark {
    background: #fff !important;
    color: #000 !important;
  }
  .hero-dark__heading { color: #000 !important; }
  .gold-rule { background: #999; }
}
