/* ==========================================================================
   Catch Signal: species guide pages (public/css/pages-species.css)

   Loaded after base.css and pages.css by /species, /species/<id> and /photo-credits
   (scripts/seo/pages/species.mjs, photo-credits.mjs). Colours come from the
   base.css variables, so the light and dark themes both work. Safari 15.4 floor:
   no nesting, no container queries, color-mix() only behind @supports.

   Contents
     1. Hero photo, name line, no-photo note
     2. Season strip, area table and calendar (text codes, not colour only)
     3. Species cards (hub)
     4. Photo credits list
     5. Small screens and print
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Hero photo, name line, no-photo note
   -------------------------------------------------------------------------- */
.species-photo picture,
.species-photo img { display: block; }
.species-photo img { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: var(--radius); background: var(--sunken); }
.species-photo figcaption a { color: inherit; }

.doc .subline { margin-top: var(--space-3); }

.no-photo {
  padding: var(--space-4);
  border: 1px dashed var(--field-line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.no-photo > * + * { margin-top: var(--space-2); }

.checked { font-size: var(--fs-sm); color: var(--muted); }

.season-now {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 4px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 500;
}
/* The island around .season-now (public/js/pages/species.js rewrites the text for today): no second box */
.live.season-live { min-height: 0; padding: 0; border: 0; background: transparent; }
.season-live .season-now { min-height: 3.25rem; }
.season-now-peak { border-left-color: var(--heat-4); }
.season-now-ok { border-left-color: var(--heat-2); }
.season-now-closed { border-left-color: var(--warn); background: var(--warn-bg); }
.season-now-soon { border-left-color: var(--caution); background: var(--caution-bg); }


/* --------------------------------------------------------------------------
   2. Season strip (one species) and calendar (all species)
   Each cell carries a letter code (P, S, C, –) so the season never relies on
   colour alone; the strip also has the full words for screen readers.
   -------------------------------------------------------------------------- */
.prose table.season-strip,
.prose table.season-calendar { table-layout: fixed; border-collapse: separate; border-spacing: 2px; }
.prose .season-strip th,
.prose .season-strip td,
.prose .season-calendar th,
.prose .season-calendar td { padding: 0; border-bottom: 0; text-align: center; vertical-align: middle; }
.prose .season-strip thead th,
.prose .season-calendar thead th {
  padding: var(--space-1) 0;
  background: transparent;
  font: 500 var(--fs-xs)/1.2 var(--font-data);
  color: var(--muted);
}
.prose .season-strip thead th abbr,
.prose .season-calendar thead th abbr { text-decoration: none; }
.prose .season-strip thead th:first-child,
.prose .season-calendar thead th:first-child { text-align: left; }
.prose .season-strip tbody th,
.prose .season-calendar tbody th {
  padding: 0 var(--space-2) 0 0;
  background: transparent;
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-sm);
  white-space: nowrap;
}
/* The name column lines up with the caption above it (the caption is inset var(--space-3); the cells already sit
   2px in, the border-spacing), instead of sitting against the box edge */
.prose .season-strip thead th:first-child,
.prose .season-strip tbody th,
.prose .season-calendar thead th:first-child,
.prose .season-calendar tbody th { padding-left: calc(var(--space-3) - 2px); }
.prose .season-strip thead th:first-child,
.prose .season-strip tbody th { width: 7rem; }
.prose .season-calendar thead th:first-child,
.prose .season-calendar tbody th { width: 9rem; }
.prose .season-calendar tbody th { padding-top: 2px; padding-bottom: 2px; white-space: normal; line-height: 1.15; }
.prose .season-calendar tbody th a { color: var(--ink); text-decoration: none; }
.prose .season-calendar tbody th a:hover { color: var(--accent); text-decoration: underline; }
.prose table.season-strip { min-width: 30rem; }
.prose table.season-calendar { min-width: 30rem; }

.ss {
  height: 1.75rem;
  border-radius: 3px;
  font: 600 var(--fs-xs)/1 var(--font-data);
}
.prose .season-strip td.ss { height: 2.25rem; }
.ss-peak { background: var(--heat-4); color: var(--heat-ink-4); }
.ss-ok { background: var(--heat-1); color: var(--heat-ink-1); }
.ss-off { background: var(--sunken); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.ss-closed { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 -3px 0 var(--warn); }
.prose .ss-now { outline: 2px solid var(--marker); outline-offset: -2px; }
.prose thead th.ss-now { color: var(--marker-text); font-weight: 700; outline: 0; }

/* "{Species} by area": month ranges and levels stay on one line; on a phone the table scrolls sideways inside
   .table-wrap (the area name stays in view) instead of squeezing the months to a word per line. */
.prose table.area-season { min-width: 34rem; }
.prose .area-season td { white-space: nowrap; }
.prose .area-season tbody th { min-width: 9rem; }

/* "Spots to try": place names wrap between words, never mid-word ("Scarboroug|h"); .prose a breaks anywhere for long URLs */
.prose .spot-picks a { overflow-wrap: normal; }

.season-key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.prose .season-key li + li { margin-top: 0; }
.season-key li { display: inline-flex; align-items: center; gap: var(--space-2); }
.season-key .ss { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.25rem; }


/* --------------------------------------------------------------------------
   3. Species cards on the hub: photo thumbnail, name, rules line
   -------------------------------------------------------------------------- */
.species-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); }
.prose.wide section > .species-cards { max-width: none; }
@media (max-width: 30rem) {
  /* two cards a row on phones: the hub lists 39 species */
  .species-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .species-cards .card { padding: var(--space-2); }
  .species-cards .card-title { font-size: var(--fs-base); }
}
.species-card picture { display: block; }
.species-card .card-meta + .card-meta { margin-top: calc(-1 * var(--space-1)); }
.thumb-none {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px dashed var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.photo-note { font-size: var(--fs-sm); color: var(--muted); }


/* --------------------------------------------------------------------------
   4. Photo credits: thumbnail beside the credit text
   -------------------------------------------------------------------------- */
.credits { margin: 0; padding: 0; list-style: none; }
.prose .credits > li + li { margin-top: 0; }
.credits > li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
}
.credits > li:last-child { border-bottom: 1px solid var(--line); }
.credits picture, .credits img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); background: var(--sunken); }
.credits .credit-name { font-weight: 600; }
.credits .credit-name a { color: var(--ink); }
.credits p { margin: 0; font-size: var(--fs-sm); }
.credits p + p { margin-top: var(--space-1); }
.credits .credit-extra { color: var(--muted); }


