/* ==========================================================================
   The home page: the spell book (a live split editor), the directive cards,
   the benchmark bars. Everything else on the page is Monsoon utilities.
   ========================================================================== */

/* -------------------------------------------------------------- the book */

.vd-book-wrap {
  max-width: 76rem;
  margin-inline: auto;
}

.vd-book {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: var(--m-radius-3xl);
  background: var(--surface);
  box-shadow:
    0 0 0 6px color-mix(in oklab, var(--primary) 7%, transparent),
    var(--m-shadow-xl);
  overflow: hidden;
}

/* The mascot sits on the book's top edge, at the right, as if peeking in. */
.vd-vudu {
  position: absolute;
  z-index: 2;
  right: 0.75rem;
  top: -5.4rem;
  width: 5.75rem;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 10px 18px oklch(0.3 0.2 288 / 0.25));
}

@media (min-width: 64rem) {
  .vd-vudu {
    right: 2.5rem;
    top: -9.6rem;
    width: 10.5rem;
  }
}

@keyframes vd-hop {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  30% {
    transform: translateY(-22px) rotate(-8deg);
  }
  60% {
    transform: translateY(0) rotate(5deg);
  }
}

.vd-vudu.vd-hop {
  animation: vd-hop 650ms cubic-bezier(0.3, 1.4, 0.6, 1);
}

.vd-book-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-2) 70%, var(--surface));
}

/* The spells: a row of tabs that scrolls sideways on a phone. */
.vd-spells {
  display: flex;
  gap: 0.25rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.vd-spells::-webkit-scrollbar {
  display: none;
}

.vd-spell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  height: 2.125rem;
  padding: 0 0.8rem;
  border-radius: var(--m-radius-full);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--m-duration-fast), color var(--m-duration-fast);
}

.vd-spell .vd-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.vd-spell:hover {
  color: var(--foreground);
  background: color-mix(in oklab, var(--foreground) 6%, transparent);
}

.vd-spell[aria-selected='true'] {
  color: var(--primary-foreground);
  background: var(--primary);
}

.vd-spell[aria-selected='true'] .vd-icon {
  color: var(--accent);
}

.vd-run .vd-icon {
  transition: transform var(--m-duration) var(--m-ease-spring);
}

.vd-run:hover .vd-icon {
  transform: rotate(-18deg) scale(1.1);
}

.vd-pages {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 56rem) {
  .vd-pages {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  }
  .vd-page-result {
    border-left: 1px solid var(--border);
  }
}

.vd-page {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.vd-page .vframe-bar {
  border-bottom-color: var(--vd-frame-line);
}

.vd-page:first-child {
  background: var(--vd-frame);
  color: var(--vd-frame-ink);
}

.vd-live {
  align-self: center;
  padding-right: 0.5rem;
  color: var(--vd-frame-dim);
  font-size: 0.75rem;
}

/* The editor: a transparent textarea over its own highlighted copy. */
.vd-editor {
  display: flex;
  height: 27rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  font-variant-ligatures: none;
}

.vd-gutter {
  flex: none;
  width: 2.75rem;
  padding: 1rem 0.75rem 1rem 0;
  overflow: hidden;
  text-align: right;
  color: var(--vd-frame-dim);
  opacity: 0.7;
  user-select: none;
  white-space: pre;
}

.vd-code {
  position: relative;
  flex: 1;
  min-width: 0;
}

.vd-code .vd-hl,
.vd-code textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 1rem 1rem 1rem 0.25rem;
  border: 0;
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  word-wrap: normal;
}

.vd-code .vd-hl {
  pointer-events: none;
  color: var(--vd-frame-ink);
  overflow: hidden;
}

.vd-code textarea {
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--vd-frame-ink);
  outline: none;
}

.vd-code textarea::selection {
  background: color-mix(in oklab, var(--primary) 30%, transparent);
  color: transparent;
}

.vd-editor:focus-within {
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--ring) 55%, transparent);
}

/* Light+ and Dark+ token colours, for the live editor (the static samples
   on the site are coloured by Shiki at build time). */
