/* =====================================================================
   Board of Directors page
   Reuses site palette tokens defined in static/css/mysite.css
     --clr-primary, --clr-primary-mid, --clr-text, --clr-text-mid,
     --clr-bg-card, --clr-border, --clr-bg-alt
   ===================================================================== */

.board-page {
    padding: 32px 0 80px;
    color: var(--clr-text, #1a2332);
}

/* ---------- Header ---------- */

.board-page__header {
    text-align: center;
    margin-bottom: 24px;
}

.board-page__title {
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    color: var(--clr-primary-dark, #013d6e);
    margin: 0 0 12px;
}

.board-page__intro {
    color: var(--clr-text-mid, #4a5568);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 70ch;
    margin: 0 auto;
}

/* ---------- Cycle selector bar ---------- */

/* Use margin-bottom only — `.container` already supplies `margin: 0 auto`
   for horizontal centering. The `margin: 0 0 40px` shorthand previously
   used here clobbered the auto left/right margins, anchoring the bar to
   the start (right edge in RTL) instead of centering it. */
.board-page__selector-bar {
    margin-bottom: 40px;
}

.board-cycle-selector {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--clr-bg-alt, #f3f7fc);
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    /* Constrain to ~half the page-content width and center inside the
       `.container`-width bar. */
    max-width: 600px;
    margin: 0 auto;
}

.board-cycle-selector__label {
    font-weight: 600;
    color: var(--clr-text, #1a2332);
    font-size: 1rem;
    flex: 0 0 auto;
}

.board-cycle-selector__select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 8px;
    background: #fff;
    color: var(--clr-text, #1a2332);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23015599' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-inline-start: 40px;
}

[dir="ltr"] .board-cycle-selector__select {
    background-position: right 14px center;
    padding-inline-end: 40px;
    padding-inline-start: 14px;
}

.board-cycle-selector__select:focus {
    outline: 2px solid var(--clr-primary, #015599);
    outline-offset: 2px;
}

.board-cycle-selector__submit {
    padding: 10px 20px;
    background: var(--clr-primary, #015599);
    color: #fff;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
}

/* ---------- Custom cycle dropdown (JS enhancement) ----------
   The native <select> popup sizes itself to the widest option text and
   overflows the viewport on phones. JS hides the <select> and swaps in a
   button + listbox whose popup matches the control width; long cycle
   titles wrap inside it instead of widening it. */

.board-cycle-selector.is-enhanced .board-cycle-selector__select {
    display: none;
}

.board-cycle-dd {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.board-cycle-dd__toggle {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 8px;
    background: #fff;
    color: var(--clr-text, #1a2332);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-align: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23015599' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 14px center;
    padding-inline-start: 40px;
}

[dir="ltr"] .board-cycle-dd__toggle {
    background-position: right 14px center;
    padding-inline-end: 40px;
    padding-inline-start: 14px;
}

.board-cycle-dd__toggle:focus-visible {
    outline: 2px solid var(--clr-primary, #015599);
    outline-offset: 2px;
}

.board-cycle-dd__list {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    max-height: min(320px, 60vh);
    overflow-y: auto;
    z-index: 50;
}

.board-cycle-dd__option {
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--clr-text, #1a2332);
    /* Long titles wrap onto a second line instead of widening the list. */
    overflow-wrap: break-word;
}

.board-cycle-dd__option:hover,
.board-cycle-dd__option:focus-visible {
    background: var(--clr-bg-alt, #f3f7fc);
    outline: none;
}

.board-cycle-dd__option.is-selected {
    background: var(--clr-primary, #015599);
    color: #fff;
    font-weight: 600;
}

/* On narrow screens the side-by-side label + select leaves too little width
   for the long cycle titles ("الدورة العشرون - من سنة 2026 الى 2029"), so the
   select clips its text mid-digit. Stack the label above a full-width select
   and trim font/padding so the longest title fits. */
@media (max-width: 640px) {
    .board-cycle-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px 16px;
    }

    .board-cycle-selector__select,
    .board-cycle-dd__toggle {
        width: 100%;
        font-size: 0.9rem;
        padding-block: 9px;
        padding-inline-end: 12px;
        padding-inline-start: 34px;
        background-position: left 12px center;
    }

    [dir="ltr"] .board-cycle-selector__select,
    [dir="ltr"] .board-cycle-dd__toggle {
        background-position: right 12px center;
        padding-inline-end: 34px;
        padding-inline-start: 12px;
    }

    .board-cycle-dd__option {
        font-size: 0.9rem;
    }
}

/* ---------- Sections ---------- */

.board-page__body {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.board-section {
    width: 100%;
}

/* All level rows use the same centered flex layout. Cards have a fixed
   250px width (matching the photo render). flex-wrap: wrap makes them flow
   onto multiple lines on narrow viewports; justify-content: center keeps
   the last (partial) row centered too. */
.board-section__row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 24px;
}

/* ---------- Card ---------- */

.board-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--clr-bg-card, #fff);
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    cursor: pointer;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    flex: 0 0 250px;
    max-width: 100%;
    padding: 0;
    font: inherit;
    color: inherit;
}

.board-card:hover,
.board-card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
    outline: none;
}

.board-card:focus-visible {
    border-color: var(--clr-primary, #015599);
}

.board-card__photo-wrap {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--clr-bg-alt, #f3f7fc);
    overflow: hidden;
    position: relative;
}

.board-card__photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.board-card__photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-muted, #a0aec0);
    font-size: 4rem;
    background: linear-gradient(180deg, #e9eef5 0%, #d6deeb 100%);
}

.board-card__placeholder-icon {
    opacity: 0.5;
}

.board-card__body {
    padding: 16px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.board-card__name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--clr-text, #1a2332);
    line-height: 1.4;
}

.board-card__role {
    font-size: 0.9rem;
    color: var(--clr-primary-mid, #0267b8);
    line-height: 1.4;
}

/* ---------- Modal ---------- */

.board-modal[hidden] {
    display: none !important;
}

.board-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.board-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.board-modal__dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 0;
}

@media (max-width: 640px) {
    .board-modal__dialog {
        grid-template-columns: 1fr;
        max-height: 95vh;
    }
}

.board-modal__close {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--clr-border, #ccd9e8);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--clr-text, #1a2332);
}

.board-modal__close:hover {
    background: #fff;
}

.board-modal__media {
    background: var(--clr-bg-alt, #f3f7fc);
}

.board-modal__photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-height: 280px;
}

.board-modal__photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6rem;
    color: var(--clr-text-muted, #a0aec0);
    min-height: 280px;
}

.board-modal__content {
    padding: 28px 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.board-modal__name {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--clr-primary-darker, #01284a);
}

.board-modal__role {
    margin: 0;
    color: var(--clr-primary-mid, #0267b8);
    font-weight: 500;
}

.board-modal__bio {
    color: var(--clr-text-mid, #4a5568);
    line-height: 1.7;
    font-size: 0.95rem;
}

.board-modal__bio--empty {
    color: var(--clr-text-muted, #a0aec0);
    font-style: italic;
}

/* Body scroll-lock when a modal is open (toggled by JS) */
body.board-modal-open {
    overflow: hidden;
}

/* ---------- Empty state ---------- */

.board-page__empty {
    text-align: center;
    color: var(--clr-text-mid, #4a5568);
    padding: 60px 20px;
    background: var(--clr-bg-alt, #f3f7fc);
    border: 1px dashed var(--clr-border, #ccd9e8);
    border-radius: 14px;
}
