/* lloverllover — minimal bare design (plan req. 4). Mobile-first; system fonts. */
* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
body { margin: 0; color: #1a1a1a; background: #fff; }
h1 { font-size: 1.25rem; margin: 0; }
h1 span { color: #4393c3; }  /* mid-tone of the marker ramp — quiet */
h2 { font-size: 1rem; margin: .2rem 0; }
a { color: #0b5fa5; }
button { font: inherit; }

header, footer, main > section, #legend { padding-left: .75rem; padding-right: .75rem; }
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem;
  padding: .5rem .75rem; border-bottom: 1px solid #ddd; }
/* v3.1: ONE subtitle line replaces the two paragraphs it used to be, so the header is a row
   shorter and nothing else moved.  v3.2: space-between puts the hydrological year FLUSH RIGHT
   on the same line; when a phone cannot hold both it wraps, and the year stays at the right
   edge of its own row — where a date belongs anyway. */
header .sub { margin: 0; font-size: .8rem; color: #555; flex-basis: 100%;
  display: flex; justify-content: space-between; align-items: baseline; gap: .1rem .9rem; }
header .sub .hy { flex: none; }
/* The top-right corner is one cluster: search field then ES|EN.  The auto margin on the
   form pushes the pair right; the adjacent rule keeps them tight together.  On about.html
   there is no form, so plain `#lang { margin-left: auto }` still right-aligns the toggle. */
#qform { margin-left: auto; }
#qform + #lang { margin-left: 0; }
#lang { margin-left: auto; }
#lang button { border: 1px solid #bbb; background: #fff; padding: .15rem .55rem; cursor: pointer; }
#lang button:first-child { border-radius: .3rem 0 0 .3rem; }
#lang button:last-child { border-radius: 0 .3rem .3rem 0; border-left: 0; }
#lang button[aria-pressed="true"] { background: #1a1a1a; color: #fff; }

#map { height: 52vh; width: 100%; }
#legend { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
  font-size: .78rem; padding-top: .4rem; padding-bottom: .4rem; border-bottom: 1px solid #eee; }
#legend b { margin-right: .25rem; }
/* v3.1: every chip knows its own range.  v3.2: it also SHOWS it without a mouse — a tap (or
   Enter/Space) opens the bubble below.  A native `title` covers the desktop pointer, and the
   `:focus`/`.open` rules cover touch and keyboard; `:hover` deliberately shows nothing, so a
   desktop reader never gets two tooltips stacked on one word. */
#legend span { display: inline-flex; align-items: center; gap: .25rem; cursor: help;
  position: relative; }
#legend .chip:focus { outline: 1px dotted #999; outline-offset: 2px; }
#legend .range { position: absolute; left: 0; top: calc(100% + .4rem); z-index: 1100;
  display: none; padding: .3rem .5rem; border-radius: .35rem; background: #1a1a1a;
  color: #fff; font-size: .72rem; line-height: 1.35; font-style: normal;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, .22); }
#legend .chip.open .range, #legend .chip:focus .range { display: block; }
/* the last chip would otherwise hang its bubble off the right edge of a phone */
#legend span:last-child .range { left: auto; right: 0; }
#legend i { width: .8rem; height: .8rem; border-radius: 50%; display: inline-block; }

#card { border: 1px solid #ddd; border-radius: .5rem; margin: .5rem .75rem; padding: .6rem .8rem; }
#card h2 { border-left: 6px solid #b0b8bf; padding-left: .5rem; }
/* v3.5: the card's place name is a LINK — it opens the place's own page (ten days,
   the table, the zoomed map).  A real anchor: middle-click, "open in new tab" and the
   keyboard all work because it is the thing itself, not a gesture imitating one. */
#card h2.goto a { color: inherit; text-decoration: none; }
#card h2.goto a:hover, #card h2.goto a:focus { text-decoration: underline dotted; }
#card p { margin: .18rem 0; font-size: .95rem; }
#card p.hl { font-weight: 600; margin-top: .45rem; }
/* The card's last line (v2.3): province · altitude on the left, the Hidrosur ficha on
   the right of the SAME line — Juanjo asked the link to sit beside the location info,
   not in a paragraph of its own.  space-between pushes them apart; wrap keeps the phone
   readable (the link drops below the place rather than squeezing the words). */
/* 9th prompt: the card's head is one row, exactly like the page per place —
   the name (with its colour bar), then municipio · provincia · altitud and the
   ficha, all baseline-aligned, wrapping below the name on a narrow phone. */
#card .cardhead { display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .1rem .8rem; }
#card .cardhead h2 { margin-bottom: 0; }
#card .meta { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  flex: 1 1 12rem; margin: 0; font-size: .8rem; color: #666; }
#card .meta a { color: #1565c0; text-decoration: none; white-space: nowrap; }
#card .meta a:hover { text-decoration: underline; }
.leaflet-popup-content p { margin: .12rem 0; font-size: .85rem; }
.leaflet-popup-content p.hl { font-weight: 600; margin-top: .35rem; }
.hint { color: #666; font-size: .8rem; margin: .2rem 0; }

/* Quiet basemap (req. 2): the TILES are muted, never the markers. Adjust these
   numbers only — markers/legend/dots keep their full colour. */
.leaflet-tile-pane { filter: grayscale(.85) brightness(1.1) contrast(.88) opacity(.8); }

#dir-section { border-top: 1px solid #eee; margin-top: .9rem; padding-top: .5rem; }
#dir-section h2 { margin-top: .3rem; }

/* One search for the whole network (req. 9): a box shown directly — no button (v2.3.1) —
   sitting TOP-RIGHT on the title line, just left of ES|EN (v2.3.2).  It finds every place,
   dry ones included (the directory only lists the wet ones).  The results DROP DOWN over
   the page (`position:absolute` + a z-index above the video popup's 1200), so opening them
   stretches nothing and moves nothing below; headerGap() still measures the header for the
   video.  On a phone the field is the elastic part: `min(17rem, 33vw)` is sized so the
   title (128 px), the field, ES|EN (81 px) and two 8 px gaps still fit one 375 px line. */
#qform { position: relative; display: flex; align-items: center; min-width: 0; }
#q { width: min(17rem, 33vw); min-width: 0; padding: .3rem .5rem; font: inherit;
  font-size: .92rem; border: 1px solid #bbb; border-radius: .4rem; }
#qhits { position: absolute; top: calc(100% + .25rem); right: 0; z-index: 1300;
  min-width: 17rem; max-width: min(26rem, calc(100vw - 1.5rem)); max-height: 55vh;
  overflow-y: auto; box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
  list-style: none; margin: 0; padding: .1rem 0; border: 1px solid #ddd;
  border-radius: .4rem; background: #fff; }
#qhits:empty { display: none; }
#qhits li { display: flex; align-items: center; gap: .35rem; padding: .28rem .5rem;
  font-size: .85rem; cursor: pointer; }
#qhits li:hover, #qhits li[aria-selected="true"] { background: #eef6fb; }
#qhits li.qnone { cursor: default; color: #666; font-size: .82rem; }
#qhits .dot { width: .5rem; height: .5rem; border-radius: 50%; flex: none;
  border: 1px solid rgba(0, 0, 0, .12); }
#qhits .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
#qhits .pr { flex: none; color: #666; font-size: .75rem; }
#qhits .val { flex: none; font-size: .78rem; color: #555; font-variant-numeric: tabular-nums; }
/* Small phones (≤440 px): trim the header's air so title + field + ES|EN still share the
   title line — below that it wraps to a row of its own, which still looks right. */
@media (max-width: 440px) {
  header { gap: .35rem; }
  #q { width: min(17rem, 30vw); }
  #lang button { padding: .15rem .45rem; }
}
/* Directory (req. 5): compact multi-column list — one line per place, forecast in
   brackets, up to four columns.  The breakpoints are set by what a PLACE NAME needs:
   below 560 px two columns would ellipsize "Embalse de Conde..." to nonsense, so a
   phone gets one readable line per place and the columns start on a tablet. */
#directory details { margin: .25rem 0; }
#directory details.prov > summary { font-weight: 600; }
#directory summary { cursor: pointer; font-size: .88rem; padding: .2rem 0;
  display: flex; align-items: center; gap: .4rem; list-style: none; }
