/* =====================================================================
 * layout.css — layout primitives: .container, .section, .grid.
 * Full-bleed sections; container constrains content where needed.
 * No hex literals.
 * ===================================================================== */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--space-5);
}

@media (min-width: 768px) {
    .container { padding-inline: var(--space-6); }
}

@media (min-width: 1024px) {
    .container { padding-inline: var(--space-7); }
}

/* --- Section --------------------------------------------------------- */
.section {
    padding-block: var(--space-7);
    background-color: var(--color-bg);
    color: var(--color-text);
}

@media (min-width: 1024px) {
    .section { padding-block: var(--space-9); }
}

.section--full-bleed {
    width: 100%;
    /* Full-bleed visual; the inner .container handles content width. */
}

.section--ice-mist {
    background-color: var(--color-surface);
}

.section--navy {
    background-color: var(--color-ink);
    color: var(--color-text-inverse);
}

/* Apply-CTA gradient overlay. Layered on top of .section--navy (which
 * supplies the navy background-color + the inverse typography / anchor /
 * breadcrumb overrides below); this modifier only adds a translucent
 * navy→teal diagonal wash so an apply-CTA reads richer than a flat fill.
 * Used on every page's apply-CTA (programs / indonesia / malaysia /
 * about) for one consistent CTA look — opt-in via the modifier so the
 * flat .section--navy (e.g. the Home stat band) is unaffected.
 *
 * The stops are translucent (color-mix … transparent) so they blend with
 * the navy base beneath — at 0% navy reads through almost unchanged, by
 * 100% the teal token dominates. Gradient-only: no background image. The
 * exact stops/angle were lifted from the Programs CTA's former inline
 * gradient-over-photo composite (the photo was dropped to unify the four
 * CTAs). No hex literals. */
.section--navy-cta {
    background-image: linear-gradient(135deg,
        color-mix(in srgb, var(--color-ink)     90%, transparent) 0%,
        color-mix(in srgb, var(--color-primary) 82%, transparent) 100%);
}

/* Deep-teal variant — interior-page hero (About, Programs, future
 * country/why/faq/contact/etc.). Mirrors --navy but uses the primary
 * brand colour so it reads warmer than navy without being as dramatic
 * as the home hero's gradient.
 *
 * Carries its own two-tone gradient so an interior hero looks complete
 * with no background imagery — the rule for interior pages is that
 * only the home hero uses photography; every other page's hero is
 * pure teal. background-color paints before the gradient renders so
 * first paint is never bare. */
.section--teal {
    background-color: var(--color-primary);
    background-image: linear-gradient(135deg,
        var(--color-primary)       0%,
        var(--color-primary-hover) 100%);
    color: var(--color-text-inverse);
}

/* Inverse-context overrides for typography inside dark sections. */
.section--navy h1, .section--navy h2, .section--navy h3,
.section--navy h4, .section--navy h5, .section--navy h6,
.section--teal h1, .section--teal h2, .section--teal h3,
.section--teal h4, .section--teal h5, .section--teal h6 {
    color: var(--color-text-inverse);
}

/* Anchor overrides in dark sections must NOT touch buttons. A bare
 * .section--navy a selector (specificity 0-1-1) outranks .btn--primary,
 * .btn--accent, .btn--secondary (each 0-1-0) and would repaint the
 * button text in the section's accent colour — exactly matching its
 * own fill, making the label invisible. The :not(.btn) guard keeps
 * the override scoped to plain links. */
.section--navy a:not(.btn) { color: var(--color-accent); }
.section--navy a:not(.btn):hover { color: var(--color-turquoise-light); }
.section--teal a:not(.btn) { color: var(--color-ice-mist); }
.section--teal a:not(.btn):hover { color: var(--color-white); }

/* Breadcrumb contrast inside dark sections. The component defaults to
 * muted ink for light backgrounds; here we lift it to ice-mist so the
 * trail is legible against navy or teal. */
.section--navy .breadcrumb,
.section--teal .breadcrumb,
.section--navy .breadcrumb__item a,
.section--teal .breadcrumb__item a { color: var(--color-ice-mist); }

.section--navy .breadcrumb__item a:hover,
.section--teal .breadcrumb__item a:hover { color: var(--color-white); }

.section--navy .breadcrumb__item--current,
.section--teal .breadcrumb__item--current { color: var(--color-text-inverse); }

.section--navy .breadcrumb__sep,
.section--teal .breadcrumb__sep { color: var(--color-ice-mist); opacity: 0.7; }

.section--centered { text-align: center; }
.section--centered p { margin-inline: auto; }

.section__title {
    font-size: clamp(1.75rem, 4vw, var(--fs-2xl));
    margin-bottom: var(--space-4);
}

.section__lead {
    font-size: var(--fs-md);
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
    max-width: 60ch;
}

.section--centered .section__lead { margin-inline: auto; }

/* --- Grid ------------------------------------------------------------ */
.grid {
    display: grid;
    gap: var(--space-5);
}

/* Mobile defaults — declared explicitly. Without these, mobile relied
 * on `display: grid` falling back to an implicit single column, which
 * works in modern browsers but leaves an ambiguous template that any
 * inline grid-template-* on a child or future cascade could break. An
 * explicit `1fr` makes the collapsed layout unambiguous and prevents
 * overflow on narrow viewports. */
.grid--2-col,
.grid--3-col,
.grid--4-col { grid-template-columns: 1fr; }

@media (min-width: 768px) {
    .grid--2-col { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .grid--3-col { grid-template-columns: repeat(3, 1fr); }
    .grid--4-col { grid-template-columns: repeat(4, 1fr); }
}

/* Mid-breakpoint friendliness: 4-col cards become 2-col on tablet. */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .grid--4-col { grid-template-columns: repeat(2, 1fr); }
}

/* Flex helpers — only the ones we genuinely use; not a full grid utility. */
.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
