/* Bogie Geographic: light, editorial.
   Layout: image-first. Edge-to-edge opener, justified photo rows, one quiet top bar,
   Cormorant Garamond for display, Karla for everything else. */
:root {
  --bg: #f4f5f2;          /* cool paper */
  --surface: #e9ebe6;
  --fg: #16201f;
  --muted: #5d6965;
  --rule: #d3d8d1;
  --accent: #1f5d58;      /* deep reef green */
  --overlay: rgba(244, 245, 242, .97);
  --on-photo: #f2f4f2;
  --display: "Cormorant Garamond", Garamond, Georgia, serif;
  --body: "Karla", "Helvetica Neue", Arial, sans-serif;
  --gap: 14px;
  --radius: 2px;
  --bar: 60px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before { transition: none !important; } }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--body); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1440px; margin: 0 auto; }
.meta { font-size: 13px; color: var(--muted); }
.display { font-family: var(--display); font-weight: 500; letter-spacing: -.005em; line-height: 1.02; text-wrap: balance; margin: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--fg); color: var(--bg); padding: 8px 14px; z-index: 100; }
.skip:focus { left: 8px; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--rule); }
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--bar); }
.brand { font-family: var(--display); font-weight: 500; font-size: 25px; text-decoration: none; white-space: nowrap; transition: opacity .3s; }
/* Home page, wide screens: the photo carries the name, so the bar's name appears only after scrolling past it */
@media (min-width: 721px) { .home:not(.brand-shown) .brand { opacity: 0; pointer-events: none; } }
.nav { display: flex; gap: clamp(14px, 3vw, 32px); }
.nav > a, .nav > .has-menu > a { text-decoration: none; font-size: 15px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.navtoggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; font-size: 20px; }
.has-menu { position: relative; }
.menu { position: absolute; top: 100%; left: -16px; min-width: 300px; background: var(--bg); border: 1px solid var(--rule); padding: 8px; display: none; box-shadow: 0 12px 32px rgba(22, 32, 31, .08); }
.has-menu:hover .menu, .has-menu:focus-within .menu { display: grid; }
.menu a { display: flex; justify-content: space-between; gap: 16px; padding: 8px 10px; text-decoration: none; font-size: 15px; }
.menu a:hover { background: var(--surface); }
.menu a span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Home opener: edge-to-edge, uncropped; the title sits in the water above the whale */
.opener { position: relative; }
.opener a { display: block; }
.opener img { width: 100%; height: auto; }
.titlecard { position: absolute; left: max(24px, 3vw, env(safe-area-inset-left, 0px)); top: clamp(16px, 2.6vw, 44px); color: var(--on-photo); pointer-events: none; text-shadow: 0 1px 12px rgba(0, 20, 40, .45); }
.titlecard h1 { font-size: clamp(30px, 3.6vw, 60px); }
.titlecard p { margin: 4px 0 0; font-size: clamp(13px, 1.1vw, 16px); color: rgba(242, 244, 242, .88); }

/* Expedition opener: cover photo with title over a soft gradient */
.hero { position: relative; color: var(--on-photo); }
.hero img { width: 100%; height: min(72vh, 720px); min-height: 340px; object-fit: cover; }
.hero .cap { position: absolute; inset: auto 0 0 0; background: linear-gradient(to top, rgba(5, 8, 10, .78), rgba(5, 8, 10, 0)); padding-block: 96px 36px; }
.hero h1 { font-size: clamp(44px, 7vw, 104px); }
.hero p { max-width: 50ch; margin: 12px 0 0; font-size: clamp(15px, 1.6vw, 19px); color: rgba(242, 244, 242, .88); }
.hero .meta { color: rgba(242, 244, 242, .78); }
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 14px; font-variant-numeric: tabular-nums; }

