/* ============================================================
   Raghadan Secondary School - Custom Theme
   Built on top of Bootstrap 5 (RTL & LTR aware)
   ============================================================ */

:root {
    --bs-primary: #0d47a1;
    --bs-primary-rgb: 13, 71, 161;
    --school-gold: #c8a951;
    --school-dark: #0a2a5e;
    --school-light: #f4f7fb;
}

body {
    font-family: 'Cairo', 'Inter', sans-serif;
    background-color: #fafbfd;
    color: #2c3e50;
}

/* ---------- Brand: school name between two logos ---------- */
.brand-with-logos {
    gap: .6rem !important;
}
.brand-with-logos .brand-logo {
    flex: 0 0 auto;
    background: #fff;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    transition: transform .3s ease;
}
.brand-with-logos:hover .brand-logo-start { transform: translateX(-3px) rotate(-6deg); }
.brand-with-logos:hover .brand-logo-end   { transform: translateX(3px)  rotate(6deg);  }
[dir="rtl"] .brand-with-logos:hover .brand-logo-start { transform: translateX(3px)  rotate(6deg);  }
[dir="rtl"] .brand-with-logos:hover .brand-logo-end   { transform: translateX(-3px) rotate(-6deg); }

/* sidebar variant: white ring so the logo reads on the dark gradient */
.admin-sidebar .brand-with-logos .brand-logo {
    background: rgba(255,255,255,.92);
}
.admin-sidebar .brand-with-logos:hover .brand-logo-start,
.admin-sidebar .brand-with-logos:hover .brand-logo-end {
    transform: none;
}

/* keep the name from squashing between the two logos on small screens */
@media (max-width: 400px) {
    .brand-with-logos .brand-logo { display: none; }
    .brand-with-logos .brand-logo-start { display: block; }
}

/* ---------- Top bar ---------- */
.top-bar {
    background: linear-gradient(90deg, var(--school-dark), var(--bs-primary)) !important;
    font-size: .85rem;
}

/* ---------- Brand ---------- */
.navbar-brand {
    font-size: 1.05rem;
    color: var(--school-dark) !important;
}
.navbar-brand strong {
    font-weight: 800;
}
.brand-text {
    line-height: 1.2;
}

/* ---------- Navbar links ---------- */
.navbar .nav-link {
    color: var(--school-dark);
    border-radius: .4rem;
    padding: .45rem .85rem;
    transition: all .25s ease;
    position: relative;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff;
    background: var(--bs-primary);
}

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}
.btn-primary:hover {
    background: var(--school-dark);
    border-color: var(--school-dark);
}
.btn-outline-primary {
    color: var(--bs-primary);
    border-color: var(--bs-primary);
}
.btn-outline-primary:hover {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* ---------- Hero slider ---------- */
.hero-slider .carousel-item {
    height: 78vh;
    min-height: 420px;
    background-size: cover;
    background-position: center;
    position: relative;
}
.hero-slider .carousel-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10,42,94,.88), rgba(10,42,94,.25));
}
.hero-slider .carousel-caption {
    bottom: 20%;
    z-index: 2;
}
.hero-slider h2 {
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    text-shadow: 0 3px 14px rgba(0,0,0,.5);
    animation: slideUp .9s ease both;
}
.hero-slider p {
    font-size: clamp(1rem, 2vw, 1.4rem);
    animation: slideUp 1.1s .15s ease both;
}
.hero-slider .btn {
    animation: slideUp 1.2s .3s ease both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Carousel controls */
.carousel-control-prev-icon,
.carousel-control-next-icon {
    background-color: var(--bs-primary);
    border-radius: 50%;
    padding: 1.6rem;
    background-size: 55%;
}

/* ---------- Section titles ---------- */
.section-title {
    position: relative;
    font-weight: 800;
    color: var(--school-dark);
    margin-bottom: 2rem;
    padding-bottom: .8rem;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bs-primary), var(--school-gold));
}

