/* Specter's stylesheet. Hand-written, custom properties for light and dark,
   no framework (§2.3). Everything here is driven by the classes the server
   already emits; the file is grouped tokens → reset → layout → components. */

/* ---------------------------------------------------------------- tokens */

:root {
  /* Tell the browser both themes are supported, so form controls, scrollbars,
     the caret and native focus rings follow the theme instead of staying
     light (NFR-UX-02). */
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #eef1f4;

  --fg: #1f2328;
  --fg-muted: #59636e;
  --fg-subtle: #818b98;

  --border: #d1d9e0;
  --border-strong: #afb8c1;

  --accent: #0969da;
  --accent-fg: #ffffff;
  --accent-bg: #ddf4ff;
  --accent-border: #b6e3ff;

  --ok: #1a7f37;
  --ok-strong: #116329;
  --ok-bg: #dafbe1;
  --ok-border: #aceebb;

  --err: #cf222e;
  --err-strong: #a40e26;
  --err-bg: #ffebe9;
  --err-border: #ffcecb;

  --warn: #9a6700;
  --warn-strong: #7a5200;
  --warn-bg: #fff8c5;
  --warn-border: #eac54f;

  /* Changed-line marks (FR-EDIT-07) and diff tints. */
  --change-bg: #f2f9ff;
  --change-rule: #54aeff;
  --add-bg: #e6ffec;
  --del-bg: #ffebe9;

  --focus: #0969da;

  --font: ui-sans-serif, system-ui, sans-serif;
  --font-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-page: 1.75rem;
  --text-lg: 1.375rem;
  --text-md: 1.125rem;
  --text: 1rem;
  --text-sm: 0.8125rem;
  --text-xs: 0.75rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius: 6px;
  --radius-lg: 10px;

  /* Motion. Short and quiet: things settle into place, nothing performs.
     Every duration, stagger and nudge below reads these tokens, and the
     reduced-motion block at the end of this file sets them to nothing and
     pauses the loops, which stops all of it in one place. */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  /* A little overshoot, for things that pop: a vote, a chip, a chevron. */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 120ms;
  --duration: 200ms;
  --duration-slow: 320ms;
  /* The gap between items of a list arriving one after another. */
  --stagger: 40ms;
  /* How far a hovered button rises, and how far a pressed one gives. */
  --lift: -1px;
  --press: 0.97;
  --loop: running;

  /* The reading measure for spec prose. */
  --measure: 72ch;
  /* The width of the sidebar in the two-column pages (B.4, B.6). */
  --sidebar: 20rem;
  --page-max: 78rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-subtle: #151b23;
    --bg-inset: #010409;

    --fg: #f0f6fc;
    --fg-muted: #9198a1;
    --fg-subtle: #6e7781;

    --border: #3d444d;
    --border-strong: #556066;

    --accent: #4493f8;
    --accent-fg: #ffffff;
    --accent-bg: #121d2f;
    --accent-border: #1f3a5f;

    --ok: #3fb950;
    --ok-strong: #56d364;
    --ok-bg: #0f2417;
    --ok-border: #1b4721;

    --err: #f85149;
    --err-strong: #ff7b72;
    --err-bg: #2a1215;
    --err-border: #5c2a2a;

    --warn: #d29922;
    --warn-strong: #e3b341;
    --warn-bg: #272115;
    --warn-border: #5a4413;

    --change-bg: #101d2e;
    --change-rule: #316dca;
    --add-bg: #0f2417;
    --del-bg: #2a1215;

    --focus: #4493f8;
  }
}

/* ----------------------------------------------------------------- reset */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  color: var(--fg);
  background: var(--bg);
  font-family: var(--font);
  font-size: var(--text);
  line-height: 1.6;
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
  transition-property: text-decoration-thickness, text-underline-offset, color;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
}

a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}

h1,
h2,
h3 {
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* One visible focus treatment everywhere, so keyboard users can always see
   where they are (NFR-UX-01). */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
  animation: focus-in var(--duration-fast) var(--ease);
}

/* Bypass the header's search box and nav on every page (NFR-UX-01). */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  transform: translateY(-200%);
  transition: transform var(--duration) var(--ease);
}

.skip-link:focus {
  transform: none;
}

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

/* ------------------------------------------------------------- controls */

button,
.button,
input,
select,
textarea {
  font: inherit;
  font-size: var(--text-sm);
  color: var(--fg);
}

