/* ============================================================================
 * H-LIFE Modern Reset
 * ============================================================================
 *
 * Современный reset, основан на подходах:
 * - Andy Bell (https://piccalil.li/blog/a-more-modern-css-reset/)
 * - Josh Comeau (https://www.joshwcomeau.com/css/custom-css-reset/)
 *
 * Цели:
 * - Убрать дефолтные стили браузера, мешающие дизайну
 * - Установить разумные defaults (box-sizing, font rendering)
 * - НЕ переопределять то, что должны решать компоненты
 *
 * @package HLife\Theme
 * ========================================================================= */

/* === Box sizing reset ==================================================== */

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

/* === Удаление дефолтных margin =========================================== */

* {
    margin: 0;
}

/* === Базовые правила для html / body ===================================== */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -moz-tab-size: 4;
    tab-size: 4;
    /* Плавный скролл к якорям */
    scroll-behavior: smooth;
    /* Учитываем sticky-header при якорном скролле */
    scroll-padding-top: var(--hlife-header-total-h, 0);
    /* Современный rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100svh;
    font-family: var(--hlife-font-sans);
    font-size: var(--hlife-text-base);
    font-weight: var(--hlife-fw-normal);
    line-height: var(--hlife-lh-normal);
    color: var(--hlife-text-primary);
    background-color: var(--hlife-bg-primary);
    overflow-wrap: break-word;
}

/* === Уважаем prefers-reduced-motion ====================================== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === Headings ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--hlife-font-serif);
    font-weight: var(--hlife-fw-semibold);
    line-height: var(--hlife-lh-tight);
    letter-spacing: var(--hlife-tracking-tight);
    color: var(--hlife-text-brand);
    text-wrap: balance;
}

h1 { font-size: var(--hlife-text-4xl); }
h2 { font-size: var(--hlife-text-3xl); }
h3 { font-size: var(--hlife-text-2xl); }
h4 { font-size: var(--hlife-text-xl); }
h5 { font-size: var(--hlife-text-lg); }
h6 { font-size: var(--hlife-text-base); }

/* === Paragraphs and text ================================================= */

p {
    text-wrap: pretty;
    max-width: var(--hlife-content-max);
}

/* === Links =============================================================== */

a {
    color: var(--hlife-color-link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: currentColor;
    transition: var(--hlife-transition-colors);
}

a:hover,
a:focus-visible {
    color: var(--hlife-color-link-hover);
}

a:focus-visible {
    outline: none;
    box-shadow: var(--hlife-focus-ring);
    border-radius: var(--hlife-radius-sm);
}

/* === Lists =============================================================== */

ul, ol {
    padding: 0;
}

ul[role="list"],
ol[role="list"] {
    list-style: none;
}

/* === Images, video, embeds =============================================== */

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

img {
    font-style: italic; /* красивый alt-fallback */
    background-repeat: no-repeat;
    background-size: cover;
    shape-margin: 1rem;
}

/* === Form elements ======================================================= */

input, button, textarea, select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 0;
    background: transparent;
    padding: 0;
}

button:disabled,
[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    resize: vertical;
}

/* Убираем дефолтный `outline` в пользу :focus-visible */
:focus {
    outline: none;
}

:focus-visible {
    outline: none;
    box-shadow: var(--hlife-focus-ring);
    border-radius: var(--hlife-radius-sm);
}

/* === Tables ============================================================== */

table {
    border-collapse: collapse;
    width: 100%;
}

/* === Code ================================================================ */

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

pre {
    overflow-x: auto;
}

/* === HR ================================================================== */

hr {
    border: 0;
    border-top: 1px solid var(--hlife-border-subtle);
    margin: var(--hlife-space-8) 0;
}

/* === Selection =========================================================== */

::selection {
    background-color: var(--hlife-color-emerald);
    color: var(--hlife-color-white);
}

/* === Hidden but accessible (a11y) ======================================== */

.screen-reader-text,
.visually-hidden {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

.screen-reader-text:focus,
.visually-hidden:focus {
    background-color: var(--hlife-color-navy);
    border-radius: var(--hlife-radius-md);
    box-shadow: var(--hlife-shadow-md);
    clip: auto !important;
    clip-path: none;
    color: var(--hlife-color-white);
    display: block;
    font-size: var(--hlife-text-sm);
    font-weight: var(--hlife-fw-medium);
    height: auto;
    left: 1rem;
    line-height: 1;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    top: 1rem;
    width: auto;
    z-index: var(--hlife-z-toast);
}

/* === Skip link =========================================================== */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: var(--hlife-z-toast);
}

.skip-link:focus,
.skip-link:focus-visible {
    left: 1rem;
    top: 1rem;
}
