/* Gulf Trade Dependency — Editorial Redesign */

/* --- Design tokens --- */

:root {
  --color-bg: #F5F1E7;
  --color-text: #000000;
  --color-text-secondary: #444;
  --color-text-muted: #666;
  --color-accent: #ff6a00;
  --color-accent-hover: #cc5500;
  --color-accent-light: rgba(255, 106, 0, 0.08);
  --color-border: rgba(0, 0, 0, 0.1);
  --color-border-light: rgba(0, 0, 0, 0.05);
  --color-card: rgba(255, 255, 255, 0.5);
  --color-card-hover: rgba(255, 255, 255, 0.75);

  --font-headline: Arial, Helvetica, sans-serif;
  --font-body: "Times New Roman", Times, serif;

  --container-max: 1100px;
  --container-narrow: 720px;

  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-xxl: 6rem;
}

/* --- Reset --- */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }

/* --- Base typography --- */

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 500;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

a { color: var(--color-text); transition: color 0.2s ease; }
a:hover { color: var(--color-accent); }

/* --- Layout --- */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 2rem;
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* --- Accent bar --- */

.accent-bar {
  height: 4px;
  background: var(--color-accent);
}

/* --- Hero --- */

.hero {
  padding: var(--space-xxl) 0 var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.hero__kicker {
  font-family: var(--font-headline);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  max-width: 16ch;
}

.hero__subtitle {
  font-family: var(--font-headline);
  font-size: clamp(1rem, 2vw, 1.2rem);
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: 1.5;
  max-width: 50ch;
}

/* --- Stats row --- */

.stats {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--color-border);
}

.stats__row {
  display: flex;
  gap: var(--space-lg);
}

.stat {
  flex: 1;
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-md);
}

