/* ==========================================================================
   Adhyayan School — Base
   Base element styles. Templates link the stylesheets in cascade order:
   variables.css → layout.css → components.css → main.css
   (separate <link>s so the browser fetches them in parallel).

   Contents
     1. Reset
     2. Typography
     3. Focus
     4. Utilities
     5. Reduced motion
   ========================================================================== */

/* ---------- 1. Reset ---------- */

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

* {
  margin: 0;
}

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

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

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
  color: var(--color-text-dark);
  background-color: var(--color-white);
  -webkit-font-smoothing: antialiased;
}

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

/* Third-party ArtiBot widget lays its icons out inline; keep the reset above out of it */
[id^='artibot-wrapper'] svg {
  display: revert;
  max-width: revert;
}

/* Centre the launcher's chat icon vertically (inline SVGs otherwise sit on the text baseline) */
[id^='artibot-wrapper'] button[class*='artibot-launcher'] svg {
  vertical-align: middle;
}

img {
  height: auto;
}

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

button {
  cursor: pointer;
}

/* ---------- 2. Typography ---------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--color-primary);
  text-wrap: balance;
}

h1 { font-size: var(--font-size-4xl); letter-spacing: -0.025em; }
h2 { font-size: var(--font-size-3xl); letter-spacing: -0.02em; }
h3 { font-size: var(--font-size-2xl); letter-spacing: -0.01em; line-height: 1.15; }
h4 { font-size: var(--font-size-xl); line-height: 1.2; }

/* No orphans: running text avoids a lone word on its last line; short labels balance their lines */
p,
li,
dd,
dt,
blockquote,
figcaption,
label,
summary {
  text-wrap: pretty;
}

.btn,
.badge,
.eyebrow {
  text-wrap: balance;
}

a {
  color: var(--color-primary);
  text-underline-offset: 0.2em;
}

/* --color-secondary-darker (5.8:1 on cream) — --color-secondary-dark is only 4.4:1 on the cream sections */
a:hover,
a:active {
  color: var(--color-secondary-darker);
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

/* ---------- 3. Focus ---------- */

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

/* Anchored sections clear the fixed header */
[id] {
  scroll-margin-top: calc(var(--header-height) + var(--space-4));
}

/* ---------- 4. Utilities ---------- */

/* Components that set `display` must still honour the hidden attribute */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  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: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip-link);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: var(--border-radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--color-white);
}

/* Scroll reveal (main.js tags [data-reveal]; html.js-reveal is never set under reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  /* Keeps the cards' hover colour fade: this rule replaces their own transition once tagged */
  .js-reveal [data-reveal] {
    transition:
      opacity var(--transition-slow) var(--reveal-delay, 0ms),
      transform var(--transition-slow) var(--reveal-delay, 0ms),
      background-color 250ms ease,
      border-color 250ms ease;
  }

  .js-reveal [data-reveal]:not(.is-visible) {
    opacity: 0;
    transform: translateY(1.5rem);
  }
}

/* ---------- 5. Reduced motion ---------- */

/* The drawer's scroll-driven backdrop is gesture-linked, not autoplaying motion, so it is excluded. */
@media (prefers-reduced-motion: reduce) {
  :not(.drawer),
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
