/* The Agentic Interface Test — page-scoped styles. Every class is
   ait- prefixed; nothing here touches other pages. One-page form,
   results in a modal (the modal mounts on <body>, outside .ait-app;
   all design tokens live on :root in styles.css, so both scopes
   resolve them). Shared components (.btn, .numbox, .input) come
   from styles.css. */

.ait-app button:focus-visible,
.ait-app input:focus-visible,
.ait-app a:focus-visible,
.ait-modal button:focus-visible,
.ait-modal a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ait-fallback {
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------- mode tabs ---------- */

.ait-mode-tabs {
  display: inline-flex;
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 0.3rem;
  gap: 0.3rem;
  margin-bottom: 2rem;
}

.ait-mode-tab {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: background 180ms;
}

.ait-mode-tab:hover { background: var(--bg-alt); }

.ait-mode-tab.active { background: var(--ink); }

.ait-mode-tab-title {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

.ait-mode-tab-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font);
  font-size: var(--label-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  background: var(--chip-bg);
  padding: 0.22rem 0.5rem;
}

.ait-mode-tab.active .ait-mode-tab-title { color: var(--on-ink); }

.ait-mode-tab.active .ait-mode-tab-chip {
  background: rgba(255, 255, 255, 0.18);
  color: var(--on-ink);
}

/* ---------- question list ---------- */

.ait-name-row { border-top: 1px solid var(--hairline); }

.ait-name-row .ait-row-main { cursor: text; }

.ait-name-row .ait-name-input {
  width: 20rem;
  max-width: 45vw;
  flex-shrink: 0;
  font-size: 0.92rem;
  padding: 0.45rem 0.7rem;
}

.ait-section { margin-bottom: 2.25rem; }

/* Each deep-dive section ends with a separator spanning the full
   viewport (through the rails), marking the section boundary more
   strongly than the per-row hairlines. */
.ait-section::after {
  content: "";
  display: block;
  height: 1px;
  background: var(--hairline);
  margin: 0 calc(50% - 50vw);
}

.ait-section .ait-rows > .ait-row:last-child { border-bottom: none; }

.ait-section-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding-top: 1.75rem;
  margin-bottom: 1.1rem;
}

.ait-section-name {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
}

.ait-section-def {
  font-size: 0.85rem;
  color: var(--muted);
}

.ait-rows { list-style: none; margin: 0; padding: 0; }

.ait-row {
  border-bottom: 1px solid var(--hairline);
  padding: 1.15rem 0.25rem;
}

/* Deep-dive sections: the rows only carry bottom borders, so the
   first question under a section head needs its own separator above.
   (Quick mode gets this line from the name row's bottom border.) */
.ait-section .ait-rows > .ait-row:first-child {
  border-top: 1px solid var(--hairline);
}

/* Run the row separators out to the container edges so they meet
   the page's vertical rails (the extra 0.25rem absorbs the row's
   own side padding). */
@media (min-width: 68rem) {
  .ait-row {
    margin: 0 calc(-1 * var(--container-pad));
    padding-left: calc(var(--container-pad) + 0.25rem);
    padding-right: calc(var(--container-pad) + 0.25rem);
  }
}

.ait-row.ait-missing {
  background: var(--bg-alt);
  box-shadow: inset 2px 0 0 var(--ink);
}

.ait-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  /* every row matches the tallest (two-line) question */
  min-height: 2.9rem;
}

.ait-row-textwrap {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  max-width: 31em;
}

.ait-row-num {
  transition: background 150ms, border-color 150ms, color 150ms;
}

.ait-row.ait-answered .ait-row-num {
  background: var(--ink);
  border-color: var(--ink);
  font-size: 0; /* hide the number; the check below replaces it */
}

.ait-row.ait-answered .ait-row-num::after {
  content: "";
  width: 0.8rem;
  height: 0.8rem;
  background: var(--icon-check-white) center / contain no-repeat;
}

