/* ============================================
   STORYTELLING PAGE (gallery-first)
   Loaded only by storytelling.html, on top of style.css, so no other
   page is affected. A tile grid at the top; each tile anchors to a
   detail section below with a description and a CTA.
============================================ */

/* Respect reduced motion: no smooth scrolling, no pulse. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Gallery ---------- */
/* The container, its edges, the wide-screen steps and the section spacing are the shared ones (css/layout-tokens.css). */
.st-gallery-section {
  background: #fff;
  padding: 128px 0 clamp(64px, 9vw, 110px);
  outline: none;
}
.st-gallery-section:has(~ .st-stories .st-story:not([hidden])) { padding-bottom: 0; }   /* the first story brings its own gap */
.st-gallery-section .section-inner { container-type: inline-size; }                        /* so the cards can be sized from the container (cqw) */
.st-heading {
  /* Same graffiti heading as the Work and Events pages, centred. */
  font-family: var(--font-display);
  font-weight: normal;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.9;
  letter-spacing: 0.5px;
  text-transform: none;
  color: var(--blue);
  text-align: center;
  margin: 0 0 clamp(28px, 4vw, 48px);
}
/* Filter tabs: quiet text tabs with counts, active one in navy. */
.st-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; margin: 0 0 26px; }
.st-filters[hidden] { display: none; }
.st-filter {
  background: none;
  border: none;
  padding: 4px 0;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: rgba(12, 0, 84, 0.42);
  cursor: pointer;
  transition: color 0.2s ease;
}
.st-filter sup { font-size: 0.62em; margin-left: 3px; font-weight: 600; }
.st-filter:hover { color: var(--blue); }
.st-filter.is-active { color: var(--navy); }
.st-filter:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
.st-gallery li[hidden], .st-story[hidden] { display: none; }

/* The pale panel (the same one the project pages use) holds the cards. Cards are a fixed share of the container's width, laid out
   in rows that start on the left: a last row that is not full starts at the left edge, and a filter that shows only a few cards gets a narrower box. */
.st-gallery {
  --cols: 1;                                   /* 1 phone, 2 tablet, 3 laptop and desktop, 4 on very wide screens */
  --gap: clamp(16px, 2vw, 24px);
  --pad: clamp(16px, 3vw, 36px);
  list-style: none;
  margin: 0 auto;
  padding: var(--pad);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: stretch;
  gap: var(--gap);
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--pale);
  border-radius: 32px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.st-gallery.is-switching { opacity: 0; transform: translateY(8px); }                       /* filter changes fade out and back in */
.st-gallery > li {
  --w: calc((100cqw - 2 * var(--pad) - (var(--cols) - 1) * var(--gap)) / var(--cols));
  flex: 0 0 var(--w);
  width: var(--w);
  min-width: 0;
  display: flex;                               /* every card in a row is as tall as the tallest */
}
@media (min-width: 640px)  { .st-gallery { --cols: 2; } }
@media (min-width: 1100px) { .st-gallery { --cols: 3; } }
@media (min-width: 1600px) { .st-gallery { --cols: 4; } }

/* Same card as the rest of the site: shared corners and the even 3D layer on all four sides, a colour change on hover. */
.st-tile {
  --edge: #b6caf5;
  --edge-deep: #7fa2ee;
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 16px;
  color: var(--navy);
  text-decoration: none;
  border-radius: var(--card-radius, 20px);
  background: #fff;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.92),
    0 0 0 1px var(--edge), 0 0 0 2px var(--edge), 0 0 0 3px var(--edge-deep),
    0 16px 26px -8px rgba(12, 0, 84, 0.3);
  transition: background-color 0.3s ease, translate 0.15s ease;
}
.st-tile:hover,
.st-tile:focus-visible { background: var(--periwinkle); --edge: #94b2f1; --edge-deep: #5d8aeb; }
.st-tile:active {
  translate: 0 2px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.92), 0 0 0 1px var(--edge-deep), 0 8px 12px -6px rgba(12, 0, 84, 0.3);
}
.st-tile:focus-visible { outline: 3px solid var(--blue); outline-offset: 6px; }

/* One picture shape on every card. Compound selector so these outrank .img-placeholder's own sizing. */
.st-tile .st-tile-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin: 0;
  border-radius: 12px;
}
.st-pill { margin: 0; transition: background-color 0.25s ease, color 0.25s ease; }
.st-tile:hover .st-pill,
.st-tile:focus-visible .st-pill { background: var(--blue); color: #fff; }
.st-tile-title {
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
}

/* Short description and "Read more" only on the default "All" view. */
.st-tile-desc, .st-tile-more { display: none; }
.st-gallery-section:not([data-filter]) .st-tile-desc,
.st-gallery-section[data-filter="all"] .st-tile-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.86rem;
  line-height: 1.45;
  color: rgba(12, 0, 84, 0.65);
}
.st-gallery-section:not([data-filter]) .st-tile-more,
.st-gallery-section[data-filter="all"] .st-tile-more {
  display: inline;
  margin-top: auto;                            /* pinned to the bottom of every card, so they line up across a row */
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}
.st-tile:hover .st-tile-more { color: var(--blue); }

