/* ==========================================================================
   Old Mizekians Association — Heritage design system
   Official school colours: Maroon #8A0808 / Gold #FF8000.
   Note: the --navy* variable names are a legacy token from an earlier pass —
   they now hold the brand MAROON, not blue. --maroon/--maroon-dark hold a
   separate deeper red used only for danger/reject actions, kept distinct
   from the brighter brand maroon so error states still stand out.
   ========================================================================== */

:root {
    --navy: #8A0808;
    --navy-dark: #5c0505;
    --navy-tint: #a61010;
    --gold: #FF8000;
    --gold-light: #ffa857;
    --maroon: #6e1423;
    --maroon-dark: #4c0e18;
    --cream: #f7f2e7;
    --parchment: #efe7d4;
    --ink: #201d18;
    --muted: #5c5747;
    --line: #ddd2b3;
    --white: #ffffff;
    --radius: 6px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
    --serif: Georgia, 'Times New Roman', 'Playfair Display', serif;
    --sans: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

html, body {
    /* Defensive backstop: long unbroken strings (emails, URLs, names) should
       wrap rather than silently force the whole page into horizontal scroll. */
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--cream);
    line-height: 1.6;
    overflow-wrap: break-word;
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
    font-family: var(--serif);
    color: var(--navy);
    line-height: 1.2;
    margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.3rem; }

a { color: var(--navy); }
a:hover { color: var(--maroon); }

p { margin: 0 0 1em; }

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 20px;
}

.section {
    padding: 64px 0;
}
.section--tight { padding: 40px 0; }
.section--parchment { background: var(--parchment); }
.section--navy { background: var(--navy); color: #dbe3ef; }
.section--navy h2, .section--navy h3 { color: var(--gold-light); }
.section--navy a { color: var(--gold-light); }

.eyebrow {
    display: inline-block;
    font-family: var(--sans);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--maroon);
    border-bottom: 2px solid var(--gold);
    padding-bottom: 4px;
    margin-bottom: 14px;
}
.section--navy .eyebrow { color: var(--gold-light); }

/* ---------- Top utility bar ---------- */
.topbar {
    background: var(--navy-dark);
    color: #b9c4d6;
    font-size: 0.8rem;
}
.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    min-height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
    row-gap: 4px;
}
.topbar a { color: #b9c4d6; text-decoration: none; margin-left: 18px; }
.topbar a:hover { color: var(--gold-light); }
.topbar .topbar-left span { margin-right: 18px; display: inline-block; }
.topbar a.topbar-donate {
    color: var(--gold);
    font-weight: 700;
    border: 1px solid var(--gold);
    border-radius: 999px;
    padding: 2px 12px;
    margin-left: 0;
}
.topbar a.topbar-donate:hover { background: var(--gold); color: var(--navy-dark); }

@media (max-width: 640px) {
    /* Email/phone are repeated in the footer — drop them here so the
       topbar never has to wrap onto the sticky header below it. */
    .topbar .topbar-left { display: none; }
    .topbar a { margin-left: 14px; }
}

/* ---------- Header / main nav ---------- */
header.site-header {
    background: var(--navy);
    border-bottom: 3px solid var(--gold);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 84px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--white);
}
.brand .brand-logo {
    /* The logo artwork has maroon wordmark text on a transparent background,
       which would nearly disappear directly on this maroon header — so it
       gets a light backing plate to read clearly regardless of page theme. */
    height: 56px;
    width: auto;
    flex-shrink: 0;
    background: var(--cream);
    padding: 6px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--gold);
}

nav.main-nav ul {
    list-style: none;
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
}
nav.main-nav a {
    color: #e7ecf4;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--radius);
    display: inline-block;
}
nav.main-nav a:hover,
nav.main-nav a.active {
    background: rgba(255, 128, 0, 0.16);
    color: var(--gold-light);
}
.nav-toggle { display: none; }

