/* luban.css — interactive Lỗ Ban ruler widget (loaded only on the app-lo-ban template). */

.mw-luban {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-card);
  background: var(--bg-panel);
  overflow: hidden;
  box-shadow: var(--shadow-terminal);
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.mw-luban__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-titlebar);
}
.mw-luban__dots { display: flex; gap: 7px; align-items: center; flex: none; }
.mw-luban__group { display: flex; gap: 4px; align-items: center; }

.mw-luban__btn {
  font: 600 12px var(--font-mono);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.mw-luban__btn:hover { color: var(--text); border-color: var(--border-ghost); }
.mw-luban__btn.is-active {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--bg);
}

.mw-luban__input {
  width: 96px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  font: 700 14px var(--font-mono);
  color: var(--text);
  text-align: right;
  transition: border-color .2s;
}
.mw-luban__input:focus { outline: none; border-color: var(--orange); }
/* Chrome/Safari show spin buttons on number inputs — they break the terminal look */
.mw-luban__input::-webkit-outer-spin-button,
.mw-luban__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mw-luban__input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.mw-luban__hint {
  font: 400 11px var(--font-mono);
  color: var(--text-faint);
  margin-left: auto;
}

/* ── Canvas ──────────────────────────────────────────────────── */
.mw-luban__stage { position: relative; }

.mw-luban__canvas {
  display: block;
  width: 100%;
  cursor: grab;
  touch-action: pan-y;   /* horizontal drag is ours; vertical stays with the page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mw-luban__canvas.is-dragging { cursor: grabbing; }
.mw-luban__canvas:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

/* ── Loading / failure state ─────────────────────────────────────
   The dataset is fetched, so there is a brief moment with no ruler. */
.mw-luban__state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font: 500 13px var(--font-mono);
  color: var(--text-faint);
  text-align: center;
  padding: 16px;
}
.mw-luban__state-error { display: none; color: var(--red); }

/* Ruler is up: nothing to say. */
.mw-luban.is-ready .mw-luban__state { display: none; }

/* Fetch failed: swap the message, and don't imply the canvas is still coming. */
.mw-luban.is-failed .mw-luban__state-loading { display: none; }
.mw-luban.is-failed .mw-luban__state-error { display: block; }
.mw-luban.is-failed .mw-luban__canvas,
.mw-luban:not(.is-ready) .mw-luban__canvas { opacity: .25; }
.mw-luban.is-ready .mw-luban__canvas { opacity: 1; transition: opacity .25s; }

/* ── "web demo stops at 10 m" notice ─────────────────────────────
   A centred dialog over a dimming scrim. The ruler underneath is a busy
   field of orange blocks — a small bar sitting on top of it disappeared,
   so the whole canvas recedes instead. */
.mw-luban__limit {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(11, 14, 20, .74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  /* The scrim must not swallow drags — only the card is interactive. */
  pointer-events: none;
  /* Hidden but still in the a11y tree so role="status" can announce it */
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.mw-luban__limit.is-open { opacity: 1; visibility: visible; }

.mw-luban__limit-card {
  pointer-events: auto;
  position: relative;
  max-width: 480px;
  width: 100%;
  padding: 26px 28px 24px;
  text-align: center;
  border: 1px solid rgba(var(--orange-rgb), .55);
  border-radius: var(--r-card);
  background: linear-gradient(180deg, #161009, var(--bg-panel));
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .95),
              0 0 60px -20px rgba(var(--orange-rgb), .35);
  transform: translateY(10px) scale(.97);
  transition: transform .28s var(--ease-out);
}
.mw-luban__limit.is-open .mw-luban__limit-card { transform: none; }

.mw-luban__limit-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  font-size: 22px;
  line-height: 1;
  color: var(--orange);
  border-radius: 50%;
  background: rgba(var(--orange-rgb), .14);
  border: 1px solid rgba(var(--orange-rgb), .4);
}

.mw-luban__limit-title {
  display: block;
  font: 700 17px var(--font-mono);
  line-height: 1.4;
  color: var(--orange);
  letter-spacing: -.2px;
}

.mw-luban__limit-body {
  margin: 10px 0 20px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-strong);
}

.mw-luban__limit-cta {
  display: inline-block;
  font: 600 14px var(--font-mono);
  background: var(--orange);
  color: var(--bg);
  text-decoration: none;
  padding: 13px 24px;
  border-radius: var(--r-btn);
  transition: transform .2s, box-shadow .2s;
}
.mw-luban__limit-cta:hover {
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -8px rgba(var(--orange-rgb), .6);
}

.mw-luban__limit-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  font: 400 20px/1 var(--font-mono);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.mw-luban__limit-close:hover {
  color: var(--text);
  border-color: var(--border-ghost);
  background: rgba(255, 255, 255, .06);
}

@media (max-width: 560px) {
  .mw-luban__limit-card { padding: 22px 20px 20px; }
  .mw-luban__limit-icon { width: 40px; height: 40px; font-size: 19px; margin-bottom: 12px; }
  .mw-luban__limit-title { font-size: 15px; }
  .mw-luban__limit-body { font-size: 14px; margin-bottom: 18px; }
  .mw-luban__limit-cta { width: 100%; padding: 13px 16px; }
}

/* ── Results ─────────────────────────────────────────────────── */
.mw-luban__results {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.mw-luban__row {
  display: flex;
  gap: 6px 14px;
  align-items: baseline;
  padding: 9px 14px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.mw-luban__row:first-child { border-top: 0; }
.mw-luban__rname {
  font: 600 12px var(--font-mono);
  color: var(--text-muted);
  flex: none;
  min-width: 172px;
}
.mw-luban__verdict {
  font: 500 13px var(--font-mono);
  flex: 1;
  min-width: 240px;
  line-height: 1.55;
}
.mw-luban__verdict.is-good { color: var(--green); }
.mw-luban__verdict.is-bad { color: var(--red); }

.mw-luban__cap {
  text-align: center;
  font: 400 11.5px var(--font-mono);
  color: var(--text-faint);
  margin-top: 10px;
}

@media (max-width: 640px) {
  .mw-luban__hint { display: none; }
  .mw-luban__rname { min-width: 0; }
  .mw-luban__input { width: 84px; }
}
