/* =====================================================================
   ФПСМ · dark theme overlay. Load AFTER fpsm-pages.css.
   Scoped to html[data-theme="dark"]. Light theme is untouched.
   --fpsm-forest is remapped to Paper for heading text; Forest surfaces
   are restored to --fpsm-band below.
   ===================================================================== */

.theme-tg {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, #F8F6F0 35%, transparent);
  background: transparent;
  color: #F8F6F0;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
html[data-theme="dark"] .site-header .theme-tg,
html[data-theme="dark"] .site-header .theme-tg .fpsm-icon {
  color: #F8F6F0;
  fill: none;
  stroke: currentColor;
}
.theme-tg:hover {
  background: color-mix(in srgb, var(--fpsm-paper) 8%, transparent);
}
.theme-tg:focus-visible {
  outline: 3px solid var(--fpsm-summit);
  outline-offset: 2px;
}
.theme-tg .i-sun { display: none; }
html[data-theme="dark"] .theme-tg .i-sun { display: block; }
html[data-theme="dark"] .theme-tg .i-moon { display: none; }
.theme-tg .fpsm-icon {
  width: 20px;
  height: 20px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --fpsm-bg: #0C1D19;
  --fpsm-surface: #132A24;
  --fpsm-surface-2: #1A342E;
  --fpsm-band: #193932;
  --fpsm-text: #E7E4DB;
  --fpsm-head: #F8F6F0;
  --fpsm-leaf: #9BCB8B;
  --fpsm-amber: #E2A66C;

  --fpsm-card: var(--fpsm-surface);
  --fpsm-sand: var(--fpsm-surface-2);
  --fpsm-ink: var(--fpsm-text);
  --fpsm-forest: var(--fpsm-head);
  --fpsm-heritage: var(--fpsm-leaf);
  --fpsm-trail-deep: var(--fpsm-amber);
  --fpsm-stone: #A9BAB3;
  --fpsm-line: #29463F;
  --fpsm-tint-green: rgba(155, 203, 139, 0.14);
  --fpsm-tint-orange: rgba(226, 166, 108, 0.16);
  --fpsm-tint-stone: rgba(248, 246, 240, 0.08);
  --fpsm-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --fpsm-focus: 0 0 0 3px var(--fpsm-bg), 0 0 0 5px var(--fpsm-leaf);
  --background: #0C1D19;
  --foreground: #E7E4DB;
  --muted-foreground: #A9BAB3;
  --card: #132A24;
  --card-foreground: #E7E4DB;
  --border: #29463F;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .site-main,
html[data-theme="dark"] .home .news,
html[data-theme="dark"] .home .komisii,
html[data-theme="dark"] .home .intl,
html[data-theme="dark"] .docs-band {
  background: var(--fpsm-bg);
  color: var(--fpsm-text);
}

/* Forest chrome stays Forest */
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .nav-mobile,
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .site-footer__main,
html[data-theme="dark"] .fpsm-title-band,
html[data-theme="dark"] .page-hero,
html[data-theme="dark"] .page-hero--standard,
html[data-theme="dark"] .fpsm-page-hero,
html[data-theme="dark"] .fpsm-hero-actions,
html[data-theme="dark"] .home .hero,
html[data-theme="dark"] .home .calendar,
html[data-theme="dark"] .fpsm-home-dock__card,
html[data-theme="dark"] .vest-band {
  background: var(--fpsm-band);
}
html[data-theme="dark"] .site-footer__bar {
  background: #0A1814;
}

/* Paper fills that must stay Paper (hero CTA, title-band buttons) */
html[data-theme="dark"] .fpsm-title-band__logo,
html[data-theme="dark"] .fpsm-btn--paper,
html[data-theme="dark"] .home .hero__actions .fpsm-btn--paper {
  background: #F8F6F0;
  color: #102B25;
  border-color: #F8F6F0;
}

/* Header/footer on Forest: inverted mark, no Paper tile */
html[data-theme="dark"] .brand__img--paper {
  display: none;
}
html[data-theme="dark"] .brand__img--forest {
  display: block;
}
html[data-theme="dark"] .site-header .brand__img,
html[data-theme="dark"] .site-header img.brand__img,
html[data-theme="dark"] .site-header .brand__mark,
html[data-theme="dark"] .site-footer .brand__img,
html[data-theme="dark"] .site-footer img.brand__img {
  background: transparent;
  padding: 0;
}
html[data-theme="dark"] .site-header .brand__name,
html[data-theme="dark"] .site-footer .brand__name {
  color: var(--fpsm-head);
}
html[data-theme="dark"] .site-header .brand__sub {
  color: var(--fpsm-text);
}

/* Selected / primary controls: Paper + Ink (kit rule) */
html[data-theme="dark"] .fpsm-pill.is-active,
html[data-theme="dark"] .fpsm-pager .is-active,
html[data-theme="dark"] .news-board .pagination .page-numbers.current,
html[data-theme="dark"] .news-archive__years a.is-active,
html[data-theme="dark"] .fpsm-news-search button,
html[data-theme="dark"] .contact-topic input:checked + span,
html[data-theme="dark"] .fpsm-kontakt .contact-form .fpsm-btn,
html[data-theme="dark"] .fpsm-btn--primary {
  background: var(--fpsm-head);
  border-color: var(--fpsm-head);
  color: #102B25;
}
html[data-theme="dark"] .fpsm-btn--outline {
  border-color: var(--fpsm-head);
  color: var(--fpsm-head);
}

html[data-theme="dark"] .fpsm-pill,
html[data-theme="dark"] .fpsm-pager a,
html[data-theme="dark"] .news-board .pagination .page-numbers,
html[data-theme="dark"] .news-archive__years a {
  background: var(--fpsm-surface);
  border-color: var(--fpsm-line);
  color: var(--fpsm-text);
}

html[data-theme="dark"] .fpsm-tag {
  background: var(--fpsm-tint-green);
  color: var(--fpsm-leaf);
}
html[data-theme="dark"] .fpsm-tag--orange,
html[data-theme="dark"] .fpsm-doc__type {
  background: var(--fpsm-tint-orange);
  color: var(--fpsm-amber);
}
html[data-theme="dark"] .fpsm-tag--summit {
  background: var(--fpsm-summit);
  color: #102B25;
}

html[data-theme="dark"] .docs-group[open] > .docs-group__summary {
  background: var(--fpsm-band);
  color: var(--fpsm-head);
}

html[data-theme="dark"] .join-steps__n,
html[data-theme="dark"] .fpsm-za-nas .about-badge__code {
  background: var(--fpsm-band);
  color: var(--fpsm-head);
}

/* Hero photo: keep Forest shade (not remapped Paper) and no dimming */
html[data-theme="dark"] .home .hero__shade {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--fpsm-band) 88%, transparent) 0%,
    color-mix(in srgb, var(--fpsm-band) 50%, transparent) 48%,
    color-mix(in srgb, var(--fpsm-band) 12%, transparent) 100%
  );
}
@media (min-width: 960px) {
  html[data-theme="dark"] .home .hero__shade {
    background: linear-gradient(
      90deg,
      color-mix(in srgb, var(--fpsm-band) 90%, transparent) 0%,
      color-mix(in srgb, var(--fpsm-band) 40%, transparent) 50%,
      color-mix(in srgb, var(--fpsm-band) 8%, transparent) 100%
    );
  }
}

