/* ==========================================================================
   NYC ReCharged StoryMap — Scoped Styles
   Applies only to .nyc-recharged-page

   No-JS baseline:  All chapter content is visible by default as static HTML.
                     The class html.sm-enhanced (set by an inline <script>)
                     enables scroll-driven opacity transitions. If JS is
                     disabled, sm-enhanced is never set and content stays
                     visible.
   Reduced motion:  All transforms and transitions are removed when
                     prefers-reduced-motion: reduce is active.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

.nyc-recharged-page {
  --sm-electric: #0088FF;
  --sm-orange: #FF6B00;
  --sm-lime: #A3FF12;
  --sm-magenta: #D946EF;
  --sm-ink: #050505;
  --sm-panel-bg: rgba(255, 255, 255, 0.86);
  --sm-panel-border: rgba(0, 0, 0, 0.10);
  --sm-kicker: var(--sm-electric);
  --sm-body-text: #404040;
  --sm-meta-text: #737373;
}

html[data-theme="dark"] .nyc-recharged-page {
  --sm-panel-bg: rgba(0, 0, 0, 0.62);
  --sm-panel-border: rgba(255, 255, 255, 0.10);
  --sm-body-text: #d4d4d4;
  --sm-meta-text: #a3a3a3;
}

/* --------------------------------------------------------------------------
   2. StoryMap Wrapper
   -------------------------------------------------------------------------- */

.sm-storymap {
  position: relative;
  border-top: 1px solid var(--sm-panel-border);
}

/* --------------------------------------------------------------------------
   3. Map Container (placeholder until Stage 3)
   -------------------------------------------------------------------------- */

.sm-map-wrap {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  background: #e5e7eb;
  overflow: hidden;
}

html[data-theme="dark"] .sm-map-wrap {
  background: #1a1a1a;
}

/* Gradient overlay: text-side fade for legibility */
.sm-map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 20%, rgba(0, 136, 255, 0.16), transparent 28%),
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.92) 0%,
      rgba(255, 255, 255, 0.58) 32%,
      rgba(255, 255, 255, 0.08) 60%,
      rgba(255, 255, 255, 0) 100%);
}

html[data-theme="dark"] .sm-map-overlay {
  background:
    radial-gradient(circle at 18% 20%, rgba(0, 136, 255, 0.18), transparent 28%),
    linear-gradient(90deg,
      rgba(5, 5, 5, 0.94) 0%,
      rgba(5, 5, 5, 0.62) 35%,
      rgba(5, 5, 5, 0.12) 66%,
      rgba(5, 5, 5, 0) 100%);
}

/* Bottom fade into next section */
.sm-map-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 10rem;
  pointer-events: none;
  background: linear-gradient(to top, #ffffff, transparent);
}

html[data-theme="dark"] .sm-map-fade {
  background: linear-gradient(to top, var(--sm-ink), transparent);
}

/* Map itself */
.sm-map {
  width: 100%;
  height: 100%;
}

/* Placeholder shown when map is not yet wired */
.sm-map-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--sm-meta-text);
  font-size: 0.875rem;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   4. Chapters Rail (left-aligned narrative panels)
   -------------------------------------------------------------------------- */

.sm-chapters {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
}

/* Right column is empty space (map shows through) */
.sm-chapters-spacer {
  display: none;
}

@media (min-width: 1024px) {
  .sm-chapters-spacer {
    display: block;
  }
}

/* Mobile: single column */
@media (max-width: 1023px) {
  .sm-chapters {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   5. Chapter Panel
   -------------------------------------------------------------------------- */

.sm-chapter {
  min-height: 100vh;
  padding: 18vh 1.25rem;
}

@media (min-width: 640px) {
  .sm-chapter {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (min-width: 1024px) {
  .sm-chapter {
    padding-left: 3rem;
    padding-right: 3rem;
  }
}

.sm-panel {
  width: 100%;
  max-width: 36rem;
  background: var(--sm-panel-bg);
  border: 1px solid var(--sm-panel-border);
  border-radius: 0.375rem;
  padding: 1.5rem;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
}

@media (min-width: 640px) {
  .sm-panel {
    padding: 2rem;
  }
}

/* --------------------------------------------------------------------------
   6. Panel Header (kicker + counter)
   -------------------------------------------------------------------------- */

.sm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sm-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--sm-kicker);
}

.sm-counter {
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--sm-meta-text);
}

/* --------------------------------------------------------------------------
   7. Panel Title + Subtitle
   -------------------------------------------------------------------------- */

.sm-title {
  margin-top: 1.25rem;
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: normal;
  text-wrap: balance;
  color: var(--text);
}

.sm-subtitle {
  margin-top: 1.25rem;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.6;
  text-wrap: pretty;
  color: var(--sm-body-text);
}

/* --------------------------------------------------------------------------
   8. Panel Body Text
   -------------------------------------------------------------------------- */

.sm-body {
  margin-top: 1.75rem;
}

.sm-body p {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--sm-body-text);
}

