/* Site chrome for the companion, sharing the look of josimar-silva.com: one palette
   in a light and a dark theme, Inter type, cards, buttons, and bands. The colors are
   HSL triplets consumed as hsl(var(--name)). The animation stage alone keeps the
   dark --kf-* tokens from tokens.css, in both themes. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Tokens */

:root {
  color-scheme: light;
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --primary: 262.1 83.3% 57.8%;
  --primary-foreground: 210 40% 98%;
  --secondary: 270 3.2% 96%;
  --secondary-foreground: 222.2 84% 4.9%;
  --muted: 270 3.2% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 270 3.2% 96%;
  --accent-foreground: 222.2 84% 4.9%;
  --border: 270 5.9% 91.4%;
  --input: 270 5.9% 91.4%;
  --ring: 262.1 83.3% 57.8%;
  --radius: 0.5rem;
  --link-color: 262.1 83.3% 57.8%;
}

.dark {
  color-scheme: dark;
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 4.9%;
  --card-foreground: 210 40% 98%;
  --primary: 263.4 70% 50.4%;
  --primary-foreground: 210 40% 98%;
  --secondary: 270 3.7% 15.9%;
  --secondary-foreground: 210 40% 98%;
  --muted: 270 3.7% 15.9%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 270 3.7% 15.9%;
  --accent-foreground: 210 40% 98%;
  --border: 270 3.7% 15.9%;
  --input: 270 3.7% 15.9%;
  --ring: 263.4 70% 50.4%;
  --link-color: 263.4 70% 65%;
}

/* Reset */

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

* {
  margin: 0;
}

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

button {
  font: inherit;
}

/* Base */

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

body {
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: hsl(var(--link-color));
  text-decoration: none;
  text-underline-offset: 0.2em;
}

a:hover,
p a {
  text-decoration: underline;
}

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

[id] {
  scroll-margin-top: 5rem;
}

/* Utilities */

.container {
  width: 100%;
  max-width: 1400px;
  margin-inline: auto;
  padding-inline: 1rem;
}

