/* Cadova · cadova.org
   Palette and type follow the Cadova brand: ink ground, tomato accent, IBM Plex. */

:root {
  --ink: #0B0D12;
  --panel: #12141A;
  --panel-2: #171A22;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --paper: #F6F3EC;
  --text: #D7D9DE;
  --muted: #9AA0AC;
  --tomato: #FF6347;
  --tomato-light: #FF9A80;
  --tomato-dark: #C8412A;
  --blueprint: #1C47A8;

  /* syntax, as in the Cadova videos */
  --syn-kw: #FC5FA3;
  --syn-ty: #5DD8FF;
  --syn-fn: #67D7B4;
  --syn-num: #D9C97C;
  --syn-lb: #9AA0AC;
  --syn-str: #FC6A5D;

  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The blueprint grid and warm glow from the videos, fixed behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 45% at 50% 18%, rgba(255, 99, 71, 0.16), transparent 70%),
    radial-gradient(ellipse 40% 35% at 12% 8%, rgba(60, 90, 255, 0.10), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--ink);
  mask-image: radial-gradient(ellipse 120% 100% at 50% 0%, #000 55%, transparent 100%);
}

a { color: var(--tomato-light); text-decoration: none; }
a:hover { color: var(--paper); }

:focus-visible { outline: 2px solid var(--tomato); outline-offset: 3px; border-radius: 6px; }

img { max-width: 100%; height: auto; display: block; }

code { font-family: var(--mono); font-size: 0.92em; }

h1, h2, h3 { color: var(--paper); margin: 0; }

h2 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.6rem, 6.8vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

h3 { font-family: var(--sans); font-weight: 600; font-size: 1.08rem; line-height: 1.35; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 18px;
}

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

