/* ==========================================================================
   AI in Practice — demo page styles
   Loads after style.css and reuses its tokens. Every class is prefixed
   gd- so nothing here collides with the rest of the site.
   ========================================================================== */

.gd {
  /* RAG colors: each passes 4.5:1 against white text */
  --gd-green: #2e7d52;
  --gd-green-tint: #e6f1ea;
  --gd-amber: #a35f00;
  --gd-amber-tint: #f8ecd8;
  --gd-red: #a93232;
  --gd-red-tint: #f6e3e0;
  --gd-gold-tint: #f6eed6;
}

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

/* ---------- Intro ---------- */

.gd-title { font-size: clamp(1.9rem, 3.6vw, 2.5rem); margin-bottom: 0.4em; }
.gd-intro { font-size: 1.1rem; color: var(--ink-soft); max-width: 60ch; }
.gd-disclosure {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--panel);
  border-left: 3px solid var(--gold);
  padding: 10px 16px;
  margin: 8px 0 0;
  max-width: none;
}

/* ---------- Lifecycle diagram ---------- */

.gd-diagram-help {
  font-size: 0.9rem;
  color: var(--ink-soft);
  max-width: 62ch;
  margin: 0 0 28px;
}

.gd-diagram {
  position: relative;
  margin: 0 0 44px;
  scroll-margin-top: 88px;
}

.gd-lines {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}
.gd-seq { stroke: var(--ink-faint); stroke-width: 1.5; fill: none; }
.gd-arrowhead { fill: var(--ink-faint); }
.gd-feed { stroke: var(--ink-faint); stroke-width: 1.5; stroke-dasharray: 5 5; fill: none; transition: stroke 0.2s ease; }
.gd-feed-label {
  font-family: var(--sans);
  font-size: 11.5px;
  fill: var(--ink-soft);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 7px;
  stroke-linejoin: round;
}
.gd-diagram[data-active="portfolio"] .gd-feed { stroke: var(--navy); }
.gd-diagram[data-active="portfolio"] .gd-feed-label { fill: var(--navy); }

.gd-row { position: relative; z-index: 1; }
.gd-row-main {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 76px;
}
.gd-row-portfolio { display: flex; justify-content: center; margin-top: 84px; }

.gd-node {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.gd-row-portfolio .gd-node { width: 300px; }
.gd-node-portfolio { border-top: 3px solid var(--gold); }
.gd-node:hover { border-color: var(--navy); }
.gd-node-name { display: block; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; line-height: 1.2; }
.gd-node-desc { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-top: 3px; }
.gd-node[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.gd-node[aria-pressed="true"] .gd-node-desc { color: #d5dae6; }
.gd-node:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }

.gd-mobile-note { display: none; }

@media (max-width: 719px) {
  .gd-lines { display: none; }
  .gd-row-portfolio { margin-top: 0; }
  .gd-row-portfolio .gd-node { width: 100%; }
  .gd-row-main { grid-template-columns: 1fr; row-gap: 30px; }
  .gd-mobile-note {
    display: block; font-size: 0.82rem; color: var(--ink-soft);
    margin: 26px 0 14px; padding-left: 12px; border-left: 2px dashed var(--ink-faint);
  }
  .gd-row-main .gd-node:not(:first-child)::before {
    content: "\2193"; position: absolute; left: 50%; top: -26px; transform: translateX(-50%);
    color: var(--ink-faint); font-size: 1rem;
  }
}

/* ---------- Shared panel ---------- */

.gd-panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  padding: 36px 40px 40px;
}
.gd-stage[hidden] { display: none; }

.gd-stage-head { margin-bottom: 30px; max-width: 64ch; }
.gd-kicker { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-faint); margin: 0 0 6px; }
.gd-stage-title { font-size: clamp(1.45rem, 2.6vw, 1.85rem); margin: 0 0 8px; outline: none; }
.gd-lead { color: var(--ink-soft); margin: 0; }

.gd-block-title {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 14px;
}

