/* =============================================================================
   AHM – Airborne HydroMapping · Sample data portal
   Hand-built stylesheet. No framework, no template.
   ========================================================================== */

/* ----------------------------------------------------------------- tokens -- */
:root {
  --ink:        #0c1a22;   /* primary text  */
  --ink-soft:   #3a4d58;   /* secondary     */
  --muted:      #6c7c86;   /* tertiary      */
  --faint:      #9aa8b0;   /* placeholders  */

  --bg:         #f3f6f7;   /* page          */
  --bg-2:       #eaf0f1;   /* alt sections  */
  --surface:    #ffffff;   /* cards         */
  --line:       #e0e7ea;   /* hairlines     */
  --line-soft:  #edf1f3;

  --brand:      #0c7ea3;   /* primary       */
  --brand-deep: #073f54;
  --brand-ink:  #06303f;
  --accent:     #16b5cc;   /* cyan          */

  /* bathymetric ramp — deep → shallow → land. Used as a thin recurring motif. */
  --ramp: linear-gradient(90deg,
            #08306b 0%, #1c5fa8 22%, #2b8cbe 44%,
            #41b6c4 64%, #7fcdbb 82%, #c7e9b4 100%);

  --shadow-sm: 0 1px 2px rgba(12,26,34,.05), 0 1px 1px rgba(12,26,34,.04);
  --shadow-md: 0 6px 22px -8px rgba(7,63,84,.22), 0 2px 6px rgba(12,26,34,.06);
  --shadow-lg: 0 18px 48px -16px rgba(7,63,84,.30);

  --r:    14px;
  --r-sm: 9px;
  --r-xs: 6px;

  --maxw: 1180px;
  --pad:  clamp(18px, 4vw, 40px);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", ui-monospace, "SFMono-Regular", "SF Mono",
          "Consolas", "Liberation Mono", "Roboto Mono", monospace;
}

/* ------------------------------------------------------------------ reset -- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.018em; margin: 0; }
::selection { background: rgba(22,181,204,.22); }

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

/* shared eyebrow / mono helpers */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
}
.mono { font-family: var(--mono); }

/* thin bathymetric rule, reused as a motif */
.ramp-rule { height: 3px; border: 0; margin: 0; border-radius: 3px; background: var(--ramp); }

/* ----------------------------------------------------------------- header -- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(243,246,247,.82);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; min-height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand__mark { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; box-shadow: var(--shadow-sm); }
.brand__name { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name b { font-size: 16px; letter-spacing: .02em; }
.brand__name span { font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.nav { display: flex; align-items: center; gap: 8px; }
.nav a {
  font-size: 13.5px; color: var(--ink-soft); padding: 8px 12px; border-radius: var(--r-xs);
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--ink); background: rgba(12,126,163,.08); }
.nav a.is-cta {
  color: #fff; background: var(--brand); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.nav a.is-cta:hover { background: var(--brand-deep); color: #fff; }

/* -------------------------------------------------------------------- hero -- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero__bg {
  position: absolute; inset: 0; z-index: 0; color: var(--brand);
  opacity: .07; pointer-events: none;
}
.hero__bg svg { width: 100%; height: 100%; }
.hero__inner { position: relative; z-index: 1; padding-block: clamp(40px, 7vw, 84px); }
.hero h1 {
  font-size: clamp(2rem, 4.4vw, 3.25rem);
  max-width: 16ch; margin-top: 14px; color: var(--brand-ink);
}
.hero h1 em { font-style: normal; color: var(--brand); }
.hero__lead {
  margin-top: 18px; max-width: 60ch; font-size: clamp(1rem, 1.4vw, 1.16rem);
  color: var(--ink-soft);
}
.hero__eyebrow-row { display: flex; align-items: center; gap: 12px; }
.hero__eyebrow-row .ramp-rule { width: 46px; }

.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.chip {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px; box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 7px;
}
.chip svg { width: 14px; height: 14px; color: var(--brand); }

/* ---------------------------------------------------------------- catalog -- */
.section { padding-block: clamp(36px, 5vw, 64px); }
.section--alt { background: var(--bg-2); border-block: 1px solid var(--line); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.section__head h2 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); color: var(--brand-ink); }
.section__head .count { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(298px, 1fr));
}

/* dataset card */
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #cfdde2; }
.card:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

.card__media { position: relative; aspect-ratio: 16 / 10; background: var(--bg-2); overflow: hidden; }
.card__media::before { /* ramp accent revealed on hover */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--ramp); z-index: 2; opacity: 0; transition: opacity .18s;
}
.card:hover .card__media::before { opacity: 1; }
.card__img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card:hover .card__img { transform: scale(1.035); }

/* generated fallback when no preview image exists / fails to load */
.thumb-fallback {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  color: #fff; text-align: center;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255,255,255,.16), transparent 60%),
    linear-gradient(160deg, #0e5e7e 0%, #0a4861 46%, #08324a 100%);
}
.thumb-fallback svg { width: 46px; height: 46px; opacity: .9; }
.thumb-fallback span { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.is-missing .card__img,
.is-missing .gallery__img { visibility: hidden; }
.is-missing .thumb-fallback { display: flex; }

.tag {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink); background: rgba(255,255,255,.92);
  padding: 5px 10px; border-radius: 999px; box-shadow: var(--shadow-sm);
  backdrop-filter: blur(3px);
}
.tag__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--muted); }

