/* ═══════════════════════════════════════════════════════════════════════════
   Cosmos V5 — Section Layouts
   Pure CSS layout system. The DOM structure never changes:
     <section data-layout="xxx">
       <header>…</header>            ← cosmos-header (rendered by header skin)
       <div class="cosmos-items">    ← items container
         <div class="cosmos-item">…</div>
         …
       </div>
     </section>
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Base / Reset ────────────────────────────────────────────────────────── */

[data-layout] .cosmos-items {
  max-width: var(--website-max-width, 80rem);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  box-sizing: border-box;
}

/* ─── 1. Cards 3-Column (default) ─────────────────────────────────────────
   Classic responsive grid: 1 → 2 → 3 columns.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="cards-3col"] .cosmos-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 640px) {
  [data-layout="cards-3col"] .cosmos-items { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  [data-layout="cards-3col"] .cosmos-items { grid-template-columns: repeat(3, 1fr); }
}

/* ─── 2. Cards 2-Column ───────────────────────────────────────────────────
   Two equal columns, great for wider cards.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="cards-2col"] .cosmos-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 640px) {
  [data-layout="cards-2col"] .cosmos-items { grid-template-columns: repeat(2, 1fr); }
}

/* ─── 3. Cards 4-Column ───────────────────────────────────────────────────
   Compact grid: 1 → 2 → 4 columns for dense content.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="cards-4col"] .cosmos-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 640px) {
  [data-layout="cards-4col"] .cosmos-items { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  [data-layout="cards-4col"] .cosmos-items { grid-template-columns: repeat(4, 1fr); }
}

/* ─── 4. Grid 2×2 ─────────────────────────────────────────────────────────
   Fixed 2-column grid, max 4 visible items. Clean square matrix.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="grid-2x2"] .cosmos-items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: min(56rem, var(--website-max-width, 56rem));
}
@media (min-width: 640px) {
  [data-layout="grid-2x2"] .cosmos-items { grid-template-columns: repeat(2, 1fr); }
}
[data-layout="grid-2x2"] .cosmos-items > :nth-child(n+5) {
  display: none;
}

/* ─── 5. List ─────────────────────────────────────────────────────────────
   Single-column stacked list. Full width items.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="list"] .cosmos-items {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: min(56rem, var(--website-max-width, 56rem));
}

/* ─── 6. Slideshow ────────────────────────────────────────────────────────
   Full-width slides with smooth transitions, arrows, and dot indicators.
   Works without JS (CSS scroll-snap), enhanced with JS (nav + dots).
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="slideshow"] .cosmos-items {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  gap: 0;
  max-width: none;
  padding: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
[data-layout="slideshow"] .cosmos-items::-webkit-scrollbar {
  display: none;
}
[data-layout="slideshow"] .cosmos-items > * {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: center;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 2rem;
}
@media (min-width: 768px) {
  [data-layout="slideshow"] .cosmos-items > * { padding: 0 4rem; }
}

/* ─── Slideshow Chrome (injected by cosmos-layouts.js) ──────────────── */

.cosmos-slide-wrap {
  position: relative;
  overflow: hidden;
}
.cosmos-slide-wrap .cosmos-items {
  padding-left: 0;
  padding-right: 0;
}

/* Arrows */
.cosmos-slide-arrow {
  position: absolute;
  top: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  color: #1d1d1f;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              background 0.2s,
              box-shadow 0.2s;
  transform: translateY(-50%) scale(1);
  opacity: 1;
}
.cosmos-slide-arrow:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
  transform: translateY(-50%) scale(1.08);
}
.cosmos-slide-arrow:active {
  transform: translateY(-50%) scale(0.95);
}
.cosmos-slide-arrow[disabled] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.85);
}
.cosmos-slide-arrow--prev { left: 1rem; }
.cosmos-slide-arrow--next { right: 1rem; }
@media (min-width: 768px) {
  .cosmos-slide-arrow { width: 3.5rem; height: 3.5rem; }
  .cosmos-slide-arrow--prev { left: 1.5rem; }
  .cosmos-slide-arrow--next { right: 1.5rem; }
}

/* Dot indicators */
.cosmos-slide-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 0 0.5rem;
}
.cosmos-slide-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  border: none;
  padding: 0;
  background: #d1d5db;
  cursor: pointer;
  transition: background 0.3s, width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.cosmos-slide-dot:hover {
  background: #9ca3af;
}
.cosmos-slide-dot--active {
  background: #1d1d1f;
  width: 1.5rem;
}

/* ─── 7. Alternating (Zigzag) ─────────────────────────────────────────────
   Full-width rows. Even items reverse direction for a zigzag feel.
   Each item becomes a horizontal row with image + text side by side.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="alternating"] .cosmos-items {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  max-width: min(72rem, var(--website-max-width, 72rem));
}
[data-layout="alternating"] .cosmos-items > * {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  [data-layout="alternating"] .cosmos-items > * {
    flex-direction: row;
    align-items: center;
  }
  [data-layout="alternating"] .cosmos-items > * > * {
    flex: 1;
  }
  [data-layout="alternating"] .cosmos-items > :nth-child(even) {
    flex-direction: row-reverse;
  }
}

/* ─── 8. Split ────────────────────────────────────────────────────────────
   Header takes the left half, items stack on the right.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="split"] {
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  [data-layout="split"] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: var(--website-max-width, 80rem);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    gap: 3rem;
    align-items: start;
  }
  [data-layout="split"] > header,
  [data-layout="split"] > :first-child {
    position: sticky;
    top: 2rem;
  }
}
[data-layout="split"] .cosmos-items {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── 9. Masonry ──────────────────────────────────────────────────────────
   CSS columns masonry layout. Staggered card heights.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="masonry"] .cosmos-items {
  column-count: 1;
  column-gap: 1.5rem;
}
[data-layout="masonry"] .cosmos-items > * {
  break-inside: avoid;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  [data-layout="masonry"] .cosmos-items { column-count: 2; }
}
@media (min-width: 1024px) {
  [data-layout="masonry"] .cosmos-items { column-count: 3; }
}

/* ─── 10. Feature Rows ────────────────────────────────────────────────────
   Each item is a wide horizontal row: image on one side, text on other.
   ──────────────────────────────────────────────────────────────────────── */

[data-layout="feature-rows"] .cosmos-items {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: min(72rem, var(--website-max-width, 72rem));
}
[data-layout="feature-rows"] .cosmos-items > * {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  border-radius: 0.75rem;
  background: #f8fafc;
}
@media (min-width: 768px) {
  [data-layout="feature-rows"] .cosmos-items > * {
    flex-direction: row;
    align-items: center;
  }
  [data-layout="feature-rows"] .cosmos-items > * > * {
    flex: 1;
  }
}
