/* Default tokens (e.g. admin article preview). Learn page overrides below. */
:root {
  --ink: #0a0a0a;
  --muted: rgba(10, 10, 10, 0.55);
  --line: rgba(10, 10, 10, 0.12);
  --bg: #ffffff;
  --brand-blue: #2d6fde;
  --logo-blue: #3d8ae8;
  --brand-yellow: #f5c842;
  --logo-pad: #0a0a0a;
  --accent-bg: var(--logo-blue);
  --accent-fg: #ffffff;
  --surface-raise: rgba(10, 10, 10, 0.04);
  --code-bg: #0a0a0a;
  --code-fg: #f5f5f5;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

/* index.php (learn) only: dark UI, no light theme (no toggle). */
html.learn.learn--dark {
  color-scheme: dark;
  --ink: #f2f2f4;
  --muted: rgba(242, 242, 244, 0.58);
  --line: rgba(255, 255, 255, 0.12);
  --bg: #0a0a0b;
  /* Same blue as the logo train body */
  --logo-blue: #3d8ae8;
  --brand-blue: var(--logo-blue);
  --brand-yellow: #f5c842;
  --logo-pad: #000000;
  --accent-bg: var(--logo-blue);
  --accent-fg: #ffffff;
  --surface-raise: rgba(255, 255, 255, 0.06);
  --code-bg: #121214;
  --code-fg: #ececf1;
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

html.learn.learn--dark,
html.learn.learn--dark body {
  background: var(--bg);
  color: var(--ink);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 4rem;
  max-width: min(44rem, 100%);
  margin: 0 auto;
}

.site-brand {
  text-decoration: none;
  color: inherit;
}

.site-brand:focus-visible {
  outline: 3px solid var(--brand-blue);
  outline-offset: 4px;
  border-radius: 20px;
}

.hero-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  color: var(--ink);
}

.hero-mark::before,
.hero-mark::after {
  content: "";
  height: 1px;
  width: 48px;
  background: var(--line);
}

.site-logo-wrap {
  display: block;
  background: var(--logo-pad);
  border-radius: 20px;
  padding: 6px;
  line-height: 0;
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.site-logo {
  display: block;
  width: 96px;
  height: auto;
  border-radius: 14px;
  vertical-align: middle;
}

.site-brand--compact .site-logo-wrap {
  border-radius: 14px;
  padding: 4px;
}

.site-brand--compact .site-logo {
  width: 56px;
  border-radius: 10px;
}

.hero-title {
  font-size: clamp(2rem, 5.5vw, 3rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-align: center;
  margin: 0 0 1.75rem;
}

.hero-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(420px, 100%);
  margin: 0 auto 1.5rem;
}

.hero-rule span {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.hero-rule i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-blue);
  display: block;
}

.sub-title {
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  font-weight: 400;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  margin: 0 auto 2.5rem;
  max-width: 36rem;
}

.cta {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--accent-bg);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  font-size: 1.12rem;
  padding: 1rem 1.35rem 1rem 1.5rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.cta:hover {
  filter: brightness(1.03);
}

.cta:active {
  transform: scale(0.99);
}

.cta:focus-visible {
  outline: 3px solid var(--brand-blue);
  outline-offset: 3px;
}

html.learn.learn--dark .cta:focus-visible {
  outline-color: rgba(255, 255, 255, 0.5);
}

.cta[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.cta-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
}

.cta-icon svg {
  width: 16px;
  height: 16px;
}

.panel {
  width: 100%;
  margin-top: 2.75rem;
}

.panel[hidden] {
  display: none !important;
}

.status {
  text-align: center;
  color: var(--muted);
  font-size: 1.08rem;
  margin-top: 1.5rem;
  min-height: 1.5rem;
}

.status--error {
  color: #f87171;
}

.article {
  width: 100%;
  margin-top: 0.5rem;
}

/* Extra scroll runway so the karaoke line can pass over the last words (reading line ~42vh). */
#article-panel:not([hidden]) .article {
  padding-bottom: max(58vh, 22rem);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.article-meta .article-meta__item {
  white-space: nowrap;
}

.article-title {
  font-size: clamp(2rem, 5vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 1rem;
  text-align: center;
}

.article-hook {
  text-align: center;
  font-size: clamp(1.2rem, 2.8vw, 1.45rem);
  color: var(--muted);
  margin: 0 auto 2.5rem;
  max-width: 40rem;
  line-height: 1.6;
}

.blocks {
  display: flex;
  flex-direction: column;
  gap: 1.65rem;
}

.article-p {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  line-height: 1.7;
  color: var(--ink);
}

.article-strong {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.05rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.28;
}

.article-highlight {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.35rem);
  line-height: 1.65;
  font-weight: 500;
  padding: 1.25rem 1.35rem;
  border-left: 3px solid var(--brand-blue);
  background: var(--surface-raise);
}

.article-quote {
  margin: 0;
  padding: 0 0 0 1.15rem;
  border-left: 2px solid var(--line);
  font-size: clamp(1.12rem, 2.3vw, 1.3rem);
  line-height: 1.65;
  color: var(--muted);
}

.article-takeaway {
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 1.5rem);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.015em;
}

.article-example {
  margin: 0;
  padding: 1.2rem 1.3rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: clamp(1.05rem, 2.1vw, 1.2rem);
  line-height: 1.65;
  color: var(--ink);
}

.article-example::before {
  content: "Example";
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.article-code {
  margin: 0;
  padding: 1.1rem 1.2rem;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 8px;
  overflow-x: auto;
  font-size: clamp(0.95rem, 2vw, 1.08rem);
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border: 1px solid var(--line);
}

.article-sep {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 0.25rem 0;
}

/* Karaoke-style reading line: words below the line stay dim; line = brand; past = full */
html.learn.learn--dark .read-word {
  transition: color 0.09s linear, opacity 0.09s linear;
}

html.learn.learn--dark .read-word--future {
  opacity: 0.34;
  color: rgba(242, 242, 244, 0.42);
}

html.learn.learn--dark .read-word--past {
  opacity: 1;
  color: var(--ink);
}

html.learn.learn--dark .read-word--current {
  opacity: 1;
  color: var(--brand-blue);
  font-weight: 700;
  text-shadow: 0 0 24px rgba(61, 138, 232, 0.35);
}

@media (max-width: 640px) {
  .page {
    padding: 2.25rem 1.15rem 3rem;
  }

  .site-logo {
    width: 80px;
  }

  #article-panel:not([hidden]) .article {
    padding-bottom: max(62vh, 18rem);
  }

  .hero-mark::before,
  .hero-mark::after {
    width: 28px;
  }

  .cta {
    width: 100%;
    justify-content: center;
  }
}
