/* ═══════════════════════════════════════════════════════════════
   XODE — HOW TO USE THE EDITORS

   The player src/howto.js builds, plus the "(i)" button that opens it
   and the three cards on the home page.

   Tokens with fallbacks throughout: this loads on the editor pages,
   which do not load shared.css, and on the site pages, which do.
   ═══════════════════════════════════════════════════════════════ */

/* ── the (i) button ───────────────────────────────────────────── */
.ht-i {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border-2, #383B46);
  background: var(--bg-2, #14141A);
  color: var(--text-2, #C9CBD4);
  font-family: var(--font-display, inherit);
  font-size: 14px; font-weight: 800; font-style: italic;
  cursor: pointer;
  transition: border-color .16s, color .16s, background .16s;
}
.ht-i:hover {
  border-color: var(--violet, #7C5CFF);
  color: #fff;
  background: rgba(124, 92, 255, .16);
}
.ht-i:focus-visible { outline: 2px solid var(--violet, #7C5CFF); outline-offset: 2px; }

/* ── the modal ────────────────────────────────────────────────── */
.ht-scrim {
  position: fixed;
  inset: 0;
  z-index: 9600;              /* above the assistant, below nothing */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  background: rgba(6, 7, 10, .8);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}
.ht-scrim.open { display: flex; }
body.ht-open { overflow: hidden; }

.ht {
  width: min(1040px, 100%);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-2, #383B46);
  border-radius: 18px;
  background: var(--bg-1, #0F0F14);
  box-shadow: 0 30px 90px rgba(var(--shadow-rgb), .6);
  overflow: hidden;
}

/* ── head ─────────────────────────────────────────────────────── */
.ht-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-1, #2A2A34);
}
.ht-head-text { display: flex; flex-direction: column; min-width: 0; }
.ht-head-text b {
  font-family: var(--font-display, inherit);
  font-size: 15px; font-weight: 800;
  color: var(--text-0, #fff);
}
.ht-head-text span {
  font-size: 12px;
  color: var(--text-3, #8B8D98);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ht-switch {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 3px;
  border-radius: 100px;
  background: var(--bg-2, #14141A);
  border: 1px solid var(--border-1, #2A2A34);
}
.ht-switch button {
  padding: 6px 14px;
  border: 0;
  border-radius: 100px;
  background: transparent;
  color: var(--text-3, #8B8D98);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.ht-switch button:hover { color: var(--text-1, #E7E7EA); }
.ht-switch button.on { background: var(--violet, #7C5CFF); color: #fff; }

.ht-x {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border-2, #383B46);
  border-radius: 9px;
  background: transparent;
  color: var(--text-2, #C9CBD4);
  cursor: pointer;
}
.ht-x svg { width: 16px; height: 16px; }
.ht-x:hover { color: #fff; border-color: var(--text-3, #8B8D98); }

/* ── the stage ────────────────────────────────────────────────── */
.ht-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  /* aspect-ratio is not everywhere; this keeps the shape without it. */
  min-height: 200px;
  background: #08090C;
  overflow: hidden;
}
.ht-stage video { width: 100%; height: 100%; display: block; background: #000; }

.ht-screen { position: absolute; inset: 0; }

.ht-panel {
  position: absolute;
  border: 1px solid rgba(var(--fg-rgb), .07);
  border-radius: 5px;
  background: rgba(var(--fg-rgb), .022);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.ht-panel span {
  font-family: var(--font-caption, inherit);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(var(--fg-rgb), .3);
  padding: 0 4px;
  text-align: center;
}

/* The pieces a step calls up: hidden until then, and they fade in
   rather than appearing, so the eye follows what changed. */
.ht-panel.is-extra {
  opacity: 0;
  transform: scale(.97);
  pointer-events: none;
  border-color: rgba(124, 92, 255, .34);
  background: rgba(124, 92, 255, .08);
  transition: opacity .32s ease, transform .32s ease;
}
.ht-panel.is-extra.on { opacity: 1; transform: none; }
.ht-panel.is-extra span { color: rgba(201, 188, 255, .82); }

/* The highlight that follows the step. */
.ht-spot {
  position: absolute;
  border: 2px solid var(--violet, #7C5CFF);
  border-radius: 7px;
  background: rgba(124, 92, 255, .1);
  box-shadow: 0 0 0 9999px rgba(6, 7, 10, .52), 0 0 26px rgba(124, 92, 255, .34);
  transition: left .55s cubic-bezier(.4, 0, .2, 1), top .55s cubic-bezier(.4, 0, .2, 1),
              width .55s cubic-bezier(.4, 0, .2, 1), height .55s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}

.ht-cursor {
  position: absolute;
  width: 22px; height: 22px;
  margin: -3px 0 0 -3px;
  color: #fff;
  filter: drop-shadow(0 2px 5px rgba(var(--shadow-rgb), .8));
  transition: left .62s cubic-bezier(.4, 0, .2, 1), top .62s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}
.ht-cursor svg { width: 100%; height: 100%; fill: #fff; stroke: #000; stroke-width: 1.1; }

/* ── caption ──────────────────────────────────────────────────── */
.ht-cap {
  padding: 18px 22px 4px;
  min-height: 92px;
}
.ht-cap b {
  display: block;
  font-family: var(--font-display, inherit);
  font-size: 16px; font-weight: 800;
  color: var(--text-0, #fff);
  margin-bottom: 6px;
}
.ht-cap p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.68;
  color: var(--text-2, #C9CBD4);
  max-width: 74ch;
}

/* ── controls ─────────────────────────────────────────────────── */
.ht-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 18px;
  flex-wrap: wrap;
}
.ht-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border: 1px solid var(--border-2, #383B46);
  border-radius: 9px;
  background: var(--bg-2, #14141A);
  color: var(--text-1, #E7E7EA);
  cursor: pointer;
}
.ht-btn svg { width: 15px; height: 15px; fill: currentColor; }
.ht-btn:hover { border-color: var(--violet, #7C5CFF); color: #fff; }
.ht-play { background: var(--violet, #7C5CFF); border-color: var(--violet, #7C5CFF); color: #fff; }

.ht-dots { display: flex; gap: 6px; flex: 1 1 auto; flex-wrap: wrap; }
.ht-dot {
  width: 22px; height: 5px;
  padding: 0;
  border: 0;
  border-radius: 100px;
  background: var(--border-2, #383B46);
  cursor: pointer;
  transition: background .2s;
}
.ht-dot:hover { background: var(--text-3, #8B8D98); }
.ht-dot.on { background: var(--violet, #7C5CFF); }

.ht-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-3, #8B8D98);
  flex-shrink: 0;
}
.ht-open { flex-shrink: 0; text-decoration: none; }

/* In video mode the step furniture has nothing to point at. */
.ht-scrim.is-video .ht-dots,
.ht-scrim.is-video .ht-btn,
.ht-scrim.is-video .ht-count { display: none; }
.ht-scrim.is-video .ht-open { margin-left: auto; }

/* ── the home-page section ────────────────────────────────────── */
.hu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: stretch;
}
.hu-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border-1, #2A2A34);
  border-radius: 16px;
  background: var(--bg-2, #14141A);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color .18s, transform .18s;
}
.hu-card:hover { border-color: var(--violet, #7C5CFF); transform: translateY(-3px); }

.hu-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124, 92, 255, .2), transparent 66%),
    #0B0C10;
  border-bottom: 1px solid var(--border-1, #2A2A34);
  overflow: hidden;
}
/* A miniature of the same schematic the player draws, so the card
   looks like the thing it opens. */
.hu-mini { position: absolute; inset: 9%; }
.hu-mini i {
  position: absolute;
  border: 1px solid rgba(var(--fg-rgb), .1);
  border-radius: 3px;
  background: rgba(var(--fg-rgb), .03);
}
.hu-mini i.lit {
  border-color: rgba(124, 92, 255, .5);
  background: rgba(124, 92, 255, .14);
}
.hu-play {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(124, 92, 255, .94);
  box-shadow: 0 8px 26px rgba(124, 92, 255, .44);
  transition: transform .2s;
}
.hu-play svg { width: 17px; height: 17px; fill: #fff; margin-left: 3px; }
.hu-card:hover .hu-play { transform: translate(-50%, -50%) scale(1.09); }

.hu-body { padding: 18px 20px 20px; }
.hu-body b {
  display: block;
  font-family: var(--font-display, inherit);
  font-size: 15px; font-weight: 800;
  color: var(--text-0, #fff);
  margin-bottom: 6px;
}
.hu-body p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2, #C9CBD4);
}
.hu-meta {
  font-family: var(--font-caption, inherit);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-3, #8B8D98);
}

/* ── narrow ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .ht-scrim { padding: 0; }
  .ht { max-height: 100vh; width: 100%; border-radius: 0; border: 0; }
  .ht-head { flex-wrap: wrap; }
  .ht-switch { margin-left: 0; order: 3; width: 100%; justify-content: space-between; }
  .ht-switch button { flex: 1; }
  .ht-x { margin-left: auto; }
  .ht-cap { padding: 14px 16px 2px; min-height: 0; }
  .ht-cap p { font-size: 13px; }
  .ht-bar { padding: 12px 16px 16px; }
  .ht-open { width: 100%; justify-content: center; }
}

/* ── reduced motion ───────────────────────────────────────────
   Nothing moves and nothing advances on its own. The walkthrough
   becomes a set of steps you press through yourself, which is the
   whole content of it anyway. */
@media (prefers-reduced-motion: reduce) {
  .ht-spot, .ht-cursor, .ht-panel.is-extra,
  .hu-card, .hu-play { transition: none; }
}
