/* Geo Story — full-screen scrollytelling map. Fonts reused from lovelanghe. */

@font-face {
  font-family: "Tiempos Headline";
  src: url("./fonts/TiemposHeadlineWeb-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Tiempos Text";
  src: url("./fonts/TiemposTextWeb-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Tiempos Text";
  src: url("./fonts/TiemposTextWeb-RegularItalic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Founders Text";
  src: url("./fonts/FoundersGroteskTextWeb-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Founders Condensed";
  src: url("./fonts/FoundersGroteskCondensedWeb-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --gs-paper: #f7f4ec;
  --gs-ink: #1d1a16;
  --gs-muted: #6a6055;
  --gs-accent: #A3225E;
  --gs-vini: #A3225E;
  --gs-nocciole: #a9742f;
  --gs-formaggi: #cda53b;
  --gs-frutta: #4a7c3f;
  --gs-condimenti: #c2561f;
  --gs-rail-width: clamp(320px, 32vw, 440px);
}

html,
body.geo-story {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #11100e;
  color: var(--gs-ink);
  font-family: "Tiempos Text", Georgia, serif;
}

.geo-story__map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

.geo-story__story {
  position: relative;
  z-index: 1;
}

.geo-story__step {
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding: 12vh 6vw;
  box-sizing: border-box;
  opacity: 0.2;
  transition: opacity 0.45s ease;
}

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

.geo-story__step.is-left {
  justify-content: flex-start;
  /* Clear the left chapter rail so previously-left cards sit beside it,
     not under it (two-column feel). Reset on mobile, where the rail is a
     top bar. */
  padding-left: calc(var(--gs-rail-width) + 3vw);
}

.geo-story__step.is-right {
  justify-content: flex-end;
}

.geo-story__step.is-center {
  justify-content: center;
}

.geo-story__card {
  max-width: 380px;
  padding: 1.75rem 1.9rem;
  background: var(--gs-paper);
  border-radius: 3px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.4);
}

.geo-story__step--intro .geo-story__card,
.geo-story__step--closing .geo-story__card,
.geo-story__step--hub .geo-story__card {
  max-width: 560px;
  text-align: center;
}

/* Full-bleed cover: the photo reaches the card edges (negative margins cancel
   the card padding), top corners rounded to match the card so the crest on
   town cards is never clipped (no overflow:hidden on the card). */
.geo-story__media {
  display: block;
  width: calc(100% + 3.8rem);
  height: auto;
  margin: -1.75rem -1.9rem 1.1rem;
  border-radius: 3px 3px 0 0;
}

/* Normal in-flow product cards: force a consistent 5:3 landscape crop so the
   varied source photos (landscape, square) read uniformly down the story. */
.geo-story__step--text .geo-story__media {
  aspect-ratio: 5 / 3;
  object-fit: cover;
}

.geo-story__eyebrow {
  margin: 0 0 0.5rem;
  font-family: "Founders Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gs-accent);
}

.geo-story__title {
  margin: 0 0 0.9rem;
  font-family: "Tiempos Headline", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.08;
}

.geo-story__step--intro .geo-story__title,
.geo-story__step--closing .geo-story__title,
.geo-story__step--hub .geo-story__title {
  font-size: clamp(2rem, 6vw, 3.1rem);
}

.geo-story__body {
  font-size: 1.05rem;
  line-height: 1.55;
  color: #2a261f;
}

.geo-story__body strong {
  font-weight: 500;
}

/* Payoff: an evocative one-line tagline under a company card's title. */
.geo-story__payoff {
  margin: -0.2rem 0 0.85rem;
  font-family: "Tiempos Text", Georgia, serif;
  font-style: italic;
  font-size: 1.12rem;
  line-height: 1.3;
  color: var(--gs-muted);
}

/* On the dark photo cards (rail + mobile cover) the payoff reads light. */
.geo-story__chapter .geo-story__payoff,
.geo-story__cover .geo-story__payoff {
  color: rgba(247, 244, 236, 0.92);
}

/* The company card description (rail, peek, mobile cover) is set in Founders
   Grotesk Text — a cleaner grotesque against the photo, distinct from the
   Tiempos serif used in the in-flow text/town/quote cards. */
.geo-story__chapter .geo-story__body,
.geo-story__chapter-peek .geo-story__body,
.geo-story__cover-body .geo-story__body {
  font-family: "Founders Text", "Helvetica Neue", sans-serif;
}

.geo-story__km0 {
  margin: 1.2rem 0 0;
  padding: 0 0 0 1rem;
  border-left: 3px solid var(--gs-nocciole);
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--gs-muted);
}

/* --- Quote card ----------------------------------------------------------
   A company's closing km0 reflection: no card chrome, large display type set
   straight over the map. A soft radial scrim keeps it legible on any terrain.
   Stays inside the company chapter (rail visible) — desktop clears the rail. */
.geo-story__step--quote {
  padding-left: calc(var(--gs-rail-width) + 3vw);
}

.geo-story__quote {
  margin: 0;
  max-width: 640px;
  padding: 3.6rem 3.2rem;
  text-align: center;
  background: radial-gradient(ellipse closest-side at center, rgba(247, 244, 236, 0.98) 0%, rgba(247, 244, 236, 0.72) 55%, rgba(247, 244, 236, 0) 100%);
}

.geo-story__quote .geo-story__eyebrow {
  margin-bottom: 0.8rem;
  color: var(--gs-accent);
}

.geo-story__quote .geo-story__title {
  margin: 0 0 1.2rem;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  color: var(--gs-accent);
}

.geo-story__quote .geo-story__body {
  max-width: 42ch;
  margin: 0 auto;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-style: italic;
  line-height: 1.55;
  color: var(--gs-ink);
}

/* --- Town card -----------------------------------------------------------
   Editorial card for `town` stops: the comune crest (stemma) protrudes,
   rounded, from the top edge; a link points to the town on its origin site.
   Crest + name + link come from the network towns projection (functions.php). */
.geo-story__town {
  position: relative;
  margin-top: 2.6rem;
  padding-top: 2.6rem;
  text-align: center;
}

.geo-story__town-crest {
  position: absolute;
  top: -2.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5.2rem;
  height: 5.2rem;
}

.geo-story__town-crest img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.geo-story__town .geo-story__body {
  text-align: center;
}

.geo-story__town-link {
  display: inline-block;
  margin-top: 1.1rem;
  font-family: "Founders Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gs-accent);
}

.geo-story__town-link:hover {
  text-decoration: underline;
}

/* CTA — a filled pill action (e.g. the hub card's "book a tasting" link). */
.geo-story__cta {
  display: inline-block;
  margin-top: 1.4rem;
  padding: 0.7rem 1.35rem;
  font-family: "Founders Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gs-paper);
  background: var(--gs-accent);
  border-radius: 999px;
  transition: background-color 0.2s ease;
}

.geo-story__cta:hover {
  background: var(--gs-ink);
}

/* --- Intro card chrome (pilot-only) --------------------------------------
   The LoveLanghe Shop wordmark hung on the top edge (same straddle idea as the
   town crest, but a wide mark sized by max-height), and the funder logo strip
   (EU · PSR · Regione · Repubblica) under the body. */
.geo-story__intro {
  position: relative;
  padding-top: 2.4rem;
}

.geo-story__intro-logo {
  position: absolute;
  top: -1.3rem;
  left: 50%;
  transform: translateX(-50%);
}

.geo-story__intro-logo img {
  display: block;
  max-height: 2.6rem;
  width: auto;
}

.geo-story__funders {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.4rem;
  margin-top: 1.7rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(29, 26, 22, 0.12);
}

.geo-story__funders img {
  display: block;
  height: 2.2rem;
  width: auto;
  object-fit: contain;
}

/* Company points are rendered as a Mapbox `circle` GL layer (see story.js):
   colored by category, scaled when active, dimmed when another is active.
   The --gs-* palette below feeds that layer (read via getComputedStyle). */

/* --- Chapter rail --------------------------------------------------------
   Persistent company panel: a full-height rail on the left (desktop) /
   sticky collapsing header up top (mobile). Driven by the scroll engine
   (story.js): filled on a company opener (hero/card stop), kept across its
   beats, swapped at the next company, hidden on intro/closing. The in-flow
   opener card is suppressed — the rail is its presentation. Skin = photo
   cover + scrim + light text (Option A), tinted per category. */
.geo-story__step--hero .geo-story__card,
.geo-story__step--card .geo-story__card {
  display: none;
}

.geo-story__chapter {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--gs-rail-width);
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--gs-ink);
  color: var(--gs-paper);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
  transition: opacity 0.5s ease;
}

/* Hidden on steps with no chapter (intro / closing) — a clean title screen. */
body.gs-no-chapter .geo-story__chapter,
body.gs-no-chapter .geo-story__chapter-bar,
body.gs-no-chapter .geo-story__chapter-peek {
  opacity: 0;
  pointer-events: none;
}

.geo-story__chapter-item {
  flex: none;
  border-bottom: 1px solid rgba(247, 244, 236, 0.1);
}

.geo-story__chapter-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.95rem 1.4rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: "Founders Text", "Helvetica Neue", sans-serif;
  max-height: 6rem;
  overflow: hidden;
  transition: background 0.25s ease, max-height 0.6s ease, padding 0.6s ease, opacity 0.4s ease;
}

