/* =============================================================================
   DragonFire Sites — Section Style Library
   =============================================================================
   Semantic, composable classes the wizard's "✨ Style this section" picker
   can apply. Auto-included by page_assembler on every new-shape site.
   Site's own /css/style.css loads AFTER this and can override anything.

   Classes are grouped:
     • Section variants    — layout + backdrop  (mix-and-match)
     • Image treatments    — applied to .section__image
     • Gallery layouts     — applied to .section--gallery
     • Typography emphasis — title + body emphasis

   Every class is opt-in: a section with no `css_classes` slot renders
   identically to before. Adding classes is purely additive styling.

   Picker hint: 0–3 classes per section is the sweet spot. More than that
   tends to fight itself visually.
============================================================================= */

/* ─── design tokens (CSS vars so site can override) ────────────────────── */
:root {
  --df-tint:      rgba(74, 158, 255, 0.06);
  --df-alt-bg:   rgba(255, 255, 255, 0.025);
  --df-card-bg:  rgba(255, 255, 255, 0.04);
  --df-card-bd:  rgba(255, 255, 255, 0.08);
  --df-shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.25);
  --df-radius-card: 14px;
}

/* ════════════════════════════════════════════════════════════════════════
   SECTION VARIANTS — apply to <section class="section ...">
   ════════════════════════════════════════════════════════════════════════ */

/* Centered single-column reading — narrows the column, centers text */
.section--centered .section__inner {
  max-width: 640px; margin-left: auto; margin-right: auto;
  text-align: center;
}
.section--centered .section__title { margin-left: auto; margin-right: auto; }

/* Narrow column — for long-form prose, comfortable line length */
.section--narrow .section__inner { max-width: 720px; }

/* Tinted accent background — subtle wash of the brand accent */
.section--tinted { background: var(--df-tint); }

/* Alternate backdrop — zebra-striping when sections alternate */
.section--alt-bg { background: var(--df-alt-bg); }

/* Card style — boxed with subtle border + radius. Looks great as a
   single mid-page callout, less so for every section in a row. */
.section--card .section__inner {
  background: var(--df-card-bg);
  border: 1px solid var(--df-card-bd);
  border-radius: var(--df-radius-card);
  padding: 36px 32px;
  box-shadow: var(--df-shadow-soft);
}

/* Hero — extra vertical padding + bigger heading */
.section--hero { padding-top: 100px; padding-bottom: 80px; }
.section--hero .section__title {
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 1.1;
}

/* ════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY EMPHASIS
   ════════════════════════════════════════════════════════════════════════ */

/* Larger title (one notch up from default, smaller than hero) */
.section--big-title .section__title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: -0.01em;
}

/* Pull-quote opener — first paragraph becomes pulled prose */
.section--pull-quote .section__body > p:first-child {
  font-size: 1.2rem; line-height: 1.5;
  border-left: 3px solid var(--accent, #4a9eff);
  padding-left: 18px;
  margin-bottom: 18px;
  font-style: italic;
}

/* ════════════════════════════════════════════════════════════════════════
   IMAGE TREATMENTS — apply to .section--text-image
   ════════════════════════════════════════════════════════════════════════ */

/* Circle crop — for portraits, profile shots */
.image--rounded-full .section__image img {
  border-radius: 50%; aspect-ratio: 1; object-fit: cover;
}

/* Drop shadow — subtle elevation */
.image--soft-shadow .section__image img { box-shadow: var(--df-shadow-soft); }

/* Bordered — thin border around image */
.image--bordered .section__image img {
  border: 1px solid var(--df-card-bd);
  border-radius: 8px;
  padding: 6px; background: var(--df-card-bg);
}

/* ════════════════════════════════════════════════════════════════════════
   GALLERY LAYOUTS — apply to .section--gallery
   ════════════════════════════════════════════════════════════════════════ */

/* Featured-first — first image spans 2 columns, rest fill in */
.gallery--featured-first .gallery-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.gallery--featured-first .gallery-grid figure:first-child {
  grid-column: span 2;
  grid-row: span 2;
  aspect-ratio: 1;
}

/* Strip — horizontal scroll on mobile, row on desktop */
.gallery--strip .gallery-grid {
  display: flex; gap: 12px; overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}
.gallery--strip .gallery-grid figure {
  flex: 0 0 280px; scroll-snap-align: start;
  aspect-ratio: 4/3;
}

/* Mosaic — irregular grid, taller cells for variety */
.gallery--mosaic .gallery-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-auto-rows: 200px;
}
.gallery--mosaic .gallery-grid figure:nth-child(3n+1) { grid-row: span 2; }

/* ════════════════════════════════════════════════════════════════════════
   COLUMNS SECTION — 2/3/4 equal columns with optional image-on-top,
   small heading, body. Stacks single-column on mobile.
   ════════════════════════════════════════════════════════════════════════ */

.section--columns .columns-grid {
  display: grid;
  gap: clamp(20px, 3vw, 32px);
  margin-top: 28px;
}

