/*
 * Созвон — base styles: self-hosted Inter Tight (+ Golos Text for ₽ and extended Cyrillic), a
 * modern reset, base elements, focus ring, selection, theme switching, reduced motion, layout
 * container, accessibility helpers, scrollbars, scroll lock and typography / layout utilities.
 * Load after tokens.css. Docs: docs/UI_KIT.md, docs/redesign/DESIGN_SYSTEM.md §4.
 */

/* ---- Inter Tight 3.004, variable 100–900, two subsets (public/vendor/fonts/inter-tight, SIL OFL
   1.1 — OFL.txt next to the files). Browsers download a file only when the page uses one of its
   characters. ---- */
@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/inter-tight/inter-tight-0.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/inter-tight/inter-tight-1.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Golos Text, fallback only: cyrillic-ext (names in other Cyrillic alphabets) and latin-ext
   (the rouble sign ₽, U+20BD) — characters Inter Tight's subsets do not have. ---- */
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-cyrillic-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-cyrillic-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-cyrillic-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-cyrillic-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-cyrillic-ext-800-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Golos Text';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/vendor/fonts/golos-text/golos-text-latin-ext-800-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  /* A control that takes the focus scrolls clear of the window's edges, its 8 px ring included. */
  scroll-padding-block: 30px 24px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--surface);
  overflow-wrap: break-word;
}

/* Any element carrying data-theme re-resolves text (and, below the root, background) colours. */
:where([data-theme]) {
  color: var(--text);
}

:where([data-theme]:not(:root)) {
  background-color: var(--surface);
}

/* Theme switch: no colour transition may animate it (theme.js adds the class for two frames). */
.theme-changing *,
.theme-changing *::before,
.theme-changing *::after {
  transition: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-size: inherit;
  font-weight: var(--fw-medium);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

p,
figure,
blockquote,
dl,
dd,
pre {
  margin: 0;
}

ul[class],
ol[class] {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
picture,
video,
canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select,
optgroup {
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--link);
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--link-hover);
}

