/**
 * sdanswer — hydrated card rows, resource paths, and snippet/collection
 * modals embedded inside `/ai/answer/*` resource-agent turns.
 *
 * Component anatomy:
 *   .sdanswer                 — server-rendered placeholder, filled by JS
 *     └ .sda-cards-row        — horizontal row of 1–4 cards
 *         ├ .sda-card-article    — anchor card linking out to a curated source
 *         ├ .sda-card-snippet    — button card; opens snippet modal
 *         └ .sda-card-collection — button card; opens collection modal
 *     └ .sda-path             — ordered, numbered steps with "DIVE IN" CTA
 *   .sda-modal                — global overlay (one per document) for snippet
 *                               and collection details
 */

/* ── Block container ──────────────────────────────────────────────────── */
.sdanswer {
  margin: 1.25rem 0;
}
.sdanswer:first-child { margin-top: 0; }
.sdanswer:last-child { margin-bottom: 0; }

/* ── Cards row ────────────────────────────────────────────────────────── */
.sda-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .75rem;
}

.sda-card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .95rem 1rem 1rem;
  background: rgba(2,4,8,.55);
  border: 1px solid rgba(0,212,255,.12);
  border-radius: 2px;
  text-align: left;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: border-color .2s, background .2s, transform .2s;
}
.sda-card:hover {
  border-color: rgba(0,212,255,.4);
  background: rgba(0,212,255,.04);
  transform: translateY(-1px);
}
button.sda-card { width: 100%; }

.sda-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}

.sda-chip {
  display: inline-block;
  font-family: var(--heading);
  font-size: .55rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 2px;
}
.sda-chip-type {
  color: var(--cyan);
  background: rgba(0,212,255,.08);
  border: 1px solid rgba(0,212,255,.25);
}
.sda-chip-cat {
  color: var(--mid);
  border: 1px solid rgba(255,255,255,.12);
}

.sda-byline {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--mid);
}

.sda-card-title {
  font-family: var(--heading);
  font-size: .92rem;
  line-height: 1.35;
  color: var(--white);
  margin: 0;
  letter-spacing: .01em;
}
.sda-card:hover .sda-card-title { color: var(--cyan); }

.sda-card-blurb {
  font-family: var(--body);
  font-size: .82rem;
  line-height: 1.55;
  color: rgba(255,255,255,.78);
  margin: 0;
}

.sda-card-cta {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--heading);
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-top: auto;
}

.sda-hex {
  color: var(--cyan);
  flex-shrink: 0;
}

/* Snippet preview block inside the card */
.sda-snippet-preview {
  margin: 0;
  padding: .6rem .75rem;
  background: rgba(0,212,255,.05);
  border-left: 2px solid rgba(0,212,255,.4);
  border-radius: 0 2px 2px 0;
  overflow: hidden;
  max-height: 6.5rem;
}
.sda-snippet-preview code {
  font-family: var(--mono);
  font-size: .72rem;
  line-height: 1.5;
  color: rgba(255,255,255,.85);
  white-space: pre;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collection preview list — tag-qualified to outrank `.ai-turn-answer ul`
   (0,1,1 vs 0,1,0) which otherwise re-applies a 1.5rem left padding. */
ul.sda-coll-preview {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
li.sda-coll-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin: 0;
  padding: .35rem .5rem;
  background: rgba(255,255,255,.02);
  border-left: 1px solid rgba(0,212,255,.18);
}
.sda-coll-row-title {
  font-family: var(--body);
  font-size: .78rem;
  color: rgba(255,255,255,.85);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Tradeoff / Prereq / Gotcha (static cards) ─────────────────────────
   These are display-only cards (no hover transform, no click), so reset
   the cursor and hover styles inherited from `.sda-card`. */
.sda-card-tradeoff,
.sda-card-prereq,
.sda-card-gotcha {
  cursor: default;
}
.sda-card-tradeoff:hover,
.sda-card-prereq:hover,
.sda-card-gotcha:hover {
  border-color: rgba(0,212,255,.12);
  background: rgba(2,4,8,.55);
  transform: none;
}

/* Tradeoff and gotcha read best when they take the full row width — the
   side-by-side options and the wrong-code block both want horizontal
   space. `auto-fit` collapses the span on narrow viewports automatically. */
.sda-card-tradeoff,
.sda-card-gotcha {
  grid-column: 1 / -1;
}

/* Tradeoff */
.sda-tradeoff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .75rem;
  margin-top: .25rem;
}
.sda-tradeoff-option {
  padding: .65rem .75rem .75rem;
  background: rgba(0,212,255,.04);
  border: 1px solid rgba(0,212,255,.15);
  border-radius: 2px;
}
.sda-tradeoff-label {
  font-family: var(--heading);
  font-size: .8rem;
  line-height: 1.35;
  color: var(--cyan);
  margin: 0 0 .45rem;
  letter-spacing: .02em;
}
ul.sda-tradeoff-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
ul.sda-tradeoff-bullets li {
  position: relative;
  margin: 0;
  padding-left: 1rem;
  font-family: var(--body);
  font-size: .8rem;
  line-height: 1.45;
  color: rgba(255,255,255,.82);
}
ul.sda-tradeoff-bullets li::before {
  content: "›";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--cyan);
  font-family: var(--mono);
}

