/* ==========================================================================
   WPS research prototypes — shared editor system
   --------------------------------------------------------------------------
   Two deliberately separate worlds live in this file:

   1. The editor chrome (`.ed-*`) — the calm, light "paper" surface where a
      client works. No trace of the client's website styling appears here, so
      "where I edit" and "how my site looks" never share a palette.
   2. The client site canvas (`.sc-*`) — the fictional Acme Co. site, a
      green-on-paper world shown only inside an explicit preview/canvas.

   Keeping them in one stylesheet with distinct prefixes makes the separation
   enforceable in code, not just in the design brief.
   ========================================================================== */

:root {
  /* Editor paper */
  --ed-bg: oklch(97% 0.004 110);
  --ed-surface: oklch(100% 0 0);
  --ed-surface-2: oklch(98.4% 0.004 110);
  --ed-ink: oklch(24% 0.012 150);
  --ed-ink-2: oklch(38% 0.012 150);
  --ed-muted: oklch(46% 0.011 150);
  --ed-line: oklch(89% 0.007 150);
  --ed-line-strong: oklch(62% 0.01 150);

  /* Content accent — a readable leaf green (brand lime is fills-only) */
  --ed-leaf: oklch(47% 0.11 145);
  --ed-leaf-soft: oklch(96% 0.03 135);

  /* Primary action — the brand lime, reserved for one CTA per view */
  --ed-cta-bg: oklch(92% 0.23 130);
  --ed-cta-ink: oklch(24% 0.09 140);

  /* Design-mode signal — amber boundary, never used in content mode */
  --ed-amber: oklch(48% 0.12 65);
  --ed-amber-soft: oklch(96% 0.035 75);

  --ed-danger: oklch(47% 0.16 28);
  --ed-focus: oklch(45% 0.11 145);

  --ed-radius: 12px;
  --ed-radius-lg: 18px;
  --ed-shadow: 0 1px 2px rgba(20, 24, 18, 0.05), 0 12px 34px rgba(20, 24, 18, 0.06);
  --ed-shadow-lg: 0 24px 70px rgba(20, 24, 18, 0.16);

  --ed-font: 'Geist', 'Geist Fallback', Arial, Helvetica, sans-serif;
  --ed-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Acme Co. site canvas */
  --sc-ink: oklch(20% 0.012 250);
  --sc-muted: oklch(49% 0.01 250);
  --sc-line: rgba(20, 24, 28, 0.1);
  --sc-paper: oklch(100% 0 0);
  --sc-brand-bg: oklch(96% 0.03 130);
  --sc-brand-ink: oklch(30% 0.05 130);
  --sc-dark-bg: oklch(22% 0.01 250);
  --sc-dark-ink: oklch(95% 0.01 130);
  --sc-accent: oklch(63% 0.13 130);
}

* { box-sizing: border-box; }

.ed-app {
  min-height: 100vh;
  background: var(--ed-bg);
  color: var(--ed-ink);
  font-family: var(--ed-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.ed-app button,
.ed-app input,
.ed-app textarea,
.ed-app select { font: inherit; color: inherit; }

.ed-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:where(.ed-app) :focus-visible {
  outline: 2px solid var(--ed-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- topbar -- */
.ed-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--ed-line);
  background: color-mix(in oklab, var(--ed-surface) 88%, transparent);
  backdrop-filter: blur(14px);
}

.ed-topbar--split { grid-template-columns: auto 1fr auto; }

.ed-backlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px 8px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ed-ink-2);
  font-size: 13px;
  font-weight: 520;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease;
}
.ed-backlink:hover { background: var(--ed-surface-2); border-color: var(--ed-line); }

.ed-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ed-doc__name {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ed-doc__path {
  color: var(--ed-muted);
  font-family: var(--ed-mono);
  font-size: 11px;
}

.ed-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  row-gap: 6px;
}

/* --------------------------------------------------------------- buttons -- */
.ed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ed-line);
  border-radius: 10px;
  background: var(--ed-surface);
  color: var(--ed-ink);
  font-size: 13px;
  font-weight: 560;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.ed-btn:hover { background: var(--ed-surface-2); border-color: var(--ed-line-strong); }