.sm-body p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   9. Proposal Card
   -------------------------------------------------------------------------- */

.sm-proposal {
  margin-top: 2rem;
  padding: 1.25rem;
  border-radius: 0.375rem;
  border: 1px solid;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .sm-proposal {
  background: rgba(17, 19, 22, 0.95);
}

.sm-proposal-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.sm-proposal-dot {
  margin-top: 0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.sm-proposal-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--sm-meta-text);
}

html[data-theme="dark"] .sm-proposal-label {
  color: #e5e5e5;
}

.sm-proposal-summary {
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

/* Stats grid */
.sm-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.sm-stat {
  padding: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--sm-panel-border);
  background: #fafafa;
}

html[data-theme="dark"] .sm-stat {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.20);
}

.sm-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--sm-meta-text);
}

html[data-theme="dark"] .sm-stat-label {
  color: #e5e5e5;
}

.sm-stat-value {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

/* Benefits list */
.sm-benefits {
  margin-top: 1rem;
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.sm-benefit {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--sm-body-text);
}

.sm-benefit-dot {
  margin-top: 0.45rem;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   10. Image Grid
   -------------------------------------------------------------------------- */

.sm-images {
  margin-top: 2rem;
  display: grid;
  gap: 0.75rem;
}

.sm-images--multi {
  grid-template-columns: 1fr 1fr;
}

@media (min-width: 640px) {
  .sm-images--multi {
    grid-template-columns: repeat(5, 1fr);
  }
}

.sm-image-card {
  overflow: hidden;
  border-radius: 0.375rem;
  border: 1px solid var(--sm-panel-border);
  background: #f5f5f5;
}

html[data-theme="dark"] .sm-image-card {
  background: #171717;
  border-color: rgba(255, 255, 255, 0.10);
}

.sm-image-card img {
  width: 100%;
  display: block;
  object-fit: cover;
}

/* Single image: landscape aspect */
.sm-images:not(.sm-images--multi) .sm-image-card img {
  aspect-ratio: 4 / 3;
}

/* Multi-image gallery: portrait aspect */
.sm-images--multi .sm-image-card img {
  aspect-ratio: 3 / 4;
}

.sm-image-caption {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--sm-panel-border);
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--sm-meta-text);
}

/* --------------------------------------------------------------------------
   10b. Image Carousel
   -------------------------------------------------------------------------- */

.sm-carousel {
  position: relative;
  margin-top: 2rem;
  border-radius: 0.375rem;
  border: 1px solid var(--sm-panel-border);
  background: #f5f5f5;
  overflow: hidden;
}

html[data-theme="dark"] .sm-carousel {
  background: #171717;
  border-color: rgba(255, 255, 255, 0.10);
}

.sm-carousel-viewport {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.sm-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.8s ease-in-out;
}

.sm-carousel-slide {
  flex: 0 0 100%;
  height: 100%;
}

.sm-carousel-slide img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Arrows */
.sm-carousel-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  color: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.sm-carousel:hover .sm-carousel-arrow,
.sm-carousel-arrow:focus-visible {
  opacity: 1;
}

/* Always show arrows on touch devices (no hover) */
@media (hover: none) {
  .sm-carousel-arrow {
    opacity: 0.7;
  }
}

.sm-carousel-arrow--prev { left: 0; border-radius: 0.375rem 0 0 0.375rem; }
.sm-carousel-arrow--next { right: 0; border-radius: 0 0.375rem 0.375rem 0; }

.sm-carousel-arrow:hover {
  background: rgba(0, 0, 0, 0.45);
}

.sm-carousel-arrow:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
}

/* Dots */
.sm-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 0;
}

