/* =====================================================================
 * components/branch-card.css — photo-led (and text-only fallback)
 * branch card for the country pages.
 *
 * Introduced in the Phase 5 Malaysia country-page build; designed to
 * be drop-in reusable. The Indonesia country page's existing
 * content-only cards (3-3-1 grid, .indonesia-branch class) will be
 * back-ported to this component in a follow-up prompt — name the
 * classes generically here so that swap is a pure markup change.
 *
 * Variants
 * --------
 *   .branch-card                — default: photo on top, body below.
 *   .branch-card--no-photo      — text-only fallback; body sits at the
 *                                  top with the photo wrapper omitted
 *                                  from the markup. The variant class
 *                                  restores rounded top corners on the
 *                                  body (the default rule expects a
 *                                  flat top edge under the figure). No
 *                                  :has() dependency — the variant is
 *                                  driven entirely by the modifier
 *                                  class on the article.
 *
 * Grid wrapper
 * ------------
 *   .branch-grid                — display: grid; gap (no columns).
 *   .branch-grid--3-2-1         — responsive: 3 cols ≥1024px /
 *                                  2 cols ≥640px / 1 col below.
 *
 * No hex literals — uses tokens from variables.css. Vendor-CSS hex
 * literals (leaflet, photoswipe) remain the only exceptions to the
 * single-hex-source rule.
 * ===================================================================== */

/* ---------------------------------------------------------------
 * 1. Card container.
 * --------------------------------------------------------------- */
.branch-card {
    display: flex;
    flex-direction: column;
    background-color: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;             /* clip the photo to the rounded top edge */
    height: 100%;                 /* fill the grid row when siblings are taller */
    transition: box-shadow var(--transition-base);
}

.branch-card:hover {
    box-shadow: var(--shadow-md);
}

/* ---------------------------------------------------------------
 * 2. Photo wrapper.
 *    16:10 aspect ratio reserves layout space BEFORE the image
 *    loads (prevents CLS) and survives a missing-image 404 — the
 *    figure keeps its height, the inner <img> just renders the
 *    browser's broken-image placeholder. width / height attrs on
 *    the <img> are still required (browser layout hint) but the
 *    aspect-ratio is the load-bearing constraint here.
 * --------------------------------------------------------------- */
.branch-card__photo {
    margin: 0;                       /* <figure> defaults to user-agent margin */
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background-color: var(--color-surface);   /* visible during image load */
}

.branch-card__photo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform var(--transition-base);
}

/* Subtle photo zoom on card hover — keeps the card itself static
 * (no transform on the whole article, which would invite layout-
 * jitter near the box-shadow). Respect prefers-reduced-motion. */
.branch-card:hover .branch-card__photo img {
    transform: scale(1.02);
}

@media (prefers-reduced-motion: reduce) {
    .branch-card,
    .branch-card__photo img {
        transition: none;
    }
    .branch-card:hover .branch-card__photo img {
        transform: none;
    }
}

/* ---------------------------------------------------------------
 * 3. Card body.
 * --------------------------------------------------------------- */
.branch-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-5);
    /* No top border-radius by default — the photo above already
     * carries the rounded top corners (via the card's overflow:
     * hidden). The --no-photo variant restores top rounding below. */
}

.branch-card__name {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
    line-height: var(--lh-tight);
    margin: 0;
}

/* Region — standalone muted single line (polish #2). Earlier drafts
 * paired this with a "Selangor · Ibu Pejabat" type span behind an
 * inline-flex meta wrapper; the type label was dropped for parity
 * with Indonesia's branch cards, which carry only region. The type
 * value still lives in the server-side $branches array for Phase 7
 * admin use; it's just not rendered on the public card body. */
.branch-card__region {
    margin: 0;
    font-size: var(--fs-sm);
    line-height: var(--lh-tight);
    color: var(--color-text-muted);
}

/* Hairline divider between region and address (polish #2). Mirrors
 * Indonesia's .indonesia-branch__divider rule byte-for-byte —
 * standalone <hr> DOM element with the border-top approach (the
 * <hr>'s own default border is reset to 0). Colour comes from
 * --color-border, which is the lightest deep-teal tone in
 * variables.css — a quiet teal hairline that reads as part of the
 * brand family without competing for attention. */
.branch-card__divider {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-2) 0;
    width: 100%;
}

/* Address row — flex container so the inline map-pin SVG sits left
 * of the address text and top-aligns with the first line when the
 * address wraps (polish #3). Mirrors Indonesia's .indonesia-branch__row
 * + .indonesia-branch__icon pair byte-for-byte: gap = --space-3,
 * icon = 1rem square in --color-accent (currentColor flows to the
 * SVG stroke), icon flex-shrink: 0 + margin-top: 0.2em to optically
 * align with the address's cap-height. */
.branch-card__address {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: 0;
    font-size: var(--fs-sm);
    line-height: var(--lh-relaxed);
    color: var(--color-text-muted);
}

.branch-card__address-icon {
    width: 1rem;
    height: 1rem;
    color: var(--color-accent);
    flex-shrink: 0;
    margin-top: 0.2em;
}

/* ---------------------------------------------------------------
 * 4. No-photo variant.
 *    Body sits flush with the top edge — restore the card's full
 *    border-radius onto the body itself (the card's own
 *    overflow:hidden + border-radius already clip the outer corners,
 *    but the body's top edge needs the rounded look explicitly to
 *    look right under hover-shadow). Done class-driven, NOT via
 *    :has(), for compatibility with older browsers and to keep the
 *    intent explicit.
 * --------------------------------------------------------------- */
.branch-card--no-photo .branch-card__body {
    padding-top: var(--space-5);   /* same vertical padding as the default */
}

/* ---------------------------------------------------------------
 * 5. Grid wrapper.
 *    Mobile-first single column; gains 2 cols at ≥640px, 3 cols at
 *    ≥1024px. Sized to play well with the .container width at every
 *    breakpoint (cards stay readable at all three sizes).
 * --------------------------------------------------------------- */
.branch-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}

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

@media (min-width: 1024px) {
    .branch-grid--3-2-1 {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-6);
    }
}
