/* ══════════════════════════════════════════════════════
   Resource Agent — ASK block on /resources + chat view
   on /ai/answer/{id}.
   ══════════════════════════════════════════════════════ */

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

/* ── ASK block on /resources ── */
.rsa {
  position: relative;
  margin: 0 0 1.75rem;
  padding: 1.1rem 1.25rem 1.1rem;
  background: linear-gradient(180deg, rgba(0,212,255,.03) 0%, rgba(0,212,255,0) 100%);
  border: 1px solid rgba(0,212,255,.3);
  border-radius: 2px;
}
/* Vivid L-shaped corner brackets (four spans positioned at each corner). */
.rsa-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.rsa-corner-tl { top: -1px; left: -1px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.rsa-corner-tr { top: -1px; right: -1px; border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.rsa-corner-bl { bottom: -1px; left: -1px; border-bottom: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.rsa-corner-br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }

/* Title bar — hex glyph + uppercase title, cyan line filling to the right. */
.rsa-head {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .9rem;
}
.rsa-title {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--heading);
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0;
  white-space: nowrap;
}
.rsa-hex {
  flex-shrink: 0;
  color: var(--cyan);
}
.rsa-head-line {
  flex: 1;
  height: 1px;
  background: rgba(0,212,255,.18);
}
.rsa-form-row {
  position: relative;
}
/* Textarea: no bg, no left/right/top border — just a bottom cyan rule, like
   a terminal prompt line. */
.rsa-input {
  display: block;
  width: 100%;
  height: calc(1em * 1.55 * 3);
  min-height: calc(1em * 1.55 * 3);
  padding: 0 0 .5rem 1.2rem;
  overflow: hidden;
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--white);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0,212,255,.1);
  border-radius: 0;
  resize: vertical;
  transition: border-color .2s;
}
.rsa-input:focus {
  outline: none;
  border-bottom-color: rgba(0,212,255,.35);
}
.rsa-input::placeholder { color: var(--mid); }
.rsa-form-row::before {
  content: '>';
  position: absolute;
  left: 0;
  top: .05rem;
  font-family: var(--mono);
  color: var(--cyan);
  font-weight: bold;
  pointer-events: none;
}

.rsa-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: .85rem;
}
.rsa-controls { justify-content: flex-end; }

.rsa-submit {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--heading);
  font-size: .65rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--cyan);
  border: 1px solid var(--cyan);
  padding: .7rem 1.4rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}
.rsa-submit-hex { flex-shrink: 0; }
.rsa-submit:hover {
  background: transparent;
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(0,212,255,.25);
}
.rsa-submit:disabled {
  opacity: .55;
  cursor: wait;
}

.rsa-hint {
  display: block;
  margin-top: .75rem;
  font-family: var(--heading);
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mid);
}
.rsa-hint[hidden] { display: none; }
.rsa-hint[data-state="error"] { color: var(--rose); }
.rsa-hint[data-state="loading"] { color: var(--cyan); }
.rsa-hint .rsa-dot {
  display: inline-block;
  width: .5em;
  animation: rsa-dot 1.2s infinite steps(4);
}
@keyframes rsa-dot {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

/* ── Anonymous CTA variant ── */
.rsa-anon {
  text-align: center;
  padding: 2rem 1rem;
}
.rsa-anon-title {
  font-family: var(--heading);
  font-size: .85rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--white);
  margin-bottom: .9rem;
}
.rsa-anon-sub {
  font-family: var(--body);
  font-size: .95rem;
  color: var(--light);
  margin-bottom: 1.5rem;
}
.rsa-anon-btn {
  display: inline-block;
  font-family: var(--heading);
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--cyan);
  text-decoration: none;
  padding: .8rem 1.6rem;
  border-radius: 2px;
  transition: background .2s, color .2s, box-shadow .2s;
}
.rsa-anon-btn:hover {
  background: transparent;
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(0,212,255,.25);
}

/* ── OR-TRY cards ── */
/* Override the framework's global section { padding } so the OR-TRY content
   and the directory grid align with the .rsa bordered box's outer edges. */
.rsa-or-try,
.vc-section { padding: 0; }
.rsa-or-try {
  margin: 0 0 2.5rem;
}
.rsa-or-try-label {
  font-family: var(--heading);
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 .85rem;
}
.rsa-or-try-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .85rem;
}
@media (max-width: 640px) {
  .rsa-or-try-grid { grid-template-columns: 1fr; }
}
.rsa-try-card {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: 1rem 1.1rem;
  font-family: var(--body);
  font-size: .9rem;
  line-height: 1.5;
  color: var(--light);
  background: rgba(2,4,8,.5);
  border: 1px solid rgba(0,212,255,.1);
  border-radius: 2px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.rsa-try-card:hover {
  border-color: rgba(0,212,255,.4);
  background: rgba(0,212,255,.04);
  color: var(--white);
}
.rsa-try-tag {
  flex-shrink: 0;
  min-width: 4.5rem;
  text-align: center;
  font-family: var(--heading);
  font-size: .55rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
  padding: .3rem .55rem;
  border: 1px solid rgba(0,212,255,.35);
  border-radius: 2px;
}

/* ══════════════════════════════════════════════════════
   Chat view — /ai/answer/{id}
   ══════════════════════════════════════════════════════ */

.ai-answer { max-width: 880px; }

.ai-answer-hero { margin-bottom: 2.5rem; }
.ai-answer-eyebrow {
  font-family: var(--heading);
  font-size: .58rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: .9rem;
}
.ai-answer-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}
.ai-answer-sub {
  margin-top: 1rem;
  font-size: .92rem;
  color: var(--light);
}
.ai-answer-sub a {
  color: var(--cyan);
  text-decoration: none;
  margin-left: .5rem;
}
.ai-answer-sub a:hover { text-decoration: underline; }

