/* ==========================================================================
   27-faq-terminal.css — Kouider TUI FAQ
   A terminal user interface: the questions are a navigable index, the answer
   streams into the pane beside it. Progressive enhancement only — without JS
   the same markup renders as a plain, fully crawlable FAQ list.
   ========================================================================== */

.k-faq { margin-top: 8px; }

/* ---- window chrome ------------------------------------------------------ */
.k-tui {
  --k-tui-mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  position: relative;
  border: 1px solid var(--wp--preset--color--k-line);
  border-radius: 10px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 38, 56, .05), transparent 60%),
    #0a0a0c;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 22px 50px -30px rgba(255, 38, 56, .35);
  font-family: var(--k-tui-mono);
}

/* faint scanlines — decorative, never over text contrast */
.k-tui::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .022) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: screen;
  opacity: .5;
}

/* ---- title bar ---------------------------------------------------------- */
.k-tui-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, .045);
  border-bottom: 1px solid var(--wp--preset--color--k-line);
}
.k-tui-dots { display: flex; gap: 6px; flex: 0 0 auto; }
.k-tui-dots i {
  width: 9px; height: 9px; border-radius: 50%; display: block;
  background: var(--wp--preset--color--k-muted);
}
.k-tui-dots i:nth-child(1) { background: var(--wp--preset--color--k-red); }
.k-tui-dots i:nth-child(2) { background: var(--wp--preset--color--k-red-bright); }
.k-tui-title {
  font-size: .7rem; letter-spacing: .1em; text-transform: lowercase;
  color: var(--wp--preset--color--k-muted);
}
.k-tui-hint {
  margin-left: auto;
  font-size: .66rem; letter-spacing: .06em;
  color: var(--wp--preset--color--k-muted);
  opacity: .75;
}

/* ---- body: index | view ------------------------------------------------- */
.k-tui-body {
  display: grid;
  grid-template-columns: minmax(0, 330px) minmax(0, 1fr);
  min-height: 340px;
}

/* ---- index pane --------------------------------------------------------- */
.k-tui-index {
  border-right: 1px solid var(--wp--preset--color--k-line);
  padding: 10px 0 12px;
  background: rgba(255, 255, 255, .012);
}
.k-tui-index-head {
  padding: 0 14px 8px;
  font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--wp--preset--color--k-muted);
  opacity: .8;
}
.k-tui-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.k-tui-li { margin: 0; padding: 0; }

