/* ==========================================================================
   Statistiky pozorování komet — page styles (loads after styles.css, shares its tokens)
   Hero: variant B of the approved layout; feed, comet and observer cards: variant C.
   ========================================================================== */

:root {
  --ccd: var(--teal-700);       /* CCD on light surfaces */
  --ccd-dark: var(--teal-400);  /* CCD on the navy hero */
  --vis: #c9822b;               /* visual estimates */
  --vis-ink: #8a5310;           /* visual as text on light (4.9:1 on the badge) */
  --teal-50: #e6f6f7;
}

/* --- Sheet ---------------------------------------------------------------- */
.sheet--page { padding-top: 0; }
.section--page-first { padding-top: clamp(32px, 5vw, 56px); }
.section__head--wrap { flex-wrap: wrap; align-items: flex-end; }
.section__sub {
  margin-top: 8px;
  max-width: 60ch;
  font-size: .9375rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.num { font-variant-numeric: tabular-nums; }

/* --- Hero on the navy sky -------------------------------------------------- */
.stats-head { padding-block: clamp(20px, 3vw, 32px) clamp(36px, 5vw, 64px); color: var(--on-dark); }
.stats-periods { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; margin-bottom: clamp(24px, 4vw, 40px); }
.stats-periods ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.stats-periods a,
.stats-pager a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid rgba(127, 224, 227, .22);
  border-radius: 999px;
  color: var(--on-dark-2);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.stats-periods a:hover,
.stats-pager a:hover { color: #fff; border-color: rgba(127, 224, 227, .5); }
.stats-periods a[aria-current="page"] { background: var(--teal-400); border-color: var(--teal-400); color: var(--navy-900); }
.stats-pager { display: flex; gap: 6px; }
.stats-pager a { border-color: transparent; }

.stats-head__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: end;
}
.stats-head__kicker { color: var(--teal-300); font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.stats-head h1 { font-size: clamp(1.5rem, 1.15rem + 1.3vw, 2.125rem); color: #fff; }
.stats-head__big {
  margin-top: 6px;
  font: 600 clamp(3.25rem, 2rem + 6vw, 5.75rem)/1 var(--font-display);
  letter-spacing: -.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stats-head__delta {
  display: inline-block;
  margin-top: 14px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(55, 198, 203, .18);
  color: var(--teal-300);
  font-size: .875rem;
  font-weight: 700;
}
.stats-head__facts { margin-top: 14px; color: var(--on-dark-2); font-size: 1rem; }
.stats-head__methods { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; color: var(--on-dark-3); font-size: .875rem; font-variant-numeric: tabular-nums; }
.stats-head__methods span { display: inline-flex; align-items: center; gap: 6px; }
.stats-head__methods .sw--ccd { background: var(--ccd-dark); }
.stats-head__start { margin-top: 16px; }
.stats-head__start a { color: var(--teal-300); font-weight: 700; }
/* The chart sits on its own quiet panel so the constellation lines of the sky do not run through the bars. */
.stats-head__chart {
  margin: 0;
  display: grid;
  gap: 8px;
  padding: 16px 18px 14px;
  border: 1px solid var(--on-dark-line);
  border-radius: var(--radius-m);
  background: rgba(4, 16, 29, .78);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.stats-head .stats-chart text { fill: var(--on-dark-3); font-size: 12px; }
.stats-head .bar-cur { fill: var(--teal-400); }
.stats-head .bar-prev { fill: rgba(226, 235, 245, .28); }

/* --- Source line under the hero ------------------------------------------ */
.stats-source { padding-top: 18px; font-size: .8125rem; color: var(--ink-3); }
.stats-source a { color: var(--ink-2); }
.stats-note { font-size: 1.0625rem; color: var(--ink-2); }

/* --- Charts and legends --------------------------------------------------- */
.stats-chart { display: block; width: 100%; height: auto; overflow: visible; }
.stats-chart text { font: 11px var(--font-body); fill: var(--ink-3); }
.stats-chart text.strong { fill: var(--ink); font-weight: 700; }
.stats-chart .grid { stroke: var(--line); stroke-width: 1; }
.stats-chart .tick { stroke: var(--line); stroke-width: 1; }
.stats-chart .bar-ccd { fill: var(--ccd); }
.stats-chart .bar-vis { fill: var(--vis); }

.stats-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0; font-size: .8125rem; color: var(--ink-2); }
.stats-legend--dark { color: var(--on-dark-2); }
.stats-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.sw--ccd { background: var(--ccd); }
.sw--vis { background: var(--vis); }
.sw--cur { background: var(--teal-400); }
.sw--prev { background: rgba(226, 235, 245, .28); }
.sw--dot-ccd { width: 8px; height: 8px; border-radius: 50%; background: var(--ccd); }
.sw--dot-vis { width: 7px; height: 7px; border-radius: 0; background: var(--vis); transform: rotate(45deg); box-shadow: 0 0 0 .5px var(--vis-ink); }
.sw--trend { width: 18px; height: 0; border-radius: 0; border-top: 2px solid var(--navy-700); }

/* --- Latest observations (C) --------------------------------------------- */
.stats-feed { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.stats-feed li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr) auto 4.75rem;
  gap: 4px 16px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: .9375rem;
}
.stats-feed__when { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-feed__what { min-width: 0; }
.stats-feed__what strong { font-weight: 600; }
.stats-feed__who { color: var(--ink-3); }
.stats-feed__who::before { content: " · "; }
.stats-feed__mag { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { justify-self: start; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.badge--ccd { background: var(--teal-50); color: var(--teal-700); }
.badge--vis { background: rgba(201, 130, 43, .14); color: var(--vis-ink); }

/* --- Comet cards (C) ------------------------------------------------------ */
.stats-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.stats-card {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--paper);
}
.stats-card h3 { font-size: 1.125rem; overflow-wrap: anywhere; }
.stats-card__counts { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.stats-card__counts span { color: var(--ink-2); font-size: .875rem; }
.stats-card__meta { color: var(--ink-3); font-size: .8125rem; }
.stats-card__none { margin-top: 8px; color: var(--ink-3); font-size: .875rem; }
.stats-curve { margin-top: 6px; }
.stats-curve text { font-size: 10.5px; }
.stats-curve .trend { fill: none; stroke: var(--navy-700); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; opacity: .7; }
.stats-curve .pt-ccd { fill: var(--ccd); opacity: .9; }
.stats-curve .pt-vis { fill: var(--vis); stroke: var(--vis-ink); stroke-width: .5; }
.stats-card__legend { font-size: .75rem; color: var(--ink-3); gap: 2px 14px; }
.stats-card__legend span { gap: 4px; }
.stats-more { margin-top: 20px; }

/* --- Observers (C) -------------------------------------------------------- */
.stats-people { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.stats-person {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.stats-person__av {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy-700);
  color: var(--on-dark);
  font-size: .875rem;
  font-weight: 700;
}
.stats-person__body { display: grid; min-width: 0; font-size: .8125rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.stats-person__body strong { color: var(--ink); font-size: .9375rem; font-weight: 600; overflow-wrap: anywhere; }

/* --- History (B) ---------------------------------------------------------- */
.stats-history { margin: 0; display: grid; gap: 12px; }
.stats-history__scroll { overflow-x: auto; overscroll-behavior-x: contain; border-radius: var(--radius-s); }
.stats-history__scroll:focus-visible, .stats-table__scroll:focus-visible { outline-offset: 2px; }
.stats-history .stats-chart { min-width: 760px; }
.stats-history .stats-chart text { font-size: 12.5px; }
.stats-history .stats-chart text.strong { paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.section--tinted .stats-history .stats-chart text.strong { stroke: var(--paper-2); }

/* --- Tables (A) ----------------------------------------------------------- */
/* `hidden` must win over the display rules below (search controls without JavaScript, shortened rows). */
.stats-tables [hidden] { display: none !important; }
.stats-tables { display: grid; gap: 40px 32px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); align-items: start; }
.stats-table { min-width: 0; }
.stats-table h3 { font-size: 1.25rem; margin-bottom: 12px; }
.stats-table__controls { display: grid; gap: 6px; margin-bottom: 10px; }
.stats-table__controls input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink);
  caret-color: var(--teal-700);
  font: inherit;
}
.stats-table__controls input::placeholder { color: var(--ink-3); opacity: 1; }
.stats-table__status { font-size: .8125rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.stats-table__scroll { overflow-x: auto; }
.stats-table table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.stats-table th,
.stats-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-table th:first-child { text-align: left; white-space: normal; }
.stats-table thead th { font-size: .6875rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); vertical-align: bottom; }
.stats-table tbody th { font-weight: 600; min-width: 9rem; }
.stats-table tr[hidden] { display: none; }
.stats-table tr.is-current { background: var(--teal-50); }
.stats-table--years tbody th { min-width: 0; }
.stats-table__empty { padding: 12px 0; color: var(--ink-3); font-size: .875rem; }
.stats-table__more {
  margin-top: 12px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: 600 .875rem/1.3 var(--font-body);
  cursor: pointer;
}
.stats-table__more:hover { border-color: var(--teal-700); color: var(--ink); }

/* --- Narrow screens ------------------------------------------------------- */
@media (max-width: 860px) {
  .stats-head__grid { grid-template-columns: minmax(0, 1fr); align-items: start; }
}
@media (max-width: 640px) {
  .stats-head .stats-chart text { font-size: 14px; }
  .stats-head__chart { padding: 12px 12px 10px; }
  .stats-feed li {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "what mag" "when badge";
    gap: 2px 12px;
  }
  .stats-feed__what { grid-area: what; }
  .stats-feed__mag { grid-area: mag; }
  .stats-feed__when { grid-area: when; font-size: .8125rem; }
  .stats-feed .badge { grid-area: badge; justify-self: end; }
  .stats-feed__who { display: block; font-size: .8125rem; }
  .stats-feed__who::before { content: none; }
  .stats-table tbody th { min-width: 7.5rem; }
}