.ait-row-text {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* controls: tooltip + answers on the right */

.ait-row-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

/* tooltip */

.ait-tip { position: relative; display: inline-flex; }

.ait-tip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-family: var(--font);
  font-size: var(--label-xs);
  color: var(--muted);
  cursor: pointer;
  vertical-align: 0.1em;
}

.ait-tip-btn:hover { border-color: var(--ink); color: var(--ink); }

.ait-tip-body {
  display: none;
  position: absolute;
  z-index: var(--z-tip);
  top: calc(100% + 0.5rem);
  right: 0;
  width: max-content;
  max-width: 22rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 0.6rem 0.85rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ait-tip-title {
  display: block;
  font-family: var(--font);
  font-size: var(--label-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.ait-tip-text {
  display: block;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* Escape adds .dismissed so a hover-shown tip can be closed without
   moving the pointer (WCAG 1.4.13); it clears on leave/blur. */
.ait-tip:not(.dismissed):hover .ait-tip-body,
.ait-tip:not(.dismissed):focus-within .ait-tip-body,
.ait-tip.open .ait-tip-body { display: block; }

/* segmented yes/no */

.ait-seg-group {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--hairline);
  background: var(--surface);
  padding: 0.15rem;
  gap: 0.15rem;
}

.ait-seg { position: relative; display: inline-flex; }

.ait-seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.ait-seg-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  min-height: 1.6rem;
  padding: 0 0.6rem;
  font-family: var(--font);
  font-size: var(--label-md);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.ait-seg:hover .ait-seg-label { background: var(--bg-alt); }

.ait-seg input:checked + .ait-seg-label {
  background: var(--ink);
  color: var(--on-ink);
}

.ait-seg input:focus-visible + .ait-seg-label {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- generate bar ---------- */

/* Full-bleed sticky bar: the frosted surface and its top separator run
   edge to edge of the screen; the horizontal padding puts the content
   back on the container grid. */
.ait-genbar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-genbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--hairline);
  padding: 0.85rem calc(50vw - 50% + 0.25rem);
  margin: 1.5rem calc(50% - 50vw) 0;
}

.ait-genleft {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.ait-genprogress {
  width: 11rem;
  max-width: 40vw;
  height: 6px;
  background: var(--track);
  overflow: hidden;
}

.ait-genprogress-fill {
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 250ms var(--ease-out);
}

.ait-gencount {
  font-family: var(--font);
  font-size: var(--label-md);
  letter-spacing: 0.02em;
  color: var(--muted);
}

.ait-genstatus {
  font-size: 0.85rem;
  color: var(--ink);
}

/* ---------- modal ---------- */

html.ait-modal-open { overflow: hidden; }

.ait-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(17, 17, 17, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 3rem 1rem;
}

.ait-modal {
  position: relative;
  width: 100%;
  max-width: 68rem;
  background: var(--bg);
  border: 1px solid var(--hairline);
  padding: 2.25rem 2.25rem 1.75rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

.ait-modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--hairline);
  color: var(--muted);
  cursor: pointer;
}

.ait-modal-close svg { display: block; }

.ait-modal-close:hover { color: var(--ink); border-color: var(--ink); }

.ait-modal-title {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 3.25rem 1.5rem 0;
}

.ait-modal-title:focus { outline: none; }

.ait-scoregrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 1.25rem;
  align-items: stretch;
  margin-bottom: 1.25rem;
}

/* --- vertical level stepper --- */

.ait-stepper {
  --stepper-pad: 1.4rem;
  --stepbox: 1.6rem;
  position: relative;
  border: 1px solid var(--hairline);
  padding: 1.25rem var(--stepper-pad);
}

.ait-stepper-track {
  position: absolute;
  left: calc(var(--stepper-pad) + var(--stepbox) / 2 - 1px);
  width: 2px;
  background: var(--track);
}

.ait-stepper-fill {
  width: 100%;
  height: 0;
  background: var(--ink);
  transition: height 700ms var(--ease-out);
}

.ait-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.ait-step {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.55rem 0;
}

.ait-step-box {
  position: relative;
  z-index: 1;
}

.ait-step-passed .ait-step-box,
.ait-step-current .ait-step-box {
  border-color: var(--ink);
  background: var(--ink);
}

.ait-step-passed .ait-step-box::after,
.ait-step-current .ait-step-box::after {
  content: "";
  width: 0.8rem;
  height: 0.8rem;
  background: var(--icon-check-white) center / contain no-repeat;
}

.ait-step-locked .ait-step-box::after {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  background: var(--icon-x-gray) center / contain no-repeat;
}

.ait-step-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--faint);
}