.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;
  z-index: 100;
  padding: 0.5rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.skip-link:focus {
  top: 1rem;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 4rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: hsl(var(--foreground));
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.875rem;
  font-weight: 700;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.site-nav {
  display: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a[aria-current='page'] {
  color: hsl(var(--link-color));
  text-decoration: none;
}

.site-nav.is-open {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 4rem;
  right: 0;
  left: 0;
  padding: 0.5rem 1rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  box-shadow: 0 8px 16px rgb(0 0 0 / 0.08);
}

.site-nav.is-open a {
  font-size: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s,
    opacity 0.15s;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  border-color: hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.btn-outline:hover,
.btn-ghost:hover,
.btn-icon:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background-color 0.15s;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
}

.icon-sun,
.dark .icon-moon {
  display: none;
}

.dark .icon-sun {
  display: block;
}

/* Cards, badges, bands */

.card {
  padding: 1.5rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border: 1px solid transparent;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1rem;
  white-space: nowrap;
}

.badge-outline {
  border-color: hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
}

.band {
  padding-block: 3rem;
}

.band-muted {
  background: hsl(var(--muted) / 0.5);
}

.section-title {
  margin-bottom: 2rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* Home */

.hero {
  padding-block: 3rem 0;
}

.hero-title {
  max-width: 20ch;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.05em;
}

.hero-lead {
  max-width: 42rem;
  margin-top: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 1.125rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.disclaimer {
  max-width: 42rem;
  margin-top: 2rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.steps,
.chapter-grid,
.anim-list,
.anim-cards,
.aside-list,
.footer-social,
.footer-col ul {
  padding: 0;
  list-style: none;
}

.steps,
.chapter-grid,
.anim-cards {
  display: grid;
  gap: 1rem;
}

.chapter-grid {
  align-items: start;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.875rem;
  font-weight: 700;
}

.step-title {
  margin-top: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.step p {
  margin-top: 0.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.chapter-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.chapter-card.is-planned {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.chapter-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chapter-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

.chapter-card-title a {
  color: inherit;
}

.anim-list {
  display: grid;
  width: 100%;
  border-top: 1px solid hsl(var(--border));
}

.anim-list a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding-block: 0.625rem;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.anim-list a:hover {
  color: hsl(var(--link-color));
  text-decoration: none;
}

.anim-figure {
  flex: none;
  min-width: 7rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
}

/* Pages */

.page {
  padding-block: 1.5rem 4rem;
}

.page-header {
  margin-top: 1.5rem;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.lead {
  max-width: 48rem;
  margin-top: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 1.125rem;
}

.chapter-ref {
  margin-top: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
  padding: 0;
  list-style: none;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.breadcrumb li {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
}

.breadcrumb li + li::before {
  content: '/';
  content: '/' / '';
  margin-right: 0.5rem;
}

.breadcrumb a {
  color: hsl(var(--muted-foreground));
}

.breadcrumb a:hover {
  color: hsl(var(--foreground));
}

.breadcrumb [aria-current='page'] {
  color: hsl(var(--foreground));
  font-weight: 500;
}

.anim-cards {
  margin-top: 2rem;
}

.anim-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  height: 100%;
  color: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.anim-card:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
  text-decoration: none;
}

.anim-card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.anim-card-text {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* The animation page */

.anim-layout {
  display: grid;
  gap: 2rem;
}

.callout {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-left: 4px solid hsl(var(--primary));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--muted) / 0.5);
}

.callout-title {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage {
  margin-top: 1.5rem;
  padding: 0.75rem;
  border: 1px solid var(--kf-grid);
  border-radius: var(--radius);
  background: var(--kf-bg);
  color: var(--kf-ink);
}

.stage object {
  width: 100%;
  height: auto;
  /* The SVGs declare no color scheme. Matching it keeps the embedded canvas
     transparent over the dark stage instead of an opaque backdrop in dark mode. */
  color-scheme: light;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.stage .btn-outline {
  border-color: var(--kf-grid);
  background: var(--kf-surface);
  color: var(--kf-ink);
}

.stage .btn-ghost {
  color: var(--kf-ink);
}

.stage .btn-outline:hover,
.stage .btn-ghost:hover {
  background: var(--kf-grid);
  color: var(--kf-ink);
}

.controls-hint {
  color: var(--kf-muted);
  font-size: 0.75rem;
}

.stage figcaption {
  margin-top: 0.75rem;
  color: var(--kf-muted);
  font-size: 0.875rem;
}

.chapter-aside {
  align-self: start;
  padding: 1.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

.aside-title {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.aside-list a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid transparent;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.aside-list a:hover {
  border-left-color: hsl(var(--border));
  text-decoration: none;
}

.aside-list a[aria-current='page'] {
  border-left-color: hsl(var(--primary));
  font-weight: 600;
}

.aside-figure {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 500;
}

.pager {
  display: grid;
  gap: 1rem;
  margin-top: 3rem;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  transition: border-color 0.15s;
}

.pager-link[href]:hover {
  border-color: hsl(var(--primary));
  text-decoration: none;
}

.pager-link[aria-disabled='true'] {
  border-style: dashed;
  background: transparent;
  color: hsl(var(--muted-foreground));
}

.pager-next {
  align-items: flex-end;
  text-align: right;
}

.pager-dir,
.pager-chapter {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.pager-dir {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pager-title {
  font-weight: 600;
}

/* About and not found */

.prose {
  max-width: 48rem;
}

.prose h2 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.prose p,
.prose ol,
.attribution {
  margin-top: 1rem;
}

.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

.attribution p + p {
  margin-top: 0.75rem;
}

.notice {
  display: grid;
  justify-items: center;
  gap: 1rem;
  max-width: 36rem;
  margin: 3rem auto;
  text-align: center;
}

/* Footer */

.site-footer {
  padding-block: 3rem;
  border-top: 1px solid hsl(var(--border));
}

.footer-grid {
  display: grid;
  gap: 2rem;
}

.footer-blurb {
  max-width: 20rem;
  margin-top: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.footer-social {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.footer-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.footer-col a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.footer-col a:hover {
  color: hsl(var(--link-color));
  text-decoration: none;
}

.footer-bottom {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  text-align: center;
}

.footer-bottom p + p {
  margin-top: 0.5rem;
}

/* Responsive: sm 640px, md 768px, lg 1024px */

@media (min-width: 640px) {
  .hero-title {
    font-size: 3rem;
  }

  .pager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pager-next {
    grid-column: 2;
  }
}

@media (min-width: 768px) {
  .container {
    padding-inline: 2rem;
  }

  .site-nav,
  .site-nav.is-open {
    display: flex;
    position: static;
    flex-direction: row;
    gap: 1.5rem;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .site-nav.is-open a {
    font-size: 0.875rem;
  }

  .menu-button {
    display: none;
  }

  .btn-icon {
    width: 2.25rem;
    height: 2.25rem;
  }

  .band {
    padding-block: 6rem;
  }

  .hero {
    padding-top: 6rem;
  }

  .section-title {
    font-size: 1.875rem;
  }

  .steps,
  .chapter-grid,
  .anim-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
  }

  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page {
    padding-block: 2rem 6rem;
  }

  .stage {
    padding: 1rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .chapter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .anim-layout {
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: 3rem;
  }

  .chapter-aside {
    position: sticky;
    top: 5rem;
  }

  .footer-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (hover: none) {
  .controls-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