input[type="text"],
input[type="search"],
select,
textarea {
  min-height: 2.125rem;
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  caret-color: var(--accent);
  transition-property: border-color, box-shadow;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
}

/* The hint steps back once you start, rather than vanishing on the first
   key. */
input::placeholder,
textarea::placeholder {
  transition: opacity var(--duration) var(--ease);
}

input:focus::placeholder,
textarea:focus::placeholder {
  opacity: 0.5;
}

input[type="text"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

textarea {
  min-height: 4rem;
  line-height: 1.5;
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.125rem;
  padding: var(--space-2) var(--space-4);
  font-weight: 500;
  text-decoration: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition-property:
    background-color, border-color, color, filter, transform, box-shadow;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
}

/* A hovered button rises a pixel onto a soft shadow, and a press gives
   under the finger, so a click is felt before the page answers. */
button:hover:not(:disabled),
.button:hover {
  border-color: var(--border-strong);
  transform: translateY(var(--lift));
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.06),
    0 3px 8px rgb(0 0 0 / 0.06);
}

button:active:not(:disabled),
.button:active {
  transform: scale(var(--press));
  box-shadow: none;
  transition-duration: calc(var(--duration-fast) / 2);
}

button:disabled,
button[disabled] {
  background: var(--bg-inset);
  color: var(--fg-subtle);
  border-color: var(--border);
  cursor: not-allowed;
}

button.primary,
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

button.primary:hover,
.button.primary:hover {
  filter: brightness(1.08);
}

/* The filled buttons catch the light when hovered: a soft sheen crosses
   them once. It resets without a transition, so it never sweeps back. */
button.primary,
.button.primary,
button.approve {
  position: relative;
  overflow: hidden;
}

button.primary::before,
.button.primary::before,
button.approve::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgb(255 255 255 / 0.22) 50%,
    transparent 70%
  );
  transform: translateX(-110%);
  pointer-events: none;
}

button.primary:hover:not(:disabled)::before,
.button.primary:hover::before,
button.approve:hover:not(:disabled)::before {
  transform: translateX(110%);
  transition: transform calc(var(--duration-slow) * 2) var(--ease);
}

/* Approve is the one affirmative action in the product; reject is outlined
   rather than filled, so the two never look interchangeable (B.6). */
button.approve {
  background: var(--ok);
  border-color: var(--ok);
  color: #ffffff;
}

button.reject {
  background: var(--bg);
  border-color: var(--err);
  color: var(--err-strong);
}

/* The button that started a request, while it runs (marked by
   `frontend/src/motion.ts`). A reply can stream for a minute; the ring says
   the click was heard and the page is still working. */
button[aria-busy="true"] {
  cursor: progress;
}

button[aria-busy="true"]::after {
  content: "";
  flex: 0 0 auto;
  width: 0.875em;
  height: 0.875em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  opacity: 0.75;
  animation: spin 700ms linear infinite var(--loop);
}

/* Forms are layout, not content: they should not force a line break of their
   own next to the button they wrap. */
form.inline {
  display: inline;
}

/* --------------------------------------------------------------- header */

.site-header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.brand-logo {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  transition: transform var(--duration-slow) var(--ease-spring);
}

/* The logo tips its hat when you reach for home. */
.brand:hover .brand-logo {
  transform: rotate(-8deg) scale(1.08);
}

.login-logo {
  width: 96px;
  height: 96px;
}

.goto-issue {
  display: flex;
  gap: var(--space-2);
  flex: 1 1 auto;
  max-width: 26rem;
}

.goto-issue input {
  flex: 1 1 auto;
  min-width: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-left: auto;
  font-size: var(--text-sm);
}

.site-header .user {
  color: var(--fg-muted);
}

/* --------------------------------------------------------------- layout */

main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-5);
}

/* The spec-beside-sidebar layout of B.4 and B.6. */
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar);
  gap: var(--space-6);
  align-items: start;
}

.columns > aside {
  position: sticky;
  top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  font-size: var(--text-sm);
}

@media (max-width: 900px) {
  .columns {
    grid-template-columns: minmax(0, 1fr);
  }

  .columns > aside {
    position: static;
  }

  .site-header {
    flex-wrap: wrap;
  }
}

/* ------------------------------------------------------------ page head */

/* The shared identity block every spec page renders (B.4 … B.7). */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-head > div {
  flex: 1 1 22rem;
  min-width: 0;
}

