/*
 * Guide for cmuxtools.
 *
 * The reader is someone who finds an English shell command frightening, so the
 * page shows one thing at a time and never presents a wall of steps. Motion is
 * used to say "you moved forward", not for decoration — and every bit of it is
 * dropped under prefers-reduced-motion.
 */

:root {
  --bg: #0e1116;
  --raised: #161b22;
  --border: #2a3139;
  --text: #e6edf3;
  --dim: #8b949e;
  --accent: #56d6a8;
  --accent-ink: #06231a;
  --alt: #7aa2f7;
  --warn: #e0af68;
  --danger: #f7768e;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.85; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

/* ───────────────────────────── landing ───────────────────────────── */

.landing {
  max-width: 760px; margin: 0 auto;
  padding: max(3.5rem, env(safe-area-inset-top)) 1.25rem 5rem;
}

.hero { text-align: center; padding: 1.5rem 0 2.5rem; }

.mark {
  width: 64px; height: 64px; margin: 0 auto 1.75rem;
  border-radius: 18px; background: var(--raised); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 3px;
}
.mark-chevron { color: var(--accent); font-size: 1.9rem; line-height: 1; font-weight: 300; }
.mark-caret {
  width: 14px; height: 3px; background: var(--alt); border-radius: 2px;
  animation: blink 1.6s steps(2, start) infinite;
}

h1 {
  font-size: clamp(1.75rem, 6vw, 2.4rem); line-height: 1.4;
  margin: 0 0 1.1rem; letter-spacing: -.02em;
}

.lede {
  color: var(--dim); font-size: 1.02rem; margin: 0 auto 2.25rem; max-width: 34rem;
}

.cta {
  display: inline-flex; flex-direction: column; align-items: center; gap: .15rem;
  min-height: 60px; padding: .9rem 2.4rem;
  border: none; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 28px rgba(86, 214, 168, .22);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(86, 214, 168, .3); }
.cta:active { transform: translateY(0); }
.cta-sub { font-size: .72rem; font-weight: 500; opacity: .72; }

.reassure {
  color: var(--dim); font-size: .84rem; margin: 1.1rem 0 0;
}

.cards {
  display: grid; gap: .9rem; margin: 1rem 0 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.card {
  background: var(--raised); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.3rem;
}
.card-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.card h3 { font-size: .98rem; margin: 0 0 .4rem; }
.card p { font-size: .87rem; color: var(--dim); margin: 0; line-height: 1.7; }

.footnote { text-align: center; color: var(--dim); font-size: .85rem; }
.footnote a, .landing a { color: var(--alt); }

/* ───────────────────────────── wizard ───────────────────────────── */

.wizard {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

/*
 * The `hidden` attribute is implemented by the UA stylesheet as
 * `[hidden] { display: none }`, which an author `display: flex` outranks.
 * Without this the wizard is permanently on top of the landing page, showing
 * an empty shell until something happens to run render().
 */
[hidden] { display: none !important; }

.wiz-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: .8rem;
  padding: .9rem 1rem .4rem;
}
.wiz-back, .wiz-close {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 1.5rem; line-height: 1; padding: .2rem .5rem; flex: 0 0 auto;
  font-family: inherit;
}
.wiz-back[disabled] { opacity: .25; cursor: default; }
.wiz-close { font-size: 1.05rem; }

.progress {
  flex: 1; height: 4px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 999px;
  transition: width .45s var(--ease);
}

.wiz-meta {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: .6rem;
  padding: .3rem 1.4rem .2rem; max-width: 720px; width: 100%; margin: 0 auto;
}
.chapter { color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.count { color: var(--dim); font-size: .75rem; margin-left: auto; font-variant-numeric: tabular-nums; }

.stage {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: .6rem 1.4rem 2rem; max-width: 720px; width: 100%; margin: 0 auto;
}

/* Each step animates in from the direction of travel, so moving forward and
   moving back feel different. */
.step-body { }

.step-body h2 {
  font-size: 1.35rem; line-height: 1.5; margin: .4rem 0 .9rem; letter-spacing: -.01em;
}
.step-body p { margin: 0 0 1rem; }
.step-body ul { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.step-body li { margin-bottom: .45rem; }
.step-body a { color: var(--alt); }
.step-body strong { color: var(--text); }

.cmd {
  position: relative; margin: 0 0 1.1rem;
  background: #0a0d11; border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 3.4rem 1rem 1rem;
  font-family: var(--mono); font-size: .84rem; line-height: 1.7;
  overflow-x: auto; white-space: pre; color: var(--accent);
}
.copy {
  position: absolute; top: .55rem; right: .55rem;
  background: var(--raised); border: 1px solid var(--border); color: var(--dim);
  border-radius: 8px; padding: .35rem .6rem; font-size: .72rem; cursor: pointer;
  font-family: var(--sans); transition: all .18s var(--ease);
}
.copy:hover { color: var(--text); }
.copy.done { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.callout {
  border-left: 3px solid var(--alt); border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--alt) 9%, var(--raised));
  padding: .9rem 1.1rem; margin: 0 0 1.1rem; font-size: .92rem;
}
.callout.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, var(--raised)); }
.callout.danger { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--raised)); }
.callout p:last-child { margin-bottom: 0; }
.callout-title { display: block; font-weight: 700; margin-bottom: .3rem; }