/* ---------- Cards ---------- */
.card {
    border: none;
    border-radius: .9rem;
    transition: transform .3s ease, box-shadow .3s ease;
    overflow: hidden;
}
.card.shadow-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 1rem 2.2rem rgba(13,71,161,.18) !important;
}
.card-img-top {
    height: 210px;
    object-fit: cover;
    transition: transform .5s ease;
}
.card.shadow-hover:hover .card-img-top {
    transform: scale(1.07);
}

/* ---------- Speeches ---------- */
.speech-card {
    background: linear-gradient(145deg, #ffffff, var(--school-light));
    border-radius: 1rem;
    border-inline-start: 5px solid var(--bs-primary);
    box-shadow: 0 .5rem 1.4rem rgba(0,0,0,.06);
}
.speech-avatar {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--bs-primary);
    box-shadow: 0 .4rem 1rem rgba(0,0,0,.15);
}

/* ---------- Feature / facility boxes ---------- */
.feature-box {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 .4rem 1.2rem rgba(0,0,0,.06);
    transition: all .3s ease;
    height: 100%;
}
.feature-box:hover {
    transform: translateY(-6px);
    box-shadow: 0 1rem 2rem rgba(13,71,161,.15);
}
.feature-box .icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    font-size: 1.9rem;
    border-radius: 50%;
    background: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
}

/* ---------- Gallery ---------- */
.gallery-item {
    position: relative;
    border-radius: .9rem;
    overflow: hidden;
    display: block;
}
.gallery-item img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    transition: transform .5s ease;
}
.gallery-item:hover img {
    transform: scale(1.1);
}
.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13,71,161,.55);
    display: grid;
    place-items: center;
    opacity: 0;
    transition: opacity .35s ease;
}
.gallery-item:hover .gallery-overlay {
    opacity: 1;
}
.gallery-overlay i {
    color: #fff;
    font-size: 2.2rem;
}

/* ---------- Timeline (news page) ---------- */
.timeline {
    position: relative;
    padding-inline-start: 2rem;
}
.timeline::before {
    content: '';
    position: absolute;
    inset-block: 0;
    inset-inline-start: 8px;
    width: 2px;
    background: var(--bs-primary);
    opacity: .25;
}
.timeline-item {
    position: relative;
    padding-bottom: 2rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    inset-inline-start: -1.65rem;
    top: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bs-primary);
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .2);
}

/* ---------- Map ---------- */
.map-embed {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 .6rem 1.6rem rgba(0,0,0,.12);
    line-height: 0;
}

/* ---------- Footer ---------- */
.site-footer {
    background: linear-gradient(160deg, var(--school-dark), #061a3d);
}
.footer-links a {
    color: rgba(255,255,255,.6);
    text-decoration: none;
    display: inline-block;
    padding: .18rem 0;
    transition: all .2s;
}
.footer-links a:hover {
    color: #fff;
    transform: translateX(4px);
}
[dir="rtl"] .footer-links a:hover {
    transform: translateX(-4px);
}
.social-link {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: #fff;
    transition: all .3s;
}
.social-link:hover {
    background: var(--school-gold);
    transform: translateY(-4px);
}

/* ---------- Page hero (inner pages) ---------- */
.page-hero {
    background: linear-gradient(120deg, var(--school-dark), var(--bs-primary));
    color: #fff;
    padding: 4rem 0 3.2rem;
    text-align: center;
}
.page-hero h1 {
    font-weight: 800;
}
.breadcrumb-custom {
    background: transparent;
    justify-content: center;
    margin: 0;
}
.breadcrumb-custom a { color: rgba(255,255,255,.75); text-decoration: none; }
.breadcrumb-custom .active { color: #fff; }

/* ---------- Contact form ---------- */
.contact-form .form-control,
.contact-form .form-select {
    border-radius: .6rem;
    padding: .75rem 1rem;
    border: 1px solid #e0e6ed;
}
.contact-form .form-control:focus,
.contact-form .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15);
}

