/* ==========================================================================
   School Life — base.css
   Reset, typography, focus styles, accessibility helpers, utilities.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-x: clip;
}

main {
  flex: 1 0 auto;
  display: block;
}

main:focus {
  outline: none;
}

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

svg {
  flex-shrink: 0;
}

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

button {
  cursor: pointer;
}

/* :where() keeps specificity at zero so component classes can set margins */
:where(ul[class], ol[class]) {
  list-style: none;
  margin: 0;
  padding: 0;
}

table {
  border-collapse: collapse;
}

[hidden],
.print-only {
  display: none !important;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5em;
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  color: var(--color-heading);
  text-wrap: balance;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-md); line-height: var(--lh-snug); }
h5,
h6 { font-size: var(--fs-base); line-height: var(--lh-snug); }

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

p:last-child {
  margin-bottom: 0;
}

:where(a) {
  color: var(--color-primary);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) ease;
}

:where(a:hover) {
  color: var(--color-primary-hover);
}

strong,
b {
  font-weight: var(--fw-semibold);
  color: var(--color-heading);
}

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

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

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

code {
  padding: 0.1em 0.4em;
  border-radius: var(--radius-xs);
  background: var(--color-surface-2);
  color: var(--color-heading);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.75em;
  font-weight: var(--fw-semibold);
  line-height: 1.5;
}

mark {
  background: var(--color-mark);
  color: var(--color-on-mark);
  border-radius: 3px;
  padding: 0 0.1em;
}

::selection {
  background: var(--color-primary-soft-2);
  color: var(--color-heading);
}

/* ---------- Focus ---------- */
:focus {
  outline: none;
}

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

/* ---------- Scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-scrollbar) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--color-scrollbar);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Accessibility helpers ---------- */
.sr-only {
  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: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  color: var(--color-on-primary);
}

/* Scroll lock used by drawer and modals (site.js / ui.js) */
html.is-scroll-locked {
  overflow: hidden;
}

html.is-scroll-locked body {
  padding-right: var(--scrollbar-w, 0px);
}

/* Smooth theme switch — only active for a moment while toggling */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color var(--dur-slow) ease, border-color var(--dur-slow) ease,
    color var(--dur-slow) ease, fill var(--dur-slow) ease, stroke var(--dur-slow) ease,
    box-shadow var(--dur-slow) ease !important;
  transition-delay: 0s !important;
}

/* ---------- Layout utilities ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: calc(var(--container-narrow) + 2 * var(--gutter));
}

.stack > * + * {
  margin-top: var(--stack-gap, var(--space-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

/* ---------- Text utilities ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.lead {
  font-size: var(--fs-md);
  color: var(--color-text-muted);
  line-height: 1.7;
}

.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; }

.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-center { text-align: center; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }

.gradient-text {
  background: var(--gradient-brand-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- Scroll reveal (driven by site.js) ---------- */
[data-reveal] {
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: calc(var(--reveal-i, 0) * 70ms);
}

html.has-reveal [data-reveal]:not(.is-visible) {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
}

/* ---------- 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;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  html.has-reveal [data-reveal]:not(.is-visible) {
    opacity: 1;
    transform: none;
  }
}