.page-head h1 {
  margin: var(--space-1) 0 0;
  font-size: var(--text-page);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.breadcrumb .number {
  font-family: var(--font-mono);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

/* Edit / Review / History stop reading as prose and start reading as the
   navigation they are. */
.spec-nav {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.spec-nav > a,
.spec-nav > span {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  background: var(--bg-subtle);
  color: var(--fg);
  text-decoration: none;
  border-right: 1px solid var(--border);
  transition-property: background-color, box-shadow;
  transition-duration: var(--duration-fast);
  transition-timing-function: var(--ease);
}

.spec-nav > a:hover {
  background: var(--bg);
}

.spec-nav > :last-child {
  border-right: 0;
}

.spec-nav > [aria-current="page"] {
  background: var(--bg);
  font-weight: 500;
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ----------------------------------------------------------------- chips */

.chip,
.label,
.state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem 0.5rem;
  font-size: var(--text-xs);
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--fg);
}

.chip.approved,
.state.open {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-strong);
}

.chip.implemented {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.chip.abandoned,
.state.closed {
  background: var(--bg-subtle);
  color: var(--fg-subtle);
}

/* ---------------------------------------------------------------- panels */

aside section,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

aside section > h2,
.panel > h2 {
  margin: 0;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

aside section > :not(h2),
.panel > :not(h2) {
  margin: 0;
  padding: var(--space-3) var(--space-4);
}

aside dl {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
}

aside dt {
  color: var(--fg-muted);
}

aside dd {
  margin: 0;
}

/* --------------------------------------------------------------- notices */

.notice,
.issue-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}

.notice > p,
.issue-banner > p {
  margin: 0;
  flex: 1 1 18rem;
}

.notice > form {
  display: flex;
  gap: var(--space-2);
}

.notice.flag {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-color: var(--warn);
  color: var(--warn-strong);
}

.notice.gone,
.notice.error {
  background: var(--err-bg);
  border-color: var(--err-border);
  border-left-color: var(--err);
  color: var(--err-strong);
}

/* "alice is generating a reply — this spec is read-only" (FR-EDIT-10). */
.notice.busy {
  background: var(--bg-subtle);
  border-color: var(--border);
  border-left-color: var(--fg-muted);
  color: var(--fg);
}

/* Someone is generating right now: a slow pulse, so the banner reads as
   live rather than as a note left behind. */
.notice.busy::before,
.generation-status.busy::before {
  content: "";
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite var(--loop);
}

/* --------------------------------------------------------- status colours */

.ok {
  color: var(--ok-strong);
}

.err {
  color: var(--err-strong);
}

.muted,
.token-totals {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.error {
  max-width: 34rem;
  margin: var(--space-7) auto;
  text-align: center;
}

.error h1 {
  font-size: 3rem;
  margin: 0;
  color: var(--fg-muted);
}

/* ----------------------------------------------------------------- votes */

.votes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-left: 0;
}

.vote {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.vote .verdict {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  line-height: 1;
}

.vote.approved .verdict {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-strong);
}

.vote.rejected .verdict {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-strong);
}

.vote .reason {
  display: block;
  color: var(--fg-muted);
  /* A reason may be several lines; show the breaks the author typed. */
  white-space: pre-wrap;
}

.tally .for {
  color: var(--ok-strong);
}

.tally .against {
  color: var(--err-strong);
}

/* ------------------------------------------------------------ spec prose */

.spec {
  max-width: var(--measure);
  font-size: var(--text);
}

.spec h1 {
  font-size: var(--text-page);
}

.spec h2 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
}

.spec h3 {
  font-size: var(--text-md);
}

.spec li {
  margin-bottom: var(--space-2);
}

.spec code,
.spec pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.spec code {
  padding: 0.1em 0.35em;
  background: var(--bg-inset);
  border-radius: 4px;
}

.spec pre {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-inset);
  border-radius: var(--radius);
  overflow-x: auto;
}

.spec pre code {
  padding: 0;
  background: none;
}

.spec table {
  border-collapse: collapse;
}

.spec th,
.spec td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  text-align: left;
}

.spec blockquote {
  margin-inline: 0;
  padding-left: var(--space-4);
  border-left: 3px solid var(--border);
  color: var(--fg-muted);
}

/* @p IDs are the spec's addresses, so they read as identifiers, not
   emphasis. */