/* Desktop column counts — driven by data-cols on the <section> */
.section--columns[data-cols="2"] .columns-grid { grid-template-columns: repeat(2, 1fr); }
.section--columns[data-cols="3"] .columns-grid { grid-template-columns: repeat(3, 1fr); }
.section--columns[data-cols="4"] .columns-grid { grid-template-columns: repeat(4, 1fr); }

/* Tablet — 3 and 4 column layouts collapse to 2 */
@media (max-width: 960px) {
  .section--columns[data-cols="3"] .columns-grid,
  .section--columns[data-cols="4"] .columns-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile — everything stacks */
@media (max-width: 640px) {
  .section--columns .columns-grid { grid-template-columns: 1fr; }
}

.section--columns .column {
  display: flex;
  flex-direction: column;
  /* min-width: 0 lets the grid item shrink below its content's intrinsic
     width — without this, a tall portrait image's natural width can blow
     the grid track wider than its allotted fraction and overflow sideways. */
  min-width: 0;
}

.section--columns .column__image {
  /* Force the image into the column's 4:3 box regardless of source
     aspect. display:block kills the inline-baseline whitespace; explicit
     width:100% + max-width:100% means the image can never overflow the
     column's measured width even for very wide source files; height:auto
     defers to aspect-ratio for the computed height; object-fit:cover
     crops (center-default) to fill the box without distortion. */
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
  border-radius: var(--df-radius, 10px);
  margin-bottom: 14px;
  background: var(--df-card-bg);
}

.section--columns .column__title {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  margin: 0 0 8px;
  font-weight: var(--font-weight-heading, 600);
  line-height: 1.3;
}

.section--columns .column__body {
  color: var(--text-dim, currentColor);
  line-height: var(--line-height-body, 1.55);
  font-size: 0.97rem;
}

.section--columns .column__body p { margin: 0 0 0.6em; }
.section--columns .column__body p:last-child { margin-bottom: 0; }

/* Clickable image on text-image sections — wraps the <figure> when the
   `link` slot is set. Subtle brightness lift on hover so users see it's
   interactive without changing the layout. */
.section--text-image .section__image-link {
  display: block;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--df-radius, 10px);
  transition: filter 0.2s ease, transform 0.2s ease;
}
.section--text-image .section__image-link:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.section--text-image .section__image-link:focus-visible {
  outline: 2px solid var(--accent, #4a9eff);
  outline-offset: 4px;
}

/* Clickable column — whole card is an <a>. Inherits flex/column from
   .column. Removes default link underline + colour; adds subtle lift +
   accent-tinted title on hover so it reads as interactive. */
.section--columns .column--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: var(--df-radius, 10px);
}
.section--columns .column--link:hover {
  transform: translateY(-2px);
}
.section--columns .column--link:hover .column__title {
  color: var(--accent, #4a9eff);
}
.section--columns .column--link:hover .column__image {
  filter: brightness(1.05);
  transition: filter 0.2s ease;
}
.section--columns .column--link:focus-visible {
  outline: 2px solid var(--accent, #4a9eff);
  outline-offset: 4px;
}

/* ════════════════════════════════════════════════════════════════════════
   VIDEO SECTION — facade-pattern embed (YouTube / Vimeo)
   Until clicked: just an image + play button (zero 3p requests).
   On click: video-player.js swaps the facade for an autoplay iframe.
   ════════════════════════════════════════════════════════════════════════ */

.section--video .video-wrap {
  margin: 24px auto 0;
}

/* Vertical (shorts/reels) — cap width so they don't tower the page */
.section--video .video-wrap[data-aspect="9:16"] {
  max-width: 380px;
}

.video-facade {
  position: relative;
  width: 100%;
  aspect-ratio: var(--video-aspect, 16 / 9);
  background: #000;
  border-radius: var(--df-radius, 10px);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--df-card-shadow, 0 8px 28px rgba(0,0,0,0.25));
}

.video-facade__thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, filter 0.2s ease;
}

.video-facade:hover .video-facade__thumb {
  transform: scale(1.03);
  filter: brightness(0.85);
}

.video-facade__play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  padding: 0;
}

.video-facade:hover .video-facade__play,
.video-facade__play:focus-visible {
  background: var(--accent, rgba(0, 0, 0, 0.8));
  transform: translate(-50%, -50%) scale(1.08);
  outline: none;
}

.video-facade__play svg {
  width: 30px; height: 30px;
  margin-left: 4px;  /* optical centering for triangle */
}

/* Once playing — iframe fills, controls visible via iframe itself */
.video-facade.is-playing { cursor: default; }
.video-facade.is-playing:hover .video-facade__thumb {
  transform: none; filter: none;
}
.video-facade__iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
  display: block;
}

.section--video .video-caption {
  margin: 14px auto 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  max-width: 720px;
}

.section--video .video-error {
  padding: 24px;
  text-align: center;
  color: var(--danger, #ff6b6b);
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--df-radius, 10px);
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .video-facade__play { width: 56px; height: 56px; }
  .video-facade__play svg { width: 24px; height: 24px; margin-left: 3px; }
}
