/* =========================================================
   Photo Gallery — /gallery (albums) and /gallery/<slug>
   Uses the tokens in variables.css so it reads as part of
   the site, not as a bolted-on section.
   ========================================================= */

.gal-page { background-color: var(--site-bg); }

/* =========================================================
   HEADER
   ========================================================= */
.gal-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 42vh;
    padding: 90px 0 56px;
    background-color: var(--dark-navy);
    overflow: hidden;
}
.gal-hero:not(.has-image) {
    background: linear-gradient(160deg, var(--dark-navy) 0%, var(--dark-navy-soft) 100%);
    align-items: center;
    min-height: 38vh;
}

.gal-hero-bg {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: center;
    transform: scale(1.06);
    filter: saturate(0.9);
}
.gal-hero-scrim {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(21,36,51,.55) 0%, rgba(21,36,51,.78) 55%, rgba(21,36,51,.94) 100%);
}

.gal-hero-inner {
    position: relative;
    z-index: 2;
    width: var(--container-width);
    max-width: var(--container-max);
    margin: 0 auto;
    color: #fff;
}

.gal-eyebrow {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: clamp(.72rem, 1.4vw, .82rem);
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.gal-hero-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 5.2vw, 3.4rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: .01em;
    text-transform: uppercase;
    color: #fff;
}

.gal-hero-lead {
    margin: 18px 0 0;
    max-width: 62ch;
    font-size: clamp(1rem, 1.5vw, 1.14rem);
    line-height: 1.7;
    color: rgba(255,255,255,.86);
}

.gal-hero-count {
    margin: 16px 0 0;
    font-family: var(--font-display);
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--accent-tan);
}

.gal-back {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 20px;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 600;
    letter-spacing: .04em;
    transition: var(--hover-transition);
}
.gal-back:hover { color: var(--accent-gold); gap: 14px; }

/* =========================================================
   SECTION SHELL
   ========================================================= */
.gal-section {
    width: var(--container-width);
    max-width: var(--container-max);
    margin: 0 auto;
    padding: clamp(46px, 7vw, 86px) 0 clamp(40px, 6vw, 70px);
}

/* Empty / not-found states */
.gal-state {
    max-width: 620px;
    margin: 0 auto;
    text-align: center;
    padding: clamp(36px, 6vw, 64px) 28px;
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent-gold);
    border-radius: 3px;
    background: #fff;
}
.gal-state h2 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 2.6vw, 1.7rem);
    color: var(--dark-navy);
    line-height: 1.25;
}
.gal-state p { margin: 0; color: #5d5d5d; line-height: 1.7; }

.gal-cta {
    display: inline-block;
    margin-top: 26px;
    padding: 15px 34px;
    background-color: var(--dark-navy);
    color: #fff;
    text-decoration: none;
    border-radius: 2px;
    font-size: .95rem;
    letter-spacing: .04em;
    transition: transform .4s var(--ease-out), box-shadow .4s ease;
    box-shadow: 0 10px 25px rgba(18,34,53,.15);
}
.gal-cta:hover { transform: translateY(-4px); box-shadow: 0 18px 36px rgba(18,34,53,.28); color: #fff; }

/* =========================================================
   ALBUM CARDS  (/gallery)
   ========================================================= */
/* auto-fit (not auto-fill) so a single album does not sit next to two
   empty columns; the card is capped and centred so it never blows up. */
.gal-albums {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    justify-items: center;
    gap: clamp(22px, 3vw, 36px);
}

.gal-album {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    transition: transform .45s var(--ease-out), box-shadow .45s ease, border-color .3s ease;
}
.gal-album:hover {
    transform: translateY(-8px);
    box-shadow: 0 26px 50px rgba(21,36,51,.18);
    border-color: var(--accent-tan);
}

.gal-album-frame {
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--dark-navy-soft);
}
.gal-album-frame img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .7s var(--ease-out);
}
.gal-album:hover .gal-album-frame img { transform: scale(1.07); }

.gal-album-nocover {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,.35);
}
.gal-album-veil {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(21,36,51,0) 45%, rgba(21,36,51,.55) 100%);
    opacity: 0;
    transition: opacity .45s ease;
}
.gal-album:hover .gal-album-veil { opacity: 1; }

.gal-album-body { padding: 26px 28px 30px; display: flex; flex-direction: column; flex: 1; }
.gal-album-body h2 {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 1.9vw, 1.4rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--dark-navy);
    overflow-wrap: anywhere;
}
.gal-album-body p {
    margin: 0 0 18px;
    color: #5d5d5d;
    font-size: .97rem;
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gal-album-count {
    margin-top: auto;
    font-family: var(--font-display);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--primary-brown);
}