.ed-btn:active { transform: translateY(1px); }

.ed-btn--primary {
  border-color: transparent;
  background: var(--ed-cta-bg);
  color: var(--ed-cta-ink);
  font-weight: 640;
}
.ed-btn--primary:hover { background: oklch(88% 0.22 130); border-color: transparent; }

.ed-btn--ghost { border-color: transparent; background: transparent; color: var(--ed-ink-2); }
.ed-btn--ghost:hover { background: var(--ed-surface-2); }

.ed-btn--danger { color: var(--ed-danger); }
.ed-btn--danger:hover { background: oklch(96% 0.03 28); border-color: oklch(85% 0.06 28); }

.ed-iconbtn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ed-ink-2);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.ed-iconbtn:hover { background: var(--ed-surface-2); border-color: var(--ed-line); color: var(--ed-ink); }
.ed-iconbtn[aria-pressed='true'] { background: var(--ed-leaf-soft); border-color: color-mix(in oklab, var(--ed-leaf) 35%, transparent); color: var(--ed-leaf); }
.ed-iconbtn:disabled { opacity: 0.35; cursor: not-allowed; }

.ed-iconbtn--sm { width: 32px; height: 32px; border-radius: 8px; }

/* ------------------------------------------------------------- segmented -- */
.ed-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--ed-line);
  border-radius: 11px;
  background: var(--ed-surface-2);
  gap: 2px;
}
.ed-seg button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ed-muted);
  font-size: 12.5px;
  font-weight: 560;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.ed-seg button:hover { color: var(--ed-ink); }
.ed-seg button[aria-pressed='true'] { background: var(--ed-surface); color: var(--ed-ink); box-shadow: 0 1px 2px rgba(20, 24, 18, 0.08); }

.ed-seg--design button[aria-pressed='true'] { background: var(--ed-amber-soft); color: var(--ed-amber); box-shadow: none; }

/* --------------------------------------------------------------- fields -- */
.ed-field { display: grid; gap: 7px; }
.ed-field > span,
.ed-field > label { color: var(--ed-ink-2); font-size: 12.5px; font-weight: 560; letter-spacing: 0.01em; }
.ed-field input,
.ed-field textarea,
.ed-textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--ed-line-strong);
  border-radius: 10px;
  background: var(--ed-surface);
  color: var(--ed-ink);
  font-size: 14px;
  line-height: 1.55;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.ed-field input:hover,
.ed-field textarea:hover { border-color: var(--ed-ink-2); }
.ed-field input:focus,
.ed-field textarea:focus {
  outline: none;
  border-color: var(--ed-leaf);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ed-leaf) 18%, transparent);
}
.ed-field textarea { resize: vertical; }
.ed-field__hint { color: var(--ed-muted); font-size: 11.5px; }
.ed-field__count { justify-self: end; color: var(--ed-muted); font-family: var(--ed-mono); font-size: 11px; }

/* ----------------------------------------------------------------- misc -- */
.ed-eyebrow {
  color: var(--ed-muted);
  font-family: var(--ed-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ed-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--ed-line);
  border-radius: 999px;
  background: var(--ed-surface-2);
  color: var(--ed-ink-2);
  font-size: 11.5px;
  font-weight: 520;
}

.ed-purpose {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ed-leaf);
  font-family: var(--ed-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ed-card {
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius-lg);
  background: var(--ed-surface);
  box-shadow: var(--ed-shadow);
}

/* -------------------------------------------------------------- switch -- */
.ed-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.ed-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ed-switch__track {
  position: relative;
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--ed-line-strong);
  transition: background 160ms ease;
}
.ed-switch__track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  content: '';
  transition: transform 160ms ease;
}
.ed-switch input:checked + .ed-switch__track { background: var(--ed-leaf); }
.ed-switch input:checked + .ed-switch__track::after { transform: translateX(16px); }
.ed-switch input:focus-visible + .ed-switch__track { outline: 2px solid var(--ed-focus); outline-offset: 2px; }
.ed-switch__label { font-size: 13px; font-weight: 520; }
.ed-switch small { display: block; color: var(--ed-muted); font-size: 11.5px; font-weight: 400; }

