/* Editor page only. Loaded after site.css, which owns every token used here.

   The page sells a tool that lets a client click a sentence on their own live
   page and retype it, so the page lets you do exactly that to itself. Two moves
   and no more: the live demo, and the x-ray that answers "what can I change?"
   for the whole page at once. Everything below serves one of those two. */

:root {
  /* The console's real rail width. One source of truth for the panel, the
     page's margin, and the x-ray legend's offset. */
  --rail-w: 248px;
}

/* ---------- 1. the rail ---------- */
/* A faithful reduction of the real console rail: same 248px, same ink, same
   mono, same vertical order. It is the product, not a drawing of it. */

.rig {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  z-index: 60;
  display: flex;
  flex-direction: column;
  font-family: var(--mono);
  transform: translateX(-100%);
  visibility: hidden;
}
.rig[data-on] { transform: none; visibility: visible; }

/* The page steps aside for the rail, exactly as a client's site does. That
   shift is the clearest single statement the page makes about what the tool
   is, so it is worth the disruption. */
body { transition: none; }
html.rig-on body { margin-left: var(--rail-w); }

.rig__head { padding: 18px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.rig__mark { width: 18px; height: 18px; flex-shrink: 0; position: relative; }
.rig__mark::before, .rig__mark::after {
  content: ''; position: absolute; width: 7px; height: 7px;
}
.rig__mark::before { top: 0; left: 0; border-top: 1.5px solid var(--sage); border-left: 1.5px solid var(--sage); }
.rig__mark::after { bottom: 0; right: 0; border-bottom: 1.5px solid var(--sage); border-right: 1.5px solid var(--sage); }
.rig__name { font-size: 11px; font-weight: 700; letter-spacing: 0.2em; color: var(--text); line-height: 1.3; }
.rig__site { font-size: 10px; color: var(--text-body); display: block; letter-spacing: 0; font-weight: 400; }

.rig__draft { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 10px; color: var(--text-body); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.rig__tabs { display: flex; border-bottom: 1px solid var(--border); }
/* A class rule with display beats the UA stylesheet's [hidden], so every part
   of the rail that sets display needs to say so itself. */
.rig__tabs[hidden], .rig__go[hidden], .rig__draft[hidden] { display: none; }
.rig__tabs button {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-body); font: 400 10px/1 var(--mono); letter-spacing: 0.1em;
  text-transform: uppercase; padding: 12px 4px; cursor: pointer;
}
.rig__tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--sage); }
.rig__tabs i { font-style: normal; color: var(--sage); }

.rig__body { flex: 1 1 auto; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.rig__pane { display: none; padding: 14px 16px; }
.rig__pane[data-on] { display: block; }
.rig__hint { font-size: 11px; line-height: 1.6; color: var(--text-body); margin: 0; }

/* Pages pane: the sections of this page, which is what "Pages" means here. */
.rig__list { list-style: none; margin: 0; padding: 0; }
.rig__list button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text-body); font: 400 12px/1.4 var(--mono); padding: 9px 0; cursor: pointer;
}
.rig__list button:hover { color: var(--sage); }
.rig__list button[aria-current="true"] { color: var(--text); }

/* Photos pane: four real project shots, so the library is also the portfolio. */
.rig__tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rig__tile { padding: 0; background: var(--chip); border: 1px solid transparent; cursor: pointer; display: block; }
.rig__tile img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.rig__tile span { display: block; font-size: 9px; color: var(--text-body); padding: 4px 5px; text-align: left; }
.rig__tile:hover, .rig__tile:focus-visible { border-color: var(--sage); }
.rig__tile[aria-pressed="true"] { border-color: var(--sage); }
.rig__tile[aria-pressed="true"] span { color: var(--sage); }