/* ---------- Story sections: rounded panels in the shared container, pale blue and white in turn ---------- */
.st-stories:has(.st-story:not([hidden])) { padding-bottom: clamp(64px, 9vw, 110px); }
.st-story {
  position: relative;
  width: min(var(--container, 1180px), 100% - 48px);
  margin: var(--section-gap, 120px) auto 0;
  padding: clamp(28px, 4vw, 56px) clamp(20px, 3.5vw, 52px);
  border-radius: 32px;
  box-sizing: border-box;
  /* Clears the floating nav pill. */
  scroll-margin-top: 84px;
  outline: none;
}
.st-story--pale { background: var(--pale); }
.st-story--white { background: #fff; box-shadow: inset 0 0 0 1.5px var(--periwinkle); }
.st-story > .section-inner { max-width: none; margin: 0; padding: 0; }   /* the panel is the container */

/* Soft pulse shown for about a second after arriving from a tile. */
.st-story::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 82, 255, 0.14);
  opacity: 0;
  pointer-events: none;
}
.st-story.is-highlight::before { animation: st-pulse 1s ease-out; }
@keyframes st-pulse { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes st-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.st-story:not([hidden]), .st-gallery > li:not([hidden]) { animation: st-in 0.4s ease both; }
@media (prefers-reduced-motion: reduce) {
  .st-story.is-highlight::before { animation: none; }
  .st-story:not([hidden]), .st-gallery > li:not([hidden]) { animation: none; }
  .st-gallery { transition: none; }
}

.st-story-inner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4.5vw, 64px);
  align-items: center;
}
.st-story--reverse .st-story-media { order: 2; }
.st-story-media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin: 0;
  border-radius: var(--card-radius, 20px);
}

/* Everything in a story is left-aligned, on every screen size. */
.st-story-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; text-align: left; }
.st-story .st-pill { align-self: flex-start; }
.st-story .st-story-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.1;
  color: var(--navy);
  margin: 0;
  text-align: left;
}
.st-story-desc {
  font-size: 1.05rem;
  line-height: 1.6;
  color: rgba(12, 0, 84, 0.78);
  margin: 0;
  max-width: 560px;
  text-align: left;
}
.st-inline-link {
  font-weight: 600;
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.st-inline-link:hover { color: var(--navy); }

.st-story-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; align-self: flex-start; gap: 12px 16px; margin-top: 4px; }

/* Rounded pill CTA: no border, no shadow. */
.st-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 0.25s ease, transform 0.25s ease;
}
.st-cta svg { width: 18px; height: 18px; transition: transform 0.25s ease; }
/* One arrow per button: the built-in pill arrow is off, the icon arrow stays. */
a.st-cta[target="_blank"]::after { content: none; }
.st-cta:hover { background: var(--navy); transform: translateY(-2px); }
.st-cta:hover svg { transform: translate(2px, -2px); }
/* One primary button (blue) and one secondary (outline), like the rest of the site */
.st-cta + .st-cta { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.st-cta + .st-cta:hover { background: var(--navy); color: #fff; }
.st-cta:focus-visible,
.st-back:focus-visible,
.st-inline-link:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }

/* Link still to come: clearly disabled, easy to find via data-link-tbc. */
.st-cta--disabled,
.st-cta[data-link-tbc="true"] {
  background: rgba(12, 0, 84, 0.12);
  color: rgba(12, 0, 84, 0.5);
  cursor: not-allowed;
  pointer-events: none;
}
.st-tbc-note { font-size: 0.82rem; font-weight: 600; color: rgba(12, 0, 84, 0.55); }

.st-back {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.st-back:hover { color: var(--blue); }

/* ---------- Mobile: image first, then text; one column of larger cards and comfortable type ---------- */
@media (max-width: 800px) {
  .st-story-inner { grid-template-columns: 1fr; }
  .st-story--reverse .st-story-media { order: 0; }
  .st-story-media { max-width: 100%; }
}
@media (max-width: 639px) {
  .st-gallery { --gap: 21px; }   /* was 16px: a little more air between the tiles on phones */
  .st-story:not([hidden]) ~ .st-story:not([hidden]) { margin-top: 72px; }   /* was 56px: each story reads as separate from the next */
  .st-tile { gap: 12px; padding: 14px 14px 18px; }
  .st-tile-title { font-size: 1.15rem; }
  .st-gallery-section[data-filter="all"] .st-tile-desc,
  .st-gallery-section:not([data-filter]) .st-tile-desc { font-size: 0.97rem; line-height: 1.5; }
  .st-gallery-section[data-filter="all"] .st-tile-more,
  .st-gallery-section:not([data-filter]) .st-tile-more { font-size: 0.97rem; }
  .st-pill { font-size: 0.875rem; }               /* no text under 14px on phones */
  .st-filter sup { font-size: 0.875rem; }
  .st-story .st-story-title { font-size: 1.9rem; }
  .st-story-desc { font-size: 1.02rem; }
}