.k-tui-row {
  display: flex; align-items: baseline; gap: 10px;
  width: 100%;
  padding: 7px 14px 7px 12px;
  background: none; border: 0; border-left: 2px solid transparent;
  color: var(--wp--preset--color--k-muted);
  font: inherit; font-size: .82rem; line-height: 1.35;
  text-align: left; cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.k-tui-num { flex: 0 0 auto; color: #6f6f78; font-size: .74rem; letter-spacing: .04em; }
.k-tui-row:hover { background: rgba(255, 255, 255, .04); color: var(--wp--preset--color--k-white); }
.k-tui-row:focus-visible {
  outline: 2px solid var(--wp--preset--color--k-red-bright);
  outline-offset: -2px;
}
.k-tui-row[aria-expanded="true"] {
  background: rgba(255, 38, 56, .09);
  border-left-color: var(--wp--preset--color--k-red);
  color: var(--wp--preset--color--k-white);
}
.k-tui-row[aria-expanded="true"] .k-tui-num { color: var(--wp--preset--color--k-red-bright); }
.k-tui-row[aria-expanded="true"] .k-tui-label::before {
  content: "▶";
  display: inline-block;
  margin-right: 7px;
  font-size: .6rem;
  vertical-align: 1px;
  color: var(--wp--preset--color--k-red);
}

/* ---- answer pane -------------------------------------------------------- */
.k-tui-view { padding: 16px 18px 20px; min-width: 0; }
.k-tui-pane { position: relative; }

.k-tui-cmd {
  margin: 0 0 12px;
  font-size: .78rem;
  color: var(--wp--preset--color--k-muted);
  border-bottom: 1px dashed var(--wp--preset--color--k-line);
  padding-bottom: 9px;
  word-break: break-word;
}
.k-tui-cmd b { color: var(--wp--preset--color--k-red); font-weight: 400; }

.k-tui-answer { margin: 0; }
/* Without JS every answer stays in the flow — a complete, crawlable FAQ list.
   With JS the index drives the pane, so only the selected one is shown. */
html.k-js .k-tui-answer { display: none; }
html.k-js .k-tui-answer.is-open { display: block; }
.k-tui-answer[hidden] { display: none; }
.k-tui-aq {
  margin: 0 0 10px;
  font-family: var(--k-tui-mono);
  font-size: .95rem; line-height: 1.45;
  color: var(--wp--preset--color--k-white);
  letter-spacing: .01em;
}
.k-tui-aq::before {
  content: "# ";
  color: var(--wp--preset--color--k-red);
}
.k-tui-a {
  font-family: var(--k-tui-mono);
  font-size: .84rem; line-height: 1.75;
  color: #c6c6cd;
  word-break: break-word;
}
.k-tui-a p { margin: 0 0 .85em; }
.k-tui-a p:last-child { margin-bottom: 0; }
.k-tui-a a { color: var(--wp--preset--color--k-red-bright); text-underline-offset: 3px; }
.k-tui-a code {
  font-family: inherit;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--wp--preset--color--k-line);
  border-radius: 3px; padding: 0 4px;
}

/* streaming caret, shown while an answer types in */
.k-tui-caret {
  display: inline-block;
  width: .58em; height: 1.02em;
  margin-left: 2px;
  vertical-align: -.16em;
  background: var(--wp--preset--color--k-red);
  animation: k-tui-blink 1s steps(1, end) infinite;
}
.k-tui-caret[hidden] { display: none; }
@keyframes k-tui-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ---- status bar --------------------------------------------------------- */
.k-tui-status {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 7px 13px;
  border-top: 1px solid var(--wp--preset--color--k-line);
  background: rgba(255, 255, 255, .03);
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--wp--preset--color--k-muted);
}
.k-tui-led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--wp--preset--color--k-red);
  box-shadow: 0 0 8px var(--wp--preset--color--k-red);
  animation: k-tui-pulse 2.4s ease-in-out infinite;
}
.k-tui-status[data-busy="1"] .k-tui-led { animation-duration: .7s; }
@keyframes k-tui-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.k-tui-sep { opacity: .4; }

/* ---- no-JS: everything readable, no chrome pretending to be interactive -- */
html:not(.k-js) .k-tui-hint,
html:not(.k-js) .k-tui-caret { display: none; }
html:not(.k-js) .k-tui-row { cursor: default; }
html:not(.k-js) .k-tui-answer { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px dashed var(--wp--preset--color--k-line); }
html:not(.k-js) .k-tui-answer:last-child { border-bottom: 0; margin-bottom: 0; }

/* with JS the index is a control surface, so the answers move into the pane */
html.k-js .k-tui-answer { animation: k-tui-in .18s ease-out both; }
@keyframes k-tui-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 900px) {
  .k-tui-body { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .k-tui-index {
    border-right: 0;
    border-bottom: 1px solid var(--wp--preset--color--k-line);
    max-height: 240px; overflow-y: auto;
  }
  .k-tui-row { font-size: .8rem; padding: 8px 12px; }
  .k-tui-view { padding: 14px 14px 18px; }
  .k-tui-hint { display: none; }
}
@media (max-width: 560px) {
  .k-tui-a, .k-tui-aq { font-size: .8rem; }
  .k-tui-cmd { font-size: .72rem; }
  .k-tui-index { max-height: 200px; }
}

/* ---- motion preference -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .k-tui-dots i, .k-tui-led, .k-tui-caret,
  html.k-js .k-tui-answer { animation: none !important; }
  .k-tui-row { transition: none; }
}
