/* ============================================================
   Story of US - Stories map, mobile exploration, filters, story wall
   ============================================================ */

.stories-hero {
  padding-block: 3.5rem 2rem;
}

.stories-hero h1 {
  font-size: clamp(2.2rem, 4.4vw, 3.6rem);
}

.stories-hero p {
  color: var(--ink-body);
  font-size: 1.1rem;
}

/* --- Persistent map plate --- */

.stories-map-plate {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  background: var(--paper-deep);
  isolation: isolate;
}

.stories-map {
  width: 100%;
  height: min(68vh, 640px);
  min-height: 380px;
  touch-action: pan-y;
}

.stories-map-plate.is-map-active .stories-map {
  touch-action: none;
}

.map-noscript {
  padding: 2rem;
  text-align: center;
  color: var(--ink-muted);
}

.stories-map .maplibregl-ctrl-attrib {
  background: color-mix(in srgb, var(--paper) 80%, transparent);
  font-family: var(--font-sans);
  font-size: 0.68rem;
}

.stories-map .maplibregl-ctrl-group {
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-soft);
}

.stories-map .maplibregl-ctrl button,
.story-panel-close,
.map-deactivate {
  min-width: 44px;
  min-height: 44px;
}

.stories-map canvas:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: -3px;
}

.map-activation,
.map-deactivate {
  display: none;
}

.map-counter {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.1rem;
  box-shadow: var(--shadow-soft);
}

.map-counter-figure {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.map-counter-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.map-keyboard-nav {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 6;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.map-keyboard-nav:focus-within {
  width: min(34rem, calc(100% - 2rem));
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  display: flex;
  align-items: end;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-input);
  background: var(--paper-raised);
  box-shadow: var(--shadow-lift);
}

.map-keyboard-nav label {
  flex: 1 1 auto;
  min-width: 0;
}

.map-keyboard-nav label span {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
}

.map-keyboard-nav select,
.map-keyboard-nav .button {
  min-width: 0;
  min-height: 44px;
}

.map-keyboard-nav select {
  width: 100%;
}

.no-js .stories-map,
.no-js .map-activation,
.no-js .map-counter,
.no-js .map-keyboard-nav {
  display: none;
}

.no-js .stories-map-plate {
  background: var(--paper-raised);
}

/* --- Story preview panel / mobile bottom sheet --- */

.story-panel {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: var(--z-menu);
  width: min(92vw, 560px);
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 1.3rem 3.5rem 1.3rem 1.5rem;
  transition: transform 300ms var(--ease-out), opacity 240ms var(--ease-out);
}

.story-panel:not(.is-open) {
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
}

.story-panel-close {
  position: absolute;
  top: 0.35rem;
  right: max(0.45rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
}

.story-panel-media img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--paper-deep);
}

.story-panel-body {
  min-width: 0;
}

.story-panel-number {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.3rem;
}

.story-panel-body h3 {
  margin-bottom: 0.15rem;
}

.story-panel-location {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
}

.story-panel-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 1rem;
}

.story-panel-link {
  min-height: 44px;
  padding: 0.6rem 1.4rem;
  font-size: 0.9rem;
}

/* --- Filter bar --- */

.filter-bar {
  margin-bottom: 2.6rem;
  display: grid;
  gap: 1.2rem;
}

.filter-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: flex-end;
}

.filter-field {
  display: grid;
  gap: 0.35rem;
  min-width: 220px;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.filter-tag {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 1rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--hairline-strong);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  transition: background-color var(--dur-state) var(--ease-out), color var(--dur-state) var(--ease-out), border-color var(--dur-state) var(--ease-out);
}

.filter-tag.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

/* --- Story wall and local filter transition --- */

.stories-wall {
  padding-top: 3rem;
}

[data-story-wall-content] {
  transition: opacity 180ms var(--ease-out);
}

[data-story-wall-content].is-filtering {
  opacity: 0.56;
  pointer-events: none;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: 1.6rem;
}