.ai-thread {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.ai-turn {
  position: relative;
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(0,212,255,.08);
  border-radius: 2px;
  background: rgba(2,4,8,.4);
}
.ai-turn-label {
  font-family: var(--heading);
  font-size: .55rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--mid);
  margin-bottom: .6rem;
}
.ai-turn-user .ai-turn-label { color: var(--cyan); }
.ai-turn-assistant {
  background: linear-gradient(180deg, rgba(0,212,255,.03) 0%, rgba(0,212,255,0) 100%);
  border-color: rgba(0,212,255,.15);
}

/* ── Copy button on assistant turns ────────────────────────────────── */
.ai-turn-copy {
  position: absolute;
  top: .75rem;
  right: .75rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .6rem;
  font-family: var(--heading);
  font-size: .58rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--mid);
  background: transparent;
  border: 1px solid rgba(0,212,255,.18);
  border-radius: 2px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  opacity: .55;
}
.ai-turn-copy:hover,
.ai-turn-copy:focus-visible {
  color: var(--cyan);
  border-color: rgba(0,212,255,.55);
  background: rgba(0,212,255,.05);
  opacity: 1;
  outline: none;
}
.ai-turn-copy.is-copied {
  color: var(--cyan);
  border-color: rgba(0,212,255,.55);
  opacity: 1;
}
.ai-turn-copy-label[hidden] { display: none; }

/* Hide the <template> if a UA ever decides to render it. */
.ai-turn-markdown { display: none; }

.ai-turn-question {
  font-family: var(--body);
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--white);
}
.ai-turn-question p { margin: 0 0 .6rem; }
.ai-turn-question p:last-child { margin-bottom: 0; }
.ai-turn-question a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,212,255,.3);
}
.ai-turn-question a:hover { border-bottom-color: var(--cyan); }

.ai-turn-answer {
  font-family: var(--body);
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--white);
}
.ai-turn-answer p {
  margin: 0 0 1rem;
}
.ai-turn-answer p:last-child { margin-bottom: 0; }
.ai-turn-answer a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0,212,255,.3);
}
.ai-turn-answer a:hover { border-bottom-color: var(--cyan); }
.ai-turn-answer code {
  font-family: var(--mono);
  font-size: .92em;
  background: rgba(0,212,255,.08);
  padding: .1em .35em;
  border-radius: 2px;
}
.ai-turn-answer ul,
.ai-turn-answer ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}
.ai-turn-answer li { margin: .25rem 0; }
.ai-turn-answer strong { color: var(--white); font-weight: 600; }

/* ── Citation cards ── */
.ai-citations {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed rgba(0,212,255,.12);
}
.ai-citations-label {
  font-family: var(--heading);
  font-size: .55rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--mid);
  margin-bottom: .75rem;
}
.ai-citation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .75rem;
}
.ai-citation-card {
  padding: .9rem 1rem;
  background: rgba(2,4,8,.55);
  border: 1px solid rgba(0,212,255,.08);
  border-radius: 2px;
  transition: border-color .2s, background .2s;
}
.ai-citation-card:hover {
  border-color: rgba(0,212,255,.25);
  background: rgba(0,212,255,.04);
}
.ai-citation-link {
  display: block;
  text-decoration: none;
}
.ai-citation-title {
  font-family: var(--heading);
  font-size: .85rem;
  letter-spacing: .04em;
  color: var(--white);
  margin: 0 0 .35rem;
  line-height: 1.35;
}
.ai-citation-link:hover .ai-citation-title { color: var(--cyan); }
.ai-citation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0 0 .4rem;
  font-family: var(--heading);
  font-size: .52rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--mid);
}
.ai-citation-type { color: var(--cyan); }
.ai-citation-blurb {
  font-family: var(--body);
  font-size: .85rem;
  line-height: 1.55;
  color: var(--light);
  margin: 0;
}

/* ── Follow-up form ── */
.ai-followup {
  margin-top: 1rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(0,212,255,.08);
  border-radius: 2px;
  background: rgba(2,4,8,.4);
}
.ai-followup textarea {
  width: 100%;
  min-height: 4rem;
  padding: .75rem 1rem;
  font-family: var(--body);
  font-size: .95rem;
  line-height: 1.55;
  color: var(--white);
  background: rgba(2,4,8,.7);
  border: 1px solid rgba(0,212,255,.12);
  border-radius: 2px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.ai-followup textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
}
.ai-followup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}
.ai-followup-hint {
  font-family: var(--heading);
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mid);
  min-height: 1.2em;
}
.ai-followup-hint[data-state="error"] { color: var(--rose); }
.ai-followup-hint[data-state="loading"] { color: var(--cyan); }
.ai-followup-btn {
  font-family: var(--heading);
  font-size: .65rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--cyan);
  border: 1px solid var(--cyan);
  padding: .65rem 1.3rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}
.ai-followup-btn:hover {
  background: transparent;
  color: var(--cyan);
  box-shadow: 0 0 18px rgba(0,212,255,.25);
}
.ai-followup-btn:disabled { opacity: .55; cursor: wait; }

.ai-followup-closed {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  font-family: var(--body);
  font-size: .9rem;
  color: var(--light);
  border: 1px dashed rgba(0,212,255,.12);
  border-radius: 2px;
  text-align: center;
}
.ai-followup-closed a {
  color: var(--cyan);
  text-decoration: none;
  margin-left: .5rem;
}
.ai-followup-closed a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .rsa-submit { width: 100%; }
}
