/* THE EMBED DEMO PAGE (go.rcsbuilder.com/rcs/embed/) - what the RCS emulator embed can do, live.
   Its own tokens, light and dark; nothing here reaches the embedded conversation (that is the frame's own page). */

:root {
  --pg-bg: #f6f7f9;
  --pg-surface: #ffffff;
  --pg-surface-2: #eef1f5;
  --pg-text: #15191f;
  --pg-text-2: #4a5462;
  --pg-line: #dde2e9;
  --pg-accent: #1a73e8;
  --pg-accent-text: #ffffff;
  --pg-good: #0b7d5b;
  --pg-warn: #9a5b00;
  --pg-warn-bg: #fff4e0;
  --pg-real-bg: #e8f3ee;
  --pg-code-bg: #0f141b;
  --pg-code-text: #e6edf3;
  --pg-focus: 0 0 0 3px rgba(26, 115, 232, .45);
  --pg-radius: 12px;
  --pg-font: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --pg-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pg-bg: #0d1117;
    --pg-surface: #151b23;
    --pg-surface-2: #1d2530;
    --pg-text: #e6edf3;
    --pg-text-2: #9aa7b6;
    --pg-line: #2a3441;
    --pg-accent: #6ea8fe;
    --pg-accent-text: #08111f;
    --pg-good: #4cc79a;
    --pg-warn: #f0b35c;
    --pg-warn-bg: #2a2112;
    --pg-real-bg: #10261d;
    --pg-code-bg: #0a0e13;
    --pg-code-text: #e6edf3;
    --pg-focus: 0 0 0 3px rgba(110, 168, 254, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--pg-bg);
  color: var(--pg-text);
  font-family: var(--pg-font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--pg-accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: var(--pg-focus);
}

.skip { position: absolute; left: -999px; top: 8px; background: var(--pg-surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 16px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

header.top { padding: 32px 0 8px; }
.eyebrow { margin: 0 0 6px; font: 600 12px/1.4 var(--pg-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--pg-text-2); }
h1 { margin: 0 0 10px; font-size: clamp(26px, 4vw, 38px); line-height: 1.12; letter-spacing: -.01em; }
.lede { margin: 0 0 14px; max-width: 72ch; color: var(--pg-text-2); font-size: 16px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; list-style: none; font-size: 14px; }

h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { margin: 0 0 16px; color: var(--pg-text-2); max-width: 80ch; }

section.block { padding: 28px 0; border-top: 1px solid var(--pg-line); }
section.block:first-of-type { border-top: 0; }

/* ── the live area: the phone beside its controls ── */
.live { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 28px; align-items: start; }
.phone-col { display: flex; flex-direction: column; align-items: center; gap: 12px; position: sticky; top: 16px; }
#phone { width: 100%; display: flex; justify-content: center; min-height: 200px; }
.phone-note { margin: 0; font-size: 13px; color: var(--pg-text-2); text-align: center; max-width: 392px; }

.panel {
  background: var(--pg-surface);
  border: 1px solid var(--pg-line);
  border-radius: var(--pg-radius);
  padding: 18px;
}
.panel + .panel { margin-top: 16px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .legend { font-size: 13px; font-weight: 600; color: var(--pg-text); }
.hint { font-size: 12.5px; color: var(--pg-text-2); margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type="text"], .row > input[type="url"], .row > input[type="search"] { flex: 1 1 140px; min-width: 0; }

input[type="text"], input[type="url"], input[type="search"], select {
  font: inherit; font-size: 14px;
  color: var(--pg-text); background: var(--pg-surface);
  border: 1px solid var(--pg-line); border-radius: 8px;
  padding: 8px 10px; min-height: 38px;
}
select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
input[type="color"] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--pg-line); border-radius: 8px; background: var(--pg-surface); }

button, .btn {
  font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 8px; padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--pg-line); background: var(--pg-surface-2); color: var(--pg-text);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary, .btn.primary { background: var(--pg-accent); color: var(--pg-accent-text); border-color: transparent; }
button:disabled { opacity: .55; cursor: not-allowed; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--pg-line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--pg-line); background: var(--pg-surface); font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--pg-accent); color: var(--pg-accent-text); }

/* The real / test drive switch says what it does, in words, beside it. */
.mode { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--pg-warn-bg); }
.mode.real { background: var(--pg-real-bg); }
.mode input { width: 20px; height: 20px; margin: 2px 0 0; flex: 0 0 auto; }
.mode b { display: block; }
.mode span { font-size: 13px; color: var(--pg-text-2); }