/* Review: the list that stands between a change and the internet. */
.rig__chg { border-top: 1px solid var(--border-inner); padding: 12px 0; }
.rig__chg:first-child { border-top: 0; }
.rig__chg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.rig__chg-where { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-label); }
.rig__chg button {
  background: none; border: 1px solid var(--border); color: var(--text-body);
  font: 400 9px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 7px; cursor: pointer; flex-shrink: 0;
}
.rig__chg button:hover { border-color: var(--sage); color: var(--sage); }
.rig__was { font-size: 11px; line-height: 1.5; color: var(--text-label); text-decoration: line-through; margin: 0 0 4px; }
.rig__now { font-size: 11px; line-height: 1.5; color: var(--text-em); margin: 0; border-left: 2px solid var(--sage); padding-left: 8px; }
.rig__swap { display: flex; align-items: center; gap: 8px; }
.rig__swap img { width: 56px; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.rig__swap img:first-child { opacity: 0.45; }
.rig__swap em { font-style: normal; color: var(--text-label); }

.rig__foot { border-top: 1px solid var(--border); padding: 12px 16px 16px; }
.rig__ask { font-size: 10px; color: var(--text-body); margin: 0 0 12px; }
.rig__ask a { color: var(--sage); text-decoration: underline; text-underline-offset: 2px; }
.rig__count { font-size: 11px; color: var(--text-em); margin: 0 0 4px; }
.rig__count b { color: var(--text); font-weight: 700; }
.rig__state { font-size: 10px; color: var(--text-body); margin: 0 0 12px; display: flex; align-items: center; gap: 6px; }
.rig__state .dot { width: 5px; height: 5px; }
.rig__go {
  width: 100%; border: 0; background: var(--sage); color: var(--bg);
  font: 700 11px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 13px 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.rig__go[disabled] { background: var(--chip); color: var(--text-label); cursor: default; }
.rig__go:not([disabled]):hover { background: #9db59c; }
.rig__back {
  background: none; border: 0; color: var(--text-body); font: 400 10px/1 var(--mono);
  padding: 10px 16px; cursor: pointer; text-align: left; width: 100%;
  border-bottom: 1px solid var(--border);
}
.rig__back:hover { color: var(--sage); }

/* ---------- 2. the chrome, ported from the console ---------- */
/* Lifted from lgd-editor/src/editor/chrome.html rather than reinvented, so the
   demo behaves exactly like the product: nothing is marked at rest, hovering
   raises the brackets, the marching ants and a chip that follows the cursor,
   and clicking swaps the ants for a cut-out scrim over everything except the
   thing being edited.

   An earlier version outlined every editable region as soon as the rail opened.
   It made the demo discoverable and it was a lie about the product, which is
   the one thing this page cannot afford.

   Token mapping: the console's --ed-sage and --ed-ink are the same values as
   the studio's --sage and --bg, and its bundled LGD Mono is Space Mono, so
   these are the site's own tokens rather than copies. */

.demo-layer { position: fixed; inset: 0; z-index: 59; pointer-events: none; }

/* The scrim, with a hole cut where the target is. Committed state only: firing
   it on hover strobes as the cursor crosses regions, and a sustained dim should
   mean "this is what you are editing", not "this is what you are near". */
#demo-scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0;
  backdrop-filter: blur(1.5px) saturate(0.78);
  -webkit-backdrop-filter: blur(1.5px) saturate(0.78);
  background: rgba(26, 26, 26, 0.25);
  -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
  -webkit-mask-position: 0 0, var(--hx, -9999px) var(--hy, -9999px);
  mask-position: 0 0, var(--hx, -9999px) var(--hy, -9999px);
  -webkit-mask-size: 100% 100%, var(--hw, 0) var(--hh, 0);
  mask-size: 100% 100%, var(--hw, 0) var(--hh, 0);
  -webkit-mask-repeat: no-repeat, no-repeat;
  mask-repeat: no-repeat, no-repeat;
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
#demo-scrim.on { opacity: 1; }

/* top/left pinned so offsets are from the viewport origin. Without them a fixed
   element starts at its static position, which the rail has already pushed
   248px right, putting every bracket off target. */
#demo-frame {
  position: fixed; top: 0; left: 0; z-index: 2; pointer-events: none;
  opacity: 0;
}
#demo-frame.on { opacity: 1; }
#demo-frame .ants {
  position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  opacity: 0;
  filter: drop-shadow(0 0 1px rgba(0,0,0,.6)) drop-shadow(0 0 2px rgba(255,255,255,.4));
}
#demo-frame.hovering .ants { opacity: 1; }
#demo-frame .ants rect {
  fill: none; stroke: var(--sage); stroke-width: 1.5;
  stroke-dasharray: 5 7;
}
/* Two shadows, one dark one light, so the sage tick stays visible on a
   near-black site and on a cream one. Cheaper than drawing two layers. */
#demo-frame i {
  position: absolute; width: 12px; height: 12px; border: 0 solid var(--sage);
  filter: drop-shadow(0 0 1px rgba(0,0,0,.65)) drop-shadow(0 0 2px rgba(255,255,255,.45));
}
#demo-frame i:nth-child(2) { top: -5px; left: -5px; border-top-width: 2px; border-left-width: 2px; }
#demo-frame i:nth-child(3) { top: -5px; right: -5px; border-top-width: 2px; border-right-width: 2px; }
#demo-frame i:nth-child(4) { bottom: -5px; left: -5px; border-bottom-width: 2px; border-left-width: 2px; }
#demo-frame i:nth-child(5) { bottom: -5px; right: -5px; border-bottom-width: 2px; border-right-width: 2px; }

