/**
 * SMD Location Sections — Stylesheet
 *
 * Section-scoped styles for the location page shortcodes.
 * Targets the latest Elementor breakpoints (tablet @ 1024px, mobile @ 767px).
 */

/* ============================================================
 * Sleep Health Section
 * ============================================================ */

.smd-sleep-health {
    --smd-sh-accent: #2279bc;
    --smd-sh-border: #f5f5f5;
    --smd-sh-radius: 25px;
    --smd-sh-card-gap: 20px;
}

.smd-sleep-health__inner {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.smd-sleep-health__content > * + * {
    margin-top: 1em;
}

.smd-sleep-health__heading {
    margin: 0 0 0.5em;
}

/* --- Cards grid --- */

.smd-sleep-health__cards {
    display: grid;
    gap: var(--smd-sh-card-gap);
    /*
     * Column count adapts to actual card count, capped at 5 on desktop.
     * --smd-card-count is set inline on the element by the shortcode.
     * min() ensures we never have more columns than cards (no empty trailing columns).
     */
    grid-template-columns: repeat(min(var(--smd-card-count, 5), 5), 1fr);
}

/* Tablet: drop to 3 columns max (or fewer if card count is lower) */
@media (max-width: 1024px) {
    .smd-sleep-health__cards {
        grid-template-columns: repeat(min(var(--smd-card-count, 3), 3), 1fr);
    }
}

/* Mobile: drop to 2 columns max */
@media (max-width: 767px) {
    .smd-sleep-health__cards {
        grid-template-columns: repeat(min(var(--smd-card-count, 2), 2), 1fr);
        gap: 12px;
    }
}

/* --- Individual card --- */

.smd-sleep-health__card {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    padding: 24px 18px;
    background: #ffffff;
    border: 2px solid var(--smd-sh-border);
    border-radius: var(--smd-sh-radius);
    text-align: center;
}

.smd-sleep-health__card-icon {
    color: var(--smd-sh-accent);
    font-size: 36px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.smd-sleep-health__card-icon i {
    /* Ensure FA icon inherits sizing from the wrapper */
    font-size: inherit;
}

.smd-sleep-health__card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.smd-sleep-health__card-desc {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #555;
}

/* --- Communities list --- */

.smd-sleep-health__communities-list {
    margin: 0;
    padding-left: 1.25em;
    columns: 2;
    column-gap: 2em;
}

.smd-sleep-health__communities-list li {
    /* Prevent items from breaking across columns */
    break-inside: avoid;
}

.smd-sleep-health__communities-list li + li {
    margin-top: 0.25em;
}

/* Single column on mobile */
@media (max-width: 767px) {
    .smd-sleep-health__communities-list {
        columns: 1;
    }
}

.smd-sleep-health__communities-inline,
.smd-sleep-health__communities-intro {
    margin: 0 0 0.5em;
}

/* ============================================================
 * Getting Here Section
 * ============================================================ */

.smd-getting-here {
    --smd-gh-accent: #2279bc;
    --smd-gh-border: #f5f5f5;
    --smd-gh-radius: 25px;
    --smd-gh-card-gap: 20px;
}

.smd-getting-here__inner {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.smd-getting-here__heading {
    margin: 0;
    text-align: center;
}

/* --- Cards grid (mirrors sleep_health) --- */

.smd-getting-here__cards {
    display: grid;
    gap: var(--smd-gh-card-gap);
    grid-template-columns: repeat(min(var(--smd-card-count, 5), 5), 1fr);
}

@media (max-width: 1024px) {
    .smd-getting-here__cards {
        grid-template-columns: repeat(min(var(--smd-card-count, 3), 3), 1fr);
    }
}

@media (max-width: 767px) {
    .smd-getting-here__cards {
        grid-template-columns: repeat(min(var(--smd-card-count, 2), 2), 1fr);
        gap: 12px;
    }
}

/* --- Individual card --- */

.smd-getting-here__card {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    padding: 24px 18px;
    background: #ffffff;
    border: 2px solid var(--smd-gh-border);
    border-radius: var(--smd-gh-radius);
    text-align: center;
}

.smd-getting-here__card-icon {
    color: var(--smd-gh-accent);
    font-size: 36px;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.smd-getting-here__card-icon i {
    font-size: inherit;
}

.smd-getting-here__card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

/* --- Card details list --- */

.smd-getting-here__card-details {
    margin: 0;
    padding-left: 1.25em;
    text-align: left;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #555;
}

.smd-getting-here__card-details li + li {
    margin-top: 0.25em;
}

/* ============================================================
 * Local FAQ Section
 * ============================================================ */

.smd-local-faq {
    --smd-faq-question-bg: #e1edfd;
    --smd-faq-answer-bg: #ffffff;
    --smd-faq-border: #d5d8dc;
    --smd-faq-text: #002036;
    --smd-faq-transition: 300ms ease;
}

.smd-local-faq__items {
    display: flex;
    flex-direction: column;
}

/* --- Item (details) --- */

.smd-local-faq__item {
    border: 1px solid var(--smd-faq-border);
    border-radius: 0;
}

/* Collapse adjacent borders so we don't get double-thickness lines */
.smd-local-faq__item + .smd-local-faq__item {
    border-top: 0;
}

/* Remove default disclosure marker (browser-rendered triangle) */
.smd-local-faq__item summary {
    list-style: none;
}
.smd-local-faq__item summary::-webkit-details-marker {
    display: none;
}

/* --- Question (summary) --- */

.smd-local-faq__question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    padding: 16px 20px;
    background: var(--smd-faq-question-bg);
    color: var(--smd-faq-text);
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
}

.smd-local-faq__question:focus-visible {
    outline: 2px solid var(--smd-faq-text);
    outline-offset: -2px;
}

.smd-local-faq__question-text {
    flex: 1;
}

/* --- Icon (rotates 90deg when open) --- */

.smd-local-faq__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    transition: transform var(--smd-faq-transition);
}

.smd-local-faq__icon-svg {
    width: 0.7em;
    height: 0.7em;
    fill: currentColor;
}

.smd-local-faq__item[open] .smd-local-faq__icon {
    transform: rotate(90deg);
}

/* When closing, animate the icon back to its default rotation */
.smd-local-faq__item.is-closing .smd-local-faq__icon {
    transform: rotate(0deg);
}

/* --- Answer wrapper (smooth slide using grid-template-rows trick) --- */

.smd-local-faq__answer-wrap {
    display: grid;
    grid-template-rows: 0fr;
    background: var(--smd-faq-answer-bg);
    color: var(--smd-faq-text);
    transition: grid-template-rows var(--smd-faq-transition);
}

.smd-local-faq__item[open] .smd-local-faq__answer-wrap {
    grid-template-rows: 1fr;
}

/* When closing, collapse back to 0fr — JS removes [open] after this transition completes */
.smd-local-faq__item.is-closing .smd-local-faq__answer-wrap {
    grid-template-rows: 0fr;
}

/* Inner content needs overflow:hidden so it actually clips during transition */
.smd-local-faq__answer {
    overflow: hidden;
    min-height: 0;
    padding: 0 20px;
    font-size: 19px;
    font-weight: 400;
    line-height: 1.5;
    transition: padding var(--smd-faq-transition), border-color var(--smd-faq-transition);
    border-top: 1px solid transparent;
}

/* Top/bottom padding animates with the answer so it doesn't pop in */
.smd-local-faq__item[open] .smd-local-faq__answer {
    padding-top: 16px;
    padding-bottom: 16px;
    border-top-color: var(--smd-faq-border);
}

/* When closing, padding animates back down */
.smd-local-faq__item.is-closing .smd-local-faq__answer {
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
}

.smd-local-faq__answer > *:first-child {
    margin-top: 0;
}
.smd-local-faq__answer > *:last-child {
    margin-bottom: 0;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .smd-local-faq__icon,
    .smd-local-faq__answer-wrap {
        transition: none;
    }
}

/* ============================================================
 * Milestone / Proudly Serving Section
 * ============================================================ */

.smd-milestone {
    --smd-ms-bg: #042035;
    --smd-ms-text: #ffffff;
    --smd-ms-radius: 25px;
    --smd-ms-padding: 40px;
}

.smd-milestone__inner {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--smd-ms-padding);
    align-items: stretch;
    padding: var(--smd-ms-padding);
    background: var(--smd-ms-bg);
    color: var(--smd-ms-text);
    border-radius: var(--smd-ms-radius);
}

.smd-milestone__content > * + * {
    margin-top: 1em;
}

.smd-milestone__heading {
    margin: 0;
    color: var(--smd-ms-text);
    font-weight: 700;
}

.smd-milestone__body {
    font-size: 18px;
    line-height: 1.5;
}

.smd-milestone__body > *:first-child {
    margin-top: 0;
}
.smd-milestone__body > *:last-child {
    margin-bottom: 0;
}

.smd-milestone__points {
    margin: 0;
    padding-left: 1.25em;
    font-size: 18px;
    line-height: 1.5;
}

.smd-milestone__points li + li {
    margin-top: 0.25em;
}

/* --- Media column --- */

.smd-milestone__media {
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-height: 0; /* allow flex child to shrink properly inside grid */
}

.smd-milestone__media .smd-milestone__image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--smd-ms-radius);
    object-fit: cover;
}

/* Stack on tablet and below to match Elementor's default behaviour */
@media (max-width: 1024px) {
    .smd-milestone__inner {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 30px;
    }

    .smd-milestone__media {
        order: -1; /* image above text on smaller screens reads better */
        align-items: center;
    }

    .smd-milestone__image {
        height: auto;
        max-height: 320px;
    }
}

@media (max-width: 767px) {
    .smd-milestone__inner {
        padding: 24px;
    }

    .smd-milestone__body,
    .smd-milestone__points {
        font-size: 16px;
    }
}