.card__body { padding: 16px 17px 0; flex: 1 1 auto; }
.card__title { font-size: 1.12rem; color: var(--brand-ink); }
.card__summary { margin-top: 8px; color: var(--ink-soft); font-size: 14px; }

.card__foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 17px 16px; margin-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.card__foot .open { color: var(--brand); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.card:hover .card__foot .open { gap: 9px; }
.card__foot .open svg { width: 14px; height: 14px; transition: transform .18s; }

.card__link { position: absolute; inset: 0; z-index: 3; } /* full-card click target */

/* ---------------------------------------------------------------- formats -- */
.formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.format {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.format__ext {
  font-family: var(--mono); font-weight: 700; font-size: 14px; color: #fff;
  background: var(--brand-deep); padding: 4px 9px; border-radius: var(--r-xs);
  display: inline-block; letter-spacing: .04em;
}
.format h3 { margin-top: 14px; font-size: 1.08rem; color: var(--brand-ink); }
.format p { margin: 8px 0 0; color: var(--ink-soft); font-size: 14.5px; }
.note {
  margin-top: 22px; padding: 14px 16px; border-radius: var(--r-sm);
  background: rgba(12,126,163,.06); border: 1px solid rgba(12,126,163,.18);
  color: var(--ink-soft); font-size: 14px;
}
.note b { color: var(--brand-ink); }

/* ----------------------------------------------------------- dataset page -- */
.backlink {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 22px;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
}
.backlink:hover { color: var(--brand); }
.backlink svg { width: 15px; height: 15px; }

.ds-head { display: grid; gap: 8px; max-width: 64ch; }
.ds-head h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); color: var(--brand-ink); margin-top: 6px; }
.ds-head p { color: var(--ink-soft); font-size: clamp(1rem, 1.3vw, 1.1rem); margin: 6px 0 0; }
.ds-head .tag { position: static; display: inline-flex; width: max-content; }

.ds-layout { display: grid; grid-template-columns: 1.55fr 1fr; gap: clamp(24px, 4vw, 48px); margin-top: 36px; align-items: start; }
@media (max-width: 880px) { .ds-layout { grid-template-columns: 1fr; } }

/* gallery */
.gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gallery--single { grid-template-columns: 1fr; }
.gallery__item {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-2); cursor: zoom-in; box-shadow: var(--shadow-sm);
}
.gallery--single .gallery__item { aspect-ratio: 16 / 9; }
.gallery__img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery__item:hover .gallery__img { transform: scale(1.04); }
.gallery__cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 7px 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: #fff;
  background: linear-gradient(transparent, rgba(6,30,40,.78));
}

/* files panel */
.files { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); overflow: hidden; }
.files__group-h {
  display: flex; align-items: center; gap: 9px; padding: 13px 16px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.files__group-h .badge { margin-left: auto; color: var(--muted); }

.frow {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.frow:last-child { border-bottom: 0; }
.frow:hover { background: rgba(12,126,163,.035); }
.frow__main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.fkind {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: var(--r-xs);
  display: grid; place-items: center; color: #fff;
}
.fkind svg { width: 17px; height: 17px; }
.fkind--f5  { background: linear-gradient(150deg, #0e6f93, #083f54); }
.fkind--vis { background: linear-gradient(150deg, #6f54b8, #4a3a86); }
.fkind--jpg { background: linear-gradient(150deg, #2a9d8f, #1d7068); }

.frow__name { font-family: var(--mono); font-size: 13px; color: var(--ink); word-break: break-all; line-height: 1.3; }
.frow__label { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.frow__right { display: flex; align-items: center; gap: 14px; }
.fsize { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); min-width: 64px; text-align: right; }
.fsize[data-state="loading"] { color: var(--faint); }
.fsize[data-state="error"]   { color: var(--faint); }

.dl {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: #fff; background: var(--brand);
  padding: 8px 13px; border-radius: var(--r-xs); border: 0; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background .15s, transform .1s;
}
.dl:hover { background: var(--brand-deep); }
.dl:active { transform: translateY(1px); }
.dl svg { width: 15px; height: 15px; }
.dl--ghost { color: var(--brand); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.dl--ghost:hover { background: rgba(12,126,163,.07); color: var(--brand-deep); }

.ds-aside .files + .note { margin-top: 18px; }

/* state / empty */
.placeholder { color: var(--muted); font-family: var(--mono); font-size: 13px; padding: 40px 0; text-align: center; }

/* -------------------------------------------------------------------- foot -- */
.site-foot { border-top: 1px solid var(--line); background: var(--bg-2); margin-top: 8px; }
.site-foot__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-block: 30px; }
.site-foot small, .site-foot a { font-size: 13px; color: var(--muted); }
.site-foot a:hover { color: var(--brand); }
.site-foot .mono { font-size: 12px; }

/* ---------------------------------------------------------------- lightbox -- */
.lightbox {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 4vmin;
  background: rgba(6,22,30,.84); backdrop-filter: blur(4px);
}
.lightbox.is-open { display: flex; }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox__close {
  position: absolute; top: 18px; right: 18px; width: 42px; height: 42px;
  border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.12); display: grid; place-items: center;
}
.lightbox__close:hover { background: rgba(255,255,255,.22); }
.lightbox__close svg { width: 20px; height: 20px; }
.lightbox__cap { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; color: #cfe6ec; font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------- reduced UX -- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
  .card:hover .card__img { transform: none; }
}