#directory summary::-webkit-details-marker { display: none; }
#directory summary::before { content: "▸"; color: #999; flex: none; font-size: .75rem; }
#directory details[open] > summary::before { content: "▾"; }
#directory ul { list-style: none; margin: 0; padding: 0; columns: 1; column-gap: 1rem; }
@media (min-width: 560px) { #directory ul { columns: 2; } }
@media (min-width: 820px) { #directory ul { columns: 3; } }
@media (min-width: 1180px) { #directory ul { columns: 4; } }
#directory li[data-n] { break-inside: avoid; border-bottom: 1px solid #f2f2f2;
  font-size: .82rem; }
/* v3.5: the whole row is one link — the place's page (dot, name, amount stay the
   same words, just wrapped in a door). */
#directory li[data-n] a { display: flex; align-items: center; gap: .3rem;
  padding: .16rem .2rem; color: inherit; text-decoration: none; min-width: 0; }
#directory li[data-n] a:hover .nm, #directory li[data-n] a:focus .nm { text-decoration: underline dotted; }
#directory .dot { width: .5rem; height: .5rem; border-radius: 50%; flex: none;
  border: 1px solid rgba(0, 0, 0, .12); }
#directory .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#directory .val { flex: none; font-size: .74rem; color: #555;
  font-variant-numeric: tabular-nums; }

