/* pattern-preview.css — CodePen-style live demo + code block for pattern entries.
   Sits inside the cream-paper page aesthetic; the demo iframe runs in its own
   document so demo styles never leak into patterns.gf.cx. */

.pattern-preview {
  margin: 22px 0;
  border: 1px solid var(--line-strong, rgba(26,24,22,0.32));
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 280px;
  position: relative;
  font-family: var(--sans, system-ui);
}

.pattern-preview__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #2a2622;
  color: #d8d2c4;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: var(--mono, ui-monospace, monospace);
  border-bottom: 1px solid #3d3833;
}

.pattern-preview__head-label { display: flex; align-items: center; gap: 8px; }
.pattern-preview__head-label::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6db86d;
  box-shadow: 0 0 6px rgba(109,184,109,0.6);
}

.pattern-preview__open-btn {
  background: none; border: 1px solid #4a443e; color: #d8d2c4;
  font-family: inherit; font-size: 10px; letter-spacing: 0.12em;
  padding: 3px 10px; border-radius: 3px; cursor: pointer;
  text-transform: uppercase;
}
.pattern-preview__open-btn:hover { background: #3d3833; color: #fff; }

.pattern-preview__demo {
  background: #fafafa;
  position: relative;
  min-height: 240px;
  border-right: 1px solid var(--line, rgba(26,24,22,0.12));
}

/* Tall variant — for demos that need vertical room to scroll inside the frame
   (e.g. the back-to-top scroll-gate). Forces the demo+code row to a fixed
   height so the iframe scrolls internally rather than fitting all content. */
.pattern-preview--tall {
  min-height: 440px;
  grid-template-rows: auto 1fr;
}
.pattern-preview__demo iframe {
  width: 100%; height: 100%; border: 0; display: block;
  min-height: 240px;
}

/* Wide variant — opt-in for image-centric demos (a landscape figure squeezed
   into the split column reads small). Set data-demo="wide" on the
   .pattern-preview: the demo spans the full width on top, the code sits below,
   and the frame gets vertical room for the figure. */
.pattern-preview[data-demo="wide"] { grid-template-columns: 1fr; }
.pattern-preview[data-demo="wide"] .pattern-preview__demo {
  border-right: 0;
  border-bottom: 1px solid var(--line, rgba(26,24,22,0.12));
}
.pattern-preview[data-demo="wide"] .pattern-preview__demo,
.pattern-preview[data-demo="wide"] .pattern-preview__demo iframe { min-height: 500px; }

/* Inline-mode demo — runs in host document, so popups (tooltips) can
   escape the demo box. Default stage centres content for visual parity
   with the iframe demo's 24px padding. */
.pattern-preview__demo--inline { padding: 0; overflow: visible; }
.pattern-preview__inline-stage {
  padding: 28px 24px;
  font-family: var(--sans, system-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink, #1a1816);
  min-height: 240px;
  display: flex; flex-direction: column; justify-content: center;
}
.pattern-preview__inline-stage > * { max-width: 42em; }

.pattern-preview__code {
  background: #1a1816;
  color: #e8e2d6;
  display: flex;
  flex-direction: column;
  font-family: var(--mono, ui-monospace, 'SF Mono', monospace);
  font-size: 12.5px;
  line-height: 1.55;
}

.pattern-preview__tabs {
  display: flex;
  background: #15130f;
  border-bottom: 1px solid #2a2622;
  padding: 0 6px;
  flex-wrap: wrap;
}

.pattern-preview__tab {
  background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #8a8174;
  padding: 9px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.pattern-preview__tab:hover { color: #d8d2c4; }
.pattern-preview__tab[aria-selected="true"] {
  color: #f0e8d6;
  border-bottom-color: var(--accent, #2c4a3a);
}

.pattern-preview__panels {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.pattern-preview__panel {
  position: absolute; inset: 0;
  padding: 14px 18px;
  overflow: auto;
  margin: 0;
  white-space: pre;
  display: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 0;
}
.pattern-preview__panel.is-active { display: block; }

.pattern-preview__copy {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #d8d2c4;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 10px; letter-spacing: 0.12em;
  padding: 4px 9px; border-radius: 3px;
  cursor: pointer; text-transform: uppercase;
  z-index: 2;
}
.pattern-preview__copy:hover { background: rgba(255,255,255,0.12); color: #fff; }
.pattern-preview__copy.is-copied { background: var(--accent, #2c4a3a); color: #fff; border-color: transparent; }

/* Mobile + narrow screens — stack vertically with demo on top */
@media (max-width: 800px) {
  .pattern-preview { grid-template-columns: 1fr; }
  .pattern-preview__demo { border-right: 0; border-bottom: 1px solid var(--line, rgba(26,24,22,0.12)); }
  .pattern-preview__code { min-height: 240px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   Gold-standard pattern-page closers — shared so every page renders them
   identically. Added 2026-06-26 (sweep). Promote-from-inline: the
   timeline-overlap-zone-card exemplar first defined these locally.
   ───────────────────────────────────────────────────────────────────────── */
ul.reuse-list { list-style: none; padding: 0; margin: 0; }
ul.reuse-list li { padding: 10px 0 10px 16px; border-top: 1px solid var(--line, rgba(26,24,22,0.12));
  position: relative; }
ul.reuse-list li:first-child { border-top: none; }
ul.reuse-list li::before { content: "\25B8"; position: absolute; left: 0; top: 10px;
  color: var(--accent, #2c4a3a); font-size: 13px; }
dl.pattern-ref { margin: 0; border-top: 1px solid var(--line, rgba(26,24,22,0.12)); }
dl.pattern-ref > div { display: grid; grid-template-columns: 168px 1fr; gap: 18px;
  padding: 13px 0; border-bottom: 1px solid var(--line, rgba(26,24,22,0.12)); }
dl.pattern-ref dt { font-family: var(--mono, ui-monospace, monospace); font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent, #2c4a3a); padding-top: 3px; }
dl.pattern-ref dd { margin: 0; color: var(--ink-soft, #5a544d); }
@media (max-width: 560px) { dl.pattern-ref > div { grid-template-columns: 1fr; gap: 4px; } }