.pick { display: grid; gap: .7rem; margin: 0 0 1rem; }
.pick button {
  display: block; width: 100%; text-align: left;
  background: var(--raised); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.15rem; color: var(--text); font-family: inherit; font-size: .97rem;
  cursor: pointer; transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.pick button:hover { border-color: var(--accent); transform: translateX(2px); }
.pick .pick-sub { display: block; color: var(--dim); font-size: .82rem; margin-top: .2rem; }

.done-mark {
  width: 76px; height: 76px; margin: 1.5rem auto 1.25rem; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center;
  color: var(--accent-ink); font-size: 2.2rem; font-weight: 700;
}

.checklist { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.checklist li {
  padding-left: 1.7rem; position: relative; margin-bottom: .55rem; color: var(--dim);
}
.checklist li::before {
  content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 700;
}

.wiz-foot {
  flex: 0 0 auto; padding: .9rem 1.4rem calc(1.1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--bg);
  max-width: 720px; width: 100%; margin: 0 auto;
}
.next {
  width: 100%; min-height: 54px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink);
  font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
.next:active { transform: scale(.985); }
.next.ghost { background: transparent; color: var(--alt); border: 1px solid var(--border); }
.hint { text-align: center; color: var(--dim); font-size: .78rem; margin: .6rem 0 0; min-height: 1.2em; }

/* ───────────────────────────── motion ───────────────────────────── */

@keyframes rise { from { transform: translateY(14px); } to { transform: none; } }
@keyframes mark-in { from { transform: scale(.82) rotate(-6deg); } to { transform: none; } }
@keyframes wizard-in { from { transform: scale(.985); } to { transform: none; } }
@keyframes step-in { from { transform: translateX(22px); } to { transform: none; } }
@keyframes step-in-back { from { transform: translateX(-22px); } to { transform: none; } }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/*
 * Safety net for the entrance animations.
 *
 * Every `rise` animation starts at `opacity: 0`, so anything that stops the
 * animation from finishing — a throttled background tab, a browser that pauses
 * compositing, a stalled paint — leaves the page permanently blank. The
 * animation is decoration; the content must not depend on it. A script adds
 * this class shortly after load, which puts everything back to its resting
 * state whether or not the animation ever ran.
 */
body.animations-settled .mark,
body.animations-settled h1,
body.animations-settled .lede,
body.animations-settled .cta,
body.animations-settled .reassure,
body.animations-settled .card {
  animation: none;
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/*
 * Entrance animations are opt-in.
 *
 * Every one of them starts at `opacity: 0`, so if an animation never runs the
 * element never appears. A throttled or backgrounded tab can freeze both
 * animations and timers, which made the whole page blank with no way to
 * recover. The resting state is now the visible one, and the script adds
 * `.animate` only once it is running — so the worst case is a page that
 * appears without the flourish.
 */
body.animate .mark { animation: mark-in .7s var(--ease) both; }
body.animate h1 { animation: rise .6s var(--ease) .08s both; }
body.animate .lede { animation: rise .6s var(--ease) .16s both; }
body.animate .cta { animation: rise .6s var(--ease) .24s both; }
body.animate .reassure { animation: rise .6s var(--ease) .32s both; }
body.animate .card { animation: rise .6s var(--ease) both; }
body.animate .card:nth-child(1) { animation-delay: .40s; }
body.animate .card:nth-child(2) { animation-delay: .48s; }
body.animate .card:nth-child(3) { animation-delay: .56s; }
body.animate .step-body { animation: step-in .38s var(--ease) both; }
body.animate .step-body.back { animation-name: step-in-back; }
body.animate .wizard { animation: wizard-in .35s var(--ease) both; }
body.animate .done-mark { animation: pop .5s var(--ease) both; }
