/* Site layer — built on top of tokens.css / the Modernist system.
   Page-specific layout only; colors, type and spacing all come from
   the design-system variables. */

:root { --wrap: 1320px; }

body { margin: 0; background: var(--color-bg); color: var(--color-text); transition: background-color .15s ease, color .15s ease; }

/* — tubelight theme toggle: a little fixture hanging at top-center of the header — */
.tubelight-toggle {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  background: none; border: none; padding: 0 10px 6px; margin: 0; cursor: pointer; z-index: 5;
  -webkit-tap-highlight-color: transparent;
}
.tubelight-toggle:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
.tubelight-svg { display: block; width: 280px; height: auto; overflow: visible; }

.tl-mount, .tl-cap { fill: #3a3a3a; transition: fill .2s ease; }
.tl-tube { fill: #fffdf4; transition: fill .2s ease; }
.tl-glow { fill: #ffdf94; opacity: .55; transition: opacity .2s ease; }
.tl-glow-inner { fill: #fff0c0; opacity: .78; }
:root:not([data-theme="dark"]) .tubelight-svg {
  filter: drop-shadow(0 4px 14px rgba(224, 164, 58, .65)) drop-shadow(0 0 30px rgba(224, 164, 58, .45));
}
:root[data-theme="dark"] .tl-mount,
:root[data-theme="dark"] .tl-cap { fill: #9a9a9a; }
:root[data-theme="dark"] .tl-tube { fill: #5c5c5c; }
:root[data-theme="dark"] .tl-glow { opacity: 0; }

@keyframes tl-flicker {
  0%, 100% { opacity: 1; }
  4% { opacity: .2; }
  8% { opacity: 1; }
  12% { opacity: .1; }
  18% { opacity: 1; }
  24% { opacity: .3; }
  32% { opacity: 1; }
  42% { opacity: .15; }
  50% { opacity: 1; }
  62% { opacity: .5; }
  70% { opacity: 1; }
}
.tubelight-toggle.is-flickering .tl-tube {
  animation: tl-flicker 520ms steps(1, end) 1;
}

a { text-decoration: none; }
a:hover { color: var(--color-accent-600); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 40px; padding-right: 40px; }
.wrap-bare { max-width: var(--wrap); margin: 0 auto; }
.rule { border-bottom: 2px solid var(--color-divider); }

/* — skip link — */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--color-accent); color: var(--color-bg);
  padding: 10px 16px; font: 600 13px var(--font-heading);
}
.skip-link:focus { left: 16px; top: 16px; }

/* — site header / nav — */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 40px; border-bottom: 2px solid var(--color-divider);
  max-width: var(--wrap); margin: 0 auto; position: relative;
}
.brand {
  font-family: var(--font-heading); font-weight: 800; font-size: 20px;
  letter-spacing: -0.02em; color: var(--color-text); margin-right: auto;
  text-decoration: none;
}
.brand:hover { color: var(--color-accent); }
.site-nav { display: flex; align-items: center; gap: 28px; }
.site-nav a {
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--color-text); padding: 4px 0; border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--color-accent); }
.site-nav a[aria-current="page"] { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--color-divider);
  width: 40px; height: 40px; align-items: center; justify-content: center; cursor: pointer;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: var(--color-text);
  position: relative; transition: transform .15s ease, opacity .15s ease;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

.page-head { padding: 40px 40px 28px; }
.page-head .kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--color-accent); margin-bottom: 6px; }
.page-head h1 { font-size: clamp(30px, 5vw, 46px); margin: 0; }
.page-head p { margin: 10px 0 0; max-width: 560px; color: color-mix(in srgb, var(--color-text) 62%, transparent); }

