/* Bahamas Caves Research Foundation
   ------------------------------------------------------------------
   One stylesheet. The header, page headings, hero and footer are always
   the deep navy of the BCRF DataHub, with its teal accent, so the two
   sites read as one family; the reading area follows the visitor's light
   or dark preference. System fonts, so nothing is fetched. No inline
   styles anywhere (the Content-Security-Policy forbids them). */

:root {
    --navy: #0b1220;
    --navy-2: #0f182b;
    --navy-3: #131d33;
    --on-navy: #e6edf7;
    --on-navy-soft: #b7c2d6;
    --on-navy-muted: #8d9bb3;
    --teal: #2dd4bf;
    --teal-ink: #063a35;
    --focus: #7dd3fc;

    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #5b6b82;
    --border: #e2e8f0;
    --link: #0f766e;
    --link-hover: #115e59;
    --accent: #0d9488;
    --accent-soft: rgba(13, 148, 136, 0.1);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);

    --radius: 16px;
    --radius-sm: 10px;
    --wrap: 1160px;
    --gutter: 16px;
    --header-h: 64px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --surface: #131d33;
        --surface-2: #182541;
        --text: #e6edf7;
        --text-soft: #c3cede;
        --muted: #8d9bb3;
        --border: rgba(148, 163, 184, 0.18);
        --link: #2dd4bf;
        --link-hover: #5eead4;
        --accent: #2dd4bf;
        --accent-soft: rgba(45, 212, 191, 0.12);
        --shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
        color-scheme: dark;
    }
}

@media (min-width: 640px) {
    :root { --gutter: 24px; }
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

main { flex: 1; }

img, video { max-width: 100%; height: auto; }

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -48px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--teal);
    color: var(--teal-ink);
    font-weight: 600;
}
.skip-link:focus { top: 8px; }

.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }

.kicker {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--accent);
}

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--teal); color: var(--teal-ink); }
.btn-primary:hover { background: #5eead4; color: var(--teal-ink); }
.btn-ghost { border-color: rgba(230, 237, 247, 0.4); color: var(--on-navy); }
.btn-ghost:hover { border-color: var(--on-navy); color: #fff; background: rgba(255, 255, 255, 0.06); }

/* ---------------------------------------------------------------- header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 18, 32, 0.92);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    color: var(--on-navy);
}

.bar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand hub" "nav nav";
    align-items: center;
    column-gap: 16px;
}

.brand {
    grid-area: brand;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: var(--header-h);
    color: var(--on-navy);
    text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-lead { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-tail { font-size: 0.8rem; color: var(--on-navy-soft); }

.btn-hub {
    grid-area: hub;
    min-height: 38px;
    padding: 7px 14px;
    background: var(--teal);
    color: var(--teal-ink);
    font-size: 0.88rem;
}
.btn-hub:hover { background: #5eead4; color: var(--teal-ink); }

.site-nav {
    grid-area: nav;
    margin-inline: calc(var(--gutter) * -1);
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav ul {
    display: flex;
    gap: 2px;
    margin: 0;
    padding: 6px var(--gutter);
    list-style: none;
    width: max-content;
}
.site-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--on-navy-soft);
    font-size: 0.93rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.site-nav a[aria-current="page"] { color: var(--teal); background: rgba(45, 212, 191, 0.12); }

@media (min-width: 1040px) {
    .bar { grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav hub"; }
    .site-nav { margin: 0; border: 0; overflow: visible; justify-self: end; }
    .site-nav ul { padding: 0; }
}

/* ---------------------------------------------------------------- hero */

.hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: min(78vh, 720px);
    padding: 96px 0 56px;
    color: var(--on-navy);
    background:
        linear-gradient(180deg, rgba(11, 18, 32, 0.35) 0%, rgba(11, 18, 32, 0.55) 45%, rgba(11, 18, 32, 0.94) 100%),
        url("../img/hero.jpg") center 40% / cover no-repeat,
        var(--navy);
}
.hero .kicker { color: var(--teal); }
.hero h1 {
    max-width: 18ch;
    margin: 0 0 16px;
    font-size: clamp(2.1rem, 6vw, 4rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
}
.hero-lede {
    max-width: 58ch;
    margin: 0 0 28px;
    font-size: clamp(1.02rem, 2.2vw, 1.2rem);
    color: var(--on-navy-soft);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; }

/* ---------------------------------------------------------------- page heading */

.page-head {
    padding: 40px 0 36px;
    color: var(--on-navy);
    background:
        radial-gradient(48rem 22rem at 12% -30%, rgba(45, 212, 191, 0.2), transparent 60%),
        radial-gradient(36rem 20rem at 95% -20%, rgba(56, 130, 246, 0.16), transparent 60%),
        var(--navy);
}
.page-head .kicker { color: var(--teal); }
.page-head h1 {
    max-width: 24ch;
    margin: 0;
    font-size: clamp(1.85rem, 4.4vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.lede {
    max-width: 62ch;
    margin: 12px 0 0;
    font-size: clamp(1.02rem, 2vw, 1.18rem);
    color: var(--on-navy-soft);
}

.crumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    font-size: 0.85rem;
}
.crumbs li + li::before { content: "/"; margin-right: 4px; color: var(--on-navy-muted); }
.crumbs a { color: var(--on-navy-soft); text-decoration: none; }
.crumbs a:hover { color: #fff; text-decoration: underline; }

/* ---------------------------------------------------------------- reading */

.page-body { padding-block: 40px 24px; }

.page-body.has-toc { display: grid; gap: 24px; }
@media (min-width: 1100px) {
    .page-body.has-toc { grid-template-columns: minmax(0, 1fr) 260px; gap: 56px; align-items: start; }
    .page-body.has-toc .toc { grid-column: 2; grid-row: 1; position: sticky; top: calc(var(--header-h) + 24px); }
    .page-body.has-toc .prose { grid-column: 1; grid-row: 1; }
}

.toc details {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 4px 16px;
}
.toc summary {
    padding: 10px 0;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
}
.toc ol { margin: 0 0 12px; padding: 0; list-style: none; font-size: 0.92rem; }
.toc li { border-left: 2px solid var(--border); }
.toc a { display: block; padding: 5px 0 5px 12px; color: var(--text-soft); text-decoration: none; line-height: 1.35; }
.toc a:hover { color: var(--link); }
.toc a[aria-current="true"] { color: var(--link); font-weight: 600; }
.toc li:has(a[aria-current="true"]) { border-left-color: var(--accent); }

.prose {
    max-width: 72ch;
    font-size: 1.0625rem;
    line-height: 1.72;
    color: var(--text-soft);
    overflow-wrap: break-word;
}
.page-body:not(.has-toc) .prose { margin-inline: auto; }
/* A page that is only pictures uses the whole width. */
.page-body .prose:has(> .gallery:only-child) { max-width: none; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose strong { color: var(--text); }
.prose h2, .prose h3, .prose h4 {
    clear: both;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.01em;
}
.prose h2 { margin: 2.2em 0 0.7em; font-size: 1.5rem; }
.prose h2::before {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    margin-bottom: 14px;
    border-radius: 2px;
    background: var(--accent);
}
.prose h3 { margin: 1.8em 0 0.5em; font-size: 1.12rem; color: var(--accent); }
.prose ul { margin: 0 0 1.2em; padding-left: 1.3em; }
.prose li { margin-bottom: 0.35em; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
    margin: 1.6em 0;
    padding: 4px 0 4px 20px;
    border-left: 3px solid var(--accent);
    font-size: 1.12rem;
    font-style: italic;
    color: var(--text);
}
.prose blockquote p:last-child:not(:first-child) { font-size: 0.9rem; font-style: normal; color: var(--muted); }
.prose blockquote p:last-child:not(:first-child)::before { content: "— "; }
.prose hr { clear: both; margin: 2.5em 0; border: 0; border-top: 1px solid var(--border); }

.file-meta { font-size: 0.85em; color: var(--muted); white-space: nowrap; }
.file-meta::before { content: "("; }
.file-meta::after { content: ")"; }

/* Pictures */

.fig { margin: 1.6em 0; }
.fig img { display: block; border-radius: 12px; background: var(--surface-2); }
.fig a { display: block; }
.fig figcaption { margin-top: 8px; font-size: 0.88rem; line-height: 1.5; color: var(--muted); }
.fig-medium { width: fit-content; max-width: 100%; margin-inline: auto; }
.fig-medium figcaption { max-width: 480px; }
.fig-small { width: fit-content; max-width: 100%; }
.fig-small figcaption { max-width: 240px; }
.fig-wide img { width: 100%; }
.fig-portrait img { max-height: min(70vh, 560px); width: auto; }
@media (min-width: 720px) {
    .fig-small { float: right; max-width: 40%; margin: 0.3em 0 1em 28px; }
}

.zoom { cursor: zoom-in; }

.gallery {
    clear: both;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin: 1.8em 0;
}
.gallery .fig { margin: 0; }
.gallery .fig img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery .fig figcaption {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.82rem;
}
@media (min-width: 900px) {
    .page-body:not(.has-toc) .gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.gallery-logos { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery-logos .fig { display: flex; flex-direction: column; }
.gallery-logos .fig a {
    display: grid;
    place-items: center;
    padding: 14px;
    aspect-ratio: 3 / 2;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
}
.gallery-logos .fig img { width: auto; max-height: 100%; aspect-ratio: auto; object-fit: contain; border-radius: 0; background: none; }
.gallery-logos .fig figcaption { -webkit-line-clamp: 4; }

/* Videos */

.video, .videos { clear: both; margin: 1.6em 0; }
.videos { display: grid; gap: 16px; }
.videos .video { margin: 0; }
@media (min-width: 720px) {
    .videos { grid-template-columns: 1fr 1fr; }
}
.yt, .video iframe {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity 0.2s; }
.yt:hover img { opacity: 1; }
.yt-play {
    position: absolute;
    inset: 50% auto auto 50%;
    width: 68px;
    height: 48px;
    transform: translate(-50%, -50%);
    border-radius: 14px;
    background: rgba(11, 18, 32, 0.8);
    transition: background-color 0.2s;
}
.yt-play::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 10px 0 10px 17px;
    border-color: transparent transparent transparent #fff;
}
.yt:hover .yt-play { background: var(--teal); }
.yt:hover .yt-play::after { border-left-color: var(--teal-ink); }
.fig video { display: block; width: 100%; border-radius: 12px; background: #000; }

/* Dive logs */

.dive {
    clear: both;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px 20px;
    margin: 1.2em 0 1.6em;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.95rem;
    line-height: 1.4;
}
.dive dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dive dd { margin: 2px 0 0; color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- cards */

.cards-section { padding-block: 40px 16px; }
.home .cards-section { padding-top: 56px; }
.section-title { margin: 0 0 20px; font-size: 1.6rem; letter-spacing: -0.01em; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.2s, border-color 0.2s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--text); }
.card-media { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--navy-3); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.card:hover .card-media img { transform: scale(1.04); }
.card-placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(18rem 10rem at 20% 0%, rgba(45, 212, 191, 0.35), transparent 70%),
        radial-gradient(14rem 10rem at 100% 100%, rgba(56, 130, 246, 0.3), transparent 70%),
        var(--navy-2);
}
.card-body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; }
.card-title { font-size: 1.15rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.card-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
    font-size: 0.93rem;
    color: var(--muted);
}
.card-more { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 14px; font-size: 0.9rem; font-weight: 600; color: var(--link); }

/* ---------------------------------------------------------------- pager */

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding-block: 24px 56px;
}
.pager a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager-next { text-align: right; }
.pager-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pager-prev .pager-label::before { content: "← "; }
.pager-next .pager-label::after { content: " →"; }
.pager-title { font-weight: 600; color: var(--text); }

/* ---------------------------------------------------------------- data hub */

.hub {
    margin-top: 40px;
    color: var(--on-navy);
    background:
        radial-gradient(40rem 20rem at 85% 120%, rgba(45, 212, 191, 0.22), transparent 60%),
        var(--navy-2);
}
.hub-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-block: 48px;
}
.hub .kicker { color: var(--teal); }
.hub h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.01em; }
.hub p { max-width: 56ch; margin: 0; color: var(--on-navy-soft); }

/* ---------------------------------------------------------------- footer */

.site-footer {
    margin-top: 40px;
    padding-top: 48px;
    color: var(--on-navy-soft);
    background: var(--navy);
    font-size: 0.93rem;
}
.home .site-footer, .hub + .site-footer { margin-top: 0; }
.site-footer a { color: var(--on-navy); text-decoration: none; }
.site-footer a:hover { color: var(--teal); text-decoration: underline; }
.footer-grid { display: grid; gap: 32px; }
@media (min-width: 720px) {
    .footer-grid { grid-template-columns: 1.4fr 1fr 1.2fr 1fr; }
}
.footer-name { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-weight: 700; color: var(--on-navy); }
.footer-name img { border-radius: 8px; }
.footer-about p:last-child { margin: 0; max-width: 40ch; }
.footer-h {
    margin: 0 0 12px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--on-navy-muted);
}
.footer-list { margin: 0; padding: 0; list-style: none; }
.footer-list li { margin-bottom: 8px; }
.footer-cols { columns: 2; column-gap: 16px; }
.footer-base {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-top: 40px;
    padding-block: 20px 28px;
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    font-size: 0.85rem;
    color: var(--on-navy-muted);
}
.footer-base p { margin: 0; }

/* ---------------------------------------------------------------- photo viewer */

.viewer {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(5, 9, 18, 0.94);
    color: var(--on-navy);
}
.viewer::backdrop { background: rgba(5, 9, 18, 0.7); }
.viewer[open] { display: grid; grid-template-rows: auto 1fr auto; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: 12px var(--gutter); font-size: 0.9rem; color: var(--on-navy-muted); }
.viewer-stage { display: grid; place-items: center; min-height: 0; padding: 0 var(--gutter); }
.viewer-stage img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.viewer-caption { max-width: 72ch; margin: 0 auto; padding: 14px var(--gutter) 20px; text-align: center; font-size: 0.95rem; color: var(--on-navy-soft); }
.viewer button {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(230, 237, 247, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--on-navy);
    font: inherit;
    font-size: 1.2rem;
    cursor: pointer;
}
.viewer button:hover { background: rgba(255, 255, 255, 0.14); }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .site-header, .site-nav, .btn-hub, .toc, .pager, .hub, .site-footer { display: none; }
    .page-head { background: none; color: #000; padding: 0; }
    .page-head .lede, .crumbs { color: #333; }
    .prose { max-width: none; color: #000; }
}