.p-id {
  font-family: var(--font-mono);
  font-size: 0.875em;
  font-style: normal;
  color: var(--fg-muted);
}

/* What changed since the parent revision (FR-EDIT-07). A rule in the margin
   says "new since you last read this"; the browser's default <mark> says
   "error", and its yellow is unreadable against the dark theme. */
mark.change {
  display: inline;
  background: var(--change-bg);
  box-shadow:
    -0.75rem 0 0 var(--change-bg),
    -1rem 0 0 var(--change-rule);
  color: inherit;
}

/* ------------------------------------------------------------------ diff */

.diff {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.diff-line {
  display: block;
  padding: 0 var(--space-3);
  white-space: pre-wrap;
  border-left: 3px solid transparent;
}

.diff-line:not(.add, .del) {
  transition: background-color var(--duration-fast) var(--ease);
}

.diff-line:not(.add, .del):hover {
  background-color: var(--bg-subtle);
}

.diff-line.add {
  background: var(--add-bg);
  border-left-color: var(--ok);
}

.diff-line.del {
  background: var(--del-bg);
  border-left-color: var(--err);
}

.diff-stat .added {
  color: var(--ok-strong);
}

.diff-stat .removed {
  color: var(--err-strong);
}

/* ---------------------------------------------------------------- tables */

.specs,
.history {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.specs caption,
.history caption {
  text-align: left;
  padding-bottom: var(--space-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.specs th,
.history th {
  text-align: left;
  font-weight: 600;
  color: var(--fg-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.specs td,
.history td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--bg-inset);
}

/* A hovered row gains an accent rule at its edge, so the eye can follow it
   across a wide table. */
.specs td:first-child,
.history td:first-child {
  transition: box-shadow var(--duration-fast) var(--ease);
}

.specs tbody tr:hover td:first-child,
.history tbody tr:hover td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

.specs tbody tr,
.history tbody tr {
  transition: background-color var(--duration-fast) var(--ease);
}

.specs tbody tr:hover,
.history tbody tr:hover {
  background: var(--bg-subtle);
}

.specs td:first-child a,
.history td:first-child a {
  font-family: var(--font-mono);
}

.project {
  margin-bottom: var(--space-6);
}

.project h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--text-lg);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.all-specs {
  margin-left: auto;
  font-size: var(--text-sm);
  font-weight: 400;
}

.paging {
  margin-top: var(--space-4);
}

/* ------------------------------------------------------------ issue text */

/* The issue's body and comments are rendered Markdown, so they read as
   prose. They stay in a bounded, scrollable region rather than pushing the
   rest of the sidebar off the page. */
.issue-digest,
.issue-body {
  max-height: 18rem;
  overflow: auto;
  font-size: var(--text-xs);
  line-height: 1.55;
  background: var(--bg-inset);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.issue-body {
  max-height: 24rem;
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
}

.issue-digest > :first-child,
.issue-body > :first-child {
  margin-top: 0;
}

.issue-digest > :last-child,
.issue-body > :last-child {
  margin-bottom: 0;
}

/* Code blocks and images come through GitHub issues constantly; neither may
   break out of the column it is read in. (`code` keeps the browser's own
   monospace: a rule for it here would sit below `.spec pre code` and never
   apply.) */
.issue-digest pre,
.issue-body pre {
  padding: var(--space-2);
  background: var(--bg);
  border-radius: var(--radius);
  overflow-x: auto;
}

.issue-digest img,
.issue-body img {
  max-width: 100%;
  height: auto;
}

/* A comment is its own block under the body, with the author and date
   above it: without the rule they run together as one long text. */
.issue-comment {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.byline {
  margin-bottom: var(--space-1);
  color: var(--fg-muted);
  font-weight: 600;
}

.disclosure {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* Every disclosure gets one chevron of our own in place of the browser's
   triangle, so it can turn as the section opens. */
details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "";
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  margin: 0 0.6em 0.15em 0.1em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--duration) var(--ease-spring);
}

details[open] > summary::before {
  transform: rotate(45deg);
}

aside details > summary {
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--accent);
}

aside details[open] > summary {
  margin-bottom: var(--space-2);
}

/* What a <details> reveals eases in rather than appearing at once. */
details[open] > :not(summary) {
  animation: enter var(--duration) var(--ease);
}

/* ----------------------------------------------- login, explore, bootstrap */

.login {
  max-width: 24rem;
  margin: var(--space-7) auto;
  text-align: center;
}

.login h1 {
  font-size: var(--text-page);
}

/* The setup wizard (spec §7.13, B.9). */
.setup {
  max-width: 36rem;
  margin: var(--space-7) auto;
}

.setup h1 {
  font-size: var(--text-page);
}

.setup-progress {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.setup form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.setup form input[type="text"],
.setup form input[type="password"] {
  width: 100%;
}

.setup .hint {
  margin: 0;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}

.setup .error,
.setup .warning {
  padding: var(--space-2) var(--space-3);
  border: 1px solid;
  border-radius: var(--radius);
}

.setup .error {
  color: var(--err-strong);
  background: var(--err-bg);
  border-color: var(--err-border);
}

.setup .warning {
  color: var(--warn-strong);
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.setup-steps li {
  margin-block: var(--space-3);
}

.setup-steps li.done {
  color: var(--fg-muted);
}

.setup-steps li.done::marker {
  color: var(--ok);
}

.exploration-messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.exploration-link,
.seed-review {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.create-spec {
  margin-top: var(--space-3);
}

.create-spec summary {
  cursor: pointer;
  color: var(--accent);
}

.confirm {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  color: var(--warn-strong);
}

.repo {
  font-family: var(--font-mono);
}

/* ------------------------------------------------------- page components */

/* The lifecycle actions of B.4 are a row of choices, not a stack of forms. */
.lifecycle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.lifecycle form {
  display: flex;
  gap: var(--space-2);
}

.lifecycle:empty {
  display: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* What is blocking approval, listed rather than counted (B.6). */
.lint {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: 0;
  font-size: var(--text-sm);
}

.lint .where,
.lint .rule {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.revisions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: 0;
}

.revisions li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.revisions .seq {
  font-family: var(--font-mono);
  color: var(--fg-muted);
}

/* The editor: the buffer fills the page, its controls sit under it. */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#editor textarea {
  width: 100%;
  min-height: 60vh;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  tab-size: 2;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.editor-actions label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.editor-actions input {
  flex: 1 1 14rem;
  max-width: 24rem;
}

.editor-actions button {
  margin-left: auto;
}

/* ------------------------------------------------- the conversation pane */

/* B.5 draws the buffer and the conversation side by side. Below the two-pane
   width the conversation follows the buffer rather than squeezing beside it. */
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 28rem);
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 1100px) {
  .editor-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The buffer's column: the form, then lint and the preview under it (B.5). */
.editor-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

/* CodeMirror, once `frontend/src/editor.ts` has mounted it over the
   textarea. Its own look is kept to structure; colours come from here, so
   both schemes follow the tokens. */
#editor .cm-editor {
  min-height: 60vh;
  font-size: var(--text-sm);
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#editor .cm-editor.cm-focused {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

#editor .cm-scroller {
  font-family: var(--font-mono);
  line-height: 1.7;
}

#editor .cm-content {
  caret-color: var(--fg);
}

#editor .cm-gutters {
  background: var(--bg-subtle);
  color: var(--fg-subtle);
  border-right: 1px solid var(--border);
}

#editor .cm-activeLine,
#editor .cm-activeLineGutter {
  background: var(--change-bg);
}

#editor .cm-tooltip {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.editor-checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.editor-checks-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
}

.editor-checks-head h2 {
  margin: 0;
  font-size: var(--text-md);
}

.lint-summary {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

#preview-toggle {
  margin-left: auto;
}

#preview-toggle[aria-pressed="true"] {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

/* The spec as the spec page will show it. */
.preview {
  max-height: 70vh;
  overflow: auto;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.conversation-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.conversation-head h2 {
  margin: 0;
  font-size: var(--text-md);
}

.conversation .earlier {
  font-size: var(--text-sm);
}

/* The message list. A long conversation scrolls inside the pane so the
   composer and the buffer stay where they were. */
.messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
}

.message {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: var(--text-sm);
  line-height: 1.6;
  transition: border-color var(--duration) var(--ease);
}

.message-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* FR-EDIT-12: author and time on every message. The avatar is initials
   rather than a GitHub image, which `img-src 'self' data:` would block. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--bg-inset);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

