/* CISI Chapters gallery — modern, dependency-free responsive styling. */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --ink: #1d2733;
    --muted: #5d6b7a;
    --line: #e2e6ea;
    --brand: #003466;      /* CIC dark blue (matches the legacy gallery header) */
    --brand-2: #436db1;    /* CIC mid blue (legacy nav bar) */
    --accent: #bd1617;     /* CIC red (header underline) */
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 30, 54, .08), 0 8px 24px rgba(16, 30, 54, .06);
    --maxw: 1240px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

.wrap { width: min(100% - 2rem, var(--maxw)); margin-inline: auto; }

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header — mirrors the legacy CIC "Photo Gallery" banner */
.site-header {
    background: var(--brand);
    color: #fff;
    border-bottom: 3px solid var(--accent);
}
.header-inner { display: flex; align-items: center; gap: 1.25rem; padding: 1rem 0; }
.crest { display: inline-flex; flex: none; }
.crest img { height: 88px; width: auto; display: block; }
.header-titles { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.ph-title {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: clamp(1.9rem, 5vw, 3.25rem);
    font-weight: 400; line-height: 1.05; color: #fff;
}
.ph-sub { font-size: clamp(1rem, 2.5vw, 1.4rem); margin-top: .15rem; color: #dfe7f1; }
.ph-sub a { color: #fff; text-decoration: none; }
.ph-sub a:hover { text-decoration: underline; }

/* Breadcrumbs */
.breadcrumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
    padding: .85rem 0; font-size: .9rem; color: var(--muted);
}
.breadcrumbs .sep { color: #aab4bf; }
.breadcrumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* Page heading */
.page-head { margin: .25rem 0 1.5rem; }
.page-head h1 { margin: 0 0 .35rem; font-size: clamp(1.5rem, 3vw, 2.2rem); color: var(--brand); }
.page-head .lead { margin: 0; color: var(--muted); }

main { padding-bottom: 3rem; }

/* Cards (section / chapter index) */
.card-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; gap: 1.25rem;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(16,30,54,.12), 0 18px 40px rgba(16,30,54,.10); }
.card a { color: inherit; display: block; }
.card a:hover { text-decoration: none; }
.card-cover {
    aspect-ratio: 4 / 3; background: #e9edf1;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cover--empty { font-size: 2.5rem; opacity: .5; }
.card-body { padding: .85rem 1rem 1rem; }
.card-title { display: block; font-weight: 700; }
.card-meta { display: block; color: var(--muted); font-size: .85rem; margin-top: .15rem; }

/* General visibility toggle (JS only adds this, so no-JS shows everything) */
.is-hidden { display: none !important; }

/* Category listing (multi-gallery albums) — big labelled cover tiles */
.card-cover { position: relative; }
.card-cover-label {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 1.4rem .8rem .6rem;
    background: linear-gradient(transparent, rgba(0, 22, 50, .8));
    color: #fff; font-weight: 700; font-size: 1.1rem;
    text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* Drill-in gallery view */
.cat-view-head { display: flex; align-items: center; gap: 1rem; margin: 0 0 1.25rem; flex-wrap: wrap; }
.cat-view-head h2 { margin: 0; color: var(--brand); font-size: clamp(1.3rem, 3vw, 1.8rem); }
.cat-back {
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    padding: .45rem 1rem; border-radius: 999px; cursor: pointer; font-size: .9rem;
}
.cat-back:hover { border-color: var(--brand-2); color: var(--brand-2); }

/* Filter bar */
.filterbar { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.5rem; }
.filter {
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    padding: .45rem .9rem; border-radius: 999px; cursor: pointer; font-size: .9rem;
    transition: all .12s ease;
}
.filter:hover { border-color: var(--brand-2); }
.filter.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Masonry photo grid (CSS columns) */
.grid { column-gap: 14px; column-width: 260px; }
.tile {
    margin: 0 0 14px; break-inside: avoid; position: relative;
    border-radius: 10px; overflow: hidden; background: #e9edf1; box-shadow: var(--shadow);
}
.tile.is-hidden { display: none; }
.tile-link { display: block; }
.tile img {
    width: 100%; height: auto; display: block;
    transition: transform .25s ease, filter .25s ease;
}
.tile:hover img { transform: scale(1.04); }
.tile figcaption {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(10,22,40,.78));
    color: #fff; font-size: .8rem; padding: 1.5rem .7rem .55rem;
    opacity: 0; transition: opacity .2s ease; pointer-events: none;
}
.tile:hover figcaption { opacity: 1; }

/* Empty / error states */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h1 { font-size: 3rem; margin: 0 0 .5rem; color: var(--brand); }
.btn {
    display: inline-block; background: var(--brand); color: #fff;
    padding: .55rem 1.1rem; border-radius: 8px; margin-top: .5rem;
}
.btn:hover { text-decoration: none; background: var(--brand-2); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.site-footer .wrap { padding: 1.25rem 0; font-size: .85rem; }

/* Lightbox */
.lb {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(8, 14, 24, .92);
    display: none; align-items: center; justify-content: center;
}
.lb.is-open { display: flex; }
.lb-img {
    max-width: 92vw; max-height: 82vh; object-fit: contain;
    border-radius: 6px; box-shadow: 0 12px 48px rgba(0,0,0,.5);
}
.lb-caption {
    position: absolute; bottom: 1.1rem; left: 0; right: 0; text-align: center;
    color: #eaeef3; font-size: .95rem; padding: 0 1rem;
    text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.lb-btn {
    position: absolute; background: rgba(255,255,255,.12); color: #fff;
    border: none; cursor: pointer; width: 52px; height: 52px; border-radius: 50%;
    font-size: 1.6rem; line-height: 1; display: flex; align-items: center; justify-content: center;
    transition: background .15s ease;
}
.lb-btn:hover { background: rgba(255,255,255,.28); }
.lb-prev { left: 2vw; top: 50%; transform: translateY(-50%); }
.lb-next { right: 2vw; top: 50%; transform: translateY(-50%); }
.lb-close { top: 1.1rem; right: 1.1rem; width: 44px; height: 44px; font-size: 1.4rem; }
.lb-counter { position: absolute; top: 1.3rem; left: 1.3rem; color: #cdd6e0; font-size: .85rem; }

@media (max-width: 600px) {
    .grid { column-width: 160px; column-gap: 10px; }
    .tile { margin-bottom: 10px; }
    .lb-btn { width: 42px; height: 42px; }
    .lb-prev { left: .5rem; } .lb-next { right: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
