/*
 * Astrocartography globe — teaser section.
 *
 * Visual brief: site/v2/_research/globe-design-brief.md (Jony, 2026-05-11)
 *
 * Slab styling mirrors .celeb-feature for visual continuity. Globe SVG is
 * inlined into #globe-teaser .globe-stage by assets/js/globe.js after the
 * reveal completes (body.has-result). Until then this file just paints the
 * outer chrome and a faint placeholder ring inside .globe-stage.
 *
 * v2 changes (2026-05-12):
 *   - .globe-section__inner switched to a relatively-positioned 2-column
 *     grid so the new .globe-panel can slide in next to the globe.
 *   - Added .globe-panel styles (pin click opens this on the right).
 *   - Added .globe-pin hover/focus affordances.
 *   - Pin-pulse animation now targets .pin-glow-outer regardless of which
 *     pin (was hard-coded to a single pin in v1).
 */

  /* Outer slab — sister surface to .celeb-feature + .paywall */
  .globe-section {
    margin: 56px auto 24px;
    max-width: 920px;
    background: linear-gradient(180deg, #F6EEE3 0%, #F1E5D2 100%);
    border: 1px solid rgba(79,54,42,0.18);
    padding: clamp(28px, 4vw, 48px);
    display: grid; gap: 28px;
    box-shadow: 0 24px 50px -28px rgba(79,54,42,.30), 0 1px 2px rgba(79,54,42,0.08);
  }

  .globe-section__head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(79,54,42,0.14);
    padding-bottom: 18px;
  }
  .globe-section__eyebrow {
    font-family: var(--f-label); letter-spacing: 0.22em; text-transform: uppercase;
    font-size: 11px; color: var(--clay-700);
  }
  .globe-section__count {
    font-family: var(--f-italic); font-style: italic; color: var(--ink-700);
    font-size: 14px;
  }

  /* Inner = relative anchor; the side panel positions inside this. */
  .globe-section__inner {
    position: relative;
    display: grid; grid-template-columns: 1fr; gap: 24px;
    align-items: center; justify-items: center;
    text-align: center;
  }

  /* Globe wrapper */
  .globe-stage {
    position: relative;
    width: 360px; height: 360px;
    max-width: 100%;
    touch-action: none;          /* lets us own pointer drag without scroll-jacking */
    -webkit-user-select: none;
    user-select: none;
  }

  /* Both views overlap — CSS crossfades between them based on the
     .is-mode-2d / .is-mode-3d class on .globe-stage. */
  .globe-stage .globe-svg,
  .globe-stage .globe-map-svg {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    display: block;
    transition: opacity 380ms ease;
  }

  /* When in 2D mode the stage stretches to give the map a 2:1 canvas that
     fills the available width (capped so it never dwarfs the section). */
  .globe-stage {
    transition: width 380ms ease, height 380ms ease;
  }
  .globe-stage.is-mode-2d {
    width: min(100%, 760px);
    height: 380px;
  }
  .globe-stage.is-mode-3d .globe-svg     { opacity: 1; pointer-events: auto; }
  .globe-stage.is-mode-3d .globe-map-svg { opacity: 0; pointer-events: none; }
  .globe-stage.is-mode-2d .globe-svg     { opacity: 0; pointer-events: none; }
  .globe-stage.is-mode-2d .globe-map-svg { opacity: 1; pointer-events: auto; }
  .globe-stage.is-mode-2d .globe-svg     { cursor: default; }

  /* ── Mode toggle (GLOBE / MAP segmented control) ────────────────────── */
  .globe-mode-toggle {
    display: inline-flex; align-items: stretch;
    border: 1px solid rgba(79,54,42,0.22);
    background: rgba(250,243,231,0.55);
  }
  .globe-mode-toggle__btn {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 8px 14px;
    font-family: var(--f-label, 'Marcellus SC', serif);
    letter-spacing: 0.18em; text-transform: uppercase;
    font-size: 11px;
    color: var(--ink-700, #4F362A);
    opacity: 0.72;
    cursor: pointer;
    transition: background 0.18s ease, opacity 0.18s ease, color 0.18s ease;
  }
  .globe-mode-toggle__btn + .globe-mode-toggle__btn {
    border-left: 1px solid rgba(79,54,42,0.18);
  }
  .globe-mode-toggle__btn:hover { opacity: 1; }
  .globe-mode-toggle__btn.is-active {
    background: var(--clay-700, #4F362A);
    color: var(--parchment, #EFE7DA);
    opacity: 1;
  }
  .globe-mode-toggle__btn:focus-visible {
    outline: 2px solid var(--clay-500, #8A6A5A);
    outline-offset: 2px;
  }
  .globe-stage:not(.is-ready)::before {
    content: "";
    position: absolute; inset: 8%;
    border-radius: 50%;
    border: 1px dashed rgba(79,54,42,0.20);
    opacity: 0.7;
  }
  .globe-stage .globe-svg {
    width: 100%; height: 100%; display: block;
    cursor: grab;
  }
  .globe-stage .globe-svg:active {
    cursor: grabbing;
  }

  /* Pin pulse — applies to every pin's outer halo */
  @keyframes globe-pin-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.95; }
  }
  .globe-stage .pin-glow-outer {
    animation: globe-pin-pulse 4s ease-in-out infinite;
    transform-origin: center;
  }
  .globe-stage .globe-pin:hover .pin-glow-outer,
  .globe-stage .globe-pin:focus-visible .pin-glow-outer {
    animation-duration: 2.5s;
  }
  /* Focused state — when a city is selected from the right-hand list.
     transform-box: fill-box is critical here: without it, CSS
     transform-origin: center resolves to the SVG VIEWPORT center, not the
     pin's center, so scaling teleports the pin to a different spot on the
     map (e.g. Mumbai's icon visually jumped over to Greenland). With
     fill-box, "center" means the element's own bounding-box center. */
  .globe-stage .globe-pin .pin-glow-outer,
  .globe-stage .globe-pin > circle:nth-child(2),
  .globe-stage .globe-pin use {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.4s cubic-bezier(.2,.7,.2,1);
  }
  .globe-stage .globe-pin.is-focused .pin-glow-outer {
    animation-duration: 1.6s;
    transform: scale(1.6);
  }
  .globe-stage .globe-pin.is-focused > circle:nth-child(2) {
    transform: scale(1.25);
  }
  .globe-stage .globe-pin.is-focused use {
    transform: scale(1.35);
  }
  .globe-stage .globe-map-svg .globe-pin.is-focused .pin-glow-outer {
    transform: scale(2.0);
  }
  .globe-stage .globe-map-svg .globe-pin.is-focused > circle:nth-child(2) {
    transform: scale(1.5);
  }
  .globe-stage .globe-map-svg .globe-pin.is-focused use {
    transform: scale(1.6);
  }
  .globe-stage .globe-pin:focus,
  .globe-stage .globe-pin:focus-visible {
    outline: none;
  }
  .globe-stage .globe-pin:focus-visible > circle:nth-child(2) {
    stroke: var(--clay-700, #4F362A);
    stroke-width: 0.8;
  }

  /* ── Caption (below the globe on desktop, centered) ─────────────────── */
  .globe-section__caption {
    max-width: 560px;
  }
  /* Headline + lead removed per Peter 2026-05-12 — the city list + panel
     description already carries the message; this was just restating it.
     Only the CTA remains in the caption. */
  .globe-section__headline,
  .globe-section__lead {
    display: none;
  }
  .globe-section__headline {
    font-family: var(--f-display);
    font-size: clamp(26px, 4vw, 32px);
    line-height: 1.1; letter-spacing: -0.005em;
    color: var(--ink-900);
    margin: 0 0 12px;
    text-wrap: balance;
  }
  .globe-section__lead {
    font-family: var(--f-italic); font-style: italic;
    color: var(--ink-700);
    font-size: 17px; line-height: 1.5;
    max-width: 48ch; margin: 0 auto 22px;
    text-wrap: balance;
  }

  .globe-section__cta {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    font-family: var(--f-label); letter-spacing: 0.18em; text-transform: uppercase;
    font-size: 12px;
    padding: 16px 26px; min-height: 52px;
    background: var(--clay-700); color: var(--parchment, #EFE7DA);
    border: 0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
  }
  .globe-section__cta:hover { background: #3a2620; }
  .globe-section__cta:active { transform: translateY(1px); }
  .globe-section__cta:focus-visible {
    outline: 2px solid var(--clay-500);
    outline-offset: 3px;
  }

  /* ── City list (right-hand column) ─────────────────────────────────── */
  .globe-cities {
    width: 100%;
    max-width: 320px;
    text-align: left;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(79,54,42,0.32) rgba(79,54,42,0.06);
  }
  .globe-cities::-webkit-scrollbar {
    width: 6px;
  }
  .globe-cities::-webkit-scrollbar-track {
    background: rgba(79,54,42,0.06);
    border-radius: 3px;
  }
  .globe-cities::-webkit-scrollbar-thumb {
    background: rgba(79,54,42,0.32);
    border-radius: 3px;
  }
  .globe-cities::-webkit-scrollbar-thumb:hover {
    background: rgba(79,54,42,0.5);
  }
  .globe-cities__header {
    font-family: var(--f-label, 'Marcellus SC', serif);
    letter-spacing: 0.22em; text-transform: uppercase;
    font-size: 11px; color: var(--clay-700, #4F362A);
    opacity: 0.72;
    padding: 0 2px 10px;
    border-bottom: 1px solid rgba(79,54,42,0.14);
    margin-bottom: 6px;
  }
  .globe-cities__list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column;
  }
  .globe-cities__item + .globe-cities__item {
    border-top: 1px solid rgba(79,54,42,0.08);
  }
  .globe-cities__btn {
    display: flex; align-items: center; gap: 14px;
    width: 100%;
    appearance: none;
    background: transparent;
    border: 0;
    padding: 14px 6px;
    text-align: left;
    cursor: pointer;
    color: inherit;
    transition: background 0.16s ease;
  }
  .globe-cities__btn:hover { background: rgba(79,54,42,0.04); }
  .globe-cities__btn.is-active { background: rgba(79,54,42,0.07); }
  .globe-cities__btn:focus-visible {
    outline: 2px solid var(--clay-500, #8A6A5A);
    outline-offset: -2px;
  }
  .globe-cities__dot {
    flex: 0 0 auto;
    width: 8px; height: 8px; border-radius: 50%;
    margin-top: 6px;
    align-self: flex-start;
  }
  .globe-cities__dot.is-supportive { background: #E8B43F; box-shadow: 0 0 0 3px rgba(232,180,63,0.18); }
  .globe-cities__dot.is-demanding  { background: #9A4A50; box-shadow: 0 0 0 3px rgba(154,74,80,0.18); }
  .globe-cities__text {
    flex: 1 1 auto;
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
  }
  .globe-cities__eyebrow {
    font-family: var(--f-label, 'Marcellus SC', serif);
    letter-spacing: 0.16em; text-transform: uppercase;
    font-size: 10px; color: var(--clay-700, #4F362A);
    opacity: 0.68;
  }
  .globe-cities__city {
    font-family: var(--f-display, 'Marcellus', serif);
    font-size: 19px; line-height: 1.15;
    color: var(--ink-900, #2C1B14);
  }
  .globe-cities__country {
    font-family: var(--f-italic, 'Spectral', serif);
    font-style: italic;
    font-size: 13px; color: var(--ink-700);
    opacity: 0.75;
  }
  .globe-cities__chev {
    font-family: var(--f-label, 'Marcellus SC', serif);
    color: var(--clay-700);
    opacity: 0.45;
    font-size: 14px;
    margin-left: 8px;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  .globe-cities__btn:hover .globe-cities__chev,
  .globe-cities__btn.is-active .globe-cities__chev {
    opacity: 0.9; transform: translateX(3px);
  }

  /* ── Pin description panel ──────────────────────────────────────────── */
  .globe-panel {
    position: absolute;
    /* Sits roughly in line with the top third of the globe. */
    top: 110px; right: 0;
    width: 280px; max-width: 92%;
    background: #FAF3E7;
    border: 1px solid rgba(79,54,42,0.18);
    padding: 22px 22px 22px 24px;
    text-align: left;
    box-shadow: 0 18px 36px -18px rgba(79,54,42,0.32);
    opacity: 0;
    transform: translate(12px, -50%);
    pointer-events: none;
    transition: opacity 220ms ease, transform 320ms cubic-bezier(.2,.7,.2,1);
    z-index: 2;
  }
  .globe-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, -50%);
  }
  /* In 2D map mode the section's inner is much taller than in 3D (map +
     cities + caption stack vertically), so a vertically-centered panel
     drifts down to the cities-list zone and visually detaches from the
     pin the user just tapped. Anchor the panel to the top-right corner
     of the map area instead. The mobile media query below still wins on
     phones (position: static, bottom-sheet pattern). */
  .globe-stage.is-mode-2d ~ .globe-panel {
    top: 20px;
    right: 20px;
    transform: translate(12px, 0);
  }
  .globe-stage.is-mode-2d ~ .globe-panel.is-open {
    transform: translate(0, 0);
  }
  .globe-panel__close {
    position: absolute; top: 10px; right: 10px;
    width: 28px; height: 28px;
    background: transparent;
    border: 1px solid rgba(79,54,42,0.22);
    border-radius: 50%;
    color: var(--clay-700, #4F362A);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.18s ease;
  }
  .globe-panel__close:hover { background: rgba(79,54,42,0.06); }
  .globe-panel__eyebrow {
    font-family: var(--f-label, 'Marcellus SC', serif);
    letter-spacing: 0.18em; text-transform: uppercase;
    font-size: 10px; color: var(--clay-700, #4F362A);
    margin-bottom: 10px;
  }
  .globe-panel__title {
    font-family: var(--f-display, 'Marcellus', serif);
    font-size: 24px; line-height: 1.1;
    color: var(--ink-900, #1F140F);
    margin: 0 0 2px;
  }
  .globe-panel__country {
    font-family: var(--f-italic, 'Spectral', serif);
    font-style: italic;
    font-size: 13px;
    color: var(--ink-700, #4F362A);
    margin-bottom: 14px;
    opacity: 0.75;
  }
  .globe-panel__body {
    font-family: var(--f-italic, 'Spectral', serif);
    font-style: italic;
    font-size: 14px; line-height: 1.55;
    color: var(--ink-700, #4F362A);
    margin: 0 0 16px;
  }
  .globe-panel__support {
    font-family: var(--f-label, 'Marcellus SC', serif);
    letter-spacing: 0.18em; text-transform: uppercase;
    font-size: 10px;
    padding-top: 12px;
    border-top: 1px solid rgba(79,54,42,0.14);
  }
  .globe-panel__support.is-supportive { color: #6B5316; }
  .globe-panel__support.is-demanding  { color: #6B2730; }

  /* ── Reduce-motion ─────────────────────────────────────────────────── */
  @media (prefers-reduced-motion: reduce) {
    .globe-stage .pin-glow-outer { animation: none; }
  }

  /* ── Desktop layout: panel sits beside globe ───────────────────────── */
  @media (min-width: 760px) {
    .globe-section__inner {
      grid-template-columns: minmax(0, 380px) 1fr;
      align-items: center;
      justify-items: start;
      text-align: left;
      column-gap: 32px;
    }
    .globe-stage { justify-self: center; grid-column: 1; grid-row: 1; }
    .globe-cities { grid-column: 2; grid-row: 1; justify-self: start; align-self: center; }
    .globe-section__caption { grid-column: 1 / -1; grid-row: 2; justify-self: center; text-align: center; }
    /* In 2D mode the stage breaks out of its column so the map can use
       the full section width; the city list drops below it. */
    .globe-stage.is-mode-2d {
      grid-column: 1 / -1;
      grid-row: 1;
      justify-self: stretch;
      width: 100%;
      max-width: 760px;
      margin: 0 auto;
    }
    .globe-stage.is-mode-2d ~ .globe-cities {
      grid-column: 1 / -1;
      grid-row: 2;
      justify-self: center;
      max-width: 520px;
      width: 100%;
    }
    .globe-stage.is-mode-2d ~ .globe-section__caption {
      grid-row: 3;
    }
    .globe-section__caption { grid-column: 1 / -1; justify-self: center; text-align: center; }
    .globe-panel {
      top: 50%;
      right: 0;
      transform: translate(12px, -50%);
    }
    .globe-panel.is-open {
      transform: translate(0, -50%);
    }
    /* In 2D map mode the inner becomes much taller (map + cities + caption
       stack vertically), so a top:50% panel falls between the map and the
       cities list and reads as visually disconnected from the pin.
       Re-anchor the panel to the TOP-RIGHT of the inner (= top-right of
       the map area) as a floating corner overlay. */
    .globe-stage.is-mode-2d ~ .globe-panel {
      top: 20px;
      right: 20px;
      transform: translate(12px, 0);
    }
    .globe-stage.is-mode-2d ~ .globe-panel.is-open {
      transform: translate(0, 0);
    }
  }

  /* ── Mobile ─────────────────────────────────────────────────────────── */
  @media (max-width: 600px) {
    .globe-section {
      margin: 40px auto 20px;
      padding: clamp(20px, 5vw, 32px);
    }
    .globe-stage {
      width: 280px; height: 280px;
    }
    .globe-section__head { gap: 8px; }
    .globe-section__headline { font-size: clamp(22px, 6vw, 26px); }
    .globe-section__lead { font-size: 16px; }
    .globe-section__cta { width: 100%; }
    /* On mobile, panel slides up from the bottom of the section rather
       than sitting beside the globe (no room). */
    .globe-panel {
      position: static;
      transform: translateY(8px);
      width: 100%;
      margin-top: 12px;
    }
    .globe-panel.is-open {
      transform: translateY(0);
    }
  }