.message .who {
  font-weight: 600;
}

.message .when {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Three weights, so a long thread has a rhythm rather than being a stack of
   identical boxes: what a person asked reads as a line of talk against the
   pane, the model's reply is the substantial thing and keeps the panel, and an
   event is a quiet note between them. */
.message.user {
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-left: 2px solid var(--accent-border);
  border-radius: 0;
  background: none;
}

/* A reply from the model, set apart from what people wrote. */
.message.assistant {
  background: var(--bg-subtle);
}

.message.assistant:hover {
  border-color: var(--border-strong);
}

/* On the plain line the name carries the weight the panel gave the reply. */
.message.user .who {
  color: var(--fg-muted);
}

.message.user .avatar {
  background: var(--accent-bg);
  color: var(--accent);
}

/* An event is what happened to the spec, so it reads as a line rather than
   as a message. */
.message.event {
  border: 0;
  padding: var(--space-1) var(--space-3);
  border-left: 2px solid var(--border);
  border-radius: 0;
  background: none;
  color: var(--fg-muted);
}

.message.event .message-body {
  white-space: normal;
}

/* B.5 draws the reasoning collapsed. */
.reasoning {
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
}

.reasoning-summary {
  cursor: pointer;
  color: var(--fg-muted);
}

.reasoning-body {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--bg-inset);
  color: var(--fg-muted);
  white-space: pre-wrap;
  max-height: 14rem;
  overflow: auto;
}