/* =========================================================
   PHOTO GRID  (/gallery/<slug>)
   A CSS-column masonry: photos keep their own proportions,
   nothing is cropped, and it reflows at any width.
   ========================================================= */
.gal-masonry {
    column-count: 3;
    column-gap: clamp(14px, 1.6vw, 22px);
}
.gal-item {
    margin: 0 0 clamp(14px, 1.6vw, 22px);
    break-inside: avoid;
    page-break-inside: avoid;
}

.gal-item-btn {
    display: block;
    position: relative;
    width: 100%;
    padding: 0;
    border: 0;
    background: var(--dark-navy-soft);
    border-radius: 3px;
    overflow: hidden;
    cursor: zoom-in;
    font: inherit;
    color: inherit;
}
.gal-item-btn img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .7s var(--ease-out), filter .5s ease;
}
.gal-item-btn:hover img,
.gal-item-btn:focus-visible img { transform: scale(1.05); filter: brightness(.82); }

.gal-item-caption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 30px 18px 16px;
    background: linear-gradient(180deg, rgba(21,36,51,0) 0%, rgba(21,36,51,.88) 100%);
    color: #fff;
    text-align: left;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .4s ease, transform .4s var(--ease-out);
}
.gal-item-caption span {
    display: block;
    font-size: .92rem;
    line-height: 1.5;
}
.gal-item-btn:hover .gal-item-caption,
.gal-item-btn:focus-visible .gal-item-caption { opacity: 1; transform: translateY(0); }

/* =========================================================
   LIGHTBOX
   ========================================================= */
.gal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 20, 29, .95);
    padding: clamp(16px, 4vw, 56px);
    animation: galLbFade .25s ease;
}
.gal-lightbox[hidden] { display: none; }
@keyframes galLbFade { from { opacity: 0; } }

.gal-lb-figure {
    margin: 0;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.gal-lb-figure img {
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 30px 80px rgba(0,0,0,.6);
    animation: galLbRise .32s var(--ease-out);
}
@keyframes galLbRise { from { opacity: 0; transform: scale(.97); } }

.gal-lb-caption {
    max-width: 70ch;
    text-align: center;
    color: rgba(255,255,255,.88);
    font-size: clamp(.9rem, 1.4vw, 1rem);
    line-height: 1.6;
}
.gal-lb-caption:empty { display: none; }

.gal-lb-close,
.gal-lb-nav {
    position: absolute;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .25s ease, transform .25s ease, opacity .25s ease;
}
.gal-lb-close:hover,
.gal-lb-nav:hover { background: rgba(255,255,255,.22); transform: scale(1.08); }

.gal-lb-close {
    top: clamp(12px, 3vw, 28px);
    right: clamp(12px, 3vw, 28px);
    width: 46px; height: 46px;
    font-size: 1.9rem;
    line-height: 1;
    padding-bottom: 4px;
}
.gal-lb-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; }
.gal-lb-nav:hover { transform: translateY(-50%) scale(1.08); }
.gal-lb-prev { left: clamp(8px, 2vw, 28px); }
.gal-lb-next { right: clamp(8px, 2vw, 28px); }
.gal-lb-nav[disabled] { opacity: .25; pointer-events: none; }

.gal-lb-counter {
    position: absolute;
    bottom: clamp(12px, 3vw, 26px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .18em;
    color: rgba(255,255,255,.6);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
    .gal-masonry { column-count: 2; }
}
@media (max-width: 860px) {
    .gal-hero { min-height: 34vh; padding: 60px 0 42px; }
    .gal-albums { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
@media (max-width: 620px) {
    .gal-masonry { column-count: 1; }
    .gal-albums { grid-template-columns: 1fr; }
    .gal-album-body { padding: 22px 22px 26px; }

    /* Phones have no hover, so the caption is always readable. */
    .gal-item-caption { opacity: 1; transform: none; padding: 26px 15px 13px; }
    .gal-item-caption span { font-size: .86rem; }

    .gal-lb-figure img { max-height: 66vh; }
    .gal-lb-nav { width: 44px; height: 44px; }
    .gal-lb-prev { left: 6px; }
    .gal-lb-next { right: 6px; }
}

/* Keyboard users get the same reveal as the mouse. */
.gal-item-btn:focus-visible { outline: 3px solid var(--accent-gold); outline-offset: 3px; }

/* The reveal animation must never leave a photo invisible if JS is off. */
.no-js .reveal-on-scroll { opacity: 1; transform: none; }
