/* ==========================================================================
   RATELi TFM Academy - Base layer
   Reset, elements, typography, utilities.
   ========================================================================== */

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

* {
  margin: 0;
}

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

body {
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "ss01";
  overflow-x: hidden;
  /* A single long word - a file path, a webhook URL, an API key - is wider
     than a phone and nothing in a normal layout will break it, so one string
     in one alert pushed the whole administration area sideways. This only
     affects words that would otherwise overflow their box. */
  overflow-wrap: break-word;
}

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

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

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

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
}

h1 { font-size: clamp(2.125rem, 1.4rem + 3vw, var(--text-5xl)); }
h2 { font-size: clamp(1.625rem, 1.15rem + 1.9vw, var(--text-3xl)); }
h3 { font-size: clamp(1.25rem, 1.05rem + 0.8vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover { color: var(--accent-text); }

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

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

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

pre.code {
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: 1.6;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection {
  background: var(--accent-soft);
  color: var(--text-strong);
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-clip: content-box; background-color: var(--text-dim); }

/* --------------------------------------------------------------------------
   The wordmark. The trailing letter is always lowercase and accent coloured.
   -------------------------------------------------------------------------- */

.wordmark {
  font-family: var(--font-display);
  font-weight: var(--weight-black);
  letter-spacing: -0.03em;
  color: var(--text-strong);
  line-height: 1;
}

.wordmark__i { color: var(--accent); }

.wordmark__suffix {
  margin-left: 0.55rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line-strong);
  font-family: var(--font-body);
  font-size: 0.62em;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Layout utilities
   -------------------------------------------------------------------------- */

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

.container--wide { max-width: var(--container-wide); }
.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: clamp(3.5rem, 2rem + 6vw, var(--space-24)); }
.section--tight { padding-block: clamp(2.5rem, 1.5rem + 4vw, var(--space-16)); }
.section--alt { background: var(--page-alt); }

.stack { display: flex; flex-direction: column; }
.stack--1 { gap: var(--space-1); }
.stack--2 { gap: var(--space-2); }
.stack--3 { gap: var(--space-3); }
.stack--4 { gap: var(--space-4); }
.stack--5 { gap: var(--space-5); }
.stack--6 { gap: var(--space-6); }
.stack--8 { gap: var(--space-8); }
.stack--10 { gap: var(--space-10); }

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

.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--center { justify-content: center; }
.row--top { align-items: flex-start; }
.row--wrap { flex-wrap: wrap; }

.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 216px), 1fr)); }

.spacer { flex: 1 1 auto; }

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent-text);
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.65;
}

.eyebrow--plain::before { display: none; }

.lede {
  font-size: clamp(1rem, 0.95rem + 0.35vw, var(--text-lg));
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  max-width: 62ch;
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.strong { color: var(--text-strong); }
.accent { color: var(--accent-text); }
.bull { color: var(--bull); }
.bear { color: var(--bear); }

.text-2xs { font-size: var(--text-2xs); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }

.caps {
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  color: var(--text-dim);
}

.numeric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

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

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

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

.visually-hidden {
  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: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  color: var(--brand-accent-ink);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  transition: top var(--duration-base) var(--ease-out);
}

.skip-link:focus { top: var(--space-4); color: var(--brand-accent-ink); }

/* --------------------------------------------------------------------------
   Rich text blocks (lesson content, articles, pages)
   -------------------------------------------------------------------------- */

.prose { color: var(--text); line-height: var(--leading-relaxed); }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-10); font-size: var(--text-2xl); }
.prose h3 { margin-top: var(--space-8); font-size: var(--text-xl); }
.prose h4 { margin-top: var(--space-6); font-size: var(--text-lg); }
.prose p { color: var(--text-muted); }
.prose strong { color: var(--text-strong); font-weight: var(--weight-semibold); }
.prose ul, .prose ol { color: var(--text-muted); padding-left: 1.3rem; }
.prose li + li { margin-top: var(--space-2); }
.prose a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.prose code {
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 0.1em 0.4em;
}
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-5);
  color: var(--text-muted);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--duration-slow) var(--ease-out), transform var(--duration-slow) var(--ease-out);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

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

  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header,
  .site-footer,
  .app-sidebar,
  .no-print { display: none !important; }

  body { background: #fff; color: #000; }
}