/* The applied edit and the open questions: the two things a reply leaves
   behind that need an answer (FR-EDIT-05, FR-EDIT-07). Both are empty until
   a reply fills them, and an empty one takes no room. */
.applied-edit:empty,
.questions:empty,
.generation-status:empty {
  display: none;
}

.applied-edit,
.questions {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--accent-bg);
  font-size: var(--text-sm);
}

.applied-edit h3,
.questions h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.edit-message {
  margin: 0 0 var(--space-1);
}

.edit-target {
  margin: 0 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.question {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--accent-border);
}

.question .q-text {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.question .q-why,
.question .q-suggested {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.question .answer {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
}

.question .skip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* FR-EDIT-10: who is generating, and the spec being read-only meanwhile. */
.generation-status.busy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--warn-border);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-strong);
  font-size: var(--text-sm);
}

.generation-status p {
  margin: 0;
  flex: 1 1 14rem;
}

/* The composer, and the presets above it (FR-EDIT-08). */
.composer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.presets button {
  font-size: var(--text-sm);
}

.composer label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.composer .message-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.6;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
}

.regenerate button {
  font-size: var(--text-sm);
}

/* The reply's token totals, a footnote under the conversation. */
.conversation .token-totals {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* The review page's own sections, which are not sidebar panels. */
.columns > div > section {
  margin-bottom: var(--space-5);
}

.columns > div > section > h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
}

.diff-stat {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 400;
}

/* Reject sits under its own label, and never looks like Approve. */
.columns > aside form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.columns > aside form label {
  flex: 1 0 100%;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.columns > aside form input[type="text"] {
  flex: 1 1 8rem;
  min-width: 0;
}

/* The rejection reason is a paragraph, not a word: it takes the full width
   of the panel and stays resizable. Keyed by id rather than by
   `aside form textarea`, which would descend below `#editor textarea`. */
#reject-reason {
  flex: 1 0 100%;
  min-width: 0;
  min-height: 7rem;
}

/* ---------------------------------------------------------------- motion */

/* What htmx swaps in (a message, a question, a banner) eases into place
   rather than popping in. `frontend/src/motion.ts` adds the class and, when
   one swap brings several things, numbers them so they arrive in turn;
   without JavaScript nothing is swapped, so nothing needs it. */
.entering {
  animation: enter var(--duration) var(--ease) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* A new message's initials land a beat after the message itself. */
.entering .avatar {
  animation: pop var(--duration-slow) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * var(--stagger) + var(--duration-fast));
}

/* A page arrives in reading order: its head first, then its lists one row
   after another. Only the first ten rows are staggered, so a long table is
   never kept waiting. */
.page-head,
.login,
.error,
.empty,
.confirm,
.notice,
.issue-banner {
  animation: enter var(--duration-slow) var(--ease) both;
}

