/* Department Single Page Styles */

html {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

body {
    font-family: 'Manrope', sans-serif;
    color: #64748B;
    background-color: #FFFFFF;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Figtree', sans-serif;
    letter-spacing: -0.02em;
    color: #0F172A;
}

/* ==========================================
   BRICKS THEME HEADING SIZE OVERRIDES
   Bricks sets very large h2/h3 sizes globally;
   scope overrides to the department page wrapper.
   ========================================== */
.shb-dept-page h2 {
    font-size: clamp(24px, 3.5vw, 36px) !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    color: #0F172A !important;
    margin-bottom: 24px !important;
    margin-top: 0 !important;
}

.shb-dept-page h3 {
    font-size: clamp(20px, 2.5vw, 28px) !important;
    line-height: 1.25 !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em !important;
    color: #0F172A !important;
    margin-top: 0 !important;
}

/* Hero h1 is intentionally large — keep it */
.shb-dept-hero h1 {
    font-size: clamp(28px, 5vw, 60px) !important;
    line-height: 1.1 !important;
}

/* ==========================================
   HERO: FULL-WIDTH BREAKOUT
   Mirrors the shb-center-single.css approach:
   left: 50% + margin-left: -50vw makes the
   hero escape any Bricks container constraint
   at every viewport width.
   ========================================== */

/* Allow hero to escape Bricks container clipping.
   Exclude .shb-dept-page so the page wrapper retains overflow-x: hidden.
   Bricks may inject an intermediate wrapper div — that is fine since it is
   NOT .shb-dept-page and will correctly receive overflow-x: visible.

   NOTE: overflow-x: visible is only needed so the hero (which is a sibling
   of .shb-dept-page) is not clipped by #brx-content. After the Alpine
   fitHero() fix (using $el.getBoundingClientRect().left), the hero is
   exactly viewport-width with no extra overflow — so visible propagation
   is harmless. The body { overflow-x: hidden } is the final safety net. */
#brx-content,
#brx-content > *:not(.shb-dept-page) {
    overflow-x: visible !important;
}

/* Counter-rule with specificity (1,1,0) — beats the (1,0,0) rule above —
   to ensure the page content wrapper ALWAYS clips overflow regardless of
   which ancestor Bricks generates as a direct child of #brx-content. */
#brx-content .shb-dept-page {
    overflow-x: hidden !important;
    min-width: 0;
}

/* Hero breakout: CSS provides a safe no-overflow fallback.
   Alpine.js x-init (in taxonomy-shb_department.php) overrides these with the
   exact viewport dimensions via setProperty(...,'important'), which beats any
   CSS !important rule. This two-layer approach is needed because:
   - CSS-only 100vw causes a ~16ms overflow window on iOS before Alpine fires,
     which is enough for WebKit to expand the scroll area and clip all content.
   - Alpine-only would flash a narrow hero if JS is slow to load. */
.shb-dept-hero {
    width: 100% !important;        /* Safe fallback: fills parent, no overflow */
    position: relative !important;
    left: 0 !important;            /* Alpine overrides to -parentLeft */
    margin-left: 0 !important;     /* Alpine overrides to -parentLeft offset */
    overflow: hidden !important;
}

/* ==========================================
   HERO GRADIENT FIX
   Tailwind does not compile via-secondary/75
   or to-secondary/30 (opacity-modifier JIT
   issue). Override with raw RGBA so the
   gradient renders correctly on all devices.
   ========================================== */
.shb-dept-hero .absolute.inset-0 > div {
    background: linear-gradient(
        to right,
        rgba(15, 23, 42, 0.95) 0%,
        rgba(15, 23, 42, 0.75) 55%,
        rgba(15, 23, 42, 0.30) 100%
    ) !important;
}

/* On mobile, use a stronger overlay so text stays readable
   across the full width of the narrow viewport */
@media (max-width: 767px) {
    .shb-dept-hero .absolute.inset-0 > div {
        background: linear-gradient(
            to bottom,
            rgba(15, 23, 42, 0.92) 0%,
            rgba(15, 23, 42, 0.82) 60%,
            rgba(15, 23, 42, 0.70) 100%
        ) !important;
    }
}