.stat__value {
  font-family: var(--font-headline);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat__label {
  font-family: var(--font-headline);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat__desc {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

/* --- Scrollytelling --- */

#scrolly {
  position: relative;
}

.scrolly__inner {
  display: flex;
  gap: 3%;
}

.scrolly__graphic {
  flex: 0 0 55%;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  overflow-y: auto;
  overflow-x: hidden;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrolly__graphic::-webkit-scrollbar {
  display: none;
}

.scrolly__text {
  flex: 0 0 42%;
  max-width: 420px;
  padding: var(--space-lg) 0;
}

.step {
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-lg) var(--space-lg) var(--space-lg) 0;
  opacity: 0.15;
  transition: opacity 0.5s ease;
}

.step.is-active {
  opacity: 1;
}

.step h2 {
  font-size: 1.4rem;
  margin-bottom: 0.6rem;
  color: var(--color-text);
}

.step p {
  font-size: 1rem;
  color: var(--color-text-secondary);
  line-height: 1.65;
}

.step .step__highlight {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 3rem;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* Scrolly chart (CSS bar chart) */

.scrolly-chart {
  width: 100%;
  max-width: 700px;
  position: relative;
}

.scrolly-hero {
  text-align: center;
  opacity: 0;
  transition: opacity 0.6s ease;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.scrolly-hero.is-active {
  opacity: 1;
  pointer-events: auto;
}

.scrolly-hero__number {
  font-family: var(--font-headline);
  font-size: 6rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.scrolly-hero__label {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
  max-width: 24ch;
  margin-left: auto;
  margin-right: auto;
}

/* --- SVG Map --- */

.scrolly-map {
  opacity: 0;
  transition: opacity 0.6s ease;
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  width: 130%;
  max-width: none;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 62% 62% at 50% 48%, black 22%, transparent 68%);
  mask-image: radial-gradient(ellipse 62% 62% at 50% 48%, black 22%, transparent 68%);
}

.scrolly-map.is-active {
  opacity: 1;
  pointer-events: auto;
}

.scrolly-map svg {
  width: 100%;
  height: auto;
}

.context-country {
  fill: #ddd;
  stroke: #ccc;
  stroke-width: 0.5;
}

.gulf-country {
  fill: #ccc;
  stroke: #bbb;
  stroke-width: 0.5;
  transition: fill 0.5s ease, stroke 0.5s ease, opacity 0.5s ease;
}

.gulf-country.is-highlighted {
  fill: var(--color-accent);
  stroke: var(--color-accent-hover);
  stroke-width: 1.5;
}

.gulf-country.is-dimmed {
  fill: #e8e4dc;
  stroke: #d5d0c8;
  opacity: 0.5;
}

.water {
  fill: #d4e8f0;
}

.strait-line {
  stroke: var(--color-accent);
  stroke-width: 2;
  opacity: 0.7;
}

.strait-label {
  font-family: var(--font-headline);
  font-size: 9px;
  fill: #666;
}

.map-label {
  font-family: var(--font-headline);
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
}

.context-label {
  fill: #999;
  font-weight: 400;
  font-size: 9px;
}

.gulf-label {
  fill: #444;
  transition: fill 0.5s ease, opacity 0.5s ease;
}

.gulf-label.is-highlighted {
  fill: var(--color-accent-hover);
  font-weight: 700;
}

.gulf-label.is-dimmed {
  fill: #bbb;
  opacity: 0.5;
}

/* --- Scrolly bars --- */

.scrolly-bars {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.scrolly-bars.is-active {
  opacity: 1;
}

.scrolly-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.4s ease, margin 0.3s ease;
  margin-bottom: 0;
  text-decoration: none;
  color: inherit;
}

.scrolly-bar.is-visible {
  max-height: 40px;
  opacity: 1;
  margin-bottom: 5px;
}

.scrolly-bar:hover .bar-fill {
  filter: brightness(0.85);
}

.bar-name {
  flex: 0 0 140px;
  font-family: var(--font-headline);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 22px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0;
  background: color-mix(in srgb, var(--bar-color, #ff6a00) 65%, transparent);
  border-left: 3px solid var(--bar-color, #ff6a00);
}

.scrolly-bar.is-visible .bar-fill {
  width: var(--fill-width);
}

.scrolly-bar:hover .bar-fill {
  filter: brightness(1.1) saturate(1.2);
}

.bar-value {
  flex: 0 0 44px;
  font-family: var(--font-headline);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: right;
}

/* --- Hand-drawn click hint --- */

.click-hint {
  position: absolute;
  top: 50%;
  left: 42%;
  transform-origin: left center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 4px;
  transform: translateY(-50%) rotate(-2deg);
}

.click-hint.is-active {
  opacity: 1;
}

.click-hint__arrow {
  display: block;
  margin-bottom: 2px;
  overflow: visible;
}

.click-hint .hint-stroke {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.click-hint.is-active .hint-stroke {
  stroke-dashoffset: 0;
  transition-delay: 1.4s;
}

.click-hint__label {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.3;
  text-align: right;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: rgba(245, 241, 231, 0.85);
  padding: 2px 6px;
  border-radius: 2px;
  margin-top: -12px;
}

.click-hint.is-active .click-hint__label {
  opacity: 1;
  transition-delay: 2s;
}

/* Step CTA styling */
.step-cta {
  display: inline-block;
  margin-top: 0.6rem;
  font-family: var(--font-headline);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.01em;
}

/* --- Tooltip --- */

.bar-tooltip {
  position: fixed;
  z-index: 1000;
  background: #333;
  color: white;
  max-width: 280px;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: var(--font-headline);
  font-size: 0.78rem;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.bar-tooltip.is-visible {
  opacity: 1;
}

.tooltip-desc {
  margin-bottom: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.tooltip-stats {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 4px;
}

.tooltip-cta {
  font-size: 0.68rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* --- Narrative (shared: index + product pages) --- */

.narrative { margin-bottom: var(--space-md); }

.narrative h2 {
  font-size: 1.4rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  margin-top: var(--space-xl);
}

.narrative p {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
  max-width: var(--container-narrow);
}

/* --- Callouts (product pages) --- */

.callout-row {
  display: flex;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.callout {
  flex: 1;
  border-left: 3px solid var(--color-accent);
  padding: 0.9rem 1.1rem;
  background: var(--color-card);
  border-radius: 0 6px 6px 0;
}

.callout-value {
  font-family: var(--font-headline);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1.1;
}

.callout-label {
  font-family: var(--font-headline);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text);
  margin-top: 0.2rem;
}

.callout-desc {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

/* --- Figure frames (product pages) --- */

.figure-frame {
  margin: var(--space-md) -2rem var(--space-lg);
  width: calc(100% + 4rem);
  -webkit-overflow-scrolling: touch;
}

.figure-frame iframe {
  display: block;
  width: 100%;
  border: none;
  min-height: 300px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.figure-caption {
  font-family: var(--font-headline);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
  padding: 0 2rem;
  font-style: italic;
}

/* --- Product page specifics --- */

.back-link {
  display: inline-block;
  margin-bottom: var(--space-md);
  font-family: var(--font-headline);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.back-link:hover { color: var(--color-accent); }

.meta {
  font-family: var(--font-headline);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.description {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
  max-width: var(--container-narrow);
  line-height: 1.65;
}

/* Product page h1 */
.container > h1 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

/* Tag (used on product pages) */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-headline);
  color: white;
  letter-spacing: 0.01em;
}

/* --- Footer --- */

footer {
  margin-top: 0;
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--color-border);
}

footer .container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

footer p {
  font-family: var(--font-headline);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 70ch;
}

footer a { color: var(--color-text-muted); }
footer a:hover { color: var(--color-accent); }

/* --- Responsive --- */

@media (max-width: 1024px) {
  .scrolly__graphic {
    flex: 0 0 50%;
  }
  .scrolly__text {
    flex: 0 0 47%;
  }
  .bar-name { flex: 0 0 110px; }
}

@media (max-width: 768px) {
  .click-hint { display: none; }
  .container { padding: 0 1.25rem; }

  .hero { padding: var(--space-xl) 0 var(--space-lg); }
  .hero h1 { max-width: none; }

  .stats__row {
    flex-direction: column;
    gap: var(--space-sm);
  }
  .stat__value { font-size: 1.8rem; }

  /* Scrollytelling: linear flow on mobile (no sticky) */
  .scrolly__inner {
    flex-direction: column;
  }
  .scrolly__graphic {
    flex: none;
    width: 100%;
    position: relative;
    height: auto;
    padding: 0;
    overflow: visible;
  }
  .scrolly-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
  }
  .scrolly__text {
    flex: none;
    width: 100%;
    padding: 0 var(--space-sm);
  }
  .step {
    min-height: auto;
    padding: var(--space-md) 0;
    opacity: 1;
  }
  .step h2 { font-size: 1.2rem; }
  .step p { font-size: 0.92rem; }

  /* Map: static, centered, with edge fade */
  .scrolly-map {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    opacity: 1;
    pointer-events: auto;
    -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 15%, transparent 60%);
    mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, black 15%, transparent 60%);
  }

  /* Hero number: visible, inline */
  .scrolly-hero {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    padding: var(--space-md) var(--space-sm);
    text-align: center;
  }
  .scrolly-hero__number { font-size: 3.5rem; }
  .scrolly-hero__label { max-width: 30ch; }

  /* Bar chart: visible, full width */
  .scrolly-bars {
    opacity: 1;
    width: 100%;
    padding: 0 var(--space-sm);
  }
  .scrolly-bar {
    max-height: 36px !important;
    opacity: 1 !important;
    margin-bottom: 4px !important;
    transition-delay: 0ms !important;
  }
  .scrolly-bar .bar-fill {
    width: var(--fill-width) !important;
  }

  .scrolly__text > div:not(.step):not(.scrolly-map):not(.scrolly-hero):not(.scrolly-bars) { display: none; }
  .bar-name { flex: 0 0 90px; font-size: 0.65rem; }
  .bar-value { font-size: 0.65rem; }
  .bar-track { height: 18px; }

  /* Product pages: figures full-bleed */
  .figure-frame {
    margin: var(--space-xs) -1.25rem var(--space-xs);
    width: calc(100% + 2.5rem);
  }
  .figure-frame iframe { min-height: 250px; }
  .figure-caption { padding: 0 1.25rem; }

  /* Product pages: stack callouts */
  .callout-row { flex-direction: column; gap: var(--space-xs); }
  .callout-value { font-size: 1.5rem; }
  .callout { padding: 0.7rem 0.9rem; }

  /* Product pages: tighter narrative spacing */
  .narrative h2 { font-size: 1.2rem; margin-top: var(--space-lg); }
  .narrative p { font-size: 0.95rem; }
  .description { font-size: 0.98rem; margin-bottom: var(--space-md); }

  /* Product page h1 */
  .container > h1 { font-size: 1.3rem; }

  /* Tooltip: hide on mobile (touch doesn't hover) */
  .bar-tooltip { display: none; }

  footer .container { flex-direction: column; }
  footer p { font-size: 0.7rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 0.85rem; }
  .hero { padding: var(--space-lg) 0 var(--space-md); }
  .hero h1 { font-size: 1.6rem; }
  .hero__subtitle { font-size: 0.9rem; }

  .stat__value { font-size: 1.5rem; }
  .stat__label { font-size: 0.72rem; }
  .stat__desc { font-size: 0.78rem; }

  .scrolly__graphic { padding: 0; }
  .scrolly-map { max-width: 300px; }
  .scrolly-hero__number { font-size: 2.8rem; }
  .bar-name { flex: 0 0 65px; font-size: 0.6rem; }
  .bar-track { height: 14px; }
  .bar-value { flex: 0 0 36px; font-size: 0.6rem; }
  .step h2 { font-size: 1.05rem; }
  .step p { font-size: 0.85rem; }
  .step .step__highlight { font-size: 2.2rem; }

  .figure-frame { margin: var(--space-xs) -0.85rem var(--space-xs); width: calc(100% + 1.7rem); }
  .figure-frame iframe { min-height: 200px; }
  .figure-caption { padding: 0 0.85rem; font-size: 0.7rem; }

  .callout-value { font-size: 1.3rem; }
  .callout-label { font-size: 0.7rem; }
  .callout { padding: 0.5rem 0.7rem; }

  .container > h1 { font-size: 1.15rem; }
  .meta { font-size: 0.78rem; }
  .description { font-size: 0.9rem; }
  .narrative h2 { font-size: 1.05rem; margin-top: var(--space-md); }
  .narrative p { font-size: 0.88rem; }

  .back-link { font-size: 0.75rem; }
  footer p { font-size: 0.65rem; }
}