.ait-step-desc {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--faint);
  margin-top: 0.15rem;
  max-width: 26em;
}

.ait-step-current .ait-step-name { color: var(--ink); font-weight: 600; }

.ait-step-current .ait-step-desc { color: var(--ink); }

/* --- radar chart --- */

.ait-radar-wrap {
  min-width: 0;
  border: 1px solid var(--hairline);
  padding: 1.25rem;
  display: flex;
  align-items: center;
}

.ait-radar { width: 100%; height: auto; display: block; }

.ait-radar-ring { fill: none; stroke: var(--hairline); }

.ait-radar-axis { stroke: var(--hairline-faint); }

.ait-radar-data {
  fill: rgba(17, 17, 17, 0.08);
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.ait-radar-label {
  font-family: var(--font);
  font-size: 13px;
  fill: var(--ink);
}

/* ---------- results blocks ---------- */

.ait-block-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 1rem;
}

.ait-gaps {
  border: 1px solid var(--hairline);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

.ait-gap-list { list-style: none; margin: 0; padding: 0; }

.ait-gap-item {
  display: flex;
  align-items: flex-start;
  gap: 1.1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--hairline);
}

.ait-gap-item:last-child { border-bottom: none; }

.ait-gap-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-top: 0.1rem;
}

.ait-level5-line {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  padding: 1rem 1.2rem;
  background: var(--bg-alt);
  border: 1px solid var(--hairline);
  margin-bottom: 2rem;
}

.ait-deep-cta {
  background: var(--bg-alt);
  border: 1px solid var(--hairline);
  padding: 1.2rem 1.3rem;
  margin-bottom: 2rem;
}

.ait-deep-cta p {
  max-width: 38em;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--ink-soft);
}

/* ---------- dark theme (rgba surfaces; tokens handle the rest) ---------- */

html[data-theme="dark"] .ait-genbar { background: rgba(17, 17, 17, 0.92); }
html[data-theme="dark"] .ait-modal-backdrop { background: rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .ait-mode-tab.active .ait-mode-tab-chip { background: rgba(0, 0, 0, 0.16); }
html[data-theme="dark"] .ait-radar-data { fill: rgba(242, 242, 242, 0.1); }

/* ---------- motion & responsive ---------- */

@media (prefers-reduced-motion: reduce) {
  .ait-app *, .ait-modal * { transition: none !important; animation: none !important; }
}

@media (max-width: 640px) {
  /* Fluid tabs with a comfortable tap height on touch screens. */
  .ait-mode-tabs { display: flex; }
  .ait-mode-tab { min-width: 0; flex: 1; min-height: 42px; justify-content: center; }

  /* Number tile on top, question below it; Yes/No sits on the text's
     left edge with the "?" on the right at a matching size. */
  .ait-row-main {
    flex-direction: column;
    align-items: stretch;
    gap: 0.8rem;
  }
  .ait-row-textwrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    max-width: none;
  }
  .ait-row-controls {
    justify-content: space-between;
  }
  .ait-tip-btn { width: 2rem; height: 2rem; }
  .ait-name-row .ait-name-input { width: 100%; max-width: none; }
  .ait-genbar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .ait-generate { width: 100%; }
  .ait-modal { padding: 1.5rem 1.1rem 1.25rem; }
  .ait-scoregrid { grid-template-columns: 1fr; gap: 1.5rem; }
  .ait-modal-backdrop { padding: 1rem 0.5rem; }
  .ait-tip-body { max-width: 80vw; }
  .ait-row-controls { align-self: stretch; justify-content: space-between; }
}