.tk-c { color: #008000; font-style: italic; }
.tk-t { color: #800000; }
.tk-a { color: #e50000; }
.tk-s { color: #0000ff; }
.tk-p { color: #800000; }
.tk-k { color: #0000ff; }
.tk-n { color: #098658; }
.tk-b { color: #795e26; font-weight: 600; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .tk-c { color: #6a9955; }
  :root:not([data-theme='light']) .tk-t { color: #569cd6; }
  :root:not([data-theme='light']) .tk-a { color: #9cdcfe; }
  :root:not([data-theme='light']) .tk-s { color: #ce9178; }
  :root:not([data-theme='light']) .tk-p { color: #808080; }
  :root:not([data-theme='light']) .tk-k { color: #569cd6; }
  :root:not([data-theme='light']) .tk-n { color: #b5cea8; }
  :root:not([data-theme='light']) .tk-b { color: #ffd700; }
}

:root[data-theme='dark'] .tk-c { color: #6a9955; }
:root[data-theme='dark'] .tk-t { color: #569cd6; }
:root[data-theme='dark'] .tk-a { color: #9cdcfe; }
:root[data-theme='dark'] .tk-s { color: #ce9178; }
:root[data-theme='dark'] .tk-p { color: #808080; }
:root[data-theme='dark'] .tk-k { color: #569cd6; }
:root[data-theme='dark'] .tk-n { color: #b5cea8; }
:root[data-theme='dark'] .tk-b { color: #ffd700; }

/* The result page. */
.vd-url {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  align-self: center;
  min-width: 0;
  padding: 0.2rem 0.75rem;
  border-radius: var(--m-radius-full);
  background: color-mix(in oklab, var(--foreground) 6%, transparent);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.vd-url .vd-icon {
  width: 0.8rem;
  height: 0.8rem;
}

.vd-page-result .vframe-bar {
  background: var(--surface-2);
  border-bottom-color: var(--border);
}

.vd-error {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  align-self: center;
  min-width: 0;
  max-width: 60%;
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 600;
}

.vd-error[hidden] {
  display: none;
}

.vd-error span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vd-stage {
  position: relative;
  height: 27rem;
  background: var(--background);
  transition: box-shadow var(--m-duration);
}

.vd-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.vd-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.5rem;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  transition: opacity var(--m-duration-slow);
}

.vd-loading.is-done {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 55.99rem) {
  .vd-editor {
    height: 21rem;
  }
  .vd-stage {
    height: 24rem;
    border-top: 1px solid var(--border);
  }
}

/* The install line under the book. */
.vd-install {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.375rem 0.375rem 0.375rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--m-radius-lg);
  background: var(--surface);
  font-size: 0.75rem;
}

.vd-install code {
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  scrollbar-width: none;
}

/* ---------------------------------------------------- directive cards */

.vd-dname {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--m-radius-md);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.vd-potion {
  transition: transform var(--m-duration) var(--m-ease), border-color var(--m-duration);
}

.vd-potion:hover {
  transform: translateY(-2px);
  border-color: color-mix(in oklab, var(--primary) 45%, var(--border));
}

.vd-mini {
  margin-top: auto;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--vd-frame-line);
  border-radius: var(--m-radius-md);
  background: var(--vd-frame);
  font-size: 0.75rem;
  overflow-x: auto;
}

.vd-tagname {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* An icon in a soft rune-like tile. */
.vd-glyph {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.25rem;
  border-radius: var(--m-radius-lg);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
  color: var(--primary);
}

.vd-glyph .vd-icon {
  width: 1.3rem;
  height: 1.3rem;
}

/* ------------------------------------------------------ benchmark bars */

.vd-bars li {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.vd-bar-name {
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vd-bar {
  height: 0.75rem;
  border-radius: var(--m-radius-full);
  background: color-mix(in oklab, var(--foreground) 7%, transparent);
  overflow: hidden;
}

.vd-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in oklab, var(--muted-foreground) 55%, transparent);
}

.vd-bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.vd-bar-me .vd-bar-name,
.vd-bar-me .vd-bar-val {
  color: var(--primary);
  font-weight: 700;
}

.vd-bar-me .vd-bar i {
  background: linear-gradient(90deg, var(--primary), var(--magenta), var(--amber));
}

@media (max-width: 30rem) {
  .vd-bars li {
    grid-template-columns: 6.25rem minmax(0, 1fr) 3rem;
    gap: 0.5rem;
  }
}

/* ---------------------------------------------------- motion on scroll */

/* Sections rise into place the first time they scroll into view. The class
   that hides them is only added by home.js when IntersectionObserver exists
   and the reader has not asked for reduced motion, so without JavaScript
   everything is simply there. */
.vd-reveal-on [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 700ms cubic-bezier(0.2, 0.8, 0.3, 1),
    transform 700ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.vd-reveal-on [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* The lesson button carries a soft shimmer, the one thing on the page that
   says start here. */
.vd-cta {
  position: relative;
  overflow: hidden;
}

.vd-cta::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, oklch(1 0 0 / 0.35) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: vd-shimmer 3.6s ease-in-out 1.2s infinite;
  pointer-events: none;
}

@keyframes vd-shimmer {
  0%,
  60% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vd-cta::after {
    animation: none;
    display: none;
  }
  .vd-reveal-on [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
