/* noaptea-licuricilor — bioluminescent night; dual theme, semantic tokens */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/newsreader-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("fonts/fraunces-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url("fonts/fraunces-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/plexmono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/plexmono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
  --bg: #faf7ef;
  --surface: #ffffff;
  --surface-2: #efece1;
  --text: #232a22;
  --muted: #57604f;
  --faint: #828c78;
  --line: #e0dccf;
  --line-strong: #c9c5b4;
  --accent: #4c7a12;         /* firefly deep green, AA on paper */
  --accent-soft: #eceee2;
  --night: #05070f;
  --glow: #d4f26a;           /* firefly light */
  --map-land: #eeeadd;
  --map-county: #d8d3c2;
  --map-county-strong: #b2ac9b;
  --focus: #3f6b10;
  --ok: #2e6b46;
  --to-top-bg: var(--surface);
  --to-top-fg: var(--text);
  --shadow: 0 1px 2px rgba(35, 42, 34, .08), 0 10px 30px rgba(35, 42, 34, .12);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0f14;
  --surface: #131a21;
  --surface-2: #1a232c;
  --text: #e9e7da;
  --muted: #a9b3a4;
  --faint: #7d887b;
  --line: #232d36;
  --line-strong: #33404d;
  --accent: #d4f26a;         /* firefly light */
  --accent-soft: #1c2415;
  --map-land: #151d26;
  --map-county: #26303d;
  --map-county-strong: #3d4a58;
  --focus: #ffd58a;
  --ok: #86d1a5;
  --to-top-bg: var(--surface);
  --to-top-fg: var(--text);
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 12px 36px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Newsreader, Georgia, serif;
  font-size: clamp(1.02rem, .96rem + .3vw, 1.14rem);
  line-height: 1.62;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--surface); color: var(--text); padding: .6rem 1rem; border: 1px solid var(--line); border-radius: 8px; transition: top .2s; }
.skip:focus { top: .6rem; }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: 44px; display: flex; align-items: center; gap: .9rem; padding: 0 .9rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); font-size: .82rem; }
.topbar .brand { font-family: Fraunces, serif; font-weight: 600; letter-spacing: .01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: .75rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { color: var(--muted); text-decoration: none; white-space: nowrap; padding: .25rem .1rem; }
.topbar nav a:hover, .topbar nav a:focus-visible { color: var(--text); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--text); background: var(--surface-2); }
.lang-switch { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font: 600 .72rem/1 "Plex Mono", monospace; }
.lang-switch a { padding: .4rem .55rem; color: var(--muted); text-decoration: none; }
.lang-switch a[aria-current="true"] { background: var(--text); color: var(--bg); }
@media (max-width: 720px) { .topbar nav { display: none; } }

