/* ==========================================================================
   SurfCheck.nz — Stories page (index + modal reader)

   Stories distinguishes itself from Learn:
     - Learn = how-to-surf content (our own articles + curated YouTube)
     - Stories = editorial / news / travelogue / culture (live from WordPress)

   Architecture:
     - /stories/ index lists posts client-side from WP REST API
     - Clicking a card opens a modal reader on the SAME page (no nav away)
     - Modal fetches the full post by slug + renders with SurfCheck styling
     - "Read on Aotearoa Surf →" link to the canonical WP URL
   ========================================================================== */

/* ── Hero ──────────────────────────────────────────────────────────────── */
.stories-hero-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 360px at 12% 30%, rgba(232,184,75,0.10) 0%, transparent 60%),
    radial-gradient(700px 360px at 92% 70%, rgba(95,183,255,0.10) 0%, transparent 60%);
}
.stories-hero-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(45deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.5;
  pointer-events: none;
}
.stories-hero {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--gap-7) var(--gap-5) var(--gap-6);
}
.stories-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sand);
  margin-bottom: var(--gap-3);
}
.stories-hero-title {
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 1.0;
  margin: 0 0 var(--gap-3);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 22ch;
}
.stories-hero-subtitle {
  font-size: clamp(16px, 1.7vw, 19px);
  color: var(--text-2);
  margin: 0;
  max-width: 64ch;
  line-height: 1.55;
}

/* ── Filter + search controls ──────────────────────────────────────────── */
.stories-section {
  max-width: var(--max-w);
  margin: var(--gap-6) auto 0;
  padding: 0 var(--gap-5);
}
.stories-controls {
  display: grid;
  gap: var(--gap-3);
  margin-bottom: var(--gap-5);
}
.stories-search {
  position: relative;
}
.stories-search input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
}
.stories-search input::placeholder { color: var(--text-3); }
.stories-search input:focus {
  outline: none;
  border-color: rgba(95,183,255,0.5);
  background: rgba(255,255,255,0.06);
}
.stories-search::before {
  content: "🔍";
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}
.stories-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-2);
  align-items: center;
}

/* ── Featured story (top card) ─────────────────────────────────────────── */
.featured-story {
  display: grid;
  grid-template-columns: 1fr;
  border-radius: var(--r-3);
  overflow: hidden;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border-2);
  margin-bottom: var(--gap-5);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
  padding: 0;
}
.featured-story:hover {
  border-color: rgba(232,184,75,0.4);
  transform: translateY(-2px);
}
@media (min-width: 800px) {
  .featured-story { grid-template-columns: 5fr 4fr; }
}
.featured-story-img {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-2);
}
@media (min-width: 800px) {
  .featured-story-img { aspect-ratio: auto; height: 100%; min-height: 360px; }
}
.featured-story-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.featured-story:hover .featured-story-img img { transform: scale(1.03); }
.featured-story-body {
  padding: var(--gap-5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--gap-3);
}
.featured-story-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sand);
}
.featured-story-title {
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--text);
}
.featured-story-excerpt {
  font-size: 15.5px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.featured-story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--gap-2);
}

/* ── Story cards grid ──────────────────────────────────────────────────── */
.stories-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-4);
}
@media (min-width: 600px) { .stories-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .stories-grid { grid-template-columns: repeat(3, 1fr); } }

.story-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-3);
  overflow: hidden;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
  padding: 0;
}
.story-card:hover { transform: translateY(-2px); border-color: var(--border-2); }
.story-card-img {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-2);
}
.story-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.story-card:hover .story-card-img img { transform: scale(1.04); }
.story-card-body {
  padding: var(--gap-4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.story-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.story-card-cat { color: var(--sand); }
.story-card-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}
.story-card-excerpt {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card hidden until "Show more" expands (uses same is-overflow pattern as Learn) */
.stories-grid:not(.show-all) > .story-card.is-overflow { display: none; }

.stories-loading,
.stories-error {
  padding: var(--gap-6);
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
  font-style: italic;
  grid-column: 1 / -1;
}
.stories-error { color: var(--poor); font-style: normal; }

/* ── Story modal reader ────────────────────────────────────────────────── */
.story-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: rgba(4, 12, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.story-modal.open { display: block; }
.story-modal-inner {
  position: relative;
  max-width: 920px;
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
}
@media (min-width: 720px) {
  .story-modal-inner {
    margin: var(--gap-5) auto var(--gap-7);
    min-height: 0;
    border-radius: var(--r-3);
    overflow: hidden;
  }
}
/* Close button sits at the TOP-RIGHT of the modal panel.
   Mobile: fixed to viewport corner (modal fills width).
   Desktop: absolute to modal-inner so it sits at the panel edge, not the
   viewport edge — matches the right edge of the hero image. */
.story-modal-close {
  position: fixed;
  top: var(--gap-3); right: var(--gap-3);
  z-index: 10;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.story-modal-close:hover { background: rgba(0,0,0,0.9); }
@media (min-width: 720px) {
  .story-modal-close {
    position: absolute;
  }
}
.story-modal-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-2);
  overflow: hidden;
}
.story-modal-hero img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.story-modal-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,18,31,0) 50%, rgba(6,18,31,0.85) 100%);
  pointer-events: none;
}
.story-modal-hero-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--gap-5);
  z-index: 2;
}
/* Meta block now lives in the BODY, not the hero overlay — pills sit below
   the hero image on every viewport. Cleaner mobile layout. */