/* ----------------------------------------------------------- popovers --- */
.ed-popover {
  position: absolute;
  z-index: 50;
  min-width: 260px;
  padding: 16px;
  border: 1px solid var(--ed-line);
  border-radius: var(--ed-radius);
  background: var(--ed-surface);
  box-shadow: var(--ed-shadow-lg);
}
.ed-popover__title { margin: 0 0 12px; font-family: var(--ed-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ed-muted); }
.ed-popover__row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 9px 0; }
.ed-popover__row + .ed-popover__row { border-top: 1px solid var(--ed-line); }

/* -------------------------------------------------------------- dialog -- */
.ed-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 20, 16, 0.42);
  backdrop-filter: blur(3px);
}
.ed-dialog {
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  border: 1px solid var(--ed-line);
  border-radius: 20px;
  background: var(--ed-surface);
  box-shadow: var(--ed-shadow-lg);
}
.ed-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 22px 16px;
}
.ed-dialog__head h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.ed-dialog__head p { margin: 6px 0 0; color: var(--ed-muted); font-size: 13px; }
.ed-dialog__body { padding: 0 22px 22px; }

/* --------------------------------------------------------------- toast -- */
.ed-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ed-ink);
  color: var(--ed-surface);
  font-size: 13px;
  box-shadow: var(--ed-shadow-lg);
  transform: translateX(-50%);
  animation: ed-toast-in 220ms ease;
}
.ed-toast button { border: 0; background: transparent; color: var(--ed-cta-bg); font-weight: 620; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@keyframes ed-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------------------- rail -- */
.ed-rail { min-width: 0; }
.ed-rail__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ed-rail__head h2 { margin: 0; font-family: var(--ed-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ed-muted); }
.ed-rail ol { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.ed-rail__item { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.ed-rail__item > button:first-child {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ed-ink-2);
  font-size: 13px;
  font-weight: 520;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.ed-rail__item > button:first-child:hover { background: var(--ed-surface-2); color: var(--ed-ink); }
.ed-rail__item[data-active='true'] > button:first-child { background: var(--ed-leaf-soft); color: var(--ed-leaf); font-weight: 600; }
.ed-rail__node { width: 7px; height: 7px; flex: none; border-radius: 2px; background: var(--ed-line-strong); }
.ed-rail__item[data-active='true'] .ed-rail__node { background: var(--ed-leaf); }

/* -------------------------------------------------- site canvas (.sc-*) -- */
.sc-site {
  overflow: hidden;
  border-radius: 14px;
  background: var(--sc-paper);
  color: var(--sc-ink);
  font-family: var(--ed-font);
}
.sc-nav { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 24px; border-bottom: 1px solid var(--sc-line); }
.sc-logo { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.sc-nav__links { display: flex; gap: 22px; color: var(--sc-muted); font-size: 12.5px; }
.sc-nav__cta { padding: 8px 12px; border-radius: 8px; background: var(--sc-ink); color: #fff; font-size: 11.5px; font-weight: 600; }
.sc-lock { display: inline-flex; align-items: center; gap: 6px; color: var(--sc-accent); font-family: var(--ed-mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; }

.sc-section { padding: 42px 40px; }
.sc-section[data-treatment='light'] { background: var(--sc-paper); color: var(--sc-ink); }
.sc-section[data-treatment='brand'] { background: var(--sc-brand-bg); color: var(--sc-brand-ink); }
.sc-section[data-treatment='dark'] { background: var(--sc-dark-bg); color: var(--sc-dark-ink); }
.sc-section[data-active='true'] { position: relative; }

.sc-eyebrow { display: block; margin-bottom: 8px; color: var(--sc-accent); font-family: var(--ed-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }
/* The brand accent is tuned for the plain canvas; on the lighter brand wash it
   drops to ~3:1, so use a deeper leaf tone inside accented sections. */
[data-treatment='brand'] .sc-eyebrow { color: oklch(42% 0.1 145); }
.sc-heading { margin: 0; max-width: 22ch; font-size: clamp(24px, 3.4vw, 34px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.sc-body { max-width: 52ch; margin: 12px 0 0; color: var(--sc-muted); font-size: 14px; line-height: 1.65; }
[data-treatment='brand'] .sc-body,
[data-treatment='brand'] .sc-card p,
[data-treatment='brand'] .sc-person span,
[data-treatment='dark'] .sc-body,
[data-treatment='dark'] .sc-card p,
[data-treatment='dark'] .sc-person span { color: inherit; opacity: 0.78; }
.sc-cta { display: inline-block; margin-top: 18px; padding: 10px 16px; border-radius: 9px; background: var(--sc-ink); color: #fff; font-size: 13px; font-weight: 640; }
.sc-section[data-treatment='dark'] .sc-cta { background: #fff; color: var(--sc-dark-bg); }

.sc-hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.85fr); gap: 28px; align-items: center; }
.sc-hero__img { min-height: 190px; border-radius: 12px; background: linear-gradient(140deg, #d8ddd1, #aab29b); }
.sc-hero[data-layout='image-led'] .sc-hero__img { order: -1; }

.sc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sc-grid[data-layout='editorial'] { grid-template-columns: 1fr; gap: 0; }
.sc-grid[data-layout='photos'] .sc-card::before { display: block; height: 76px; margin: 0 0 12px; border-radius: 9px; background: linear-gradient(140deg, #d8ddd1, #aab29b); content: ''; }
.sc-card { padding: 18px 16px; border: 1px solid var(--sc-line); border-radius: 12px; }
.sc-grid[data-layout='editorial'] .sc-card { border: 0; border-top: 1px solid var(--sc-line); border-radius: 0; padding: 16px 0; }
.sc-card strong { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 620; }
.sc-card p { margin: 0; color: var(--sc-muted); font-size: 12.5px; line-height: 1.55; }

.sc-quote { max-width: 46ch; font-size: 19px; font-weight: 500; line-height: 1.45; letter-spacing: -0.01em; }
.sc-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(140deg, #d8ddd1, #aab29b); }
.sc-person { display: inline-flex; align-items: center; gap: 10px; margin-top: 16px; }
.sc-person strong { display: block; font-size: 13px; }
.sc-person span { color: var(--sc-muted); font-size: 11.5px; }
/* Card outlines are tuned for the plain canvas; on brand/dark sections the
   default hairline disappears, so re-point it at the treatment ink. Declared
   here, after the layout variants, so it also wins for the editorial grid. */
[data-treatment='brand'] .sc-grid .sc-card,
[data-treatment='dark'] .sc-grid .sc-card { border-color: color-mix(in oklab, currentColor 22%, transparent); }

@media (max-width: 760px) {
  .ed-topbar { grid-template-columns: 1fr auto; }
  .ed-doc { justify-content: flex-end; }
  .ed-actions { grid-column: 1 / -1; flex-wrap: wrap; justify-content: flex-start; }
  .sc-hero { grid-template-columns: 1fr; }
  .sc-grid, .sc-grid[data-layout='photos'] { grid-template-columns: 1fr; }
  .sc-nav__links { display: none; }
  .ed-dialog__body > div[style*='grid-template-columns'] { grid-template-columns: 1fr !important; }
}

/* Comfortable 44px touch targets on touch devices, where icons stay visible. */
@media (pointer: coarse) {
  .ed-btn { min-height: 44px; }
  .ed-iconbtn { width: 44px; height: 44px; }
  .ed-iconbtn--sm { width: 44px; height: 44px; }
  .ed-seg button { min-height: 40px; }
  .ed-rail__item > button:first-child { min-height: 44px; }
  .ed-app .tone__opt { min-height: 44px; }
  .ed-app .job__opt { min-height: 44px; padding: 15px; }
  .ed-app .design__chip { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