/* ---------- night hero ---------- */
.night-hero { position: relative; height: 92svh; min-height: 620px; overflow: hidden; background: #05070f; color: #e9e7da; }
@media (max-height: 700px) { .night-hero { height: 100svh; } }
.night-stage { position: absolute; inset: 0; }
#firefly-stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.night-scrim { position: absolute; inset: 0; background: linear-gradient(92deg, rgba(5,7,15,.86) 0%, rgba(5,7,15,.72) 24%, rgba(5,7,15,.48) 38%, rgba(5,7,15,.22) 50%, rgba(5,7,15,.06) 62%, rgba(5,7,15,0) 74%); pointer-events: none; }
.night-copy { position: absolute; z-index: 2; left: max(1.4rem, 6vw); top: 50%; transform: translateY(-50%); max-width: min(620px, 92vw); }
.night-kicker { color: var(--glow); }
.night-copy h1 { font-family: Fraunces, serif; font-weight: 600; font-size: clamp(2.2rem, 1.4rem + 3.6vw, 4rem); line-height: 1.04; letter-spacing: -.015em; margin: 0 0 1.1rem; text-wrap: balance; color: #f2f0e2; text-shadow: 0 2px 34px rgba(5,7,15,.95); }
.night-sub { font-size: clamp(1.02rem, .98rem + .4vw, 1.22rem); line-height: 1.55; color: #d4d4c2; margin: 0 0 1.4rem; max-width: 52ch; text-shadow: 0 1px 22px rgba(5,7,15,.9); }
.night-sub em { color: #ffe9a8; font-style: italic; }
.lamp-row { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.lamp-btn { display: inline-flex; align-items: center; gap: .6rem; font: 600 .92rem/1 "Plex Mono", monospace; color: #05070f; background: #ffd98a; border: 0; border-radius: 999px; padding: .72rem 1.2rem; cursor: pointer; letter-spacing: .02em; }
.lamp-btn:hover, .lamp-btn:focus-visible { filter: brightness(1.07); }
.lamp-btn[aria-pressed="false"] { background: #202a34; color: var(--glow); border: 1px solid #33404d; }
.lamp-dot { width: .7rem; height: .7rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px 2px currentColor; }
.lamp-note { font-size: .74rem; color: #8b9078; max-width: 46ch; margin: 0; }
.lamp-note em { color: #c9c9b8; }
.scroll-cue { position: absolute; z-index: 2; left: 50%; bottom: 1.1rem; transform: translateX(-50%); width: 2px; height: 44px; overflow: hidden; background: rgba(233,231,218,.14); border-radius: 2px; }
.scroll-cue span { position: absolute; left: 0; top: -40%; width: 100%; height: 40%; background: var(--glow); animation: cue 2.2s ease-in-out infinite; }
@keyframes cue { 0% { top: -40%; } 60%, 100% { top: 110%; } }

/* phone: the meadow keeps the top of the screen, the text sits below it, never on top */
@media (max-width: 720px) {
  .night-hero { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .night-stage { position: relative; inset: auto; height: 42svh; min-height: 250px; }
  .night-scrim { background: linear-gradient(180deg, rgba(5,7,15,0) 70%, rgba(5,7,15,.9) 100%); }
  .night-copy { position: static; transform: none; max-width: none; padding: 1.1rem 1.25rem 2.6rem; }
  .night-copy h1 { font-size: clamp(1.9rem, 1.2rem + 4vw, 2.5rem); }
  .scroll-cue { display: none; }
}
.ladder-scale { font-size: .9rem; color: var(--muted); margin: .9rem 0 0; padding-left: .9rem; border-left: 2px solid var(--accent); max-width: 64ch; }
.museum-note { margin-top: clamp(1.4rem, 3vw, 2.2rem); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(1rem, 2.4vw, 1.6rem) clamp(1.1rem, 3vw, 2rem); max-width: 820px; }
.museum-note h3 { margin-top: 0; font-size: 1.2rem; }
.museum-note p { margin: 0; color: var(--muted); max-width: 68ch; }

/* ---------- layout ---------- */
.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.wrap-narrow { width: min(880px, 100% - 2.5rem); margin-inline: auto; }
section { padding: clamp(2.2rem, 4vw, 4rem) 0; border-top: 1px solid var(--line); }
.night-hero { border-top: 0; padding: 0; }
.kicker { font: 600 .68rem/1.4 "Plex Mono", monospace; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin: 0 0 .8rem; }
h1, h2, h3 { font-family: Fraunces, serif; color: var(--text); text-wrap: balance; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.3rem); line-height: 1.14; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .9rem; }
h3 { font-size: 1.08rem; margin: 1.2rem 0 .35rem; }
.standfirst { font-size: clamp(1.06rem, .98rem + .5vw, 1.3rem); line-height: 1.5; color: var(--muted); margin: 0 0 1.4rem; max-width: 52ch; }
.standfirst strong { color: var(--text); }
.prose p, .prose li { max-width: 70ch; }
.prose a { color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.quiet-note { font-size: .86rem; color: var(--faint); border-left: 2px solid var(--line-strong); padding-left: .8rem; }

/* ---------- lux ladder ---------- */
.lux-ladder { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: .55rem; }
.lux-ladder li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 1rem; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .65rem .9rem; }
.lux-num { font: 600 1.3rem/1.1 "Plex Mono", monospace; color: var(--accent); letter-spacing: -.01em; }
.lux-txt { color: var(--muted); font-size: .92rem; }
.lux-txt strong { color: var(--text); }
@media (max-width: 560px) { .lux-ladder li { grid-template-columns: 1fr; gap: .15rem; } }

/* ---------- data grid ---------- */
.data-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(1.2rem, 3vw, 2.4rem); align-items: stretch; margin-top: .4rem; }
@media (max-width: 980px) { .data-grid { grid-template-columns: 1fr; } }
.map-frame { background: var(--map-land); border: 1px solid var(--line); border-radius: 18px; padding: clamp(.6rem, 2vw, 1.2rem); }
.map-frame svg { display: block; width: 100%; height: auto; }
.county { fill: var(--map-land); stroke: var(--map-county); stroke-width: .7; }
.country-line { fill: none; stroke: var(--map-county-strong); stroke-width: 1.4; }
.sp-dot { fill: #ffd75e; }
.sp-dot.sp-lusitanica { fill: #8affd0; }
.sp-dot.sp-hemipterus { fill: #7ab8ff; }
.sp-dot.sp-zenkeri { fill: #ff9de2; }
.sp-dot.sp-other { fill: #c8c8c8; }
:root:not([data-theme="dark"]) .sp-dot.sp-noctiluca { fill: #a8860b; }
:root:not([data-theme="dark"]) .sp-dot.sp-lusitanica { fill: #1d9e6b; }
:root:not([data-theme="dark"]) .sp-dot.sp-hemipterus { fill: #2f6fd0; }
:root:not([data-theme="dark"]) .sp-dot.sp-zenkeri { fill: #c95bb0; }
:root:not([data-theme="dark"]) .sp-dot.sp-other { fill: #8a8a8a; }
.night-hero.webgl-fallback { display: grid; place-items: center; }
#firefly-stage.no-webgl { display: none; }
.night-hero.webgl-fallback .night-stage { display: none; }
.night-hero.webgl-fallback .night-copy { position: relative; transform: none; top: auto; left: auto; padding: 4rem 1.4rem; }
.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; }
.dot[data-sp="noctiluca"] { background: #d9b13b; }
.dot[data-sp="lusitanica"] { background: #1d9e6b; }
.dot[data-sp="hemipterus"] { background: #2f6fd0; }
.dot[data-sp="zenkeri"] { background: #c95bb0; }
.dot[data-sp="other"] { background: #8a8a8a; }
[data-theme="dark"] .dot[data-sp="noctiluca"] { background: #ffd75e; }
[data-theme="dark"] .dot[data-sp="lusitanica"] { background: #8affd0; }
[data-theme="dark"] .dot[data-sp="hemipterus"] { background: #7ab8ff; }
[data-theme="dark"] .dot[data-sp="zenkeri"] { background: #ff9de2; }
.map-legend { display: flex; flex-wrap: wrap; gap: .45rem 1rem; margin-top: .7rem; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.map-note { font-size: .76rem; color: var(--faint); margin-top: .5rem; max-width: 60ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(1rem, 2vw, 1.5rem); }
.panel-h { font-size: 1.02rem; margin: .2rem 0 .5rem; }
.panel-h-spaced { margin-top: 1.3rem; }
.county-label { display: block; font: 600 .66rem/1.4 "Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.county-select { width: 100%; font: 500 1rem Newsreader, serif; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px; padding: .65rem .8rem; margin: .35rem 0 .7rem; }
.county-select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.county-result { font-size: .98rem; color: var(--text); margin: 0 0 .4rem; }
.county-result strong { font-weight: 700; }
.inat-link { margin-top: .3rem; }
.btn-ghost { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 600; padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line-strong); font-size: .9rem; }
.btn-ghost:hover, .btn-ghost:focus-visible { border-color: var(--text); }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 88px; margin: .6rem 0 .3rem; }
.mini-bars i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .88; }
.mini-bars.years i { background: var(--accent); opacity: .8; }
.mini-bars-cap { display: flex; justify-content: space-between; font: 400 .6rem/1 "Plex Mono", monospace; color: var(--faint); }
.panel-foot { font-size: .72rem; color: var(--faint); margin-top: .4rem; }

/* ---------- checklist ---------- */
.checklist { counter-reset: step; list-style: none; padding: 0; display: grid; gap: .6rem; }
.checklist li { counter-increment: step; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1rem .8rem 3.2rem; }
.checklist li::before { content: counter(step); position: absolute; left: .9rem; top: .8rem; font: 600 1.1rem/1.6 "Plex Mono", monospace; color: var(--accent); }
.checklist strong { color: var(--text); }

/* ---------- share ---------- */
.share-block { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.share-line { font-weight: 600; margin: 0 0 .6rem; }
.share-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.share-label { font-size: .8rem; color: var(--faint); margin-right: .25rem; }
.share-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.share-btn:hover, .share-btn:focus-visible { color: var(--text); border-color: var(--text); }
@media (pointer: coarse) { .share-btn { width: 44px; height: 44px; } }
.copy-status { font-size: .8rem; color: var(--ok); min-height: 1.2em; margin: .35rem 0 0; }

/* ---------- method ---------- */
.source-list { font-size: .88rem; color: var(--muted); }
.source-list li { margin-bottom: .3rem; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); padding: 2rem 0 3rem; color: var(--muted); font-size: .85rem; }
.foot-title { margin: 0; font-weight: 600; color: var(--text); }
.foot-sub { margin: .4rem 0 0; }
footer a { color: var(--muted); }
footer a:hover { color: var(--text); }
.sp-dot { stroke: var(--map-land); stroke-width: 1.2; }
[data-theme="dark"] .sp-dot { filter: drop-shadow(0 0 5px currentColor); }
[data-theme="dark"] .sp-dot.sp-noctiluca { color: #ffd75e; }
[data-theme="dark"] .sp-dot.sp-lusitanica { color: #8affd0; }
[data-theme="dark"] .sp-dot.sp-hemipterus { color: #7ab8ff; }
[data-theme="dark"] .sp-dot.sp-zenkeri { color: #ff9de2; }