/* ---------- Pagination ---------- */
.pagination .page-link {
    color: var(--bs-primary);
    border-radius: .5rem;
    margin: 0 .18rem;
    border: none;
    box-shadow: 0 .15rem .5rem rgba(0,0,0,.06);
}
.pagination .page-item.active .page-link {
    background: var(--bs-primary);
    color: #fff;
}

/* ---------- Alert ---------- */
.alert { border-radius: .7rem; border: none; }

/* ---------- Utilities ---------- */
.text-primary { color: var(--bs-primary) !important; }
.bg-primary-soft { background: rgba(var(--bs-primary-rgb), .08) !important; }
.bg-primary-soft.text-primary,
.text-primary    { color: var(--bs-primary) !important; }
.bg-info-soft    { background: rgba(13,202,240,.12) !important; }
.text-info       { color: #0aa2c0 !important; }
.bg-success-soft { background: rgba(25,135,84,.12) !important; }
.text-success    { color: #198754 !important; }
.rounded-2xl { border-radius: 1.2rem !important; }
.min-vh-50 { min-height: 50vh; }

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* ============================================================
   STAFF SECTION + ORGANIZATIONAL TREE
   ============================================================ */

/* ---------- Teaser staff cards ---------- */
.staff-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem 1rem;
    text-align: center;
    box-shadow: 0 .35rem 1rem rgba(0,0,0,.06);
    transition: transform .3s ease, box-shadow .3s ease;
    height: 100%;
    border: 1px solid rgba(13,71,161,.07);
}
.staff-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 1rem 2rem rgba(13,71,161,.16);
}
.staff-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bs-primary);
    box-shadow: 0 .3rem .8rem rgba(0,0,0,.18);
    margin: 0 auto .85rem;
    display: block;
}
.staff-card h6 {
    font-weight: 700;
    margin-bottom: .2rem;
    color: var(--school-dark);
}
.staff-role {
    font-size: .82rem;
    color: var(--bs-primary);
    font-weight: 600;
}

/* ---------- "View All Team" trigger ---------- */
.team-toggle {
    position: relative;
    overflow: hidden;
}
.team-toggle .chev {
    display: inline-block;
    transition: transform .35s ease;
}
.team-toggle[aria-expanded="true"] .chev {
    transform: rotate(180deg);
}
/* subtle pulse to draw attention */
@keyframes teamPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(13,71,161,.35); }
    50%     { box-shadow: 0 0 0 .5rem rgba(13,71,161,0); }
}
.team-toggle.pulse { animation: teamPulse 2.4s ease-out infinite; }

/* ---------- The revealed organizational tree ---------- */
.team-panel {
    background: linear-gradient(160deg, #ffffff, var(--school-light));
    border-radius: 1.2rem;
    box-shadow: 0 .6rem 1.6rem rgba(0,0,0,.08) inset;
}
.org-tree {
    direction: inherit;
    padding: 1rem 0;
}
/* each horizontal tier of the chart */
.org-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0 1.25rem;
}
.org-row + .org-row { margin-top: 2.6rem; }

/* a node = card + optional connector to its children */
.org-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 210px;
    padding-top: 2.4rem;            /* room for the connector rail */
}
/* root node (no incoming line) */
.org-node.is-root { padding-top: 0; }

/* vertical drop from the tier above down into this node */
.org-node::before {
    content: "";
    position: absolute;
    top: calc(-1 * 2.6rem);          /* reaches up into the row gap */
    left: 50%;
    width: 2px;
    height: calc(2.4rem + 2.6rem);  /* gap + node's own rail space */
    background: rgba(var(--bs-primary-rgb), .3);
    transform: translateX(-50%);
}
.org-node.is-root::before { display: none; }

/* horizontal rail that joins siblings, drawn via ::after */
.org-node::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(var(--bs-primary-rgb), .3);
}
.org-node:first-child::after { left: 50%; }
.org-node:last-child::after  { right: 50%; }
.org-node:only-child::after  { display: none; }
.org-node.is-root::after    { display: none; }