/* Links inside running text need more than colour to stand out. */
p a:not([class]),
.prose a {
  text-decoration-line: underline;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

b,
strong {
  font-weight: var(--fw-semibold);
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

th {
  font-weight: var(--fw-ui);
  text-align: left;
}

hr {
  height: 0;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--border);
  color: inherit;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

textarea {
  resize: vertical;
}

summary {
  cursor: pointer;
}

::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

[hidden] {
  display: none !important;
}

/* ---- Focus and selection ---- */
/* Buttons, links, summary: a 3 px ring 5 px away (fields: border + glow, grid cells: 2 px inset —
   components.css). */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 5px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Programmatic focus on a container shows no ring (docs/SPEC.md §15.4-6): <main>, a section, a
   list, a dialog panel or a heading that a script focuses after a view change, a skip link or an
   in-page anchor. tabindex="-1" keeps them out of the Tab order, so they never get focus from Tab;
   controls with tabindex="-1" (menu items, roving tabs, calendar days) keep their ring.
   focusContainer() (dom.js) also marks a container that is a tab stop of its own with
   .is-programmatic-focus while it holds focus. */
[tabindex="-1"]:not(a[href], button, input, select, textarea, summary, [contenteditable]:not([contenteditable="false"]),
  [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="slider"],
  [role="spinbutton"], [role="textbox"], [role="searchbox"], [role="combobox"], [role="listbox"],
  [role="option"], [role="tab"], [role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"],
  [role="grid"], [role="gridcell"], [role="tree"], [role="treegrid"], [role="treeitem"]):focus-visible {
  outline: none;
}

/* A rule of its own: a browser that rejected the selector list above would drop this one too. */
[tabindex].is-programmatic-focus:focus-visible {
  outline: none;
}

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

/* ---- Reduced motion: stop animations and transitions (spinners keep turning, components.css) ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Layout container: the prototype's .page-width (max 1440, gutters 44 / 28 / 20 / 14) ---- */
.container,
.page-width {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---- Accessibility helpers ---- */
.sr-only,
.sr-only-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Skip link (DESIGN_SYSTEM §8.3): a surface card that slides in at the top-left on focus. */
.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-12);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-popover);
  font-size: var(--fs-14);
  font-weight: var(--fw-ui);
  line-height: 1.4;
}

.skip-link:focus,
.skip-link:hover {
  top: 10px;
  color: var(--text);
}

/* ---- Scrollbars: thin everywhere inside dark scopes and on .scroll-thin ---- */
[data-theme="dark"] {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

[data-theme="dark"] *,
.scroll-thin {
  scrollbar-width: thin;
}

.scroll-thin {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

@supports not (scrollbar-color: auto) {
  :is([data-theme="dark"] *, .scroll-thin)::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  :is([data-theme="dark"] *, .scroll-thin)::-webkit-scrollbar-track {
    background: transparent;
  }

  :is([data-theme="dark"] *, .scroll-thin)::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 10px;
    background: var(--scrollbar-thumb);
    background-clip: padding-box;
  }
}

/* ---- Scroll lock while a modal is open (set by js/lib/modal.js) ---- */
html.is-scroll-locked {
  overflow: hidden;
}

html.is-scroll-locked--gutter {
  scrollbar-gutter: stable;
}

/* ---- Page backgrounds: .bg-calm (cabinet, legal, kit) — the sky layer is .sky-background ---- */
body.bg-calm,
.bg-calm {
  background:
    radial-gradient(ellipse at 90% 0%, var(--calm-glow), transparent 45%) 0 0 / 100% 100vh no-repeat,
    var(--surface);
}

/* ---- Typography utilities (DESIGN_SYSTEM §4.2) ---- */
.h-display {
  font-size: var(--fs-display);
  font-weight: var(--fw-medium);
  line-height: 1.05;
  letter-spacing: var(--tracking-display);
}

/* Section title (landing h2 «Важен не повод.») */
.h-1 {
  font-size: var(--fs-42);
  font-weight: var(--fw-medium);
  line-height: 1.15;
  letter-spacing: var(--tracking-section);
}

/* Page title («Ваш профиль», «Мои встречи») */
.h-2 {
  font-size: var(--fs-36);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: var(--tracking-title);
}

/* Modal / form title («Мои встречи» dialog, «Начать встречу» with .fw-600) */
.h-3 {
  font-size: var(--fs-32);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: var(--tracking-title);
}

/* Panel title («29 октября») */
.h-4 {
  font-size: var(--fs-27);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: var(--tracking-dialog);
}

/* Card title (large) */
.h-5 {
  font-size: var(--fs-20);
  font-weight: var(--fw-ui);
  line-height: 1.4;
}

/* Card title («Личные данные») */
.h-6 {
  font-size: var(--fs-18);
  font-weight: var(--fw-ui);
  line-height: 1.5;
}

/* Dialog title («Давайте разберёмся.») */
.h-dialog {
  font-size: var(--fs-30);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: var(--tracking-dialog);
}

@media (max-width: 1050px) {
  .h-1 {
    font-size: 36.8px;
  }

  .h-display {
    font-size: 64px;
  }
}

@media (max-width: 760px) {
  .h-display {
    font-size: clamp(52.8px, 10vw, 72px);
  }

  .h-1 {
    font-size: 35.2px;
  }

  .h-2 {
    font-size: 32px;
  }

  .h-3 {
    font-size: 27.2px;
  }

  .h-4 {
    font-size: 24px;
  }
}

@media (max-width: 650px) {
  .h-dialog {
    font-size: 27.2px;
  }
}

@media (max-width: 360px) {
  .h-display {
    font-size: 50.4px;
  }
}

.text-lead {
  font-size: var(--fs-15);
  line-height: 1.6;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .text-lead {
    font-size: var(--fs-14);
  }
}

.text-lg {
  font-size: var(--fs-17);
}

.text-base {
  font-size: var(--fs-16);
}

.text-md {
  font-size: var(--fs-15);
}

.text-sm {
  font-size: var(--fs-14);
}

.text-xs {
  font-size: var(--fs-13);
}

.text-2xs {
  font-size: var(--fs-12);
}

.text-3xs {
  font-size: var(--fs-11);
}

.text-4xs {
  font-size: var(--fs-10);
}

.lh-tight {
  line-height: 1.15;
}

.lh-snug {
  line-height: 1.45;
}

.lh-normal {
  line-height: 1.5;
}

.lh-relaxed {
  line-height: 1.65;
}

.fw-400 {
  font-weight: var(--fw-regular);
}

.fw-450 {
  font-weight: var(--fw-book);
}

.fw-500 {
  font-weight: var(--fw-medium);
}

.fw-550 {
  font-weight: var(--fw-ui);
}

.fw-600 {
  font-weight: var(--fw-semibold);
}

.fw-650 {
  font-weight: var(--fw-brand);
}

.fw-700 {
  font-weight: var(--fw-bold);
}

.fw-800 {
  font-weight: var(--fw-heavy);
}

.muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent-text);
}

.text-danger {
  color: var(--danger-text);
}

.text-success {
  color: var(--success);
}

.text-center {
  text-align: center;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nowrap {
  white-space: nowrap;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* User-entered strings (names, meeting titles) may be one long word. */
.user-text {
  overflow-wrap: anywhere;
}

/* Long-form text (help, legal): comfortable rhythm and underlined links. */
.prose {
  max-width: 720px;
  font-size: var(--fs-15);
  line-height: 1.7;
  color: var(--text);
}

.prose > * + * {
  margin-top: 16px;
}

.prose h2 {
  margin-top: 40px;
  font-size: 24px;
  font-weight: var(--fw-medium);
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.prose h3 {
  margin-top: 28px;
  font-size: var(--fs-18);
  font-weight: var(--fw-ui);
  line-height: 1.4;
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 12px;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 6px;
}

.prose code {
  padding: 1px 6px;
  border-radius: var(--r-6);
  background: var(--surface-soft);
}

/* ---- Layout utilities ---- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.wrap {
  flex-wrap: wrap;
}

.between {
  justify-content: space-between;
}

.items-start {
  align-items: flex-start;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.shrink-0 {
  flex-shrink: 0;
}

.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-14 { gap: 14px; }
.gap-16 { gap: 16px; }
.gap-18 { gap: 18px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }
.gap-40 { gap: 40px; }

.bg-surface {
  background-color: var(--surface);
}

.bg-soft {
  background-color: var(--surface-soft);
}

.bg-raised {
  background-color: var(--surface-raised);
}

.list-reset {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- Forced colours (Windows High Contrast): fields keep a real focus outline ---- */
@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid Highlight;
  }
}