@media (max-width: 900px) {
    nav.main-nav { display: none; }
    .nav-toggle {
        display: inline-block;
        background: none;
        border: 1px solid var(--gold);
        color: var(--gold-light);
        padding: 8px 12px;
        border-radius: var(--radius);
    }
    nav.main-nav.open {
        display: block;
        position: absolute;
        top: 84px;
        left: 0;
        right: 0;
        background: var(--navy);
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    nav.main-nav.open ul { flex-direction: column; padding: 10px 20px 20px; }
}

/* ---------- Hero ---------- */
.hero {
    background:
        linear-gradient(160deg, rgba(138,8,8,0.92), rgba(138,8,8,0.85)),
        repeating-linear-gradient(45deg, rgba(255,128,0,0.05) 0 2px, transparent 2px 40px);
    color: var(--white);
    padding: 90px 0 70px;
    text-align: center;
    border-bottom: 4px solid var(--gold);
}
.hero .eyebrow { color: var(--gold-light); border-color: var(--gold-light); }
.hero h1 { color: var(--white); max-width: 820px; margin-left: auto; margin-right: auto; }
.hero p.lede {
    max-width: 700px;
    margin: 0 auto 28px;
    font-size: 1.1rem;
    color: #cfd8e6;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,128,0,0.14);
    border: 1px solid var(--gold);
    color: var(--gold-light);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 22px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 12px 24px;
    border-radius: var(--radius);
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
}
.btn-gold { background: var(--gold); color: var(--navy-dark); }
.btn-gold:hover { background: var(--gold-light); color: var(--navy-dark); }
.btn-outline { border-color: var(--gold); color: var(--gold-light); background: transparent; }
.btn-outline:hover { background: rgba(255,128,0,0.14); color: var(--gold-light); }
.btn-outline-navy { border-color: var(--navy); color: var(--navy); background: transparent; }
.btn-outline-navy:hover { background: rgba(138,8,8,0.08); color: var(--navy); }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { background: var(--navy-tint); color: var(--white); }
.btn-maroon { background: var(--maroon); color: var(--white); }
.btn-maroon:hover { background: var(--maroon-dark); }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- Cards / grids ---------- */
.grid {
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.card img { aspect-ratio: 16/10; object-fit: cover; width: 100%; }
.card-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.card-body h3 { margin-bottom: 8px; }
.card-body .meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.card-body p { color: #40402f; }
.card-body .btn { margin-top: auto; align-self: flex-start; }
.card-gold-top { border-top: 4px solid var(--gold); }

/* Events page: the single soonest event (or ties on its date) gets primary
   focus; the next distinct date gets a lighter highlight. */
.event-grid-featured { grid-template-columns: 1fr; }
.event-featured {
    flex-direction: row;
    border: 2px solid var(--gold);
    box-shadow: 0 8px 28px rgba(138,8,8,0.16);
}
.event-featured img { width: 42%; aspect-ratio: auto; height: 100%; min-height: 220px; }
.event-featured .card-body { padding: 28px; }
.event-featured .badge-navy { background: var(--navy); color: #fff; margin-left: 6px; }
@media (max-width: 720px) {
    .event-featured { flex-direction: column; }
    .event-featured img { width: 100%; aspect-ratio: 16/10; min-height: 0; }
}
.event-highlight { border-top: 4px solid var(--maroon); }

/* ---------- Timeline (History page) ---------- */
.timeline { position: relative; margin: 40px 0; padding-left: 32px; border-left: 3px solid var(--gold); }
.timeline-item { position: relative; padding-bottom: 36px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -41px;
    top: 4px;
    width: 16px;
    height: 16px;
    background: var(--navy);
    border: 3px solid var(--gold);
    border-radius: 50%;
}
.timeline-year { font-family: var(--serif); font-weight: 700; color: var(--maroon); font-size: 1.1rem; }

/* ---------- Plaque / quote motif ---------- */
.plaque {
    background: var(--navy);
    color: var(--gold-light);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    font-family: var(--serif);
    font-size: 1.2rem;
    font-style: italic;
}

.contact-grid {
    display: grid;
    gap: 32px;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.3fr);
    align-items: start;
}
@media (max-width: 700px) {
    .contact-grid { grid-template-columns: 1fr; }
}

/* ---------- Cookie consent banner ---------- */
.cookie-consent {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: var(--navy-dark);
    color: #dbe3ef;
    padding: 16px 24px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
    border-top: 3px solid var(--gold);
}
.cookie-consent p { margin: 0 0 10px; font-size: 0.88rem; max-width: 900px; }
.cookie-consent a { color: var(--gold-light); }
@media (max-width: 600px) {
    .cookie-consent .btn-row { justify-content: stretch !important; }
    .cookie-consent .btn-row .btn { flex: 1; }
}

/* ---------- Simple bar chart (Analytics / Membership Reports) ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.bar-chart-row { display: grid; grid-template-columns: 140px 1fr 60px; align-items: center; gap: 10px; font-size: 0.88rem; }
.bar-chart-label { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-chart-track { background: var(--parchment); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-chart-fill { background: var(--gold); height: 100%; border-radius: 999px; }
.bar-chart-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
    .bar-chart-row { grid-template-columns: 100px 1fr 44px; font-size: 0.8rem; }
}

/* ---------- Contact dialog (Alumni Directory relay message) ---------- */
.contact-dialog {
    border: none;
    border-radius: var(--radius);
    padding: 28px;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.contact-dialog::backdrop { background: rgba(20, 10, 5, 0.6); }
.contact-dialog h3 { margin-top: 0; }

/* ---------- Gallery: YouTube video thumbnails + embed dialog ---------- */
.video-thumb {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
}
.video-thumb img { display: block; width: 100%; }
.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(20, 10, 5, 0.65);
    color: var(--gold-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    padding-left: 4px;
}
.video-dialog { max-width: 720px; }
.video-embed-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-embed-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Link preview card (Facebook/LinkedIn-style link unfurl) ---------- */
.link-preview-card {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    background: var(--white);
    box-shadow: var(--shadow);
    margin: 20px 0;
}
.link-preview-card img { width: 180px; height: 130px; object-fit: cover; flex-shrink: 0; }
.link-preview-card .lpc-body { padding: 16px; min-width: 0; }
.link-preview-card .lpc-title { font-family: var(--serif); color: var(--navy); font-weight: 700; margin-bottom: 6px; }
.link-preview-card .lpc-desc { color: var(--muted); font-size: 0.88rem; }
.link-preview-card .lpc-url { font-size: 0.72rem; color: var(--gold); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 8px; }
@media (max-width: 500px) {
    .link-preview-card { flex-direction: column; }
    .link-preview-card img { width: 100%; height: 160px; }
}

/* ---------- Attachment list (News/Events documents & pictures) ---------- */
.attachment-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attachment-list a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    text-decoration: none;
    color: var(--navy);
    font-size: 0.88rem;
}
.attachment-list a:hover { border-color: var(--gold); color: var(--maroon); }

/* Long-form article copy (History, News articles) — justified for a more
   polished, book-like read, with hyphenation so justified spacing doesn't
   create awkward gaps on narrower columns. */
.prose p {
    text-align: justify;
    hyphens: auto;
}

/* ---------- Tables (committee, downloads) ---------- */
/* Every <table> is wrapped in .table-scroll so wide tables scroll internally
   on narrow screens instead of forcing the whole page to scroll sideways. */
.table-scroll { width: 100%; overflow-x: auto; margin-bottom: 1.2em; -webkit-overflow-scrolling: touch; }
/* min-width keeps columns readable (not crushed to one letter per line) —
   on narrow screens the table-scroll wrapper above scrolls it horizontally
   instead of squeezing every column down to fit. */
.table-scroll table { margin-bottom: 0; min-width: 560px; }
table { width: 100%; border-collapse: collapse; background: var(--white); }
table th, table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table th { background: var(--navy); color: var(--gold-light); font-family: var(--serif); }

/* ---------- Forms ---------- */
.form-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 520px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.88rem; color: var(--navy); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #c7bd9c;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--sans);
    background: var(--white);
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(138,8,8,0.14);
}
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; }
.checkbox-row input { width: auto; margin-top: 4px; }
.help-text { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.92rem;
}
.alert-error { background: #fbe6e6; border: 1px solid var(--maroon); color: var(--maroon-dark); }
.alert-success { background: #e9f3e3; border: 1px solid #4c7a2e; color: #33501f; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-gold { background: rgba(255,128,0,0.18); color: #8a4a00; }
.badge-maroon { background: rgba(110,20,35,0.12); color: var(--maroon); }
.badge-navy { background: rgba(138,8,8,0.1); color: var(--navy); }

/* ---------- Footer ---------- */
footer.site-footer {
    background: var(--navy-dark);
    color: #aab6c8;
    padding: 56px 0 24px;
    margin-top: 60px;
}
footer.site-footer h4 { color: var(--gold-light); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; }
footer.site-footer a { color: #aab6c8; text-decoration: none; }
footer.site-footer a:hover { color: var(--gold-light); }
.footer-grid { display: grid; gap: 32px; grid-template-columns: 2fr 1fr 1fr 1fr; }
.footer-grid > div { min-width: 0; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; font-size: 0.9rem; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 40px;
    padding-top: 20px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
@media (max-width: 800px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
}

/* ---------- Dashboard / admin ---------- */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 20px; margin: 24px 0 40px; }
.stat-box { background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius); padding: 18px 20px; }
.stat-box .stat-value { font-family: var(--serif); font-size: 1.8rem; color: var(--navy); }
.stat-box .stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Same auto-fit grid rhythm as .dash-stats, so Quick Actions lines up with
   the stat tiles above it instead of a ragged flex-wrap of button widths. */
.quick-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin: 24px 0 40px; }
.quick-actions-grid .btn { width: 100%; text-align: center; }

.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 0; min-height: 70vh; }
.admin-sidebar { background: var(--navy); color: #dbe3ef; padding: 24px 0; }
.admin-sidebar a { display: block; color: #dbe3ef; text-decoration: none; padding: 10px 24px; font-size: 0.9rem; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(255,128,0,0.16); color: var(--gold-light); }
.admin-main { padding: 32px; }
@media (max-width: 800px) {
    .admin-shell { grid-template-columns: 1fr; }
}

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.muted { color: var(--muted); }