/* the person card inside a node */
.org-card {
    background: #fff;
    border-radius: .9rem;
    padding: 1rem .75rem;
    width: 100%;
    text-align: center;
    box-shadow: 0 .3rem .9rem rgba(0,0,0,.07);
    border: 1px solid rgba(var(--bs-primary-rgb), .12);
    transition: transform .25s ease, box-shadow .25s ease;
}
.org-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 .8rem 1.5rem rgba(13,71,161,.18);
}
.org-card .staff-photo { width: 78px; height: 78px; }
.org-card h6 { font-size: .9rem; font-weight: 700; margin: .5rem 0 .15rem; }
.org-card .staff-role { font-size: .78rem; }

/* tier tints by category */
.org-node[data-cat="admin"] .org-card       { border-top: 3px solid var(--bs-primary); }
.org-node[data-cat="educational"] .org-card  { border-top: 3px solid var(--school-gold); }
.org-node[data-cat="support"] .org-card     { border-top: 3px solid #198754; }

/* children block sits under a node's card */
.org-children {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0 1.25rem;
    width: 100%;
}
/* vertical line that descends into the children block */
.org-children::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 2.4rem;
    background: rgba(var(--bs-primary-rgb), .3);
    transform: translateX(-50%);
    display: none; /* hooked by .has-children below */
}
.org-node.has-children { position: relative; }
.org-node.has-children > .org-children {
    position: relative;
    margin-top: 2.4rem;
}
.org-node.has-children > .org-children::before {
    display: block;
}

/* ---------- Smooth fade-in for the revealed content ----------
   NOTE: Bootstrap puts .show / .collapsing on the element that has
   class="collapse" (that is #orgTree), NOT on the inner .team-panel,
   so the reveal selector must descend from #orgTree.               */
.team-panel .org-tree {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease .05s, transform .5s ease .05s;
}
#orgTree.show .org-tree,
#orgTree.collapsing .org-tree,
.team-panel.is-open .org-tree {
    opacity: 1;
    transform: translateY(0);
}
/* Fallback: also honour any .collapse/.collapsing ancestor */
.collapse.show .org-tree,
.collapse.collapsing .org-tree {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Gallery: media grid (images + videos) ---------- */
.gallery-grid .gallery-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}
.gallery-grid .gallery-item img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    transition: transform .5s ease;
    display: block;
}
.gallery-grid .gallery-item.is-video img {
    height: 200px;
}
.gallery-grid .gallery-item:hover img {
    transform: scale(1.1);
}
.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13,71,161,.55);
    display: grid;
    place-items: center;
    opacity: 0;
    transition: opacity .35s ease;
}
.gallery-item:hover .gallery-overlay,
.gallery-item:focus-visible .gallery-overlay {
    opacity: 1;
}
.gallery-overlay i {
    color: #fff;
    font-size: 2.2rem;
}
.gallery-item.is-video .gallery-overlay {
    background: rgba(220,53,69,.45);
}
.gallery-item.is-video .gallery-overlay i {
    font-size: 3rem;
}
/* small "VIDEO" chip on video tiles */
.gallery-badge {
    position: absolute;
    bottom: .5rem;
    inset-inline-start: .5rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .5rem;
    border-radius: 2rem;
    font-size: .7rem;
    font-weight: 600;
    color: #fff;
    background: rgba(220,53,69,.92);
}
.gallery-item.not-playable {
    cursor: default;
}
.gallery-item.not-playable img {
    filter: grayscale(1);
    opacity: .7;
}

/* ---------- Gallery modal player ---------- */
.gallery-modal .modal-content {
    border-radius: 1rem;
    overflow: hidden;
}
.gallery-modal .gallery-modal-bar {
    background: #0a2a5e;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.gallery-stage {
    display: grid;
    place-items: center;
    min-height: 320px;
    max-height: 76vh;
    background: #000;
    overflow: hidden;
}
.gallery-stage img {
    max-width: 100%;
    max-height: 76vh;
    object-fit: contain;
}
.gallery-stage-link {
    display: block;
    line-height: 0;
}
.gallery-stage--video {
    padding: 0;
}
.gallery-stage--video iframe,
.gallery-stage--video video {
    width: 100%;
    height: 100%;
    min-height: 320px;
    max-height: 76vh;
    border: 0;
    background: #000;
}
.gallery-modal .btn-outline-light {
    --bs-btn-color: rgba(255,255,255,.85);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: rgba(255,255,255,.15);
    --bs-btn-hover-color: #fff;
}
.gallery-modal .btn-close-white {
    color: #fff;
}