.gd-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}
.gd-data { padding-right: 40px; }
.gd-output { border-left: 1px solid var(--line); padding-left: 40px; scroll-margin-top: 96px; }
.gd-layout-stack .gd-split { grid-template-columns: 1fr; }
.gd-layout-stack .gd-data { padding-right: 0; }
.gd-layout-stack .gd-output { border-left: none; padding-left: 0; border-top: 1px solid var(--line); margin-top: 32px; padding-top: 28px; }

@media (max-width: 860px) {
  .gd-panel { padding: 26px 20px 30px; }
  .gd-split { grid-template-columns: 1fr; }
  .gd-data { padding-right: 0; }
  .gd-output { border-left: none; padding-left: 0; border-top: 1px solid var(--line); margin-top: 28px; padding-top: 24px; }
}

.gd-actions { margin-top: 24px; }

/* ---------- Scripted output ---------- */

.gd-output-label {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gold-text);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 4px 10px;
  margin: 0 0 18px;
}
.gd-output-empty { color: var(--ink-faint); font-style: italic; margin: 0; }
.gd-output-body { display: none; }
.gd-scripted[data-state="revealed"] .gd-output-body { display: block; }
.gd-scripted[data-state="revealed"] .gd-output-empty { display: none; }

.gd-output-body p { max-width: 62ch; }
.gd-output-lead { font-family: var(--serif); font-size: 1.15rem; line-height: 1.5; color: var(--ink); }

.gd-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--navy);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 9px;
  margin: 0 0 14px;
}

.gd-closing-wrap { display: none; }
.gd-scripted[data-state="revealed"] .gd-closing-wrap {
  display: block; margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line);
}
.gd-closing {
  font-family: var(--serif); font-style: italic; font-size: 1.2rem; line-height: 1.5;
  color: var(--ink); max-width: 60ch; margin: 0 0 14px;
}

.gd-handoff { margin: 18px 0 0; font-size: 0.95rem; color: var(--ink-soft); }
.gd-handoff-link { margin: 6px 0 0; font-size: 0.95rem; }
.gd-link {
  font: inherit; font-weight: 500; color: var(--navy);
  background: none; border: none; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line);
}
.gd-link:hover { text-decoration-color: currentColor; }
.gd-link:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }

/* ---------- Flags (appear only after the example is shown) ---------- */

.gd-flag {
  display: none;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 2px;
  white-space: nowrap;
}
.gd-scripted[data-state="revealed"] .gd-flag { display: inline-block; }
.gd-flag:empty { display: none !important; }

.gd-flag--look,
.gd-flag--vendor,
.gd-flag--ask,
.gd-flag--dep { background: var(--gold); color: var(--navy); }
.gd-flag--wait,
.gd-flag--gap { background: var(--panel); color: var(--ink-soft); border: 1px solid var(--line); }

/* ---------- Intake: form fields ---------- */

.gd-fields { margin: 0; }
.gd-field {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 4px 16px;
  align-items: baseline;
  padding: 12px 12px;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.gd-field:last-child { border-bottom: 1px solid var(--line); }
.gd-field dt { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint); }
.gd-field dd { margin: 0; }
.gd-field .gd-flag { margin-left: 10px; vertical-align: 1px; }
.gd-scripted[data-state="revealed"] .gd-field[data-flag="look"] { background: var(--gd-gold-tint); border-left-color: var(--gold); }
.gd-scripted[data-state="revealed"] .gd-field[data-flag="wait"] { color: var(--ink-soft); }

@media (max-width: 520px) {
  .gd-field { grid-template-columns: 1fr; }
}

/* ---------- Closure: project list ---------- */

.gd-projects { list-style: none; margin: 0; padding: 0; }
.gd-project {
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.gd-project:last-child { border-bottom: 1px solid var(--line); }
.gd-project-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.gd-project-name { font-weight: 600; }
.gd-project-outcome { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); }
.gd-project-note { margin: 6px 0 0; font-size: 0.92rem; color: var(--ink-soft); max-width: none; }
.gd-project-notelabel { font-weight: 600; color: var(--ink); }
.gd-project .gd-flag { margin-top: 10px; }
.gd-scripted[data-state="revealed"] .gd-project[data-flag="vendor"] { background: var(--gd-gold-tint); border-left-color: var(--gold); }