.geo-story__chapter-head:hover,
.geo-story__chapter-item.is-open .geo-story__chapter-head {
  background: rgba(247, 244, 236, 0.06);
}

/* The open chapter collapses its own row (smoothly, to avoid the switch hiccup)
   on desktop so the card fills the height. Re-shown in the mobile drawer. */
.geo-story__chapter-item.is-open .geo-story__chapter-head {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  pointer-events: none;
}

.geo-story__chapter-num {
  flex: none;
  font-family: "Founders Condensed", "Arial Narrow", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: rgba(247, 244, 236, 0.55);
}

.geo-story__chapter-name {
  flex: 1 1 auto;
  font-size: 1rem;
  line-height: 1.2;
}

.geo-story__chapter-town {
  flex: none;
  max-width: 42%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.78rem;
  color: rgba(247, 244, 236, 0.55);
}

.geo-story__chapter-panel {
  position: relative;
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.7s ease-in-out, opacity 0.7s ease-in-out;
}

.geo-story__chapter-item.is-open .geo-story__chapter-panel {
  height: 88vh;
  opacity: 1;
}

.geo-story__chapter-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.geo-story__chapter-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(17, 16, 14, 0.95) 0%,
    rgba(17, 16, 14, 0.6) 50%,
    rgba(17, 16, 14, 0.2) 100%
  );
}