.story-modal-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: var(--gap-4);
}
.story-modal-meta .pill.cat {
  background: rgba(232,184,75,0.18);
  border-color: rgba(232,184,75,0.45);
  color: var(--sand);
  font-weight: 700;
}
.story-modal-title {
  font-size: clamp(24px, 4.4vw, 40px);
  font-weight: 800;
  line-height: 1.1;
  color: #fff;
  margin: 0;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 24px rgba(0,0,0,0.6);
  max-width: 25ch;
}

/* Modal hero save-star (top-right of hero image) */
.story-modal-hero .save-star {
  position: absolute;
  top: var(--gap-3); left: auto; right: calc(var(--gap-3) + 86px); bottom: auto;
  width: 42px; height: 42px;
  font-size: 19px;
  background: rgba(0,0,0,0.55);
  border-color: rgba(255,255,255,0.25);
}
.story-modal-hero .save-star.saved {
  background: rgba(232,184,75,0.28);
}

.story-modal-body {
  padding: var(--gap-5) var(--gap-5) var(--gap-6);
}
.story-modal-excerpt {
  font-size: clamp(16px, 1.8vw, 18px);
  font-weight: 500;
  color: var(--text);
  line-height: 1.55;
  margin: 0 0 var(--gap-5);
  padding-bottom: var(--gap-5);
  border-bottom: 1px solid var(--border);
}
.story-modal-content {
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--text-2);
}
.story-modal-content p { margin: 0 0 var(--gap-4); }
.story-modal-content h2 {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 700;
  margin: var(--gap-6) 0 var(--gap-3);
  color: var(--text);
}
.story-modal-content h3 {
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 700;
  margin: var(--gap-5) 0 var(--gap-2);
  color: var(--text);
}
.story-modal-content ul, .story-modal-content ol {
  margin: 0 0 var(--gap-4);
  padding-left: var(--gap-5);
}
.story-modal-content li { margin-bottom: 6px; }
.story-modal-content a {
  color: var(--accent);
  border-bottom: 1px dotted rgba(95,183,255,0.4);
}
.story-modal-content a:hover { color: var(--accent-2); }
.story-modal-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-2);
  margin: var(--gap-4) 0;
}
.story-modal-content blockquote {
  margin: var(--gap-4) 0;
  padding: var(--gap-3) var(--gap-4);
  border-left: 3px solid var(--accent);
  background: rgba(95,183,255,0.06);
  color: var(--text);
  font-style: italic;
}
.story-modal-content figure { margin: var(--gap-4) 0; }
.story-modal-content figcaption {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

/* YouTube/Vimeo embed extracted from Elementor video widgets */
.story-video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: var(--gap-4) 0;
  border-radius: var(--r-3);
  overflow: hidden;
  background: #000;
}
.story-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* Strip Elementor's own scaffolding visual styling — we just want the
   inner content to render in our typography. Reset margins/widths. */
.story-modal-content .elementor,
.story-modal-content .elementor-section,
.story-modal-content .elementor-container,
.story-modal-content .elementor-column,
.story-modal-content .elementor-widget-wrap,
.story-modal-content .elementor-widget,
.story-modal-content .elementor-widget-container,
.story-modal-content .elementor-element {
  all: unset;
  display: block;
}

.story-modal-footer {
  margin-top: var(--gap-6);
  padding-top: var(--gap-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-3);
  align-items: center;
  justify-content: space-between;
}
.story-modal-canonical {
  font-size: 13px;
  color: var(--text-3);
}
.story-modal-canonical a {
  color: var(--accent);
  font-weight: 600;
}

.story-modal-loading,
.story-modal-error {
  padding: var(--gap-7) var(--gap-5);
  text-align: center;
  color: var(--text-3);
  font-style: italic;
}
.story-modal-error { color: var(--poor); font-style: normal; }

/* ── Page-hero override (matches the look of /learn/) ──────────────────
   When .page-hero-bg is on .stories-hero-wrap the photo + shared dark
   gradient should win over the subtle hatched texture this page used
   to ship with. */
.stories-hero-wrap.page-hero-bg::before {
  background-image:
    linear-gradient(180deg,
      rgba(6, 18, 31, 0.55) 0%,
      rgba(6, 18, 31, 0.20) 40%,
      rgba(6, 18, 31, 0.30) 75%,
      rgba(6, 18, 31, 0.65) 100%) !important;
  background-size: 100% 100% !important;
  opacity: 1 !important;
}
