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

body {
  margin: 0;
  font-family: monospace;
  background: #f8f8f8;
  color: #222;
}

/* ---- Nav ---- */
nav {
  font-family: monospace;
  font-size: 0.85em;
  padding: 12px 20px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  background: #f8f8f8;
  z-index: 10;
}
nav a { color: inherit; text-decoration: none; }
nav a:hover { text-decoration: underline; }

/* ---- Progress bar ---- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 100%;
  background: #e0e0e0;
  z-index: 100;
  transform-origin: left;
}
.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #222;
  transform-origin: left;
  transform: scaleX(0);
  animation: grow-width linear;
  animation-timeline: scroll(root);
}

@keyframes grow-width {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ---- Layout ---- */
main {
  max-width: 700px;
  margin: auto;
  padding: 0 24px 120px;
}

.hero {
  padding: 60px 0 20px;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 20px;
}

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1rem; margin: 0 0 6px; }
p  { margin: 0 0 12px; font-size: 0.85rem; color: #aaa; line-height: 1.6; }
p code {
  background: #fff;
  border: 1px solid #e0e0e0;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.9em;
  color: #222;
}

.hint { color: #aaa; font-style: italic; }

.section {
  margin-top: 48px;
  padding: 28px 24px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.code-block {
  margin-top: 14px;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 14px 16px;
}
.code-block pre {
  margin: 0;
  font-family: monospace;
  font-size: 0.8rem;
  color: #222;
  line-height: 1.6;
}

/* ---- view() cards ---- */
.cards-container {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Keyframes ---- */
@keyframes fade-up-in {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slide-left-in {
  from { opacity: 0; transform: translateX(-60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slide-right-in {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- view() driven cards ---- */
.view-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.view-card.fade-up {
  animation: fade-up-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

.view-card.delay-1 {
  animation: fade-up-in linear both;
  animation-timeline: view();
  animation-range: entry 10% entry 50%;
}

.view-card.scale-in {
  animation: scale-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

.view-card.slide-left {
  animation: slide-left-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

.view-card.slide-right {
  animation: slide-right-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

.card-number {
  font-size: 2rem;
  font-weight: bold;
  color: #e0e0e0;
  flex-shrink: 0;
  width: 48px;
  text-align: center;
}

.card-text strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #222;
}
.card-text p { margin: 0; font-size: 0.78rem; color: #aaa; }

/* ---- animation-range demo ---- */
.range-demo {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

@keyframes highlight-in {
  from { background: #f8f8f8; border-color: #e0e0e0; transform: translateX(0); }
  to   { background: #222; border-color: #222; color: #fff; transform: translateX(12px); }
}

.range-card {
  padding: 16px 20px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #f8f8f8;
  font-size: 0.82rem;
  transition: color 0.3s;
}
.range-card strong { display: block; margin-bottom: 4px; }
.range-card p { margin: 0; font-size: 0.78rem; color: #aaa; }

.entry-range {
  animation: highlight-in linear both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

.cover-range {
  animation: highlight-in linear both;
  animation-timeline: view();
  animation-range: cover 20% cover 80%;
}

.exit-range {
  animation: highlight-in linear both;
  animation-timeline: view();
  animation-range: exit 60% exit 100%;
}

/* ---- Scrub bar ---- */
.counter-section {
  margin-top: 80px;
}

@keyframes scrub-grow {
  from { width: 0%; }
  to   { width: 100%; }
}

.scrub-bar-wrap {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.scrub-bar-wrap span { font-size: 0.78rem; color: #aaa; white-space: nowrap; }

.scrub-bar {
  flex: 1;
  height: 12px;
  background: #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.scrub-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #222;
  transform-origin: left;
  transform: scaleX(0);
  animation: grow-width linear;
  animation-timeline: scroll(root);
}

/* ---- Spacer ---- */
.spacer { height: 120px; }