/* Prereq */
ul.sda-prereq-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
li.sda-prereq-item {
  position: relative;
  margin: 0;
  padding: .35rem .5rem .35rem 1.6rem;
  font-family: var(--body);
  font-size: .82rem;
  line-height: 1.45;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.02);
  border-left: 1px solid rgba(0,212,255,.18);
}
li.sda-prereq-item::before {
  content: "□";
  position: absolute;
  left: .55rem;
  top: .35rem;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: .82rem;
}
li.sda-prereq-item-link a {
  color: rgba(255,255,255,.92);
  text-decoration: none;
  border-bottom: 1px dashed rgba(0,212,255,.4);
  transition: color .2s, border-color .2s;
}
li.sda-prereq-item-link a:hover {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

/* Gotcha */
.sda-card-gotcha {
  border-color: rgba(255, 110, 110, .25);
}
.sda-card-gotcha .sda-chip-warn {
  color: #ff9b9b;
  background: rgba(255, 110, 110, .08);
  border: 1px solid rgba(255, 110, 110, .35);
}
.sda-gotcha-wrong {
  margin: 0;
  padding: .7rem .85rem;
  background: rgba(40, 8, 10, .55);
  border-left: 2px solid rgba(255, 110, 110, .55);
  border-radius: 0 2px 2px 0;
  overflow: auto;
  position: relative;
}
.sda-gotcha-wrong code {
  font-family: var(--mono);
  font-size: .76rem;
  line-height: 1.55;
  color: rgba(255, 200, 200, .78);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 110, 110, .65);
  text-decoration-thickness: 1px;
  white-space: pre;
  display: block;
}
.sda-gotcha-right {
  margin: .5rem 0 0;
  font-family: var(--body);
  font-size: .82rem;
  line-height: 1.55;
  color: rgba(255,255,255,.82);
}
.sda-gotcha-right-label {
  font-family: var(--heading);
  font-size: .6rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-right: .35rem;
}

/* ── Resource path ────────────────────────────────────────────────────── */
.sda-path {
  margin: 0;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid rgba(0,212,255,.15);
  background: rgba(2,4,8,.45);
  border-radius: 2px;
}
.sda-path-header {
  font-family: var(--heading);
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 .85rem;
}
.sda-path-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.sda-path-step {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: .85rem;
  padding: .75rem .65rem;
  border-top: 1px dashed rgba(0,212,255,.1);
}
.sda-path-step:first-child { border-top: none; }

.sda-path-num {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--cyan);
  letter-spacing: .08em;
}
.sda-path-body { min-width: 0; }
.sda-path-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin-bottom: .3rem;
}
.sda-path-title {
  font-family: var(--heading);
  font-size: .86rem;
  line-height: 1.35;
  color: var(--white);
  margin: 0;
  letter-spacing: .01em;
}
.sda-path-estimate {
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .04em;
  color: rgba(0,212,255,.85);
  padding: .1rem .4rem;
  border: 1px solid rgba(0,212,255,.25);
  border-radius: 2px;
  background: rgba(0,212,255,.05);
}
.sda-path-desc {
  font-family: var(--body);
  font-size: .8rem;
  line-height: 1.55;
  color: rgba(255,255,255,.7);
  margin: .25rem 0 0;
}
.sda-path-cta {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--heading);
  font-size: .6rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  text-decoration: none;
  padding: .35rem .6rem;
  border: 1px solid rgba(0,212,255,.3);
  border-radius: 2px;
  transition: border-color .2s, background .2s;
  white-space: nowrap;
}
.sda-path-cta:hover {
  border-color: var(--cyan);
  background: rgba(0,212,255,.08);
}

