/* ============================================================
   LAYOUT
   Page wrappers and composable layout primitives.
   ============================================================ */

/* ── Page wrappers ────────────────────────────────────────── */

/* Standard authenticated page — sits below the nav */
.page {
  background-color: var(--color-bg-page);
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--page-padding);
}

/* Vertically + horizontally centres children — used by auth flows */
.page-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--space-8) var(--space-4);
}

/* ── Containers ───────────────────────────────────────────── */

/* Narrow container — forms, settings, account pages */
.container--narrow {
  max-width: 640px;
  margin-inline: auto;
}

/* ── Stack — vertical flex column ────────────────────────── */
/*
  Each direct child is separated by a uniform gap.
  Usage: <div class="stack"> ... </div>
*/
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--xs { gap: var(--space-2); }
.stack--sm { gap: var(--space-3); }
.stack--lg { gap: var(--space-8); }
.stack--xl { gap: var(--space-12); }

/* ── Cluster — horizontal flex wrap ──────────────────────── */
/*
  Children flow inline and wrap naturally.
  Usage: <div class="cluster"> ... </div>
*/
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.cluster--sm      { gap: var(--space-2); }
.cluster--lg      { gap: var(--space-6); }
.cluster--center  { justify-content: center; }
.cluster--end     { justify-content: flex-end; }
.cluster--between { justify-content: space-between; }

/* ── Sidebar layout ───────────────────────────────────────── */
/*
  Usage: <div class="sidebar-layout">
           <aside> ... </aside>    ← fixed-width
           <main>  ... </main>     ← fills remaining space
         </div>
*/
.sidebar-layout {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
}

.sidebar-layout > :first-child {
  flex: 0 0 260px;
}

.sidebar-layout > :last-child {
  flex: 1 1 0;
  min-width: 0;
}

/* ── Auto-fill responsive grid ───────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--space-6);
}

.grid--tight { gap: var(--space-4); }
.grid--wide  { gap: var(--space-8); }

/* ── Hero layout ──────────────────────────────────────────── */

/* Hero — fills the available page height (above the footer) and centres the
   two-column layout both horizontally and vertically within that space.
   max-width prevents content running edge-to-edge on wide screens;
   margin-inline: auto centres the constrained block within .page's padding. */
.hero {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-10);
  align-items: center;        /* columns align with each other */
  align-content: center;      /* grid row centred vertically in the full hero height */
  max-width: 1100px;
  width: 100%;
  margin-inline: auto;
  padding: var(--space-8) 0;
}

.hero__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.hero__headline {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
}

.hero__lead {
  font-size: var(--text-md);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
}

.hero__bullets {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.hero__bullet {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.hero__bullet-icon {
  color: var(--color-accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.hero__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Animation column — matches height of content column automatically.
   min-height ensures it never collapses too small. */
.hero__animation {
  align-self: stretch;
  min-height: 380px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

@media (max-width: 768px) {
  .hero {
    grid-template-columns: 1fr;
    gap: var(--space-6);
    padding: var(--space-8) 0;
  }

  /* On mobile the animation appears below the text at a fixed height */
  .hero__animation {
    align-self: auto;
    min-height: 300px;
    height: 300px;
  }
}

/* ── Button Grid Hero component ──────────────────────────── */

.bgh-container {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-surface);
  overflow: hidden;
}

/* height: 100% + grid-auto-rows: 1fr fills the full container height
   and distributes rows equally rather than sizing from button content. */
.bgh-grid {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: 1fr;
  gap: 3px;
  padding: 6px;
  box-sizing: border-box;
}

.bgh-btn {
  border: none;
  border-radius: 4px;
  color: #ffffff;
  font-size: 11px;
  font-family: system-ui, -apple-system, sans-serif;
  font-weight: 500;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Button colour palette */
.bgh-col-1  { background-color: hsl(0,   70%, 50%); }
.bgh-col-2  { background-color: hsl(25,  70%, 50%); }
.bgh-col-3  { background-color: hsl(45,  70%, 48%); }
.bgh-col-4  { background-color: hsl(80,  65%, 42%); }
.bgh-col-5  { background-color: hsl(120, 65%, 40%); }
.bgh-col-6  { background-color: hsl(160, 65%, 40%); }
.bgh-col-7  { background-color: hsl(195, 70%, 45%); }
.bgh-col-8  { background-color: hsl(220, 70%, 52%); }
.bgh-col-9  { background-color: hsl(245, 70%, 57%); }
.bgh-col-10 { background-color: hsl(270, 70%, 55%); }
.bgh-col-11 { background-color: hsl(300, 65%, 50%); }
.bgh-col-12 { background-color: hsl(335, 70%, 50%); }

/* Floating list panel — centred over the grid */
.bgh-list {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50%;
  height: 60%;
  background-color: var(--color-bg-surface-raised);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-lg);
  padding: 5%;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 5%;
}

.bgh-list-item {
  height: calc(1em + 1vmin);
  min-height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* List item width classes */
.bgh-w-20 { width: 20%; }
.bgh-w-30 { width: 30%; }
.bgh-w-40 { width: 40%; }
.bgh-w-50 { width: 50%; }
.bgh-w-60 { width: 60%; }
.bgh-w-70 { width: 70%; }
.bgh-w-80 { width: 80%; }

@media (max-width: 480px) {
  .bgh-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Page footer ─────────────────────────────────────────── */

.page-footer {
  margin-top: auto;           /* pushes footer to bottom of .page flex column */
  padding: var(--space-6) var(--page-padding);
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.page-footer__copy {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.page-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-footer__links a {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  text-decoration: none;
}

.page-footer__links a:hover {
  color: var(--color-text-secondary);
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar-layout {
    flex-direction: column;
  }

  .sidebar-layout > :first-child {
    flex: none;
    width: 100%;
  }

  .page,
  .page-centered {
    padding: var(--space-4);
  }
}