/* --------------------------------------------------------------------------
   5. Small screens and print
   -------------------------------------------------------------------------- */
@media (max-width: 30rem) {
  .credits > li { grid-template-columns: 5.5rem minmax(0, 1fr); }
  /* the one-species strip fits a 375 px phone: narrow label column, smaller codes */
  .prose table.season-strip { min-width: 0; }
  .prose .season-strip thead th:first-child,
  .prose .season-strip tbody th { width: 5rem; padding-left: calc(var(--space-2) - 2px); padding-right: var(--space-1); font-size: var(--fs-xs); }
  .prose .season-strip thead th, .prose .season-strip td.ss { font-size: .75rem; }
  /* the 39-species calendar scrolls sideways inside its box; the names stay in view */
  .prose .season-calendar thead th:first-child,
  .prose .season-calendar tbody th { position: sticky; left: 0; z-index: 1; width: 7.5rem; background: var(--surface); }
  .prose .area-season thead th:first-child,
  .prose .area-season tbody th { position: sticky; left: 0; z-index: 1; min-width: 7.5rem; }
  .prose .area-season thead th:first-child { background: var(--sunken); }
}

@media print {
  .ss { border: 1px solid #999; }
  .species-card { break-inside: avoid; }
  .live.season-live { display: block; }
}

@media (forced-colors: active) {
  .ss { border: 1px solid CanvasText; }
  .ss-closed { text-decoration: underline; }
}