.choices { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.choices button { font-weight: 500; font-size: 13px; min-height: 32px; padding: 4px 10px; }

/* ── the event log ── */
.log {
  margin: 0; padding: 10px 12px; height: 260px; overflow: auto;
  background: var(--pg-code-bg); color: var(--pg-code-text);
  border-radius: 10px; font: 12.5px/1.55 var(--pg-mono); white-space: pre-wrap; word-break: break-word;
}
/* The events playground's switches: one per event of the standard (pressed = shown in the log). */
.ev-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.ev-filter button { font: 12px/1 var(--pg-mono); min-height: 28px; padding: 4px 9px; }
.ev-filter button[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.ev-copy { margin-top: 8px; }
.log .ev { color: #7ee2b8; }
.log .err { color: #ff9a8f; }
.log .cmd { color: #9ccbff; }

/* ── snippets ── */
.snip { position: relative; margin: 0 0 16px; }
.snip pre {
  margin: 0; padding: 14px 16px; overflow: auto; max-height: 360px;
  background: var(--pg-code-bg); color: var(--pg-code-text);
  border-radius: 10px; font: 12.5px/1.6 var(--pg-mono);
}
.snip .copy { position: absolute; top: 8px; right: 8px; min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tabs button[aria-selected="true"] { background: var(--pg-accent); color: var(--pg-accent-text); border-color: transparent; }

/* ── the three looks, side by side ── */
.looks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.look { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.look .frame { width: 100%; display: flex; justify-content: center; min-height: 120px; }
.look p { margin: 0; font-size: 13px; color: var(--pg-text-2); text-align: center; }

.status { font-size: 13px; color: var(--pg-text-2); min-height: 1.5em; margin: 6px 0 0; }
.status.bad { color: var(--pg-warn); }

/* Read by a screen reader, never drawn. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ── design it (design.js) ── */
.panel.design { display: flex; flex-direction: column; gap: 14px; }
.panel.design h3 { margin: 0; }
.starters { display: flex; flex-wrap: wrap; gap: 6px; }
.starters button { font-weight: 500; font-size: 13px; min-height: 32px; padding: 4px 12px; border-radius: 999px; }
.starters button[aria-pressed="true"] { background: var(--pg-accent); color: var(--pg-accent-text); border-color: transparent; }
textarea {
  font: 13px/1.55 var(--pg-mono); color: var(--pg-code-text); background: var(--pg-code-bg);
  border: 1px solid var(--pg-line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 150px; resize: vertical;
  tab-size: 2;
}
.verdict { font-size: 13px; border-radius: 10px; }
.verdict:empty { display: none; }
.verdict p { margin: 0; font-weight: 600; }
.verdict ul { margin: 6px 0 0; padding-left: 18px; font-family: var(--pg-mono); font-size: 12px; overflow-wrap: anywhere; }
.verdict.good, .verdict.bad, .verdict.warn, .verdict.busy { padding: 10px 12px; }
.verdict.good { background: var(--pg-real-bg); color: var(--pg-good); }
.verdict.bad, .verdict.warn { background: var(--pg-warn-bg); color: var(--pg-warn); }
.verdict.busy { background: var(--pg-surface-2); color: var(--pg-text-2); }
#inspect[aria-pressed="true"] { background: var(--pg-accent); color: var(--pg-accent-text); border-color: transparent; }
#inspect-out { overflow-wrap: anywhere; }

/* ── the sample page ── */
.sample { margin-top: 18px; border: 1px solid var(--pg-line); border-radius: var(--pg-radius); overflow: hidden; background: #fbf8f2; color: #2b2620; }
.sample-bar { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; align-items: baseline; padding: 14px 18px; background: #2f4a3a; color: #f4efe4; }
.sample-bar span { font-size: 13px; opacity: .85; }
.sample-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 24px; padding: 22px 18px; align-items: start; }
.sample-copy h3 { font-size: 22px; margin: 0 0 8px; }
.sample-copy p { margin: 0 0 12px; max-width: 52ch; }
.sample-copy a { color: #2f6b4a; }
.sample-copy .hint { color: #6b6257; }
.sample-inline { display: flex; justify-content: center; min-width: 0; }

/* ── the defaults ── */
#defaults .panel + .panel { margin-top: 16px; }
.tokens-head { margin-bottom: 8px; }
.tokens-head input[type="search"] { flex: 1 1 180px; min-width: 0; }
.tokens-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--pg-line); border-radius: 10px; }
.tokens { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tokens th, .tokens td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--pg-line); vertical-align: top; overflow-wrap: anywhere; }
.tokens thead th { position: sticky; top: 0; background: var(--pg-surface); font-weight: 600; }
.tokens tbody th { font: 500 12px var(--pg-mono); }
.tokens td:nth-child(3), .tokens td:nth-child(4) { font-family: var(--pg-mono); font-size: 12px; }
.tokens tr.changed td:nth-child(4) { color: var(--pg-accent); font-weight: 600; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; border: 1px solid var(--pg-line); vertical-align: -1px; }
.src {
  margin: 10px 0 0; padding: 12px 14px; max-height: 360px; overflow: auto;
  background: var(--pg-code-bg); color: var(--pg-code-text); border-radius: 10px; font: 12px/1.55 var(--pg-mono); white-space: pre;
}

footer { padding: 24px 0 40px; color: var(--pg-text-2); font-size: 13px; border-top: 1px solid var(--pg-line); }

@media (max-width: 960px) {
  /* minmax(0, 1fr), never 1fr: a bare 1fr grows to its widest child - the 392 px phone - and pushes the page past a phone's
     width. The phone's frame then takes the column's width (max-width: 100%) and the emulator draws its device to fit. */
  .live { grid-template-columns: minmax(0, 1fr); }
  .phone-col { position: static; }
  .looks { grid-template-columns: minmax(0, 1fr); }
  .sample-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