/* ---------- Portfolio: project table ---------- */

.gd-ptable { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.gd-ptable th {
  text-align: left; font-family: var(--mono); font-size: 0.74rem; font-weight: 400;
  color: var(--ink-faint); padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
.gd-ptable td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.gd-pname > span:first-child { font-weight: 600; display: block; }
.gd-pname .gd-flag { margin-top: 8px; }
.gd-pbudget { font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }
.gd-pnote { color: var(--ink-soft); }
.gd-prow td:first-child { border-left: 3px solid transparent; }
.gd-scripted[data-state="revealed"] .gd-prow[data-flag] td { background: var(--gd-gold-tint); }
.gd-scripted[data-state="revealed"] .gd-prow[data-flag] td:first-child { border-left-color: var(--gold); }

.gd-rag {
  display: inline-block;
  font-size: 0.78rem; font-weight: 500; line-height: 1;
  color: #fff; padding: 5px 9px; border-radius: 2px;
}
.gd-rag--green { background: var(--gd-green); }
.gd-rag--amber { background: var(--gd-amber); }
.gd-rag--red { background: var(--gd-red); }

@media (max-width: 640px) {
  .gd-ptable thead { display: none; }
  .gd-ptable, .gd-ptable tbody, .gd-ptable tr, .gd-ptable td { display: block; }
  .gd-ptable tr { padding: 12px 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
  .gd-ptable td { border: none; padding: 3px 10px; }
  .gd-ptable td:nth-child(2), .gd-ptable td:nth-child(3) { display: inline-block; vertical-align: middle; }
  .gd-prow td:first-child { border-left: none; }
  .gd-scripted[data-state="revealed"] .gd-prow[data-flag] { background: var(--gd-gold-tint); border-left-color: var(--gold); }
  .gd-scripted[data-state="revealed"] .gd-prow[data-flag] td { background: none; }
  .gd-scripted[data-state="revealed"] .gd-prow[data-flag] td:first-child { border-left: none; }
}

.gd-desktop-only { display: inline; }
@media (max-width: 719px) { .gd-desktop-only { display: none; } }

/* Portfolio sources */
.gd-sources { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.gd-sources-title { font-family: var(--sans); font-size: 0.95rem; font-weight: 600; margin: 0 0 14px; }
.gd-source-list { list-style: none; margin: 0; padding: 0; }
.gd-source-list li {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.gd-chip {
  display: inline-block; font-family: var(--mono); font-size: 0.74rem; text-align: center;
  padding: 3px 8px; border-radius: 2px; justify-self: start;
}
.gd-chip--stage {
  background: var(--navy); color: #fff; border: 1px solid var(--navy); cursor: pointer;
}
.gd-chip--stage:hover { background: var(--navy-soft); }
.gd-chip--stage:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.gd-chip--outside { background: var(--bg); color: var(--ink); border: 1px dashed var(--ink-faint); }
@media (max-width: 520px) { .gd-source-list li { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Execution stage ---------- */

.gd-exec-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 44px; }
@media (max-width: 860px) { .gd-exec-grid { grid-template-columns: 1fr; gap: 32px; } }

/* Each signal is a row; the extra margin lets the highlight bleed into the gutter
   while the content stays aligned with the column title. */
.gd-input-group {
  border: none; border-left: 3px solid transparent;
  padding: 10px 12px 12px 12px;
  margin: 0 -12px 8px -15px;
  min-width: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.gd-input-label {
  font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint);
  padding: 0; margin-bottom: 8px; display: block; float: none;
}
.gd-input-label .gd-flag { margin-left: 10px; vertical-align: 1px; }
.gd-exec .gd-flag { display: none; }
.gd-exec .gd-input-group[data-hl] { background: var(--gd-gold-tint); border-left-color: var(--gold); }
.gd-exec .gd-input-group[data-hl] .gd-flag { display: inline-block; }

.gd-segments { display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); }
.gd-segments--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 520px) { .gd-segments { grid-template-columns: 1fr; } }

.gd-seg-wrap { position: relative; }
.gd-radio { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gd-seg {
  display: block; height: 100%;
  padding: 10px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.gd-seg[data-rag="G"] { --c: var(--gd-green); }
.gd-seg[data-rag="A"] { --c: var(--gd-amber); }
.gd-seg[data-rag="R"] { --c: var(--gd-red); }
.gd-seg-title { display: block; font-size: 0.88rem; font-weight: 500; line-height: 1.25; }
.gd-seg-detail { display: block; font-size: 0.76rem; line-height: 1.3; margin-top: 2px; color: var(--ink-soft); }
.gd-seg:hover { border-color: var(--c); }
.gd-radio:checked + .gd-seg { background: var(--c); border-color: var(--c); color: #fff; }
.gd-radio:checked + .gd-seg .gd-seg-detail { color: #fff; }
.gd-radio:focus-visible + .gd-seg { outline: 2px solid var(--navy); outline-offset: 2px; }

/* Live result card: deterministic rules, so it switches instantly (no color blend) */
.gd-verdict { border-radius: 4px; padding: 20px 26px 24px; color: #fff; background: var(--gd-green); }
.gd-verdict[data-rag="amber"] { background: var(--gd-amber); }
.gd-verdict[data-rag="red"] { background: var(--gd-red); }
.gd-verdict-top { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.gd-verdict-label { font-size: 0.82rem; font-weight: 500; }
.gd-live-chip {
  font-size: 0.74rem; font-weight: 500; line-height: 1;
  padding: 5px 9px; border: 1px solid #fff; border-radius: 2px;
}
.gd-verdict-word { display: block; font-family: var(--serif); font-weight: 700; font-size: 2.7rem; line-height: 1.1; margin: 6px 0 10px; }
.gd-verdict-esc { display: inline-block; font-size: 0.88rem; font-weight: 500; padding: 4px 10px; border: 1px solid #fff; border-radius: 2px; }
.gd-verdict-esc.is-raised { background: #fff; color: var(--gd-red); }
.gd-verdict-exp { margin: 16px 0 0; font-size: 0.95rem; line-height: 1.55; max-width: 56ch; }

.gd-rule { margin: 14px 0 0; font-size: 0.86rem; line-height: 1.55; color: var(--ink-soft); max-width: 60ch; }
.gd-rule strong { color: var(--ink); font-weight: 600; }

/* Scripted output panel (below the live card) */
.gd-exec-output { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 96px; }
.gd-ai-heading { font-family: var(--sans); font-size: 0.95rem; font-weight: 600; margin: 0 0 8px; }
.gd-ai-text { margin: 0 0 24px; max-width: 60ch; }

.gd-plug { list-style: none; margin: 0; padding: 0; }
.gd-plug-row { padding: 12px 0; border-top: 1px solid var(--line); }
.gd-plug-row:last-child { border-bottom: 1px solid var(--line); }
.gd-plug-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.gd-plug-step { font-size: 0.9rem; font-weight: 600; }
.gd-plug-row .gd-tag { margin: 0; }
.gd-plug-row p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); max-width: 58ch; }

/* The Augmentation row carries the thesis, so it is the one emphasized row */
.gd-plug-row--emph {
  background: var(--gd-gold-tint);
  border-top-color: var(--gold);
  border-left: 4px solid var(--gold);
  padding: 14px 16px;
  margin: 6px 0;
}
.gd-plug-row--emph .gd-tag { background: var(--gold); border-color: var(--gold); }
.gd-plug-row--emph p { font-size: 0.95rem; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .gd *, .gd *::before, .gd *::after { transition: none !important; }
}