footer { border-top: 1px solid #ddd; margin-top: 1.2rem; padding: .6rem .75rem; }
footer p { font-size: .75rem; color: #555; }

/* The paired day series (v3.5, Phase 17): one column per day, TWO thin bars each —
   BLACK = the millimetres the gauges closed that day with, BLUE = the forecast for it
   (a past day gets its own archived morning 00z; today and beyond get the live cycle).
   A value nobody has is a "–" in its bar's colour — never a zero, never invented.  The
   hairline just left of today's column splits memory from forecast.  Heights are
   logarithmic (barFrac in plot.js) and ONE scale fits black and blue together, so a
   tall black over a short blue really means the gauges beat the morning's word. */
.fcbars { display: inline-flex; align-items: flex-end; gap: .2rem; }
.fcbars .fcday { display: flex; flex-direction: column; align-items: center; position: relative; }
.fcbars .fctrack { position: relative; width: 1.14rem; height: 2.5rem; flex: none; }
/* the pair: observation LEFT, forecast RIGHT, each under half the track */
.fcbars .obar, .fcbars .fbar { position: absolute; bottom: 0; width: 46%; min-height: 2px;
  border-radius: 2px 2px 0 0; }
.fcbars .obar { left: 1px; }
.fcbars .fbar { right: 1px; }
/* a thin paired bar can never HOLD its number (a "12,4" is wider than any bar) —
   so numbers ride above, dark, and only where there is room for them: the live
   columns on the map page, every column on the place's own page */
.fcbars .fbar b, .fcbars .obar b { position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 100%; color: #444; font-weight: 500; font-size: .56rem; line-height: 1;
  white-space: nowrap; font-variant-numeric: tabular-nums; padding-bottom: 1px; }
.fcbars .fdash { position: absolute; bottom: 0; width: 46%; text-align: center;
  font-style: normal; font-weight: 700; font-size: .72rem; line-height: 1; }
.fcbars .fdash.obs { left: 1px; color: #1f2937; }
.fcbars .fdash.fc { right: 1px; color: #4ba3d3; }
.fcbars .fcwd { font-size: .56rem; font-weight: 500; color: #777; line-height: 1;
  border-top: 1px solid #ccc; margin-top: 2px; padding: .14rem .06rem 0; white-space: nowrap; }
.fcday.now .fcwd { color: #08519c; font-weight: 700; }      /* today's column */
.fcday.now::before { content: ""; position: absolute; left: -.12rem; top: -.55rem;
  bottom: 0; width: 1px; background: #0f172a; opacity: .5; }
/* THE BALLOON WEARS NO SUCH LINE (9th prompt): a balloon holds only the five live days,
   so a rule at its left edge would mark the start of the picture, not the turn from
   memory to forecast that the line was invented to say.  Today keeps its bold blue
   initial; the card and the page per place keep the line, where the past really is
   on the other side of it. */
.leaflet-popup-content .fcday.now::before { content: none; }
/* fourteen columns on a 375 px screen: the line scrolls in its paragraph instead
   of the numbers lying about the week.  THE BALLOON IS NOT IN THAT LIST (v3.7):
   it shows the five live days only, which always fit — no scrollbar in a balloon.
   And every scrollable series reserves headroom for the numbers riding above the
   bars: max-height keeps even a 100 % bar below the label line, so a wet day's
   number can never be cut by the box (req. 6-2). */
#card p.hl, #stseries-wrap p.hl { overflow-x: auto; }
.fcbars { padding-inline: .6rem; }                /* edge labels hang nowhere to */
.leaflet-popup-content .fbar, .leaflet-popup-content .obar { max-height: calc(100% - .72rem); }
#card .fcbars .fbar, #card .fcbars .obar { max-height: calc(100% - .84rem); }
#stseries-wrap .fbar, #stseries-wrap .obar { max-height: calc(100% - .82rem); }
.leaflet-popup-content .fctrack { width: .98rem; height: 2.3rem; }
.leaflet-popup-content .fcbars { gap: .15rem; }
#card .fcbars .fctrack { width: 1.5rem; height: 3.1rem; }  /* a little larger in the card */
#card .fcbars .fbar b, #card .fcbars .obar b { font-size: .64rem; }
#card .fcbars .fcwd { font-size: .66rem; }
/* The quantity lines (req. 3, v2.3): each line is a number cell and a words cell.  The
   number is right-aligned inside a box as wide as the widest number of that place
   (`--qw`, set by detailLines in `ch` = tabular digits), so the lines line up **by their
   last digit** — 185,6 over 28,8 over 4,3 — and every line of words starts at the same x.
   The digits are tabular so they really are equal width; the leading space of the words
   cell is dropped by CSS at the start of a line and exists only for copy-paste.
   `q` and both of its cells stay the same font size in the number column: a smaller `b`
   would shrink its own `ch` and break the flush edge (only the words may differ). */
.q { display: block; margin: .28rem 0 .12rem; }
.q .qrow { display: flex; align-items: baseline; gap: .3rem; margin: .1rem 0; }
.q .qrow b { flex: none; width: var(--qw, 4ch); text-align: right; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: pre; }
.q .qrow i { font-style: normal; min-width: 0; }
.q .tot i { font-size: .9em; color: #555; }
#card .q { font-size: .95rem; }
.leaflet-popup-content .q { font-size: .85rem; }

/* The intro block (req. 8): app.js lifts this element into the popup below on
   load, and closing the popup takes it out of the page for good — so the inline
   copy is only ever what a browser with no JavaScript sees (see #intro-holder). */
.intro { margin: .6rem .75rem; border: 1px solid #ddd; border-radius: .5rem; padding: .1rem .8rem; }
.intro iframe { display: block; margin: .6rem auto .2rem; width: 100%; max-width: 720px;
  /* the slash is mandatory: `aspect-ratio: 16 9` is dropped by Firefox, which left
     the player at the UA default 150px tall — a thin strip with bars at the sides */
  aspect-ratio: 16 / 9; height: auto; min-height: 0; border: 0; }
.video-alt { font-size: .75rem; color: #666; margin: .2rem 0 .6rem; }

/* Popup: the same block, centred over the page and as BIG as the screen allows.
   It must never cover the page title, so it starts BELOW the header: `--head` is
   the real header height, measured by app.js (headerGap), with a CSS fallback for
   browsers without scripts.  The card's width is capped by the space left under
   that header × 16/9, so the player fills the screen without being cropped or
   letterboxed — portrait or landscape. */
.pop { position: fixed; inset: var(--head, 4.6rem) 0 0 0; z-index: 1200;
  display: grid; place-items: center; box-sizing: border-box; padding: .4rem;
  overflow: auto; background: rgba(22, 26, 30, .62); }
.pop[hidden] { display: none; }
body.pop-open { overflow: hidden; }        /* the page waits; nothing slides aside */
.pop-card { position: relative; background: #fff; border-radius: .6rem;
  box-sizing: border-box; padding: 1.5rem .5rem .35rem;
  width: min(calc(100vw - .8rem), calc((100vh - var(--head, 4.6rem) - 4.6rem) * 16 / 9));
  width: min(calc(100vw - .8rem), calc((100dvh - var(--head, 4.6rem) - 4.6rem) * 16 / 9)); }
.pop-card .intro { margin: 0; border: 0; padding: 0; border-radius: 0; }
.pop-card .intro iframe { max-width: 100%; margin-left: 0; }
.pop-close { position: absolute; top: .1rem; right: .2rem; border: 0; background: none;
  font-size: 1.5rem; line-height: 1; padding: .35rem .5rem; cursor: pointer; color: #666; }
.pop-close:hover { color: #1a1a1a; }
.ratio { position: relative; aspect-ratio: 16 / 9; }
.ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* about.html is a text page: `prose` is the measure, and it needs the
   same .75rem gutter the rest of the site uses — otherwise a phone puts the paragraph
   hard against the edge of the screen. */
.prose { max-width: 46rem; line-height: 1.55; padding-left: .75rem; padding-right: .75rem; }
.prose h2 { font-size: 1.15rem; margin-top: 1.2rem; }
.prose h3 { font-size: .95rem; margin-top: 1rem; }
@media (min-width: 48rem) {
  #map { height: 62vh; }
  #card { margin: .75rem 0; }
}

/* ---------- the page per place (v3.5, Phase 17) ---------- */
/* station.html?e=<name>: header keeps the logo (the way back) and ES|EN; below, the
   place's own big pair series, its day-by-day table and a zoomed map.  Every block
   reuses the map page's rules — colours, bars, numbers come from plot.js, so a
   "–" here means exactly what a "–" means on the balloon. */
.station-page header.solo h1 a { color: inherit; text-decoration: none; }
#place h2 { border-left: 6px solid #b0b8bf; padding-left: .5rem; }
/* v3.8 (req. 7): one line — name, then municipio·provincia·altura·ficha LEFT right
   after it; only Volver al mapa is pushed to the right margin.  Wraps below the
   name on narrow screens, never orphaned. */
#place .sthead { display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .15rem .8rem; }
#place .stmeta { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  flex: 1 1 14rem; margin: 0; font-size: .8rem; color: #666; }
#place .stwhere { display: inline-flex; align-items: baseline; gap: .6rem;
  flex-wrap: wrap; }
#place .stmeta > a:last-child { margin-left: auto; }
#place .stmeta a { color: #1565c0; text-decoration: none; white-space: nowrap; }
#place .stmeta a:hover { text-decoration: underline; }
#place .q { font-size: .92rem; margin-top: .5rem; }   /* the two hydro-year lines */
/* 9th prompt: those lines are the last thing before the box, so they need room to
   breathe on both sides — glued to the head line above, or to the border below. */
#place #stacc { margin-bottom: .85rem; }
#place .meta { display: flex; justify-content: space-between; align-items: baseline;
  gap: .2rem .7rem; flex-wrap: wrap; margin: .4rem 0 .1rem; font-size: .8rem; color: #666; }
#place .meta a { color: #1565c0; text-decoration: none; white-space: nowrap; }
#place .meta a:hover { text-decoration: underline; }

#stseries-wrap h2, #sttable-wrap h2 { font-size: .92rem; color: #555; margin: .1rem 0 .5rem; }
#stseries-wrap .fctrack { width: 2.05rem; height: 3.4rem; } /* the grown-up series */
#stseries-wrap .fbar b, #stseries-wrap .obar b { font-size: .62rem; }
#stseries-wrap .fcwd { font-size: .62rem; }
#stseries-wrap .fdash { font-size: .9rem; }
/* v3.6: the table is WIDE now (one column per cycle that fully covered the day:
   up to seventeen forecast columns) — it earns its own horizontal scroll on a
   phone instead of squeezing numbers into unreadable slivers. */
.rainwrap { overflow-x: auto; }
table.rain { border-collapse: collapse; font-size: .8rem; width: 100%; min-width: 46rem; }
table.rain th, table.rain td { border: 1px solid #e4e7ea; padding: .26rem .38rem;
  text-align: right; font-variant-numeric: tabular-nums; }
table.rain thead th { background: #f6f8fa; font-weight: 600; white-space: nowrap; }
table.rain thead tr.hrs th { font-size: .68rem; font-weight: 500; color: #666;
  background: #fbfcfd; text-align: center; }
table.rain tbody th { text-align: left; font-weight: 600; background: #fafbfc;
  white-space: nowrap; }
table.rain td.obs { color: #1f2937; font-weight: 600; }    /* the measured day */
#stmap { height: 340px; margin: .9rem .75rem .3rem; }

/* ---------- the family page (puerto-del-barco.html, 9th prompt) ---------- */
/* ONE column, everything centred, top down: the dedication, the picture, its line of
   caption, and BELOW them the map — as big as the map on any page per place, because this
   page is one of those pages.  The image keeps its own
   width and height so the browser reserves the space (no jump), and it is never upscaled past
   40rem: the point of the small, soft copy is that it stays a memory, not a file to be mined.
   The words are centred too — a dedication reads above a photograph, not in its corner. */
.famcol { display: grid; justify-items: center; gap: .85rem; text-align: center;
  margin: .6rem auto 1.6rem; padding-inline: .75rem; max-width: 44rem; }
.famcol img { display: block; width: 100%; max-width: 40rem; height: auto;
  border: 1px solid #ddd; border-radius: .5rem; }
/* No height here: the shared `#stmap { height: 340px }` — the map of every page per place —
   is what sizes it.  This rule only lets it FILL the column (a centred grid item shrinks to
   nothing without a width) and keeps it at the photograph's measure, and framed like the
   photograph, since the two are this page's two windows. */
.famcol #stmap { width: 100%; max-width: 40rem; margin: .25rem 0 0;
  border: 1px solid #ddd; border-radius: .5rem; }
.famcap { margin: 0; font-size: 1.02rem; line-height: 1.4; }
.famwhy { margin: 0; max-width: 34rem; font-size: .98rem; line-height: 1.55; color: #333; }
.famded { margin: 0; max-width: 34rem; font-size: .9rem; font-style: italic; color: #555; }