/* Sections and headings */
.section { padding-block: clamp(48px, 7vw, 96px) 0; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.head h2 { font-size: clamp(34px, 4.8vw, 62px); }
.head p { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }
.textlink { font-size: 15px; text-decoration: none; border-bottom: 1px solid var(--accent); padding-bottom: 2px; white-space: nowrap; }
.story { max-width: 62ch; font-size: 19px; line-height: 1.65; }
.story p { margin: 0 0 1em; }

/* Expedition cards */
.trips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 40px 24px; }
.trip { display: block; text-decoration: none; }
.trip .imgbox, .subj .imgbox { overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.trip img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; transition: transform .6s ease; }
.trip:hover img, .subj:hover img { transform: scale(1.03); }
.trip .t { padding-top: 14px; }
.trip h3 { font-size: clamp(28px, 3vw, 40px); margin-top: 4px; }
.trip p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* Subject tiles */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: var(--gap); }
.subj { display: block; text-decoration: none; }
.subj img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; transition: transform .6s ease; }
.subj .t { padding: 10px 2px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.subj .t b { font-weight: 600; font-size: 15px; }

/* Chapter chips on expedition pages */
.chips { position: sticky; top: var(--bar); z-index: 15; background: var(--bg); border-bottom: 1px solid var(--rule); }
.chips .wrap { display: flex; gap: 8px; overflow-x: auto; padding-block: 12px; scrollbar-width: none; }
.chips a { flex: none; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.chips a:hover, .chips a.on { color: var(--fg); border-color: var(--accent); }
.sec, .group { scroll-margin-top: calc(var(--bar) + 72px); }
.sec + .sec { border-top: 1px solid var(--rule); margin-top: clamp(48px, 6vw, 80px); }
.group { margin-top: 28px; }
.group h3 { font: 600 16px/1.3 var(--body); margin: 0 0 10px; display: flex; gap: 12px; align-items: baseline; }
.group h3 a { text-decoration: none; }

/* Justified photo rows: each photo grows in proportion to its aspect ratio */
.rows { display: flex; flex-wrap: wrap; gap: var(--gap); }
.rows::after { content: ""; flex-grow: 999; }
.ph { position: relative; display: block; overflow: hidden; border-radius: var(--radius); background: var(--surface); cursor: zoom-in; }
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.ph:hover img { transform: scale(1.02); }
.ph .who { position: absolute; left: 10px; bottom: 8px; font-size: 13px; color: var(--on-photo); text-shadow: 0 1px 6px rgba(0, 0, 0, .7); opacity: 0; transition: opacity .2s; }
.ph:hover .who, .ph:focus-visible .who { opacity: 1; }
.video { display: flex; flex-direction: column; justify-content: end; gap: 6px; min-height: 160px; padding: 18px; text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); flex: 1 1 260px; }
.video:hover { border-color: var(--accent); }
.video b { font-weight: 600; }

/* Previous / next expedition */
.next { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); margin-top: clamp(48px, 7vw, 96px); }
.next a { position: relative; display: block; overflow: hidden; text-decoration: none; border-radius: var(--radius); }
.next img { width: 100%; aspect-ratio: 21 / 9; object-fit: cover; opacity: .92; transition: opacity .3s; }
.next a:hover img { opacity: 1; }
.next .t { position: absolute; inset: auto 16px 14px; color: var(--on-photo); text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.next .t .meta { color: rgba(242, 244, 242, .82); }
.next h4 { margin: 4px 0 0; font: 500 clamp(22px, 2.4vw, 32px)/1.1 var(--display); }
.next .r { text-align: right; }

/* Species index */
.index { columns: 3 240px; column-gap: 40px; }
.index .cat { break-inside: avoid; margin-bottom: 28px; }
.index h4 { margin: 0 0 8px; font: 600 15px var(--body); padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.index a { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; text-decoration: none; font-size: 15px; }
.index a:hover { color: var(--accent); }
.index a span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.index a em { font-style: normal; color: var(--muted); }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.about img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius); }
.about p { font-size: 18px; max-width: 58ch; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.links a { text-decoration: none; border: 1px solid var(--rule); padding: 8px 16px; border-radius: 999px; font-size: 15px; }
.links a:hover { border-color: var(--accent); }
form.contact { display: grid; gap: 12px; margin-top: 40px; max-width: 520px; }
form.contact label { font-size: 14px; color: var(--muted); display: grid; gap: 6px; }
form.contact input, form.contact textarea { font: inherit; color: var(--fg); background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; }
form.contact button { justify-self: start; background: var(--fg); color: var(--bg); border: 0; padding: 10px 22px; cursor: pointer; border-radius: var(--radius); }

footer { margin-top: clamp(64px, 8vw, 120px); border-top: 1px solid var(--rule); padding-block: 28px 40px; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer a { text-decoration: none; }
.notfound { padding-block: 120px; text-align: center; }

/* Photo viewer */
.lb { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: calc(env(safe-area-inset-top, 0px) + 8px) max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 12px) max(12px, env(safe-area-inset-left, 0px)); }
.lb .top { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.lb .stage { position: relative; min-height: 0; display: grid; place-items: center; touch-action: pan-y; }
.lb .stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.lb .cap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 12px; }
.lb .cap b { font-weight: 600; }
.lb .iconbtn { background: none; border: 0; cursor: pointer; padding: 10px; font-size: 15px; }
.lb .arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; background: color-mix(in srgb, var(--bg) 60%, transparent); cursor: pointer; font-size: 22px; }
.lb .arrow.l { left: 0; }
.lb .arrow.r { right: 0; }

@media (max-width: 720px) {
  .navtoggle { display: block; }
  .nav { position: absolute; top: var(--bar); left: 0; right: 0; flex-direction: column; gap: 0; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 8px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); display: none; }
  .nav.open { display: flex; }
  .nav > a, .nav > .has-menu > a { display: block; padding: 10px 0; font-size: 17px; }
  .menu { display: none !important; }
  .titlecard { position: static; color: var(--fg); text-shadow: none; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
  .titlecard h1 { font-size: 40px; }
  .titlecard p { color: var(--muted); }
  .about, .next { grid-template-columns: 1fr; }
  .lb .arrow { display: none; }
}