/* Dark chip, light text, readable on a near-black site and on a cream one. The
   outer light ring is what separates it from a dark background. */
#demo-chip {
  position: fixed; top: 0; left: 0; z-index: 7; pointer-events: none;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--sage);
  box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 6px 22px rgba(0,0,0,.45);
  font: 700 10px/1 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  opacity: 0; transform: translate3d(-9999px, -9999px, 0);
}
#demo-chip.on { opacity: 1; }
#demo-chip .dot { width: 6px; height: 6px; background: var(--sage); flex: 0 0 auto; border-radius: 0; }
#demo-chip .count { color: #8a8a8a; letter-spacing: .12em; }
#demo-chip.locked { background: var(--sage); color: var(--bg); }
#demo-chip.locked .dot { background: var(--bg); }
#demo-chip.locked .count { color: rgba(26,26,26,.62); }
#demo-chip.over { background: #c9833f; border-color: #e0a05a; color: #1a1a1a; }
#demo-chip.over .dot { background: #1a1a1a; }
#demo-chip.over .count { color: rgba(26,26,26,.75); }

/* The page's own styles stay untouched: the browser's focus ring on a live node
   would be a second frame around the one the chrome is already drawing. */
[data-ed-live] { outline: none !important; }
.ed[contenteditable="true"] { caret-color: var(--sage); }
.ed--photo { display: block; }
.ed--photo img { display: block; width: 100%; height: auto; }

/* ---------- 3. x-ray ---------- */
/* One control, one whole-page answer. Everything recedes except what a client
   can reach, which is the argument this page exists to make.

   Done with a scrim rather than by dimming sections, because opacity on a
   parent cannot be undone by a child: a section at 0.2 would take its editable
   regions down with it. A fixed scrim above the nav and below the rail, with
   the editable nodes raised through it, is the only version that actually
   lights them. */

.xray-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(20, 20, 20, 0.86);
  -webkit-backdrop-filter: saturate(0.25);
  backdrop-filter: saturate(0.25);
  opacity: 0; visibility: hidden;
}
html.xray .xray-scrim { opacity: 1; visibility: visible; }

html.xray .ed {
  position: relative; z-index: 56;
  background: var(--bg);
  outline: 1.5px solid var(--sage); outline-offset: 7px;
  box-shadow: 0 0 0 7px var(--bg);
}
html.xray .ed--photo { box-shadow: none; }

.xray-legend {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 58; background: var(--bg-alt); border: 1px solid var(--border);
  padding: 16px 22px; display: none; gap: 12px 24px; align-items: center;
  font: 400 11px/1.5 var(--mono); color: var(--text-body);
  max-width: calc(100vw - 48px); flex-wrap: wrap;
}
html.xray .xray-legend { display: flex; }
html.rig-on .xray-legend { left: calc(50% + (var(--rail-w) / 2)); }
.xray-legend b { color: var(--text); font-weight: 400; }
.xray-legend .key { display: inline-flex; align-items: center; gap: 9px; }
.xray-legend .sw { width: 15px; height: 15px; flex-shrink: 0; }
.xray-legend .sw--yes { border: 1.5px solid var(--sage); background: rgba(143, 166, 142, 0.14); }
.xray-legend .sw--no {
  border: 1px solid var(--border);
  background: repeating-linear-gradient(135deg, #3a3a3a 0 2px, #242424 2px 5px);
}
.xray-legend button {
  background: none; border: 1px solid var(--border); color: var(--text-body);
  font: 400 10px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  padding: 9px 12px; cursor: pointer;
}
.xray-legend button:hover { border-color: var(--sage); color: var(--sage); }

/* The headline's two halves each take a line, so each gets a clean rectangle
   instead of a staircase around wrapped inline fragments. */
.h1-inner .ed { display: block; }

.when-on { display: none; }
html.rig-on .when-on { display: inline-flex; }
html.rig-on .when-off { display: none; }

/* ---------- 3b. odds the markup needs ---------- */

/* Review and the published notice take over the body of the rail rather than
   opening somewhere else, which is what the real console does. */
.rig__sheet { display: block; flex: 1 1 auto; overflow-y: auto; }
.rig__sheet[hidden] { display: none; }
.rig__done-h { font: 700 13px/1.4 var(--mono); color: var(--text); margin: 0 0 10px; }
.rig__go--quiet { background: none; border: 1px solid var(--border); color: var(--text-body); }
.rig__go--quiet:hover { border-color: var(--sage); color: var(--sage); background: none; }
.rig__draft button {
  background: none; border: 0; color: var(--text-body); font: 400 10px/1 var(--mono);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 0;
}
.rig__draft button:hover { color: var(--sage); }

/* In x-ray a photo target sits inside a frame box that clips, so its marking
   goes inward rather than out. The hover chrome has no such problem: it draws
   on its own fixed layer above the page. */
html.xray .ed--photo { outline-offset: -3px; }

.xray-cta { margin-bottom: 36px; }
.em-quiet { color: var(--text-em); font-weight: 400; }
.cell-h { font-size: 17px; margin: 0; }
.panel-h { font-size: 20px; margin: 0; }
.panel-p { margin: 0; }
.faq-h { margin-bottom: 48px; }

/* ---------- 4. page furniture ---------- */

.try-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 40px; }
.try-note { font-size: 12px; color: var(--text-label); }