/* syntax */
.kw { color: var(--syn-kw); }
.ty { color: var(--syn-ty); }
.fn { color: var(--syn-fn); }
.num { color: var(--syn-num); }
.lb { color: var(--syn-lb); }
.str { color: var(--syn-str); }
.prompt { color: var(--tomato); }
.comment { color: #6C7986; }

/* ---------------------------------------------------------------- nav */
.nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.nav-logo img { width: 148px; height: auto; }
.nav nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav nav a {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
}
.nav nav a:hover { color: var(--paper); background: rgba(255, 255, 255, 0.05); }
.nav nav a.nav-github { border: 1px solid var(--line-strong); }

/* ---------------------------------------------------------------- sections */
main > section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section-head { max-width: 720px; margin-bottom: 44px; }
.section-head p:not(.eyebrow) { color: var(--muted); font-size: 1.08rem; margin: 18px 0 0; }

/* ---------------------------------------------------------------- hero */
.hero { padding-top: clamp(48px, 9vw, 110px) !important; padding-bottom: 56px !important; }

.hero h1 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.9rem, 8.6vw, 5.6rem);   /* the longest line is ~10.2em of monospace */
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.caret {
  display: inline-block;
  width: 0.09em;
  height: 0.82em;
  margin-left: 0.08em;
  background: var(--tomato);
  vertical-align: -0.04em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.lede {
  max-width: 640px;
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  color: var(--text);
  margin: 28px 0 0;
}

.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 36px; }
.cta.center { justify-content: center; margin-top: 52px; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--paper);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.98rem;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.button:hover { color: var(--paper); border-color: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.button.primary {
  background: var(--tomato);
  border-color: var(--tomato);
  color: #170806;
  font-weight: 600;
}
.button.primary:hover { background: #FF7A62; color: #170806; }
.button.primary::after { content: "→"; }
.button.external::after { content: "↗"; color: var(--tomato); }

.facts {
  list-style: none;
  padding: 0;
  margin: 34px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--muted);
}
.facts li::before { content: "■"; color: var(--tomato); font-size: 0.6em; margin-right: 8px; vertical-align: 0.25em; }

/* ---------------------------------------------------------------- video */
.film { padding-bottom: clamp(80px, 12vw, 150px) !important; }

.film-frame {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #000;
  aspect-ratio: 16 / 9;
  box-shadow: 0 40px 140px -30px rgba(255, 99, 71, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.film-frame iframe { width: 100%; height: 100%; display: block; border: 0; }

/* The video loads from YouTube only when played: until then it's the poster and a play button. */
.video-facade { position: absolute; inset: 0; display: block; cursor: pointer; }
.video-facade img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease, filter 0.3s ease; }
.video-facade:hover img { transform: scale(1.02); filter: brightness(1.08); }
.play-button {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(64px, 9vw, 96px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--tomato);
  box-shadow: 0 0 0 10px rgba(255, 99, 71, 0.22), 0 18px 50px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.play-button::after {
  content: "";
  position: absolute;
  left: 54%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 0.9em 0 0.9em 1.5em;
  border-color: transparent transparent transparent #170806;
  font-size: clamp(11px, 1.4vw, 16px);
}
.video-facade:hover .play-button, .video-facade:focus-visible .play-button {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 0 0 16px rgba(255, 99, 71, 0.18), 0 18px 50px rgba(0, 0, 0, 0.45);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- try it */
.play { padding-bottom: clamp(80px, 12vw, 150px) !important; }

.play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 32px;
  align-items: center;
}

.editor, .snippet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.editor-bar span { width: 11px; height: 11px; border-radius: 50%; background: #2A2E38; }
.editor-bar em { font-style: normal; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); margin-left: 10px; }

pre.code {
  margin: 0;
  padding: 22px 24px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
}
.ln { display: inline-block; width: 2.2em; color: #3E4450; user-select: none; }

.num.live {
  color: var(--tomato);
  background: rgba(255, 99, 71, 0.13);
  border-bottom: 1px dashed rgba(255, 99, 71, 0.8);
  border-radius: 4px;
  padding: 2px 4px;
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
  transition: background 0.15s ease;
}
.num.live:hover, .num.live.active { background: rgba(255, 99, 71, 0.26); }
body.scrubbing, body.scrubbing * { cursor: ew-resize !important; }

.hint {
  margin: 0;
  padding: 0 24px 18px 3.4em;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--tomato);
  opacity: 0.75;
}

.stage {
  margin: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stage::before {
  content: "";
  position: absolute;
  inset: 8% 4% 12%;
  background: radial-gradient(closest-side, rgba(255, 99, 71, 0.22), transparent);
  z-index: -1;
}
.stage img { width: auto; max-height: min(470px, 64vh); }
.stage figcaption {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------------------------------------------------------------- gallery */
.built { padding-bottom: clamp(80px, 12vw, 150px) !important; }

.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 20px;
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 8px;
  transition: transform 0.35s ease;
}
.card h3 { margin-top: 14px; }
.card p { margin: 6px 0 0; color: var(--muted); font-size: 0.93rem; line-height: 1.5; }
.card code { color: var(--syn-fn); }
a.card:hover { color: var(--text); border-color: rgba(255, 99, 71, 0.55); transform: translateY(-3px); }
a.card:hover img { transform: scale(1.04) rotate(-1deg); }
a.card h3::after { content: " ↗"; color: var(--tomato); font-family: var(--mono); font-size: 0.9em; }

/* ---------------------------------------------------------------- features */
.features { padding-bottom: clamp(80px, 12vw, 150px) !important; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.feature-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  background: rgba(18, 20, 26, 0.7);
  display: flex;
  flex-direction: column;
}
.feature-grid p { color: var(--muted); margin: 8px 0 18px; font-size: 0.97rem; flex: 1; }
.feature-grid code {
  align-self: flex-start;
  color: var(--syn-fn);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- viewer */
.viewer {
  display: flex !important;
  align-items: center;
  gap: clamp(24px, 4vw, 56px);
  margin-bottom: clamp(80px, 12vw, 150px) !important;
  padding: clamp(28px, 5vw, 56px) !important;
  border-radius: 24px;
  border: 1px solid rgba(110, 150, 255, 0.25);
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(160deg, #1F57B9, #1A3A93);
  max-width: calc(var(--max) - 2 * var(--gutter)) !important;
}
.viewer > img { width: clamp(110px, 16vw, 168px); flex: none; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.35)); }
.viewer .eyebrow { color: rgba(234, 242, 255, 0.75); }
.viewer p:not(.eyebrow) { color: #E3EBFF; max-width: 560px; margin: 14px 0 24px; }
.viewer .button { background: rgba(11, 13, 18, 0.35); border-color: rgba(234, 242, 255, 0.35); }

/* ---------------------------------------------------------------- get started */
.start { padding-bottom: clamp(80px, 12vw, 140px) !important; }

.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.1fr) minmax(0, 0.8fr);
  gap: 16px;
  counter-reset: step;
}
.steps li { counter-increment: step; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.steps h3::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--tomato);
  color: #170806;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}
.steps li > p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.snippet { position: relative; }
.snippet pre.code { font-size: 0.84rem; line-height: 1.75; padding: 46px 20px 18px; }
.snippet pre.code:only-child { padding-top: 18px; }
.copy {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
}
.copy:hover { color: var(--paper); }

/* ---------------------------------------------------------------- footer */
footer {
  border-top: 1px solid var(--line);
  padding: 40px var(--gutter) 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}
footer p { margin: 0; }
footer .host { font-size: 0.8rem; }
footer .host a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
footer nav { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; font-family: var(--mono); font-size: 0.86rem; }

/* ---------------------------------------------------------------- learn (home) */
.learn { padding-bottom: clamp(80px, 12vw, 150px) !important; }

.episode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.episode-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); }
.episode-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.episode-card span { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.episode-card span b { color: var(--tomato); font-weight: 600; }
.episode-card h3 { margin: -4px 0 0; }
a.episode-card:hover { color: var(--text); }
a.episode-card:hover img { transform: translateY(-3px); border-color: rgba(255, 99, 71, 0.55); }

/* ---------------------------------------------------------------- tutorials page */
.tutorials-head { padding-top: clamp(40px, 7vw, 90px) !important; padding-bottom: clamp(48px, 7vw, 80px) !important; }
.tutorials-head h1 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(1.9rem, 6.4vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.episodes { display: flex; flex-direction: column; gap: clamp(56px, 8vw, 96px); padding-bottom: clamp(80px, 12vw, 140px) !important; }
.episode {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
  scroll-margin-top: 24px;
}
.episode-video {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #000;
  aspect-ratio: 16 / 9;
}
.episode-video iframe { width: 100%; height: 100%; display: block; border: 0; }
/* the poster carries the title in its middle, so the button sits in its empty bottom-right corner */
.episode-video .play-button { width: clamp(48px, 5.5vw, 66px); left: auto; top: auto; right: 7%; bottom: 10%; transform: none; }
.episode-video .video-facade:hover .play-button, .episode-video .video-facade:focus-visible .play-button { transform: scale(1.08); }
.episode-text .eyebrow { margin-bottom: 10px; }
.episode-text h2 { font-size: clamp(1.4rem, 3.2vw, 2.1rem); }
.episode-text > p:not(.eyebrow) { color: var(--muted); margin: 14px 0 0; }
.episode-code { margin: 18px 0 0; }
.episode-code .button { min-height: 40px; padding: 0 16px; font-size: 0.86rem; }
.chapters ol { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--line); }
.chapters li { border-bottom: 1px solid var(--line); }
.chapters a { display: flex; gap: 14px; padding: 8px 2px; color: var(--text); font-size: 0.95rem; }
.chapters a span { font-family: var(--mono); font-size: 0.85rem; color: var(--tomato-light); min-width: 3.2em; padding-top: 1px; }
.chapters a:hover { color: var(--paper); background: rgba(255, 255, 255, 0.03); }
.nav nav a[aria-current="page"] { color: var(--paper); background: rgba(255, 255, 255, 0.07); }

/* ---------------------------------------------------------------- reveal on scroll */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.7s ease, transform 0.7s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 980px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .play-grid { grid-template-columns: minmax(0, 1fr); }
  .stage img { max-height: 420px; }
  .episode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .episode { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .nav { flex-direction: column; align-items: flex-start; gap: 12px; }
  .nav nav { justify-content: flex-start; margin-left: -12px; }
  .feature-grid { grid-template-columns: minmax(0, 1fr); }
  .gallery { gap: 12px; }
  .episode-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 12px 12px 16px; }
  .viewer { flex-direction: column; align-items: flex-start; }
  pre.code { font-size: 0.8rem; padding: 18px 16px; }
  .ln { width: 1.8em; }
  .hint { padding-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .caret { animation: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .button, .card, .card img, .video-facade img, .play-button, .episode-card img { transition: none; }
}