.sm-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.20);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.sm-carousel-dot--active {
  background: var(--sm-electric, #0088FF);
  transform: scale(1.25);
}

html[data-theme="dark"] .sm-carousel-dot {
  background: rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] .sm-carousel-dot--active {
  background: var(--sm-electric, #0088FF);
}

.sm-carousel-dot:focus-visible {
  outline: 2px solid var(--sm-electric, #0088FF);
  outline-offset: 2px;
}

/* Caption inside carousel reuses .sm-image-caption (already styled) */
.sm-carousel-slide .sm-image-caption {
  border-top: 1px solid var(--sm-panel-border);
}

@media (prefers-reduced-motion: reduce) {
  .sm-carousel-track {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   11. CTA Buttons (final chapter)
   -------------------------------------------------------------------------- */

.sm-cta {
  margin-top: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .sm-cta {
    flex-direction: row;
  }
}

.sm-cta-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: var(--sm-electric);
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 18px 46px rgba(0, 136, 255, 0.25);
  transition: background 0.2s ease;
  cursor: pointer;
}

.sm-cta-primary:hover {
  background: #0073d8;
}

.sm-cta-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.2s ease;
  cursor: pointer;
}

.sm-cta-secondary:hover {
  border-color: rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .sm-cta-secondary {
  border-color: rgba(255, 255, 255, 0.20);
}

html[data-theme="dark"] .sm-cta-secondary:hover {
  border-color: rgba(255, 255, 255, 0.45);
}

/* --------------------------------------------------------------------------
   12. Scroll-Driven Opacity (JS-enhanced only)
   -------------------------------------------------------------------------- */

/* No-JS safe: chapters fully visible by default */
.sm-chapter {
  opacity: 1;
}

/* JS available: inactive chapters dim */
html.sm-enhanced .sm-chapter {
  opacity: 0.48;
  transition: opacity 0.35s ease;
}

html.sm-enhanced .sm-chapter.sm-active {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   13. Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html.sm-enhanced .sm-chapter {
    transition: none;
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   CTA pill overrides -- kill inherited underline-grow, fix color & alignment
   -------------------------------------------------------------------------- */

.nyc-recharged-page .sm-cta-primary::after,
.nyc-recharged-page .sm-cta-secondary::after {
  display: none !important;
  content: none !important;
}

.nyc-recharged-page .sm-cta-primary {
  color: #ffffff !important;
}

.nyc-recharged-page .sm-cta-secondary {
  color: var(--text) !important;
}

.nyc-recharged-page .sm-cta-primary,
.nyc-recharged-page .sm-cta-secondary {
  text-align: center;
}

/* --------------------------------------------------------------------------
   14. StoryMap Markers
   -------------------------------------------------------------------------- */

.sm-marker {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sm-marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--marker-accent, #00A878);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

html[data-theme="dark"] .sm-marker-dot {
  border-color: #0a0a0a;
}

.sm-marker.is-active .sm-marker-dot {
  transform: scale(1.5);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--marker-accent) 35%, transparent), 0 2px 10px rgba(0, 0, 0, 0.45);
}

.sm-marker:focus-visible .sm-marker-dot {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px var(--marker-accent);
}

@media (prefers-reduced-motion: reduce) {
  .sm-marker-dot { transition: none; }
}

/* Existing installation marker (distinct from proposed) */
.sm-marker--existing .sm-marker-dot {
  width: 16px;
  height: 16px;
  background: #ffffff;
  border: 4px solid var(--marker-accent);
}

html[data-theme="dark"] .sm-marker--existing .sm-marker-dot {
  background: #0a0a0a;
}

/* --------------------------------------------------------------------------
   15. StoryMap Popups
   -------------------------------------------------------------------------- */

.sm-mapbox-popup .mapboxgl-popup-content {
  background: var(--sm-panel-bg);
  border: 1px solid var(--sm-panel-border);
  border-radius: 0.375rem;
  padding: 0.75rem 0.875rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.sm-mapbox-popup .mapboxgl-popup-tip { display: none; }

.sm-popup-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.sm-popup-meta { margin-top: 0.15rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--sm-meta-text); }
.sm-popup-body { margin-top: 0.4rem; font-size: 0.8rem; line-height: 1.4; color: var(--sm-body-text); }
.sm-popup-alloc { margin-top: 0.3rem; font-size: 0.75rem; line-height: 1.35; color: var(--sm-meta-text); }