.project,
.specs tbody tr,
.history tbody tr,
.lint > li,
.revisions > li,
.votes > li,
.exploration-messages > *,
.columns > aside > *,
.columns > div > section {
  animation: enter var(--duration-slow) var(--ease) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* The editor's lint list is redrawn as you type; entries that rose into
   place on every pause would never sit still. */
.lint.live > li {
  animation: none;
  padding-left: var(--space-2);
  border-left: 3px solid var(--border);
}

.lint.live > li.severity-error {
  border-left-color: var(--err);
}

.lint.live > li.severity-warning {
  border-left-color: var(--warn);
}

/* Each entry's line number is a button that moves the cursor there. */
.lint.live .where {
  display: inline;
  min-height: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(2) {
  --i: 1;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(3) {
  --i: 2;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(4) {
  --i: 3;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(5) {
  --i: 4;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(6) {
  --i: 5;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(7) {
  --i: 6;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(8) {
  --i: 7;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(9) {
  --i: 8;
}

:is(
    tbody,
    .lint,
    .revisions,
    .votes,
    .exploration-messages,
    aside,
    .columns > div
  )
  > :nth-child(n + 10) {
  --i: 9;
}

/* Chips and verdicts pop in just after the row that carries them. */
.chip,
.state,
.vote .verdict {
  animation: pop var(--duration-slow) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * var(--stagger) + var(--duration-fast));
}

/* The current tab draws its underline as the page arrives. */
.spec-nav > [aria-current="page"] {
  animation: tab-in var(--duration-slow) var(--ease) both;
}

/* What changed since you last read it rules itself into the margin a beat
   after the page settles, so the eye is drawn to it. */
mark.change {
  animation: mark-in var(--duration-slow) var(--ease) both;
  animation-delay: var(--duration-slow);
}

/* A failure gives one small shake of the head. */
.notice.error,
.err {
  animation:
    enter var(--duration-slow) var(--ease) both,
    nudge var(--duration-slow) var(--ease) var(--duration);
}

/* The two images that stand alone on a page breathe, very slowly. */
.login-logo,
.error h1 {
  animation: float 5s ease-in-out infinite var(--loop);
}

/* While the browser leaves for another page (a link, a plain form post), a
   thin bar runs along the top: the click was heard. `motion.ts` sets the
   class and clears it when a page is shown again. */
html.navigating body::before {
  content: "";
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  pointer-events: none;
  animation: progress 1.1s var(--ease) infinite var(--loop);
}

/* One page gives way to the next with a crossfade, and the header, the same
   on every page, holds still through it. Browsers without cross-document
   view transitions simply navigate. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  html {
    scroll-behavior: smooth;
  }
}

.site-header {
  view-transition-name: site-header;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration);
}

/* A long spec's paragraphs rise into place as they scroll into view. Only
   where scroll-driven animation exists, only on screen, and never under
   reduced motion: elsewhere the prose simply sits there. */
@media screen and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .spec > * {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(0.25rem);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

@keyframes tab-in {
  from {
    box-shadow: inset 0 0 0 var(--accent);
  }
}

@keyframes mark-in {
  from {
    background: transparent;
    box-shadow:
      -0.75rem 0 0 transparent,
      -1rem 0 0 transparent;
  }
}

@keyframes nudge {
  25% {
    transform: translateX(-3px);
  }

  50% {
    transform: translateX(3px);
  }

  75% {
    transform: translateX(-1px);
  }
}

@keyframes float {
  50% {
    transform: translateY(-4px);
  }
}

@keyframes progress {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

@keyframes focus-in {
  from {
    outline-offset: 5px;
    outline-color: transparent;
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Honour the system's reduced-motion setting. Every transition, entrance,
   stagger and nudge takes no time, nothing rises or gives, and the loops
   hold still: a still ring and a still dot still say "working", and the
   navigation bar stands at full width instead of running. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0s;
    --duration: 0s;
    --duration-slow: 0s;
    --stagger: 0s;
    --lift: 0;
    --press: 1;
    --loop: paused;
  }

  html.navigating body::before {
    width: 100%;
    transform: none;
    opacity: 0.6;
  }
}

/* ----------------------------------------------------------------- print */

@media print {
  .site-header,
  .spec-nav,
  .skip-link {
    display: none;
  }

  /* A printed spec is a document, not a control panel. The bare element
     selectors are deliberate here: nothing in print should re-show them.
     biome-ignore lint/style/noDescendingSpecificity: a print reset */
  form,
  button {
    display: none;
  }

  .columns {
    display: block;
  }

  .spec {
    max-width: none;
  }

  mark.change {
    box-shadow: none;
    border-left: 3px solid #888888;
    padding-left: 0.5rem;
  }
}