/* Missing Tailwind utility: shadow-glow */
.shadow-glow {
    box-shadow: 0 0 20px rgba(45, 172, 201, 0.15);
}

/* ==========================================
   SECTION SPACING
   ========================================== */
.shb-dept-page main > section {
    margin-bottom: 80px !important;
}

.shb-dept-page main > section:last-child {
    margin-bottom: 0 !important;
}

@media (max-width: 767px) {
    .shb-dept-page main > section {
        margin-bottom: 56px !important;
    }

    .shb-dept-page main > section:last-child {
        margin-bottom: 0 !important;
    }

    .dept-overview-content {
        margin-bottom: 24px !important;
    }
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn-primary {
    background: linear-gradient(135deg, #2DACC9 0%, #2492AB 100%);
    color: white;
    border-radius: 100px;
    padding: 12px 32px;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px -5px rgba(45, 172, 201, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(45, 172, 201, 0.5);
    color: white;
}

.btn-secondary {
    background-color: transparent;
    color: #0F172A;
    border: 1px solid #E2E8F0;
    border-radius: 100px;
    padding: 12px 32px;
    font-family: 'Manrope', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: #2DACC9;
    color: #2DACC9;
    background-color: #F8FAFC;
}

/* ==========================================
   SCROLL REVEAL ANIMATION
   ========================================== */
.reveal-text {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-text.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar-card {
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 24px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.sidebar-title {
    font-family: 'Figtree', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0F172A;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #F1F5F9;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #64748B;
    line-height: 1.5;
}

.info-list li:last-child {
    margin-bottom: 0;
}

.info-list li strong {
    display: block;
    color: #0F172A;
    font-weight: 600;
    margin-bottom: 2px;
}

/* ==========================================
   SERVICE LIST ITEMS (KEY SERVICES)
   ========================================== */
.service-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #F1F5F9;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    transition: color 0.2s ease, padding-left 0.2s ease;
    text-decoration: none;
}

.service-item:last-child {
    border-bottom: none;
}

.service-item:hover {
    color: #2DACC9;
    padding-left: 6px;
}

.service-item i,
.service-item svg {
    flex-shrink: 0;
    color: #2DACC9;
    width: 16px;
    height: 16px;
}

/* ==========================================
   DEPT OVERVIEW CONTENT (replaces prose plugin)
   ========================================== */
.dept-overview-content {
    margin-bottom: 32px;
    /* Prevent any wide WYSIWYG content (tables, images, pre) from
       breaking the layout. Each department's content differs, so
       we need a hard boundary here. */
    overflow-x: hidden;
    max-width: 100%;
}

.dept-overview-content img,
.dept-overview-content table,
.dept-overview-content figure,
.dept-overview-content iframe {
    max-width: 100% !important;
    height: auto;
}

.dept-overview-content table {
    overflow-x: auto;
    display: block;
}

.dept-overview-content p {
    margin-bottom: 16px;
    line-height: 1.7;
}

.dept-overview-content p:last-child {
    margin-bottom: 0;
}

.dept-overview-content strong {
    font-weight: 700;
    color: #0F172A;
}

.dept-overview-content ul,
.dept-overview-content ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

.dept-overview-content li {
    margin-bottom: 6px;
    line-height: 1.6;
}

/* ==========================================
   DOCTOR GRID
   ========================================== */
.doctor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
}

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

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

/* ==========================================
   DOCTOR CARD
   Matches actual template HTML:
   <div class="doctor-card">
     <div class="h-64 bg-gray-100 overflow-hidden">...</div>
     <div class="p-6 flex flex-col flex-grow">...</div>
   </div>
   ========================================== */
.doctor-card {
    background: #FFFFFF;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid #E2E8F0;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.doctor-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -4px rgba(15, 23, 42, 0.12);
    border-color: #2DACC9;
}

/* Image container inside card */
.doctor-card > div:first-child {
    flex-shrink: 0;
}

/* View profile button inside card */
.doctor-card a[href]:last-child,
.doctor-card .view-profile-btn {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.doctor-card:hover .view-profile-btn {
    background-color: #0F172A !important;
    color: #FFFFFF !important;
    border-color: #0F172A !important;
}

.doctor-card .view-profile-btn {
    color: #0F172A;
    text-decoration: none;
}

/* ==========================================
   PROCEDURE CARDS
   ========================================== */
.procedure-card {
    background: #F8FAFC;
    border-radius: 16px;
    padding: 24px;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid transparent;
}

.procedure-card:hover {
    background: white;
    border-color: #2DACC9;
    box-shadow: 0 10px 30px -5px rgba(45, 172, 201, 0.1);
}

/* ==========================================
   PACKAGES SPLIDE SLIDER (sidebar)
   ========================================== */
.packages-slider .splide__pagination {
    bottom: 8px;
    position: relative;
    padding-top: 0;
    margin-top: 12px;
}

.packages-slider .splide__pagination__page {
    background: #CBD5E1;
    width: 6px;
    height: 6px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.packages-slider .splide__pagination__page.is-active {
    background: #2DACC9;
    transform: scale(1.3);
}

/* Hide arrows on the package slider (pagination dots only) */
.packages-slider .splide__arrows {
    display: none;
}

/* Default state: gray outlined arrow */
.packages-slider .pkg-arrow {
    background-color: #F8FAFC;
    border-color: #E2E8F0;
    color: #94A3B8;
}

/* Hover state: teal filled arrow with white icon */
.packages-slider a:hover .pkg-arrow {
    background-color: #2DACC9;
    border-color: #2DACC9;
    color: white;
}

.packages-slider a:hover .pkg-arrow svg {
    stroke: white;
}

/* ==========================================
   SPLIDE DOCTOR CAROUSEL
   ========================================== */
.shb-doctor-splide .splide__slide {
    /* Ensure cards fill their slide */
    display: flex;
    flex-direction: column;
}

.shb-doctor-splide .splide__slide .doctor-card {
    height: 100%;
}

/* Prevent image container from collapsing inside flex card */
.doctor-card > div:first-child {
    flex-shrink: 0;
    min-height: 256px;
}

.doctor-card > div:first-child img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center; /* anchor to top so face is always visible in portrait headshots */
    display: block;
}

/* ==========================================
   IOS SAFARI WEBKIT COMPOSITING FIX
   Splide animates .splide__list via translateX(). On real iOS devices (not
   Chrome mobile emulator), WebKit promotes transformed children to their own
   GPU compositing layers. Without a matching compositing layer on the PARENT
   (.splide__track), the child layer can visually escape the parent's
   overflow:hidden boundary — causing the slide list to bleed beyond the track.
   Forcing translateZ(0) on the track creates a GPU compositing layer for it,
   which properly clips all child compositing layers on iOS WebKit.
   ========================================== */
.shb-doctor-splide .splide__track {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Arrow buttons: match brand */
.shb-doctor-splide .splide__arrow {
    background: white;
    border: 1px solid #E2E8F0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    width: 44px;
    height: 44px;
    opacity: 1;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.shb-doctor-splide .splide__arrow:hover {
    background: #2DACC9;
    border-color: #2DACC9;
}

.shb-doctor-splide .splide__arrow svg {
    fill: #0F172A;
    width: 16px;
    height: 16px;
    transition: fill 0.2s ease;
}

.shb-doctor-splide .splide__arrow:hover svg {
    fill: white;
}

/* Pagination dots */
.shb-doctor-splide .splide__pagination {
    bottom: -32px;
}

.shb-doctor-splide .splide__pagination__page {
    background: #E2E8F0;
    width: 8px;
    height: 8px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.shb-doctor-splide .splide__pagination__page.is-active {
    background: #2DACC9;
    transform: scale(1.2);
}

/* Extra bottom space for pagination dots */
.shb-doctor-splide {
    padding-bottom: 48px;
}

/* ==========================================
   GLOBAL OVERFLOW CONTAINMENT
   Applies at ALL screen sizes to prevent any
   department-specific content from widening the page.

   min-width: 0 is REQUIRED on every flex/grid child — by default, flex/grid
   items have min-width: auto which allows them to grow as wide as their
   content, breaking out of their cell and causing horizontal overflow.
   ========================================== */
.shb-dept-page {
    overflow-x: hidden;
}

.shb-dept-page .grid {
    min-width: 0;
}

.shb-dept-page .grid > * {
    min-width: 0;
}

.shb-dept-page main {
    overflow-x: hidden;
    min-width: 0;
}

.shb-dept-page main > section {
    min-width: 0;
    max-width: 100%;
}

.shb-dept-page aside {
    min-width: 0;
    overflow: clip;
}

/* Every direct flex/grid child in the content grid must not escape its cell */
.shb-dept-page .grid > aside,
.shb-dept-page .grid > main {
    min-width: 0;
    overflow: clip;
}

@media (max-width: 767px) {

    /* ------------------------------------------
       HERO: Mobile-specific adjustments.
       Full-width breakout (left/margin-left)
       is now applied globally above this media
       query so no need to repeat here.
       ------------------------------------------ */
    .shb-dept-hero {
        min-height: 340px;
    }

    /* More padding to clear the fixed header */
    .shb-dept-hero > div.relative.z-10 {
        padding-top: 80px !important;
        padding-bottom: 40px !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    /* Hero h1: prevent text overflow on narrow screens */
    .shb-dept-hero h1 {
        font-size: clamp(24px, 7vw, 40px) !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Stats row: tighter gap on small screens */
    .shb-dept-hero .flex.flex-wrap {
        gap: 20px !important;
    }

    /* ------------------------------------------
       PAGE WRAPPER: remove excessive vertical
       padding and ensure no horizontal overflow.
       Use both max-width AND overflow to prevent
       any child element from expanding the page.
       ------------------------------------------ */
    .shb-dept-page {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Tighter horizontal padding inside the content area */
    .shb-dept-page > div {
        padding-left: 16px !important;
        padding-right: 16px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ensure headings don't overflow on mobile */
    .shb-dept-page h2,
    .shb-dept-page h3,
    .shb-dept-page h4 {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* ------------------------------------------
       SPLIDE SLIDER: Hard-contain the carousel
       and its parent section so no child element
       can expand the page beyond 100vw on mobile.
       ------------------------------------------ */
    .shb-dept-page main > section:has(#shb-doctor-splide),
    .shb-dept-page main > section:last-of-type {
        overflow: hidden !important;
        max-width: 100% !important;
    }

    #shb-doctor-splide,
    .shb-doctor-splide,
    .shb-doctor-splide .splide__track {
        overflow: hidden !important;
        max-width: 100% !important;
    }
    /* .splide__list is intentionally excluded: the list must extend beyond the
       track width to hold all slides. The track already clips it with
       overflow: hidden. Adding overflow:hidden on the list breaks Splide's
       internal transform-based slide positioning. */

    /* ------------------------------------------
       DOCTOR CARD IMAGE: fixed height so the
       image never collapses inside the flex card
       or the Splide slider.
       360px gives a comfortable headshot crop on
       a full-width mobile card (one per screen).
       object-position: top center anchors the
       image to the top so the doctor's face is
       always visible in portrait headshots.
       ------------------------------------------ */
    .doctor-card > div:first-child {
        height: 360px !important;
        min-height: 360px !important;
        flex-shrink: 0 !important;
    }

    .doctor-card > div:first-child img {
        object-position: top center !important;
    }

    /* Splide track: let cards size naturally */
    .shb-doctor-splide .splide__slide {
        align-items: stretch;
    }

    .shb-doctor-splide .splide__slide .doctor-card {
        height: auto !important;
    }

    /* ------------------------------------------
       SIDEBAR
       ------------------------------------------ */
    .sidebar-card {
        padding: 20px;
    }

    /* ------------------------------------------
       BUTTONS
       ------------------------------------------ */
    .btn-primary,
    .btn-secondary {
        padding: 10px 24px;
        font-size: 14px;
    }

    /* Full-width Book Appointment button on mobile */
    .sidebar-card .btn-primary {
        width: 100%;
    }
}