/* Lightbox fixes */
.lb-data .lb-caption { font-family: 'Cairo', sans-serif; }

/* ---------- Responsive: stack into a simple grid on small screens ---------- */
@media (max-width: 767.98px) {
    .org-row,
    .org-children {
        flex-direction: column;
        align-items: center;
        gap: 1.25rem;
    }
    .org-node { width: 100%; max-width: 300px; }
    .org-row + .org-row { margin-top: 1.25rem; }
    .org-node.has-children > .org-children { margin-top: 1.25rem; }
    /* simpler connectors on mobile: keep only the drop line */
    .org-node::after { display: none; }
    .org-node::before {
        top: -1.25rem;
        height: calc(1.25rem + 2.4rem);
    }
}

/* ---------- Section: light rules ---------- */
.section-title.text-start::after {
    left: 0;
    transform: none;
}

/* ---------- Clickable staff cards ---------- */
.staff-click {
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}
.staff-click:focus-visible {
    outline: 3px solid rgba(var(--bs-primary-rgb), .35);
    outline-offset: 3px;
}
/* small "i" badge that hints the card opens details */
.staff-more {
    display: inline-grid;
    place-items: center;
    width: 26px; height: 26px;
    margin-top: .5rem;
    border-radius: 50%;
    font-size: .8rem;
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .1);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .3s ease, transform .3s ease;
}
.staff-click:hover .staff-more,
.staff-click:focus-visible .staff-more {
    opacity: 1;
    transform: translateY(0);
}
.org-card .staff-more {
    position: absolute;
    top: .5rem;
    inset-inline-end: .5rem;
    margin-top: 0;
}
.org-card { position: relative; }

/* ---------- Staff detail modal ---------- */
.staff-modal-head {
    background: linear-gradient(150deg, var(--school-dark), var(--bs-primary));
}
.staff-modal-photo {
    width: 120px; height: 120px;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 .4rem 1rem rgba(0,0,0,.25);
    margin-top: -1.5rem;
    background: #fff;
}

/* ============================================================
   STUDENT BOOKS
   ============================================================ */
.book-card {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 .35rem 1rem rgba(0,0,0,.07);
    transition: transform .3s ease, box-shadow .3s ease;
    display: flex;
    flex-direction: column;
}
.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 1rem 2rem rgba(13,71,161,.18);
}
.book-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #eef2f7;
}
.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
}
.book-card:hover .book-cover img {
    transform: scale(1.06);
}
.book-format {
    position: absolute;
    top: .55rem;
    inset-inline-end: .55rem;
    padding: .12rem .5rem;
    border-radius: 2rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .03em;
    color: #fff;
    background: rgba(220,53,69,.92);
}
.book-card .card-body { padding: 1rem; }
.book-title {
    font-size: .98rem;
    font-weight: 700;
    color: var(--school-dark);
    margin-bottom: .35rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

/* ============================================================
   TEXT-TO-SPEECH
   ============================================================ */
.tts-bar {
    border-inline-start: 4px solid var(--bs-primary) !important;
}
.tts-bar .progress {
    border-radius: 0 0 1rem 1rem;
    background: rgba(var(--bs-primary-rgb), .08);
}
.tts-bar .progress-bar {
    background: linear-gradient(90deg, var(--bs-primary), var(--school-gold));
    transition: width .25s linear;
}
.tts-status { font-size: .85rem; }
.tts-reading {
    box-shadow: inset 4px 0 0 var(--bs-primary);
}
/* ---------- Divider ---------- */
.section-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--bs-primary-rgb), .25), transparent);
}
