/* ==========================================================================
   BASE — Reset + typography + base elements
   ========================================================================== */

/* Modern reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--ink-soft);
  background-color: var(--surface);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Soft Kazakh pattern overlay — only this pseudo-element gets opacity,
   content stays full opacity */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("/assets/img/kz-pattern.png");
  background-repeat: repeat;
  background-size: 200px auto;
  opacity: 0.02;
  pointer-events: none;
  z-index: -1;
}

/* Section bg overrides keep the pattern visible only on default surface sections */
.section--alt,
.section--dark,
.section--primary,
.site-header,
.site-footer,
.page-hero,
.fair-hero,
.article-hero,
.breadcrumbs-wrap,
.hero-home {
  position: relative;
  isolation: isolate;
}

@media (max-width: 768px) {
  body::before {
    background-size: 150px auto;
  }
}

main {
  display: block;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--ink);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-4xl); font-weight: var(--fw-extra); letter-spacing: -0.025em; }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 { font-size: var(--fs-md); }

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

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

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

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

ul, ol {
  padding-left: 1.25rem;
}

ul ul, ol ol, ul ol, ol ul {
  margin-top: var(--space-2);
}

li + li {
  margin-top: var(--space-2);
}

strong, b {
  font-weight: var(--fw-semi);
  color: var(--ink);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--fs-sm);
  color: var(--muted);
}

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

blockquote {
  border-left: 4px solid var(--brand-primary);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-alt);
  font-style: italic;
  color: var(--ink);
  margin: var(--space-5) 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.92em;
}

code {
  padding: 0.125em 0.375em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

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

img {
  font-style: italic; /* alt text styling if image fails */
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Accessibility helpers */
.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--ink);
  color: var(--surface);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: var(--fw-semi);
  z-index: var(--z-toast);
  transition: top var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
  color: var(--surface);
}

/* Selection */
::selection {
  background: var(--brand-primary);
  color: var(--surface);
}

/* Focus ring fallback */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Reduce motion safer */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* Fonts — relying on system font stack until woff2 files are added to /assets/fonts/.
   To enable self-hosted fonts later: drop woff2 files into /assets/fonts/ and
   re-add @font-face declarations with url() src. */
