/* =============================================================================
   UIKit — base
   -----------------------------------------------------------------------------
   Document-level typography, link behaviour and the focus ring.

   Scope discipline: this file styles bare elements only. It contains no class
   selectors that name a component, no layout, no widgets. Anything that has a
   name ("card", "badge", "empty state") belongs in components.css.

   Every color and every step of the type, spacing, radius and shadow scales
   comes from tokens.css — literal values appear only for hairlines and optical
   nudges that no scale governs (1px borders, the 2px focus outline, the
   underline offset).
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Document
   -------------------------------------------------------------------------- */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--ui-font-sans);
    font-size: var(--ui-font-size-md);
    font-weight: var(--ui-font-weight-normal);
    line-height: var(--ui-line-height-base);
    color: var(--ui-color-text);
    background-color: var(--ui-color-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* -----------------------------------------------------------------------------
   Headings

   Six levels drawn from the 7-step type scale: 40 / 32 / 24 / 20 / 16 / 14.
   The scale is the ceiling — a heading larger than h1 does not exist.
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    margin-top: 0;
    margin-bottom: var(--ui-space-2xs);
    font-family: inherit;
    font-weight: var(--ui-font-weight-bold);
    line-height: var(--ui-line-height-tight);
    text-wrap: balance;
    /* Цвет намеренно не задан: заголовок наследует цвет контейнера. Иначе он
       перебивает `color` цветных hero-блоков и текст на них становится
       нечитаемым — проверено на /tags. */
}

h1, .h1 { font-size: var(--ui-font-size-3xl); }
h2, .h2 { font-size: var(--ui-font-size-2xl); }
h3, .h3 { font-size: var(--ui-font-size-xl); }
h4, .h4 { font-size: var(--ui-font-size-lg); }
h5, .h5 { font-size: var(--ui-font-size-md); font-weight: var(--ui-font-weight-semibold); }
h6, .h6 { font-size: var(--ui-font-size-sm); font-weight: var(--ui-font-weight-semibold); }

/* -----------------------------------------------------------------------------
   Text
   -------------------------------------------------------------------------- */

p {
    margin-top: 0;
    margin-bottom: var(--ui-space-sm);
    text-wrap: pretty;
}

small {
    font-size: var(--ui-font-size-sm);
}

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

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

hr {
    margin: var(--ui-space-md) 0;
    border: 0;
    border-top: 1px solid var(--ui-color-border-subtle);
    opacity: 1;
}

blockquote {
    margin: 0 0 var(--ui-space-sm);
    padding-left: var(--ui-space-sm);
    border-left: 1px solid var(--ui-color-border);
    color: var(--ui-color-text-muted);
}

/* -----------------------------------------------------------------------------
   Links

   Underlined by default: color alone must never be the only signal that
   something is a link (story 23). Navigation and buttons opt out via their
   own classes, which is what those classes are for.
   -------------------------------------------------------------------------- */

a {
    color: var(--ui-color-link);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    transition: var(--ui-transition-color);
}

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

/* Structural links carry their own affordance and stay clean. */
.nav-link,
.navbar-brand,
.dropdown-item,
.page-link,
.btn,
.list-group-item-action {
    text-decoration: none;
}

/* -----------------------------------------------------------------------------
   Media & tables
   -------------------------------------------------------------------------- */

img, video {
    max-width: 100%;
}

/* -----------------------------------------------------------------------------
   Focus

   Non-negotiable and never removed. Mouse users do not see it (:focus-visible),
   keyboard users always do. The ring sits outside the element so it survives
   overflow: hidden on cards.

   It also never touches geometry: an outline that carried a border-radius made
   pill chips and square inputs change shape the moment they took focus.
   -------------------------------------------------------------------------- */

:focus-visible {
    outline: 2px solid var(--ui-color-focus);
    outline-offset: 2px;
}

/* Bootstrap's controls draw their own ring as a box-shadow; make it ours and
   suppress the doubled outline on exactly those. */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.page-link:focus-visible {
    outline: 0;
    box-shadow: var(--ui-focus-ring);
}

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

/* -----------------------------------------------------------------------------
   Interaction targets

   Font inheritance and tap responsiveness for bare controls — nothing more.
   The 44x44 CSS px minimum touch target (story 24) is deliberately NOT enforced
   here: a blanket min-height would inflate every icon button, navbar toggler
   and inline control on the nine untranslated zones. It is an obligation of
   each component, sized against that component's own shape.
   -------------------------------------------------------------------------- */

button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"] {
    font-family: inherit;
    touch-action: manipulation;
}

/* -----------------------------------------------------------------------------
   Motion

   Every transition on the site has an off switch. This one block covers the
   whole document, including Bootstrap's own animations.
   -------------------------------------------------------------------------- */

@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;
    }
}
