/*
 * Dokino Base Styles
 * Reset, typography, accessibility primitives and small utility classes.
 * Depends on tokens.css.
 */

/* --- Reset --- */

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

* {
    margin: 0;
    padding: 0;
}

/* The `hidden` attribute must win over component `display` rules. */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
}

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

body {
    min-height: 100vh;
    font-family: var(--font-fa);
    font-size: var(--text-body-md);
    line-height: var(--leading-normal);
    color: var(--md-sys-color-on-background);
    background-color: var(--md-sys-color-background);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--motion-medium) var(--motion-easing),
        color var(--motion-medium) var(--motion-easing);
}

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

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

button {
    background: none;
    border: none;
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

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

a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    transition: color var(--motion-fast) var(--motion-easing);
}

a:hover {
    color: var(--md-sys-color-primary-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- Typography --- */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--md-sys-color-on-surface);
}

h1 { font-size: var(--text-display-sm); }
h2 { font-size: var(--text-headline-sm); }
h3 { font-size: var(--text-title-lg); }
h4 { font-size: var(--text-title-md); }

p {
    line-height: var(--leading-relaxed);
}

code,
kbd,
pre,
samp {
    font-family: var(--font-mono);
    font-size: 0.85em;
    direction: ltr;
    text-align: left;
}

:not(pre) > code {
    padding: 2px 6px;
    color: var(--md-sys-color-on-surface);
    background-color: var(--md-sys-color-code-bg);
    border-radius: var(--md-sys-shape-xs);
}

pre {
    overflow-x: auto;
    padding: var(--space-4);
    background-color: var(--md-sys-color-code-bg);
    border-radius: var(--md-sys-shape-sm);
}

/* --- Focus & selection --- */

:focus-visible {
    outline: 2px solid var(--md-sys-color-focus-ring);
    outline-offset: 2px;
    border-radius: var(--md-sys-shape-xs);
}

::selection {
    color: var(--md-sys-color-on-primary-container);
    background-color: var(--md-sys-color-primary-container);
}

/* --- Accessibility --- */

.visually-hidden {
    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;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    z-index: 2000;
    padding: var(--space-2) var(--space-4);
    color: var(--md-sys-color-on-primary);
    background-color: var(--md-sys-color-primary);
    border-radius: var(--md-sys-shape-sm);
    transform: translateY(-200%);
    transition: transform var(--motion-fast) var(--motion-easing);
}

.skip-link:focus {
    transform: translateY(0);
    text-decoration: none;
}

/* --- Layout containers --- */

.container {
    width: 100%;
    max-width: var(--layout-max-width);
    padding-inline: var(--space-4);
    margin-inline: auto;
}

@media (min-width: 768px) {
    .container {
        padding-inline: var(--space-6);
    }
}

/* --- Page progress bar --- */

.page-progress {
    position: fixed;
    top: 0;
    inset-inline: 0;
    z-index: 2000;
    height: 3px;
    overflow: hidden;
    pointer-events: none;
}

.page-progress::before {
    content: "";
    display: block;
    width: 0;
    height: 100%;
    background-color: var(--md-sys-color-primary);
    box-shadow: 0 0 8px color-mix(in srgb, var(--md-sys-color-primary) 70%, transparent);
    transition: width 300ms ease;
}

html.is-navigating .page-progress::before {
    width: 85%;
    transition: width 6s cubic-bezier(0.1, 0.6, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
    .page-progress {
        display: none;
    }
}

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

.text-muted {
    color: var(--md-sys-color-on-surface-variant);
}

.text-success { color: var(--md-sys-color-success); }
.text-error { color: var(--md-sys-color-error); }
.text-warning { color: var(--md-sys-color-warning); }

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

.text-sm { font-size: var(--text-body-sm); }
.text-xs { font-size: var(--text-label-md); }

.fw-bold { font-weight: 700; }
.fw-medium { font-weight: 500; }

.ltr { direction: ltr; unicode-bidi: embed; }
.rtl { direction: rtl; unicode-bidi: embed; }

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

.max-w-220 { max-width: 220px; }
.max-w-260 { max-width: 260px; }
.max-w-320 { max-width: 320px; }
.max-w-340 { max-width: 340px; }
.max-w-440 { max-width: 440px; }
.max-w-640 { max-width: 640px; }
.max-w-720 { max-width: 720px; }
.max-w-860 { max-width: 860px; }
.min-w-160 { min-width: 160px; }
.min-w-0 { min-width: 0; }

.text-pre-wrap { white-space: pre-wrap; }

.line-clamp-2 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.line-clamp-3 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* --- Spacing utilities --- */

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.pt-4 { padding-top: var(--space-4); }

/* --- Flex & grid utilities --- */

.d-flex { display: flex; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-none { display: none; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

@media (max-width: 767.98px) {
    .d-md-none { display: none !important; }
}

@media (min-width: 768px) {
    .d-md-block { display: block !important; }
}
