/* ==========================================================================
   Смарт Решения — Design System · Base
   Reset, document defaults, layout primitives and the ambient page wash.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* The HTML `hidden` attribute is only a UA-level `display: none`, so any
   component that sets its own `display` silently defeats it. Since hidden
   state is how the tab panels, the theme-toggle icons and the form's success
   panel are driven, it has to win outright. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--surface-page);
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-text);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Guard rail against sideways scroll. `clip` rather than `hidden` because
     hidden turns the element into a scroll container (which would break
     position: sticky for descendants); clip just clips. `hidden` stays first
     as the fallback for engines without overflow: clip. */
  overflow-x: hidden;
  overflow-x: clip;
  transition: background-color var(--dur-slow) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}

/* Ambient aurora wash: three soft radial pools behind everything. In the
   light theme the same layer resolves to a near-invisible tint. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 85% -10%, var(--aurora-1), transparent 65%),
    radial-gradient(900px 640px at -12% 30%, var(--aurora-2), transparent 62%),
    radial-gradient(1100px 800px at 72% 112%, var(--aurora-3), transparent 62%);
  transition: opacity var(--dur-slow) var(--ease-out);
}

::selection { background: var(--selection-bg); color: var(--text-primary); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
  margin: 0;
  color: var(--text-primary);
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: var(--transition-ui);
}
a:hover { color: var(--text-primary); }

img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

/* Screen-reader-only text and the skip link. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sr-skip {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 999;
  padding: 12px 20px;
  background: var(--action-solid-bg);
  color: var(--action-solid-fg);
  font-size: var(--type-body-sm-size);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-xs);
  transform: translateY(-160%);
  transition: transform var(--dur-base) var(--ease-out);
}
.sr-skip:focus-visible { transform: translateY(0); color: var(--action-solid-fg); }

/* ------------------------------------------------------- Layout primitives */

.sr-container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--page-margin);
}

.sr-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--grid-gutter);
}
@media (max-width: 900px) {
  .sr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Section shell. `tone` drives the surface; padding is fluid by default. */
.sr-section {
  position: relative;
  padding-block: var(--section-y);
}
.sr-section--compact { padding-block: var(--section-y-compact); }
.sr-section--subtle { background: var(--surface-subtle); }
.sr-section--inverse {
  background: var(--surface-inverse);
  color: var(--text-primary);
  /* Hairlines rather than tone alone: in dark mode the band is only a few
     steps off the page, and the rules are what make the edge legible. */
  border-block: var(--border-hairline) solid var(--line-hairline);
}
/* In the light theme an inverse band really is inverted, so the text tokens
   inside it have to flip too. In dark mode the band is merely a shade
   darker and inherits the page's own text colours. */
:root[data-theme='light'] .sr-section--inverse {
  color: var(--white);
  --text-primary: var(--white);
  --text-secondary: rgba(255, 255, 255, .70);
  --text-tertiary: rgba(255, 255, 255, .52);
  --text-accent: var(--blue-300);
  --line-hairline: var(--line-inverse);
  --line-strong: var(--line-inverse-strong);
  --line-heavy: rgba(255, 255, 255, .85);
  --surface-card: transparent;
  --surface-card-hover: var(--surface-inverse-raised);
  --surface-subtle: rgba(255, 255, 255, .04);
  --action-solid-bg: var(--white);
  --action-solid-bg-hover: var(--ink-150);
  --action-solid-fg: var(--ink-900);
  --focus-ring: var(--blue-300);
}

/* Two-column editorial split: header left, content right. Collapses to one. */
.sr-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: var(--block-gap);
}
.sr-split--narrow-first { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr); }
.sr-split--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sr-split--wide-first { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }

@media (max-width: 1000px) {
  .sr-split,
  .sr-split--narrow-first,
  .sr-split--even,
  .sr-split--wide-first {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(2.5rem, 6vw, 3.5rem);
  }
}

/* Card grids.
   Bare `.sr-cards` is the flexible one — auto-fit, reflows on its own.
   The numbered variants are DETERMINISTIC: "3-up" means three columns on a
   desktop and a defined collapse below it. auto-fit would happily fit four
   288px cards into a 1192px container and break a six-item 3×2 layout into
   4+2 with two dead cells. */
.sr-cards {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15.5rem), 1fr));
}

.sr-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sr-cards--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sr-cards--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1180px) {
  .sr-cards--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .sr-cards--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sr-cards--2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 680px) {
  .sr-cards--3,
  .sr-cards--4 { grid-template-columns: minmax(0, 1fr); }
}

/* Hairline-separated grid: the 1px gap trick, done so it can't leak. */
.sr-cards--seam {
  gap: var(--border-hairline);
  background: var(--line-hairline);
  border: var(--border-hairline) solid var(--line-hairline);
}
.sr-cards--seam > * { background: var(--surface-page); }
:root[data-theme='light'] .sr-cards--seam > * { background: var(--surface-card); }

/* Utility helpers used sparingly by page layouts. */
.sr-stack { display: flex; flex-direction: column; }
.sr-stack--tight { gap: var(--stack-tight); }
.sr-stack--base { gap: var(--stack); }
.sr-stack--loose { gap: var(--stack-loose); }
.sr-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.sr-measure { max-width: var(--measure); }
.sr-measure-short { max-width: var(--measure-short); }
.sr-mt-block { margin-top: var(--block-gap); }
.sr-mt-loose { margin-top: var(--stack-loose); }

/* ----------------------------------------------------------- Text styles */
.sr-lede {
  font-family: var(--font-text);
  font-size: var(--type-body-lg-size);
  line-height: var(--type-body-lg-line);
  letter-spacing: var(--type-body-lg-track);
  color: var(--text-secondary);
  max-width: var(--measure);
}
.sr-body { font-size: var(--type-body-size); line-height: var(--type-body-line); }
.sr-body-sm {
  font-size: var(--type-body-sm-size);
  line-height: var(--type-body-sm-line);
  color: var(--text-secondary);
}
.sr-caption {
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
  color: var(--text-tertiary);
}
.sr-mono {
  font-family: var(--font-mono);
  font-size: var(--type-mono-size);
  line-height: var(--type-mono-line);
  letter-spacing: var(--type-mono-track);
  color: var(--text-tertiary);
}
.sr-overline {
  font-family: var(--font-text);
  font-size: var(--type-overline-size);
  line-height: var(--type-overline-line);
  letter-spacing: var(--type-overline-track);
  text-transform: uppercase;
  font-weight: var(--weight-medium);
  color: var(--text-tertiary);
}
.sr-display-m {
  font-family: var(--font-display);
  font-size: var(--type-display-m-size);
  line-height: var(--type-display-m-line);
  letter-spacing: var(--type-display-m-track);
  font-weight: var(--weight-light);
}
.sr-h2 {
  font-size: var(--type-h2-size);
  line-height: var(--type-h2-line);
  letter-spacing: var(--type-h2-track);
}
.sr-h3 {
  font-size: var(--type-h3-size);
  line-height: var(--type-h3-line);
  letter-spacing: var(--type-h3-track);
}
.sr-h4 {
  font-size: var(--type-h4-size);
  line-height: var(--type-h4-line);
  letter-spacing: var(--type-h4-track);
}
.sr-text-primary { color: var(--text-primary); }
.sr-text-secondary { color: var(--text-secondary); }
.sr-text-tertiary { color: var(--text-tertiary); }
.sr-text-accent { color: var(--text-accent); }