.geo-story__chapter-text {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  padding: 1.6rem 1.5rem 1.9rem;
}

.geo-story__chapter .geo-story__eyebrow {
  color: var(--gs-paper);
  opacity: 0.82;
}

.geo-story__chapter .geo-story__title {
  margin: 0 0 0.6rem;
  color: var(--gs-paper);
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
}

.geo-story__chapter .geo-story__body {
  font-size: 0.98rem;
  color: rgba(247, 244, 236, 0.9);
}

.geo-story__chapter .geo-story__km0 {
  color: rgba(247, 244, 236, 0.8);
  border-left-color: var(--chapter-accent, var(--gs-paper));
}

.geo-story__chapter-bar,
.geo-story__chapter-peek,
.geo-story__cover {
  display: none;
}

@media (max-width: 768px) {
  .geo-story__step {
    justify-content: center;
    padding: 9vh 5vw;
  }

  .geo-story__step.is-left {
    padding-left: 5vw;
  }

  .geo-story__card {
    max-width: 100%;
  }

  /* Chapter index -> off-canvas drawer, opened by the bar trigger. */
  .geo-story__chapter {
    width: min(86vw, 360px);
    padding-top: 3rem;
    transform: translateX(-100%);
    transition: transform 0.45s ease-in-out;
    box-shadow: 6px 0 40px rgba(0, 0, 0, 0.5);
  }

  body.gs-drawer-open .geo-story__chapter {
    transform: translateX(0);
  }

  .geo-story__chapter-bar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 1.1rem;
    background: rgba(17, 16, 14, 0.9);
    color: var(--gs-paper);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: opacity 0.4s ease;
  }

  .geo-story__chapter-toggle {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--gs-paper);
    font-family: "Founders Condensed", "Arial Narrow", sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .geo-story__chapter-current {
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
  }

  /* Re-show the active row in the drawer (only collapsed on the desktop rail). */
  .geo-story__chapter-item.is-open .geo-story__chapter-head {
    max-height: 6rem;
    padding: 0.95rem 1.4rem;
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile peek — tap the bar label to reveal the current company's card;
     it auto-updates while you scroll through the chapters. */
  .geo-story__chapter-peek {
    position: fixed;
    top: 2.9rem;
    left: 0;
    right: 0;
    z-index: 2;
    display: block;
    height: 0;
    overflow: hidden;
    background: var(--gs-ink);
    color: var(--gs-paper);
    transition: height 0.5s ease-in-out;
  }

  body.gs-peek-open .geo-story__chapter-peek {
    height: 62vh;
  }

  .geo-story__chapter-peek::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
      to top,
      rgba(17, 16, 14, 0.95) 0%,
      rgba(17, 16, 14, 0.6) 50%,
      rgba(17, 16, 14, 0.2) 100%
    );
  }

  .geo-story__chapter-peek .geo-story__eyebrow,
  .geo-story__chapter-peek .geo-story__title {
    color: var(--gs-paper);
  }

  .geo-story__chapter-peek .geo-story__body {
    color: rgba(247, 244, 236, 0.9);
  }

  .geo-story__chapter-peek .geo-story__km0 {
    color: rgba(247, 244, 236, 0.8);
    border-left-color: var(--gs-paper);
  }

  /* Scroll-linked company cover — only where scroll-driven animations exist.
     The rise from the bottom comes free from `position: sticky`; the
     view-timeline collapses the cover into its title bar as the section
     reaches the top. Falls back to the JS peek (#chapter-peek) otherwise.
     v1 — tune heights / keyframe ranges in-browser. */
  @supports (animation-timeline: view()) {
    .geo-story__step--hero,
    .geo-story__step--card {
      display: block;
      view-timeline-name: --company;
      view-timeline-axis: block;
    }

    .geo-story__chapter-peek {
      display: none;
    }

    .geo-story__cover {
      display: block;
      position: sticky;
      top: 2.9rem;
      overflow: hidden;
      background: var(--gs-ink);
      color: var(--gs-paper);
    }

    .geo-story__cover-media {
      position: absolute;
      inset: 0;
      z-index: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .geo-story__cover::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 1;
      background: linear-gradient(
        to bottom,
        rgba(17, 16, 14, 0.9) 0%,
        rgba(17, 16, 14, 0.25) 32%,
        rgba(17, 16, 14, 0.88) 100%
      );
    }

    .geo-story__cover-bar {
      position: relative;
      z-index: 2;
      padding: 0.7rem 1.2rem;
    }

    .geo-story__cover-bar .geo-story__title {
      margin: 0;
      color: var(--gs-paper);
      font-size: 1.5rem;
      line-height: 1.15;
    }

    .geo-story__cover-body {
      position: relative;
      z-index: 2;
      max-height: 70vh;
      overflow: hidden;
      padding: 0 1.2rem 1.7rem;
      animation: gs-cover-collapse linear both;
      animation-timeline: --company;
    }

    .geo-story__cover-body .geo-story__eyebrow {
      color: var(--gs-paper);
      opacity: 0.82;
    }

    .geo-story__cover-body .geo-story__body {
      color: rgba(247, 244, 236, 0.9);
    }

    .geo-story__cover-body .geo-story__km0 {
      color: rgba(247, 244, 236, 0.8);
      border-left-color: var(--gs-paper);
    }

    @keyframes gs-cover-collapse {
      0%, 45% { max-height: 70vh; opacity: 1; }
      100% { max-height: 0; opacity: 0; padding-bottom: 0; }
    }
  }
}
