/* ==========================================================================
   Sweden Trade Intelligence — scrollytelling story page
   Reuses the design tokens and structural classes from styles.css (colors,
   type scale, .shell/.section/.hero/.btn/.arrow-link/.eyebrow/.lede) and
   only adds what's specific to the sticky-graphic + stepped-text layout.

   Progressive enhancement: everything under .story is a single readable
   column with no sticky graphic until the `.js` class lands on <html> (see
   /js/js-on.js, same technique the site already uses for .reveal). Only
   then does the two-column sticky layout and the D3-driven chart appear.
   ========================================================================== */

.story {
  padding-block: clamp(2rem, 4vw, 3rem) clamp(3rem, 6vw, 5rem);
}

/* Country switcher: sits beside the eyebrow in the hero, full-page
   navigates on change (no client-side data swap -- this page stays
   zero-runtime-dependency/SSR-first). Styled as a small labeled pill
   rather than a bare <select> so a single-option dropdown (today, while
   Sweden is the only populated country) still reads as an intentional,
   finished control rather than an inert leftover. */
.story__country-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}

.story__country-switch-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.story__country-select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.35rem 1.9rem 0.35rem 0.9rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23002d5c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  cursor: pointer;
  transition: border-color var(--duration-fast, 150ms) var(--ease, ease);
}

.story__country-select:hover,
.story__country-select:focus-visible {
  border-color: var(--navy);
}

.story__country-select:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.story__steps {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 6vw, 5rem);
  max-width: var(--shell-narrow);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.story__step {
  padding-block: clamp(1.5rem, 3vw, 2.25rem);
}

.story__step .eyebrow {
  margin-bottom: 1rem;
}

.story__step .lede {
  margin-bottom: 1rem;
}

.story__step p + p {
  margin-top: 1rem;
}

.story__figure-fallback {
  margin-top: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.story__figure-fallback--list {
  display: grid;
  gap: 0.4rem;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

/* The sticky graphic itself: hidden entirely without JS, since a pinned
   panel that never updates is worse than no panel -- the fallback list
   above already carries the same numbers in normal reading flow. */
.story__sticky-wrap {
  display: none;
}

.story__sticky {
  background: var(--navy);
  color: #fff;
  border-radius: 6px;
  padding: clamp(1.5rem, 2.5vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.story__stat-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: -0.02em;
  margin: 0;
  min-height: 1.1em;
}

.story__annotation {
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  min-height: 2.6em;
}

.story__svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.story__caption {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

.story__provenance {
  max-width: var(--shell-narrow);
  margin: 0 auto clamp(3rem, 6vw, 5rem);
  padding-inline: var(--gutter);
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.story__provenance a {
  color: var(--cobalt);
  text-decoration: underline;
}

/* D3-drawn bars/lines (public/js/story.js) -- one muted tone by default,
   the cyan accent reserved for the single item each scene calls out. Same
   restraint rule as the rest of the site: one accent, used deliberately. */
.story-bar {
  fill: var(--slate-light);
}

.story-bar--highlight {
  fill: var(--cyan);
}

.story-value-label {
  fill: #fff;
  font-family: var(--font-body);
  font-size: 12px;
}

.story-axis-label {
  fill: rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono);
  font-size: 10px;
}

.story-line {
  fill: none;
  stroke-width: 2.5px;
}

.story-line--imports {
  stroke: var(--slate-light);
}

.story-line--exports {
  stroke: var(--cyan);
}

.story-zero-line {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1px;
}

/* --------------------------------------------------- JS-enhanced layout */

.js .story__figure-fallback {
  display: none;
}

.js .story__sticky-wrap {
  display: block;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  z-index: 2;
  margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.js .story__sticky {
  min-height: 300px;
  justify-content: center;
}

.js .story__step {
  opacity: 0.4;
  transition: opacity 0.4s var(--ease);
}

.js .story__step.is-active {
  opacity: 1;
}

@media (min-width: 901px) {
  .js .story {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .js .story__steps {
    grid-column: 1;
    max-width: none;
    margin-inline: 0;
    padding-inline: 0;
  }

  .js .story__sticky-wrap {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    top: calc(var(--header-h) + 2rem);
    margin-bottom: 0;
  }

  .js .story__step {
    min-height: 62vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .story__step {
    opacity: 1;
    transition: none;
  }
}