/* — stats bar — */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { padding: 22px 32px; border-right: 2px solid var(--color-divider); }
.stat:last-child { border-right: 0; }
.stat-num { font-family: var(--font-heading); font-weight: 800; font-size: 38px; line-height: 1; }
.stat-num.accent { color: var(--color-accent); }
.stat-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: 6px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* — browse / chip nav — */
.chipnav { padding: 16px 40px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chipnav .label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) 55%, transparent); margin-right: 6px; }
.chip {
  border: 1px solid var(--color-divider); padding: 6px 12px; font-size: 13px; font-weight: 600;
  color: var(--color-text); background: transparent; cursor: pointer; font-family: var(--font-body);
}
.chip:hover { border-color: var(--color-accent); color: var(--color-accent); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }
.chip-more { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--color-accent); }

/* — photo placeholder (stand-in until real frames are dropped in) — */
.photo {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--color-neutral-200) 0 16px, var(--color-neutral-300) 16px 17px);
  border: 1px solid var(--color-divider);
}
.photo::after {
  content: attr(data-label);
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  font: 600 11px var(--font-heading); letter-spacing: .03em; text-transform: uppercase;
  color: var(--color-neutral-800); background: color-mix(in srgb, var(--color-bg) 84%, transparent);
  padding: 3px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* real photos size the frame themselves — width fills the slot, height follows
   the photo's own aspect ratio, so nothing gets cropped or padded out. */
.photo.has-photo { height: auto; background: var(--color-neutral-200); }
.photo.has-photo::after { display: none; }
.photo.has-photo img { display: block; width: 100%; height: auto; }
/* — portrait is a headshot, not a bird photo — cropped to fill like a normal profile photo — */
.about-portrait .photo.has-photo { height: 100%; }
.about-portrait .photo.has-photo img { height: 100%; object-fit: cover; }
.photo .lb-img { display: none; }
.photo.has-photo .lb-img { display: block; }

.photo-link { display: block; width: 100%; height: 100%; border: none; background: none; padding: 0; cursor: pointer; }

/* — masonry gallery — */
.gallery { padding: 32px 40px 40px; column-count: 4; column-gap: 20px; }
.gallery figure { break-inside: avoid; margin: 0 0 20px; }
.gallery figcaption { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-top: 8px; }
.gallery figcaption .name { font-weight: 600; }
.gallery figcaption .when { color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.gallery .photo:hover { outline: 2px solid var(--color-accent); outline-offset: -1px; }

/* — species shelves — */
.shelf { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--color-divider); }
.shelf:last-child { border-bottom: 0; margin-bottom: 0; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.shelf-head h2 { font-size: 19px; margin: 0; }
.shelf-head .count { color: color-mix(in srgb, var(--color-text) 45%, transparent); font-weight: 400; font-size: 14px; margin-left: 10px; }
.shelf-head a { font-size: 13px; font-weight: 600; color: var(--color-accent); }
.shelf-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px 12px; align-items: start; }
.shelf-item { display: block; color: var(--color-text); min-width: 0; }
.shelf-item[hidden], .shelf[hidden] { display: none; }
.shelf-item .photo { aspect-ratio: 1 / 1; }
.shelf-item .photo.has-photo { aspect-ratio: auto; }
.shelf-item .sp-name { font-size: 13px; margin-top: 6px; margin-bottom: 4px; line-height: 1.35; }
.shelf-item .sp-count { color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.unseen { padding: 14px 0 0; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.unseen .tag { opacity: .55; }

/* — species detail — */
.crumb { font-size: 13px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.crumb a { color: inherit; }
.crumb a:hover { color: var(--color-accent); }
.sp-hero { padding: 0 40px; margin: 0 auto 24px; max-width: var(--wrap); }
.sp-hero .photo { height: min(58vw, 480px); }
.sp-hero .photo.has-photo { height: auto; width: fit-content; max-width: 100%; margin: 0 auto; }
.sp-hero .photo.has-photo img { display: block; width: auto; max-width: 100%; height: auto; max-height: min(58vw, 480px); }
.sp-gallery {
  padding: 0 40px 32px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  align-items: start;
}
.sp-gallery .photo-link { display: block; cursor: pointer; }
.sp-gallery .photo { aspect-ratio: 1 / 1; }
.sp-gallery .photo.has-photo { aspect-ratio: auto; }
.sp-nav { display: flex; justify-content: space-between; padding: 20px 40px; }

/* — sighting log / tables — */
.log { display: grid; gap: 0; }
.log-row { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--color-divider); font-size: 14px; }
.log-row span:first-child { flex: 0 0 90px; color: var(--color-accent); font-weight: 600; }
.log-row span:nth-child(2) { flex: 1; }
.log-row span:last-child { color: color-mix(in srgb, var(--color-text) 50%, transparent); }

/* — notes index — */
.notes-list { padding: 8px 40px 24px; display: grid; }
.note-row {
  display: flex; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
}
.note-row .photo { flex: 0 0 130px; height: 96px; }
.note-row .photo.has-photo { height: auto; align-self: flex-start; }
.note-row .body { flex: 1; min-width: 0; }
.note-row .when { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--color-accent); }
.note-row h3 { font-size: 20px; margin: 6px 0; }
.note-row p { font-size: 14px; margin: 0 0 8px; color: color-mix(in srgb, var(--color-text) 62%, transparent); }
.note-row .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.note-row[hidden] { display: none; }

/* — note detail — */
.note-head { padding: 28px 40px 18px; max-width: 760px; margin: 0 auto; }
.note-head .when { font-size: 13px; font-weight: 600; color: var(--color-accent); }
.note-head h1 { font-size: clamp(28px, 5vw, 44px); margin: 8px 0 0; }
.note-body { max-width: 760px; margin: 0 auto; padding: 0 40px 8px; font-size: 17px; line-height: 1.7; }
.note-body p { margin: 0 0 20px; }
.note-figure { max-width: 760px; margin: 28px auto; padding: 0 40px; }
.note-figure .photo { height: 360px; }
.note-figure .photo.has-photo { height: auto; }
.note-figure figcaption { font-size: 13px; margin-top: 8px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.note-figure.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.note-figure.pair .photo { height: 220px; }
.note-figure.pair .photo.has-photo { height: auto; }
.note-species { max-width: 760px; margin: 32px auto 0; padding: 20px 40px; border-top: 2px solid var(--color-divider); }
.note-species h2 { font-size: 16px; }
.note-species .tags { display: flex; gap: 8px; flex-wrap: wrap; }

/* — about — */
.about-grid { display: flex; gap: 28px; padding: 32px 40px; }
.about-portrait { flex: 0 0 220px; }
.about-portrait .photo { height: 260px; }
.about-portrait figcaption { text-align: center; }
.about-copy { flex: 1; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.about-copy h1 { font-size: clamp(26px, 4vw, 38px); }
.two-col { display: flex; }
.two-col > div { flex: 1; padding: 20px 40px; }
.two-col > div:first-child { border-right: 2px solid var(--color-divider); }
.kv-list { display: grid; gap: 8px; margin-top: 4px; }
.kv-row { display: flex; justify-content: space-between; font-size: 14px; border-bottom: 1px solid var(--color-divider); padding-bottom: 6px; }
.kv-row:last-child { border-bottom: 0; }
.contact { padding: 20px 40px; }
.contact .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.contact .chips a.chip { display: inline-block; }

.latest-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }

/* — footer — */
.site-footer { max-width: var(--wrap); margin: 0 auto; padding: 28px 40px 40px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer .fine { font-size: 13px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.site-footer .links { display: flex; gap: 18px; }
.site-footer a { color: var(--color-text); font-size: 13px; }
.site-footer a:hover { color: var(--color-accent); }

/* — lightbox — */
.lightbox {
  position: fixed; inset: 0; z-index: 200; display: none;
  background: rgba(20, 18, 15, .94);
  align-items: center; justify-content: center; padding: 40px;
}
.lightbox.is-open { display: flex; }
.lightbox-frame { width: min(920px, 100%); position: relative; }
.lightbox .photo { height: min(64vh, 620px); }
.lightbox .photo.has-photo { height: auto; width: fit-content; max-width: 100%; margin: 0 auto; }
.lightbox .photo.has-photo img { display: block; width: auto; max-width: 100%; height: auto; max-height: min(64vh, 620px); }
.lightbox-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 14px; color: #fff; }
.lightbox-meta a { color: #fff; text-decoration: underline; }
.lb-when { color: rgba(255, 255, 255, .65); }
.lb-link { border-color: rgba(255, 255, 255, .5); white-space: nowrap; }
.lb-link:hover { border-color: var(--color-accent); color: var(--color-accent); }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; background: none; border: 1px solid rgba(255, 255, 255, .5);
  color: #fff; cursor: pointer; font-family: var(--font-heading); font-weight: 700;
}
.lightbox-close { top: 24px; right: 24px; width: 40px; height: 40px; }
/* top is half the photo's own max-height (min(64vh,620px)), not 50% of the
   frame, so the arrows stay centered on the photo regardless of how tall
   the meta block below it is. */
.lightbox-prev, .lightbox-next { top: min(32vh, 310px); transform: translateY(-50%); width: 44px; height: 44px; }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* — responsive — */
@media (max-width: 900px) {
  .tubelight-svg { width: 150px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .gallery { column-count: 2; }
  .sp-gallery { grid-template-columns: repeat(4, 1fr); }
  .latest-notes { grid-template-columns: repeat(2, 1fr); }
  .about-grid { flex-direction: column; }
  .about-portrait { flex: none; }
  .two-col { flex-direction: column; }
  .two-col > div:first-child { border-right: 0; border-bottom: 2px solid var(--color-divider); }
}
@media (max-width: 640px) {
  .wrap, .site-header, .page-head, .chipnav, .gallery, .notes-list,
  .sp-hero, .sp-gallery, .sp-nav, .about-grid, .two-col > div, .contact, .site-footer,
  .note-head, .note-body, .note-figure, .note-species {
    padding-left: 20px; padding-right: 20px;
  }
  .site-nav { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; background: var(--color-bg);
    border-bottom: 2px solid var(--color-divider); flex-direction: column; align-items: flex-start;
    gap: 0; padding: 8px 20px 16px; display: none; }
  .site-nav.is-open { display: flex; }
  .site-nav a { width: 100%; padding: 10px 0; }
  .nav-toggle { display: flex; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .gallery { column-count: 2; column-gap: 12px; }
  .gallery figcaption { flex-direction: column; align-items: flex-start; gap: 1px; font-size: 11px; line-height: 1.3; margin-top: 6px; }
  /* deliberate varied-height rhythm, mobile only — desktop still shows every
     photo full and uncropped; this repeating pattern crops to fill instead,
     purely so tiles read as more varied side by side. */
  .gallery figure:nth-child(6n+1) .photo.has-photo { height: 320px; }
  .gallery figure:nth-child(6n+2) .photo.has-photo { height: 220px; }
  .gallery figure:nth-child(6n+3) .photo.has-photo { height: 260px; }
  .gallery figure:nth-child(6n+4) .photo.has-photo { height: 340px; }
  .gallery figure:nth-child(6n+5) .photo.has-photo { height: 200px; }
  .gallery figure:nth-child(6n) .photo.has-photo { height: 290px; }
  .gallery .photo.has-photo img { height: 100%; object-fit: cover; }
  .sp-gallery { grid-template-columns: repeat(3, 1fr); }
  .note-row { flex-direction: column; }
  .latest-notes { grid-template-columns: 1fr; gap: 24px; }
  .note-row .photo { width: 100%; height: 160px; }
  .note-figure.pair { grid-template-columns: 1fr; }
  .lightbox { padding: 16px; }
  .lightbox-meta { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* below the meta block instead of floating over the photo */
  .lightbox-prev, .lightbox-next {
    position: static; transform: none; width: 44px; height: 44px; margin-top: 14px;
  }
  .lightbox-next { margin-left: 10px; }
}