@media (max-width: 640px) {
  .sda-path-step {
    grid-template-columns: 2rem 1fr;
    grid-template-rows: auto auto;
  }
  .sda-path-cta {
    grid-column: 2 / -1;
    justify-self: start;
    margin-top: .3rem;
  }
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.sda-modal[hidden] { display: none; }
.sda-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.sda-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2,4,8,.75);
  backdrop-filter: blur(4px);
}
.sda-modal-window {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  background: rgba(8,12,20,.98);
  border: 1px solid rgba(0,212,255,.35);
  border-radius: 2px;
  padding: 1.5rem 1.6rem 1.75rem;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.sda-modal-close {
  position: absolute;
  top: .6rem;
  right: .75rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--white);
  font-size: 1rem;
  line-height: 1;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.sda-modal-close:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.sda-modal-eyebrow {
  font-family: var(--heading);
  font-size: .6rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 .5rem;
}
.sda-modal-title {
  font-family: var(--heading);
  font-size: 1.15rem;
  color: var(--white);
  margin: 0 0 .65rem;
  letter-spacing: .01em;
  line-height: 1.3;
}
.sda-modal-desc {
  font-family: var(--body);
  font-size: .92rem;
  line-height: 1.6;
  color: rgba(255,255,255,.78);
  margin: 0 0 1.1rem;
}

.sda-modal-snippet {
  border: 1px solid rgba(0,212,255,.18);
  border-radius: 2px;
  overflow: hidden;
}
.sda-modal-snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem .65rem;
  background: rgba(0,212,255,.05);
  border-bottom: 1px solid rgba(0,212,255,.18);
}
.sda-modal-copy {
  font-family: var(--heading);
  font-size: .6rem;
  letter-spacing: .22em;
  background: transparent;
  border: 1px solid rgba(0,212,255,.35);
  color: var(--cyan);
  padding: .3rem .65rem;
  cursor: pointer;
  border-radius: 2px;
  transition: background .2s;
}
.sda-modal-copy:hover { background: rgba(0,212,255,.08); }
.sda-modal-snippet pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: rgba(2,4,8,.65);
  overflow: auto;
  max-height: 60vh;
}
.sda-modal-snippet code {
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--white);
  white-space: pre;
}

.sda-modal-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .65rem;
}

body.sda-modal-open { overflow: hidden; }

/* ── Links card ────────────────────────────────────────────────────────
   A titled vertical list of `{label, url, description?}` rows. Spans
   the full cards row when used alone (the agent typically uses it as
   the single rich block in an answer). */
.sda-card-links {
  grid-column: 1 / -1;
  cursor: default;
}
.sda-card-links:hover {
  border-color: rgba(0,212,255,.12);
  background: rgba(2,4,8,.55);
  transform: none;
}
ul.sda-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
li.sda-link-row {
  margin: 0;
  padding: 0;
}
.sda-link-anchor {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .6rem .75rem;
  text-decoration: none;
  color: inherit;
  border-left: 2px solid rgba(0,212,255,.18);
  background: rgba(0,212,255,.02);
  border-radius: 0 2px 2px 0;
  transition: border-color .15s, background .15s;
}
.sda-link-anchor:hover {
  border-left-color: var(--cyan);
  background: rgba(0,212,255,.06);
}
.sda-link-anchor:hover .sda-link-label { color: var(--cyan); }
.sda-link-anchor:hover .sda-link-arrow { color: var(--cyan); }
.sda-link-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.sda-link-label {
  font-family: var(--heading);
  font-size: .85rem;
  letter-spacing: .01em;
  color: var(--white);
  line-height: 1.35;
  transition: color .15s;
}
.sda-link-desc {
  font-family: var(--body);
  font-size: .8rem;
  line-height: 1.5;
  color: rgba(255,255,255,.6);
  margin-top: .2rem;
}
.sda-link-arrow {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: .9rem;
  color: var(--mid);
  transition: color .15s;
}

/* ── Hint / Tip / Warning callouts ─────────────────────────────────────
   One paragraph + optional one-line title, tinted by kind. Span the full
   cards row by default (callouts read better wide). */
.sda-card-callout {
  grid-column: 1 / -1;
  cursor: default;
}
.sda-card-callout:hover {
  background: rgba(2,4,8,.55);
  transform: none;
}
.sda-callout-body {
  font-family: var(--body);
  font-size: .92rem;
  line-height: 1.6;
  color: rgba(255,255,255,.85);
  margin: 0;
}

/* Hint = cyan/blue, informational. */
.sda-card-callout-hint {
  border-color: rgba(0,212,255,.22);
  background: rgba(0,212,255,.03);
  border-left: 3px solid var(--cyan);
}
.sda-card-callout-hint:hover { border-color: rgba(0,212,255,.22); }
.sda-chip-callout-hint {
  color: var(--cyan);
  background: rgba(0,212,255,.08);
  border: 1px solid rgba(0,212,255,.3);
}

/* Tip = green, "here's the cheat code". */
.sda-card-callout-tip {
  border-color: rgba(89, 230, 144, .25);
  background: rgba(89, 230, 144, .03);
  border-left: 3px solid #59e690;
}
.sda-card-callout-tip:hover { border-color: rgba(89, 230, 144, .25); }
.sda-chip-callout-tip {
  color: #79f3a8;
  background: rgba(89, 230, 144, .08);
  border: 1px solid rgba(89, 230, 144, .35);
}

/* Warning = amber/rose, "watch out". */
.sda-card-callout-warning {
  border-color: rgba(255, 184, 92, .28);
  background: rgba(255, 184, 92, .03);
  border-left: 3px solid #ffb85c;
}
.sda-card-callout-warning:hover { border-color: rgba(255, 184, 92, .28); }
.sda-chip-callout-warning {
  color: #ffc97b;
  background: rgba(255, 184, 92, .08);
  border: 1px solid rgba(255, 184, 92, .4);
}