/* Calendar stays Forest; dots and featured card use real Forest/Ink, not remapped tokens */
html[data-theme="dark"] .home .calendar {
  background: var(--fpsm-band);
  color: var(--fpsm-head);
}
html[data-theme="dark"] .home .timeline__dot {
  box-shadow: 0 0 0 4px var(--fpsm-band);
}
html[data-theme="dark"] .home .timeline__item.is-next .timeline__dot {
  box-shadow:
    0 0 0 4px var(--fpsm-band),
    0 0 0 8px color-mix(in srgb, var(--fpsm-summit) 35%, transparent);
}
html[data-theme="dark"] .fpsm-home-state {
  background: color-mix(in srgb, #102B25 82%, transparent);
  color: var(--fpsm-head);
  border-color: color-mix(in srgb, var(--fpsm-head) 16%, transparent);
}
html[data-theme="dark"] .fpsm-home-state__date,
html[data-theme="dark"] .fpsm-home-state .fpsm-btn--paper {
  background: #F8F6F0;
  color: #102B25;
  border-color: #F8F6F0;
}

html[data-theme="dark"] .home .komisii a p:first-of-type,
html[data-theme="dark"] .home .komisii a p:first-child {
  color: var(--fpsm-head);
}
html[data-theme="dark"] .home .komisii .muted,
html[data-theme="dark"] .muted {
  color: var(--fpsm-stone);
}

html[data-theme="dark"] .fpsm-event-chip--state {
  background: var(--fpsm-summit);
  color: #102B25;
}
html[data-theme="dark"] .fpsm-event-chip--intl {
  background: var(--fpsm-trail);
  color: #102B25;
}
html[data-theme="dark"] .fpsm-event-chip--regional {
  background: transparent;
  border-color: color-mix(in srgb, var(--fpsm-head) 55%, transparent);
  color: var(--fpsm-head);
}

/* Homepage 112: same page colour as the kit, solid rescue badge, Paper heading */
html[data-theme="dark"] .home .fpsm-home-112 {
  background: var(--fpsm-surface-2);
}
html[data-theme="dark"] .fpsm-home-112__panel {
  background: transparent;
  border: 0;
}
html[data-theme="dark"] .fpsm-home-112__badge {
  background: var(--fpsm-rescue);
  color: #F8F6F0;
}
html[data-theme="dark"] .fpsm-home-112__copy h2,
html[data-theme="dark"] .fpsm-home-112__copy h2 a {
  color: var(--fpsm-head);
}
html[data-theme="dark"] .home .fpsm-home-112 .fpsm-btn--outline {
  border-color: var(--fpsm-head);
  color: var(--fpsm-head);
}

html[data-theme="dark"] .contact-112,
html[data-theme="dark"] .pateki-aside-112,
html[data-theme="dark"] .fpsm-sos,
html[data-theme="dark"] .sos-panel {
  background: rgba(198, 40, 40, 0.14);
  border-color: rgba(255, 138, 128, 0.45);
}

html[data-theme="dark"] .fpsm-blaze {
  background: linear-gradient(90deg, #DB8A3E 0 33.3%, #E7E4DB 33.3% 66.6%, #DB8A3E 66.6%);
}

html[data-theme="dark"] .fpsm-content-card img,
html[data-theme="dark"] .news-tile img {
  filter: brightness(0.92);
}

html[data-theme="dark"] .fpsm-btn--join,
html[data-theme="dark"] .site-header .btn-join,
html[data-theme="dark"] .site-header .fpsm-btn--join {
  background: var(--fpsm-trail);
  color: #102B25;
}

/* За нас / органи: leftover --primary names were Ink-dark on dark cards */
html[data-theme="dark"] .organ-roster__name,
html[data-theme="dark"] .organ-index__term,
html[data-theme="dark"] .fpsm-za-nas .organ-index__term,
html[data-theme="dark"] .fpsm-za-nas h2 {
  color: var(--fpsm-head);
}
html[data-theme="dark"] .organ-roster__note,
html[data-theme="dark"] .organ-index__desc,
html[data-theme="dark"] .fpsm-za-nas .organ-index__desc {
  color: var(--fpsm-stone);
}
html[data-theme="dark"] .organ-roster__mail,
html[data-theme="dark"] .organ-back a {
  color: var(--fpsm-leaf);
}

/* Colour club logos: Paper tile. Missing logo: inverted mark on Forest */
html[data-theme="dark"] .club-mark,
html[data-theme="dark"] .fpsm-klubovi .club-mark {
  background: #F8F6F0;
  border-color: #E3DFD3;
}
html[data-theme="dark"] .club-mark--fallback,
html[data-theme="dark"] .fpsm-klubovi .club-mark--fallback {
  background: #193932;
  border-color: color-mix(in srgb, #F8F6F0 16%, transparent);
}
html[data-theme="dark"] .fpsm-klubovi .club-mark img.is-fallback--paper {
  display: none;
}
html[data-theme="dark"] .fpsm-klubovi .club-mark img.is-fallback--forest {
  display: block;
  filter: none;
  opacity: 1;
  padding: 4px;
}