.story-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.story-card-media img,
.story-card-placeholder {
  aspect-ratio: 4 / 3;
}

.story-card-placeholder {
  display: grid;
  place-items: center;
  background: var(--ink-wash);
}

.story-card-placeholder .brand-mark {
  width: 64px;
  height: 64px;
  opacity: 0.75;
}

.story-card-body {
  min-width: 0;
  padding: 1.3rem 1.4rem 1.6rem;
}

.story-card-number {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 0.6rem;
}

.story-card-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.story-card-topline .story-card-number {
  margin-bottom: 0;
}

.story-card-reads {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}

.story-card-body h3 {
  margin-bottom: 0.15rem;
}

.story-card-meta {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin-bottom: 0.8rem;
}

.story-card-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 0.9rem;
}

.story-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.story-card-tags span {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--ink-wash);
  border-radius: var(--radius-pill);
  padding: 0.22rem 0.7rem;
}

@media (hover: hover) and (pointer: fine) {
  .story-panel-close:hover {
    color: var(--ink);
  }

  .filter-tag:hover {
    border-color: var(--ink);
  }
}

@media (max-width: 767px), (hover: none), (pointer: coarse) {
  .stories-map {
    height: min(52vh, 480px);
    min-height: 320px;
    pointer-events: none;
  }

  .stories-map-plate.is-map-active .stories-map {
    pointer-events: auto;
  }

  .map-keyboard-nav:focus-within {
    flex-direction: column;
    align-items: stretch;
  }

  .stories-map-plate.is-map-active .map-keyboard-nav {
    bottom: 4.25rem;
  }

  .map-activation {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1.25rem;
    text-align: center;
    background: color-mix(in srgb, var(--paper) 40%, transparent);
    transition: opacity 260ms var(--ease-out), visibility 260ms var(--ease-out);
  }

  .map-activation .button {
    min-width: 44px;
    min-height: 48px;
  }

  .map-activation span {
    max-width: 30ch;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    color: var(--ink-body);
    font-size: 0.78rem;
  }

  .stories-map-plate.is-map-active .map-activation {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .map-deactivate {
    position: absolute;
    left: 0.65rem;
    bottom: 0.65rem;
    z-index: 5;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-pill);
    padding: 0.5rem 0.9rem;
    background: color-mix(in srgb, var(--paper) 94%, transparent);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: var(--shadow-soft);
  }

  .map-deactivate:not([hidden]) {
    display: inline-flex;
  }

  .map-counter {
    top: 0.65rem;
    right: 0.65rem;
    padding: 0.42rem 0.8rem;
  }

  .map-counter-label {
    font-size: 0.68rem;
  }

  .story-panel {
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    transform: translateY(0);
    border-radius: var(--radius) var(--radius) 0 0;
    border-inline: 0;
    padding: 1.15rem 3.5rem max(1.1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }

  .story-panel:not(.is-open) {
    transform: translateY(28px);
  }
}

@media (max-width: 640px) {
  .stories-hero {
    padding-block: 2.25rem 1.5rem;
  }

  .stories-hero p {
    font-size: 1rem;
  }

  .filter-selects {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.9rem;
  }

  .filter-field {
    min-width: 0;
  }

  .filter-tags-scroller {
    position: relative;
    min-width: 0;
    margin-inline: calc(var(--gutter) * -1);
  }

  .filter-tags-scroller::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 2.2rem;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--paper));
  }

  .filter-tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    padding-inline: var(--gutter);
    padding-bottom: 0.35rem;
    scroll-padding-inline: var(--gutter);
  }

  .filter-tags::-webkit-scrollbar {
    display: none;
  }

  .filter-tag {
    flex: none;
  }

  .story-panel-media img {
    width: 68px;
    height: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-panel,
  .map-activation,
  [data-story-wall-content],
  .filter-tag {
    transition: none;
  }
}