.ed-hero { display: flex; flex-wrap: wrap; gap: 48px 64px; align-items: center; }
.ed-hero__copy { flex: 1 1 440px; min-width: 0; max-width: 620px; }
.ed-hero__shot { flex: 0 1 380px; min-width: 0; }

.shot--ui { height: auto; object-fit: contain; }

.proof { display: flex; flex-direction: column; gap: 80px; }
.proof__row > .frame { display: block; }
.proof__head { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: start; margin-bottom: 28px; }
.proof__head > div { flex: 0 1 320px; }
.proof__head > p { flex: 1 1 420px; min-width: 0; max-width: 620px; margin: 0; }
.proof__head h3 { font-size: 24px; margin: 0; }

.dash-list--muted li::before { color: var(--text-label); }

.demo-only { display: none; }
html.js .demo-only { display: revert; }
html.js .demo-only.try-row { display: flex; }
html:not(.js) .no-js-note { display: block; }
.no-js-note { display: none; }

/* ---------- 5. small screens ---------- */
/* Declared before the media block below: a bare rule of equal specificity
   placed after it would win, and the note would never show. */
.narrow-note {
  display: none; font-size: 12px; color: var(--text-label); margin-top: 32px;
  border-left: 2px solid var(--sage); padding-left: 16px; max-width: 560px;
}
/* The demo needs the page beside the rail, which is the same constraint the
   real tool has. Under 900px the page says so rather than running a cramped
   version of it, which is also the honest preview of the product's own floor. */

@media (max-width: 899px) {
  .rig, .xray-legend, .demo-layer { display: none !important; }
  html.rig-on body { margin-left: 0; }
  html.xray .ed { outline: 0; box-shadow: none; }
  .xray-scrim { display: none !important; }
  /* The x-ray needs the scrim and the outlines, both switched off above, so
     its button would be a control that does nothing. */
  .try-row, .xray-cta { display: none !important; }
  .narrow-note { display: block; }
}

/* ---------- 6. motion ---------- */
/* Three layers, per the studio standard: declare transitions only under
   no-preference, switch them off again under reduce, and let the script check
   matchMedia before it animates anything itself.

   The chrome's timings are the console's, to the millisecond. */

@media (prefers-reduced-motion: no-preference) {
  .rig { transition: transform .45s cubic-bezier(.2,.7,.2,1), visibility 0s linear 0s; }
  .rig:not([data-on]) { transition: transform .45s cubic-bezier(.2,.7,.2,1), visibility 0s linear .45s; }
  html.rig-on body, body { transition: margin-left .45s cubic-bezier(.2,.7,.2,1); }

  #demo-frame {
    transition: opacity 180ms ease,
                left 200ms cubic-bezier(.2,.7,.2,1),
                top 200ms cubic-bezier(.2,.7,.2,1);
  }
  #demo-frame .ants { transition: opacity 200ms ease; }
  #demo-chip { transition: opacity 160ms ease; }
  #demo-scrim { transition: opacity 260ms ease; }

  .xray-scrim { transition: opacity .35s ease, visibility 0s linear 0s; }
  html:not(.xray) .xray-scrim { transition: opacity .35s ease, visibility 0s linear .35s; }
}

/* 5 + 7 = 12, so travelling 24 lands exactly two patterns on and loops
   seamlessly. */
#demo-frame .ants rect { animation: demo-ants 3.2s linear infinite; }
@keyframes demo-ants { to { stroke-dashoffset: -24; } }

@media (prefers-reduced-motion: reduce) {
  .rig, body, #demo-frame, #demo-chip, #demo-scrim, .xray-scrim {
    transition: none !important;
  }
  #demo-frame .ants rect { animation: none; }
}
