/*
 * Direction C, the pull request. Plain CSS, no framework.
 * Tokens come from design/boards and docs/design-handoff.md ("Final details
 * from the design pass"). Use the custom properties, never raw values.
 */

/* Fonts: self-hosted, SIL Open Font License 1.1. Licenses sit beside the files in app/assets/fonts. */
@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/space-grotesk-latin-variable-3b2bde23.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/assets/inter-latin-variable-1f021a24.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/jetbrains-mono-latin-variable-7c88d0cc.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Color */
  --color-bg: #F3F5F8;
  --color-panel: #FFFFFF;
  --color-text: #151B26;
  --color-text-secondary: #2D3748;
  --color-text-muted: #4A5568;
  --color-accent: #1D4ED8;
  --color-accent-hover: #1E3A8A;
  --color-on-accent: #FFFFFF;
  --color-tint: #E6ECFD;
  --color-on-tint: #1E3A8A;
  --color-border: #D5DAE3;
  --color-divider: #E4E8EF;
  --color-border-card: #A9B2C3;
  --color-border-control: #6B7689;
  --color-border-strong: #151B26;
  --color-quiet: #EEF1F6;
  --color-quiet-subtle: #F7F8FB;
  --color-focus: #1D4ED8;
  --color-on-accent-muted: #DCE6FE;

  /* Type */
  --font-heading: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", Menlo, monospace;

  --text-title: 52px;
  --text-counter: 88px;
  --text-intro: 18px;
  --text-entry-title: 18px;
  --text-summary: 28px;
  --text-panel-title: 20px;
  --text-merge-title: 22px;
  --text-body: 16px;
  --text-card: 15px;
  --text-tab: 15px;
  --text-secondary: 14px;
  --text-small: 13px;
  --text-mono-heading: 14px;
  --text-mono-breadcrumb: 13px;
  --text-mono-meta: 12px;
  --text-chip: 11px;

  --leading-tight: 1.05;
  --leading-heading: 1.2;
  --leading-snug: 1.25;
  --leading-check: 1.35;
  --leading-body: 1.5;
  --leading-branch: 1.9;

  --tracking-title: -0.02em;
  --tracking-chip: 0.06em;
  --tracking-label: 0.08em;
  --tracking-day: 0.1em;

  /* Spacing */
  --space-2: 2px;
  --space-3: 3px;
  --space-4: 4px;
  --space-6: 6px;
  --space-8: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-14: 14px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-28: 28px;
  --space-40: 40px;

  --page-max-width: 1280px;
  --page-gutter: var(--space-40);
  --panel-gap: var(--space-24);
  --panel-header-padding: var(--space-14) var(--space-20);
  --panel-body-padding: var(--space-20);
  --check-icon-size: 22px;
  --list-indent: var(--space-20);
  --list-indent-ordered: 22px;

  /* Radius */
  --radius-panel: 10px;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-chip: 4px;
  --radius-pill: 999px;

  /* Touch targets */
  --target-tab: 48px;
  --target-action: 48px;
  --target-control: 44px;
  --target-pill: 32px;
  --target-small: 32px;

  /* Review thread. On desktop, beside the long Description, the panel is at
     least this tall once the thread has a question (852px, or the window
     less a margin, if shorter); the thread takes the extra height (about
     500px) and is never shorter than its minimum. Before the first question
     it is the smaller height, so at 1440 by 900 the question box is on the
     first screen (site spec) and the empty thread is not left hollow. The
     minimum stays low so that on a short window the header and the
     question box still fit on screen. */
  --thread-panel-height: 53.25rem;
  --thread-panel-height-empty: 48rem;
  --thread-min-height: 340px;
  /* Stacked below the Description (about 641 to 1100 wide) the panel fits
     its content and the thread is this tall. */
  --thread-stacked-height: 408px;
  --spinner-size: 14px;
  --text-input: 15px;
}

/* The mobile board (390 wide) uses smaller type and tighter spacing. */
@media (max-width: 640px) {
  :root {
    --text-title: 34px;
    --text-counter: 64px;
    --text-intro: 16px;
    --text-entry-title: 16px;
    --text-summary: 22px;
    --text-panel-title: 18px;
    --text-merge-title: 20px;
    --text-body: 15px;
    --text-tab: 14px;
    --text-secondary: 13px;
    --text-mono-heading: 13px;
    --text-mono-breadcrumb: 12px;
    --text-mono-meta: 11px;

    --leading-tight: 1.08;

    --page-gutter: var(--space-16);
    --panel-gap: var(--space-16);
    --panel-header-padding: var(--space-12) var(--space-16);
    --panel-body-padding: var(--space-16);
    --check-icon-size: 20px;
    --list-indent: 18px;
    --list-indent-ordered: var(--space-20);
    --text-input: 16px; /* 16px keeps phones from zooming into the box */
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

h1, h2, h3, p, ul, ol {
  margin: 0;
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--color-accent-hover);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-chip);
}

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

.skip-link {
  position: absolute;
  top: var(--space-8);
  left: var(--space-8);
  z-index: 1;
  padding: var(--space-8) var(--space-14);
  background: var(--color-panel);
  font-weight: 700;
  transform: translateY(-200%);
}

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

/* As on the boards: 1280px of content plus the side gutters (the boards size
   the container by its content box). */
.container {
  width: 100%;
  max-width: calc(var(--page-max-width) + 2 * var(--page-gutter));
  margin: 0 auto;
  padding-inline: var(--page-gutter);
}

/* Page header */
.page-header {
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
}

.page-header__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding-top: var(--space-20);
}

.breadcrumb {
  font-family: var(--font-mono);
  font-size: var(--text-mono-breadcrumb);
  color: var(--color-text-muted);
}

.page-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-title);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-title);
}

.page-title__number {
  font-weight: 500;
  color: var(--color-text-muted);
}

.pr-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12) var(--space-16);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--target-pill);
  padding: 0 var(--space-14);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-secondary);
  font-weight: 700;
  border-radius: var(--radius-pill);
}

.branch-line {
  font-family: var(--font-mono);
  font-size: var(--text-secondary);
  line-height: var(--leading-branch);
}

.branch {
  padding: var(--space-3) var(--space-8);
  background: var(--color-tint);
  color: var(--color-on-tint);
  border-radius: var(--radius-chip);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.summary-line {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: var(--text-summary);
  line-height: var(--leading-snug);
  text-wrap: pretty;
}

/* The main page header's "Show contact and resume details": top right, level with the
   title, on wide screens. Its column has a fixed width that holds both the
   button and the revealed details, so a reveal never rewraps the title; and
   it spans the title and status rows, which together are taller than the
   details (phone, email, LinkedIn, and the résumé row), so a reveal never
   changes the header's height. In this 18rem column the LinkedIn value
   wraps under its label, and the details are about 134px. Up to about
   1300px wide the title and status rows are at least 135px; wider, they
   fit on one line each (about 97px), so from 80rem the column also spans
   the summary line, which moves into the first column (it fits there at
   that width). The margin is small, so anything added to the details needs
   a recheck. On narrow screens it is a full-width row under the summary
   line, where it sits in the HTML. Other page headers keep the plain column
   layout. */
@media (width > 640px) {
  .page-header__inner--contact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    column-gap: var(--space-24);
  }

  .page-header__inner--contact > * {
    grid-column: 1 / -1;
  }

  .page-header__inner--contact > .page-title,
  .page-header__inner--contact > .pr-meta {
    grid-column: 1;
  }

  .page-header__inner--contact > .page-header__contact {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: start;
    justify-self: end;
    max-width: 100%;
  }
}

@media (width >= 80rem) {
  .page-header__inner--contact > .summary-line {
    grid-column: 1;
  }

  .page-header__inner--contact > .page-header__contact {
    grid-row: 2 / span 3;
  }
}

.page-header__contact .button {
  min-height: var(--target-action);
}

/* Tab bar: in-page anchor links, not ARIA tabs. */
.tabs {
  margin-top: var(--space-4);
  overflow-x: auto;
}

.tabs__list {
  display: flex;
  gap: var(--space-4);
  padding: 0;
  list-style: none;
}

.tabs__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-tab);
  padding: 0 var(--space-14);
  font-size: var(--text-tab);
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.tabs__link:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-border-card);
}

.tabs__link[aria-current] {
  font-weight: 700;
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}

.tabs__link:focus-visible {
  outline-offset: -3px;
}

/* Main layout */
.page-main {
  flex: 1 0 auto;
}

.page-main__inner {
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap);
  padding-top: var(--space-20);
  padding-bottom: var(--space-40);
}

/* Description and Review thread sit side by side, and stack below about
   1100px. The Review thread keeps its own height beside the long
   Description (see "Review thread" below). The row is a size container so
   that height applies exactly when the two fit side by side. */
.discussion-row {
  container-type: inline-size;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--panel-gap);
}

.discussion-row > .panel--description {
  flex: 1.3 1 600px;
}

.discussion-row > .panel--review-thread {
  flex: 1 1 400px;
}

/* Checks and Commits sit side by side, and stack below about 1065px. */
.proof-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr));
  gap: var(--panel-gap);
  align-items: stretch;
}

/* Panel */
.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  scroll-margin-top: var(--space-16);
}

.panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4) var(--space-8);
  padding: var(--panel-header-padding);
  border-bottom: 1px solid var(--color-border);
}

.panel--description .panel__header {
  padding-inline: var(--space-24);
}

.panel__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-panel-title);
  line-height: var(--leading-snug);
}

.panel__meta {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
}

.panel__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding: var(--panel-body-padding);
}

/* Description */
.description {
  --panel-body-padding: var(--space-24);
  gap: var(--space-24);
}

.description__part {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.mono-heading {
  font-family: var(--font-mono);
  font-size: var(--text-mono-heading);
  font-weight: 700;
  color: var(--color-accent);
}

.prose-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding-left: var(--list-indent);
}

ol.prose-list {
  padding-left: var(--list-indent-ordered);
}

/* The trailer fills the panel width. Its width and height attributes reserve
   the space before anything loads, and the dark background shows until the
   poster does. */
.trailer {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

/* "Sound on" over the poster, where the video's own label sits in its first
   seconds (right edge 5.7% in, top 6.5% down). trailer_controller.js shows it
   and hides it once the video plays. Clicks pass through to the video. */
.trailer-frame {
  position: relative;
}

.trailer__sound {
  position: absolute;
  top: 6.5%;
  right: 5.7%;
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-10);
  background: color-mix(in srgb, var(--color-text) 80%, transparent);
  color: var(--color-on-accent);
  border: 1px solid var(--color-on-accent-muted);
  border-radius: var(--radius-pill);
  font-family: var(--font-heading);
  font-size: var(--text-small);
  font-weight: 500;
  line-height: var(--leading-snug);
  pointer-events: none;
}

.trailer__sound[hidden] {
  display: none;
}

.trailer__sound-icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

/* Paragraphs keep a readable line length when the panel spans the full row. */
.description__part > p {
  max-width: 75ch;
}

/* Placeholders: nothing unconfirmed may pass as final copy. */
.placeholder {
  padding: 1px var(--space-6);
  background: var(--color-tint);
  color: var(--color-on-tint);
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 500;
  border: 1px dashed var(--color-accent);
  border-radius: var(--radius-chip);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.placeholder-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-14) var(--space-16);
  background: var(--color-tint);
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius-card);
}

.placeholder-block__label {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  font-weight: 700;
  letter-spacing: var(--tracking-chip);
  color: var(--color-on-tint);
}

.placeholder-block__text {
  font-size: var(--text-card);
  color: var(--color-text);
}

/* Checks */
.checks {
  padding: 0;
  list-style: none;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-10) var(--space-20);
  border-bottom: 1px solid var(--color-divider);
}

.check:last-child {
  border-bottom: 0;
  border-radius: 0 0 var(--radius-panel) var(--radius-panel);
}

.check__icon {
  flex: 0 0 auto;
  width: var(--check-icon-size);
  height: var(--check-icon-size);
  margin-top: var(--space-2);
}

.check--passing .check__icon {
  color: var(--color-accent);
}

.check__tick {
  stroke: var(--color-on-accent);
}

.check--waiting .check__icon {
  color: var(--color-text-muted);
}

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

.check__category {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
}

.check__value {
  font-weight: 700;
  line-height: var(--leading-check);
}

.check__detail {
  font-size: var(--text-secondary);
  line-height: var(--leading-check);
  color: var(--color-text-muted);
}

.check__detail .placeholder {
  font-size: var(--text-mono-meta);
}

.check--waiting {
  background: var(--color-quiet-subtle);
}

.check--waiting .check__value {
  color: var(--color-text-muted);
}

/* Empty and unavailable states */
.empty-state {
  font-size: var(--text-card);
  color: var(--color-text-secondary);
}

.system-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-14) var(--space-16);
  background: var(--color-quiet);
  border-radius: var(--radius-card);
}

.system-panel__label {
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  font-weight: 700;
  letter-spacing: var(--tracking-chip);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.system-panel__text {
  font-size: var(--text-card);
  color: var(--color-text-secondary);
}

/* Merge area */
.merge-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16) var(--space-24);
  padding: var(--space-20) var(--space-24);
  background: var(--color-panel);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-panel);
}

.merge-area__text {
  flex: 999 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.merge-area__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-merge-title);
  line-height: var(--leading-heading);
}

.merge-area__note {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

/* Contact details: a button until a visitor asks, then Philip's phone,
   email, and LinkedIn and two résumé links in its place
   (ContactRevealsController). */
.merge-area__contact {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
}

.merge-area__contact .button {
  min-height: var(--target-action);
}

.contact-details__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
}

.contact-details__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-10);
  min-width: 0;
}

.contact-details__label {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--color-text-muted);
  /* As wide as the longest label, "LinkedIn", so the values line up. */
  min-width: 8ch;
}

.contact-details__value {
  margin: 0;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.contact-details__resume {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-16);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
}

.contact-details__note {
  margin: 0;
  color: var(--color-text-secondary);
}

.contact-page {
  padding-block: var(--space-24);
}

/* Footer */
.page-footer {
  background: var(--color-panel);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
}

.page-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8) var(--space-24);
  padding-block: var(--space-16);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-16);
  padding: 0;
  list-style: none;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-control);
}

@media (max-width: 640px) {
  .page-header__inner {
    gap: var(--space-12);
    padding-top: var(--space-20);
    padding-inline: var(--space-20);
  }

  .status-pill {
    align-self: flex-start;
  }

  .branch-line {
    font-size: var(--text-small);
  }

  .summary-line {
    margin-top: 0;
  }

  .page-header__contact .button {
    width: 100%;
  }

  .tabs {
    margin: var(--space-4) calc(-1 * var(--space-10)) 0;
  }

  .tabs__list {
    gap: 0;
  }

  .tabs__link {
    padding: 0 var(--space-10);
  }

  .panel--description .panel__header {
    padding-inline: var(--space-16);
  }

  .description {
    --panel-body-padding: var(--space-16);
    gap: var(--space-20);
  }

  .description__part {
    gap: var(--space-8);
  }

  .prose-list {
    gap: var(--space-6);
  }

  .check {
    gap: var(--space-10);
    padding: var(--space-12) var(--space-16);
  }

  .merge-area {
    padding: var(--space-16);
  }

  .merge-area__text {
    flex-basis: 100%;
  }

  .page-footer__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-14) var(--space-20);
  }
}

/* Philip's Activities: shared pieces */
.kind-chip {
  align-self: flex-start;
  padding: var(--space-4) var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  font-weight: 700;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-chip);
  text-transform: uppercase;
  border-radius: var(--radius-chip);
}

.kind-chip--pr_merged {
  background: var(--color-tint);
  color: var(--color-on-tint);
}

.kind-chip--direct_push {
  background: var(--color-text);
  color: var(--color-on-accent);
}

/* Private entries are quieter: an outlined chip, never a filled one. */
.entry--private .kind-chip {
  padding: var(--space-3) 7px;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 400;
  border: 1px solid var(--color-border-control);
}

/* Commits preview on the main page */
.preview-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding: 0;
  list-style: none;
}

.preview-entry {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-12) var(--space-14);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-card);
}

.preview-entry--private {
  gap: var(--space-4);
  padding: var(--space-10) var(--space-14);
  background: var(--color-quiet);
  border-style: dashed;
}

.preview-entry__label {
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  font-weight: 700;
  letter-spacing: var(--tracking-chip);
  text-transform: uppercase;
  color: var(--color-accent);
}

.preview-entry--private .preview-entry__label {
  font-weight: 400;
  color: var(--color-text-muted);
}

.preview-entry__text {
  font-size: var(--text-card);
  line-height: 1.4;
}

.preview-entry--private .preview-entry__text {
  font-size: var(--text-secondary);
  color: var(--color-text-secondary);
}

.preview-entry__stats,
.entry__stats {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
}

.view-all {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: var(--target-control);
  font-size: var(--text-card);
  font-weight: 700;
}

/* The activity page */
.activity-header {
  gap: var(--space-14);
  padding-bottom: var(--space-28);
}

.activity-header__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8) var(--space-16);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--target-control);
  font-size: var(--text-card);
  font-weight: 700;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.activity-intro {
  max-width: 760px;
  font-size: var(--text-intro);
  color: var(--color-text-secondary);
  text-wrap: pretty;
}

.last-checked {
  font-family: var(--font-mono);
  font-size: var(--text-small);
}

/* The log and the sidebar sit side by side, and stack below about 1005px. */
.activity-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--panel-gap);
  padding-top: var(--space-28);
  padding-bottom: var(--space-40);
}

.activity-log {
  flex: 999 1 600px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.activity-sidebar {
  flex: 1 1 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

.filter-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-control);
  padding: 0 var(--space-16);
  background: var(--color-panel);
  color: var(--color-text);
  font-size: var(--text-secondary);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
}

.filter-button:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

.filter-button[aria-current] {
  background: var(--color-text);
  color: var(--color-on-accent);
  font-weight: 700;
  border-color: var(--color-text);
}

.activity-day {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  margin-top: var(--space-10);
}

.day-heading {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 700;
  letter-spacing: var(--tracking-day);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

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

.entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-16) var(--space-20);
  background: var(--color-panel);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-panel);
}

.entry--private {
  gap: var(--space-6);
  padding-block: var(--space-12);
  background: var(--color-quiet);
  border-style: dashed;
}

.entry__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8);
}

.entry__repo {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 700;
}

.entry__where {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
}

.entry__title {
  font-size: var(--text-entry-title);
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* The title links to the PR or the push. Underlined, so it reads as a link without relying on color. */
.entry__title a {
  color: inherit;
}

.entry__title a:hover {
  color: var(--color-accent-hover);
}

.entry__summary {
  font-size: var(--text-card);
  color: var(--color-text-secondary);
}

.entry--private .entry__summary {
  line-height: 1.45;
}

.entry__commits summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-control);
  color: var(--color-accent);
  font-size: var(--text-secondary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  list-style: none;
  cursor: pointer;
}

.entry__commits summary::-webkit-details-marker {
  display: none;
}

.entry__commits summary:hover {
  color: var(--color-accent-hover);
}

.entry__commits[open] .when-closed,
.entry__commits:not([open]) .when-open {
  display: none;
}

.commit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-12) var(--space-14);
  list-style: none;
  background: var(--color-quiet);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  line-height: 1.4;
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
}

.activity-empty {
  padding: var(--space-20);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8) var(--space-24);
  margin-top: var(--space-10);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-control);
  font-weight: 700;
}

.counter-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-24);
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-panel);
}

.counter-card__label {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-on-accent-muted);
}

.counter-card__number {
  font-family: var(--font-heading);
  font-size: var(--text-counter);
  font-weight: 700;
  line-height: 1;
}

.counter-card__note {
  font-size: var(--text-secondary);
  line-height: 1.45;
  color: var(--color-on-accent-muted);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-14);
  padding: var(--space-20);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
}

.legend__title {
  font-family: var(--font-heading);
  font-size: var(--text-panel-title);
  font-weight: 700;
}

.legend__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  font-size: var(--text-secondary);
}

.legend__item p {
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.legend__item--private {
  padding: var(--space-10) var(--space-12);
  background: var(--color-quiet);
  border: 1px dashed var(--color-border-card);
  border-radius: var(--radius-card);
}

@media (max-width: 640px) {
  .activity-header {
    padding-bottom: var(--space-20);
  }

  .activity-layout {
    padding-top: var(--space-20);
  }

  .entry {
    padding-inline: var(--space-16);
  }
}

/* Buttons: cobalt primary, outlined secondary, and an underlined text
   control. Every state has a visible focus ring (see the base focus rule). */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: var(--target-control);
  padding: 0 var(--space-14);
  font: inherit;
  font-size: var(--text-secondary);
  font-weight: 600;
  line-height: var(--leading-snug);
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.button--primary {
  padding-inline: var(--space-20);
  font-size: var(--text-card);
  font-weight: 700;
  color: var(--color-on-accent);
  background: var(--color-accent);
  border: 0;
}

.button--primary:hover {
  background: var(--color-accent-hover);
}

.button--secondary {
  color: var(--color-text);
  background: var(--color-panel);
  border: 1px solid var(--color-border-control);
}

.button--secondary:hover {
  background: var(--color-quiet-subtle);
  border-color: var(--color-text);
}

.button--small {
  min-height: var(--target-small);
  padding: 0 var(--space-10);
  font-size: var(--text-small);
}

.button--text {
  padding: 0 var(--space-4);
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.button--text:hover {
  color: var(--color-text);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  cursor: not-allowed;
  color: var(--color-text-muted);
  background: var(--color-border);
  border-color: var(--color-border);
  transform: none;
}

.button--secondary:disabled {
  background: var(--color-quiet);
  border-color: var(--color-border-card);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3) var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  font-weight: 700;
  color: var(--color-on-tint);
  background: var(--color-tint);
  border-radius: var(--radius-chip);
  white-space: nowrap;
}

/* Review thread: Ask about Phil (design/boards/AskAboutPhil.html and the
   Review thread section of the main page boards). */
.panel--review-thread {
  scroll-margin-top: var(--space-16);
}

.ask-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8) var(--space-12);
}

/* The header keeps its height when Start over appears in it, so the box
   below never shifts when a question posts. */
@media (width > 640px) {
  .ask-header {
    min-height: var(--target-small);
  }
}

.ask-header__actions:empty {
  display: none;
}

/* The panel body: the thread above, the question box below. On desktop the
   thread fills what the box leaves of the panel and scrolls inside itself,
   so the box never moves as the conversation grows. Without JavaScript the
   thread is not a scroll box and the panel simply fits its content. */
.ask-panel,
.ask {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Only while the panel sits beside the Description: the row is at least
   600px + 400px + the 24px gap wide (the flex bases of .discussion-row).
   Stacked below it, the panel fits its content, the thread at its stacked
   height. */
@media (scripting: enabled) {
  @container (width >= 1024px) {
    .panel--review-thread {
      min-height: min(var(--thread-panel-height-empty), calc(100dvh - 2 * var(--space-16)));
    }

    .panel--review-thread:has(.ask-exchange) {
      min-height: min(var(--thread-panel-height), calc(100dvh - 2 * var(--space-16)));
    }
  }
}

/* The thread scrolls inside the panel at every width. When it reaches its
   top or bottom, scrolling carries on to the page (no overscroll
   containment), so a finger on the thread never traps the page. Only with a
   mouse beside the Description does the wheel stay in the thread. */
.ask-thread {
  flex: 1 1 0;
  min-height: var(--thread-stacked-height);
  overflow-y: auto;
  border-bottom: 1px solid var(--color-border);
}

/* Beside the Description the panel's own height sets the thread's; this is
   only its floor. */
@container (width >= 1024px) {
  .ask-thread {
    min-height: var(--thread-min-height);
  }
}

@media (pointer: fine) {
  @container (width >= 1024px) {
    .ask-thread {
      overscroll-behavior: contain;
    }
  }
}

.ask-thread:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: -3px;
}

.ask-thread__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-16) var(--space-20);
}

.ask-thread__exchanges {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

.ask-thread__exchanges:empty {
  display: none;
}

.ask-empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 46ch;
}

.ask-empty__title {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  font-weight: 700;
  color: var(--color-text-muted);
}

.ask-empty__text {
  font-size: var(--text-card);
  color: var(--color-text-secondary);
}

/* One exchange: the question, then its answer. */
.ask-exchange,
.ask-exchange__part {
  display: flex;
  flex-direction: column;
}

.ask-exchange {
  gap: var(--space-12);
}

.ask-exchange__part {
  gap: var(--space-4);
}

.ask-exchange__label {
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  font-weight: 700;
  color: var(--color-text-muted);
}

.ask-exchange__label--agent {
  color: var(--color-accent);
}

.ask-bubble {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  padding: var(--space-12) var(--space-14);
  font-size: var(--text-card);
  line-height: var(--leading-body);
  border-radius: var(--radius-card);
  overflow-wrap: anywhere;
}

.ask-bubble--question {
  padding-block: var(--space-10);
  line-height: 1.45;
  background: var(--color-quiet);
  white-space: pre-wrap; /* a question keeps its line breaks */
}

.ask-bubble--answer,
.ask-bubble--answered {
  background: var(--color-panel);
  border: 1px solid var(--color-border-card);
}

.ask-bubble--declined,
.ask-bubble--failed {
  background: var(--color-quiet-subtle);
  border: 1px dashed var(--color-border-control);
}

.ask-bubble__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.ask-bubble__stream {
  white-space: pre-wrap;
}

/* The waiting line gives way as soon as the answer starts to stream. */
.ask-bubble__stream:empty {
  display: none;
}

.ask-bubble__stream:not(:empty) ~ .ask-bubble__waiting {
  display: none;
}

/* A question asked while the thread compacts waits for it, and says so for
   as long as the compacting status is on screen. */
.ask-bubble__waiting.ask-bubble__waiting--compacting {
  display: none;
}

#ask-exchanges:has(#ask-compaction-status) .ask-bubble__stream:empty ~ .ask-bubble__waiting--compacting {
  display: inline-flex;
}

#ask-exchanges:has(#ask-compaction-status) .ask-bubble__waiting--answer {
  display: none;
}

.ask-bubble__waiting {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-secondary);
  color: var(--color-text-muted);
}

.ask-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border-control);
  border-radius: var(--radius-chip);
}

.ask-exchange__retry {
  align-self: flex-start;
  margin-top: var(--space-4);
}

.ask-chip svg {
  flex: none;
}

/* The compaction marker and the compacting status: a hairline rule with a
   mono label. A system element, not a message from either side. */
.ask-divider__line,
.ask-divider--running {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  min-height: var(--target-control);
}

.ask-divider__rule {
  flex: 1 1 0;
  height: 1px;
  background: var(--color-border-card);
}

.ask-divider__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  color: var(--color-text-muted);
  text-align: center;
}

.ask-divider__line {
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-chip);
}

.ask-divider__line::-webkit-details-marker {
  display: none;
}

.ask-divider__line:hover .ask-divider__label {
  color: var(--color-text);
}

/* The open and close cue. The details element exposes its state, so the cue
   has empty alternative text and is not read twice. */
.ask-divider__line .ask-divider__label::after {
  content: "Show summary";
  content: "Show summary" / "";
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.ask-divider--marker[open] .ask-divider__label::after {
  content: "Hide summary";
  content: "Hide summary" / "";
}

.ask-divider--marker .system-panel {
  margin-top: var(--space-4);
  padding: var(--space-10) var(--space-14) var(--space-12);
}

.system-panel__text p + p,
.system-panel__list {
  margin-top: var(--space-4);
}

.system-panel__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-left: 18px;
  font-size: var(--text-secondary);
  line-height: 1.45;
}

.ask-spinner {
  flex: none;
  width: var(--spinner-size);
  height: var(--spinner-size);
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: var(--radius-pill);
  animation: ask-spin 0.8s linear infinite;
}

@keyframes ask-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ask-spinner {
    animation: none;
  }
}

/* Below the thread: the confirmation, the box's status, a refused
   question's notice, and the question form. */
.ask-compose,
.ask-compose__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.ask-compose {
  padding: var(--space-14) var(--space-20) var(--space-16);
}

#ask-confirm:empty,
.ask-compose__status:empty,
.ask-compose__start-over:empty {
  display: none;
}

.ask-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8) var(--space-12);
  margin-top: var(--space-4);
}

.ask-confirm__keep {
  display: flex;
}

.system-panel__action {
  align-self: flex-start;
  margin-top: var(--space-4);
}

.ask__notice {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-14);
  background: var(--color-panel);
  border: 1px solid var(--color-border-control);
  border-left: 4px solid var(--color-text);
  border-radius: var(--radius-card);
}

.ask__notice-label {
  font-family: var(--font-mono);
  font-size: var(--text-chip);
  font-weight: 700;
  letter-spacing: var(--tracking-chip);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.ask__notice-text {
  font-size: var(--text-card);
}

.ask-form__fields {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  border: 0;
}

.ask-form__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4) var(--space-12);
}

.ask-form__label {
  font-size: var(--text-small);
  font-weight: 600;
}

.ask-form__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-8);
}

.ask-form__input {
  flex: 999 1 220px;
  min-width: 0;
  min-height: var(--target-action);
  max-height: 8lh;
  padding: 11px var(--space-14);
  font: inherit;
  font-size: var(--text-input);
  line-height: 1.45;
  color: var(--color-text);
  background: var(--color-panel);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  resize: none; /* it grows with the question where field-sizing is supported */
  field-sizing: content;
}

.ask-form__input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.ask-form__input:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.ask-form__submit {
  flex: 1 0 auto;
  min-height: var(--target-action);
}

.ask-form__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-mono-meta);
  line-height: var(--leading-check);
  color: var(--color-text-muted);
}

.ask-form__over:empty {
  display: none;
}

/* Over the cap: said in words, and marked by more than color. */
.ask-form__fields--over .ask-form__input {
  border: 2px solid var(--color-text);
  padding: 10px 13px;
}

.ask-form__fields--over .ask-form__count,
.ask-form__over {
  font-weight: 700;
  color: var(--color-text);
}

.ask-form__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin-top: var(--space-4);
}

/* Disabled while an answer is on its way, at the backstop, or switched off. */
.ask-form__fields:disabled .ask-form__input {
  cursor: not-allowed;
  color: var(--color-text-muted);
  background: var(--color-quiet);
  border-color: var(--color-border-card);
  resize: none;
}

.ask-compose__start-over {
  display: flex;
}

/* Mobile: the thread fits its content up to 65% of the window's height,
   then scrolls inside the panel, opening at the newest message
   (ask_thread_controller.js), so a long thread never pushes the rest of the
   page away; the box, the suggestions, and the panel's header stay usable on
   a small phone. Buttons are full-width tap targets. */
@media (max-width: 640px) {
  .ask-thread {
    flex: none;
    min-height: 0;
    max-height: 65vh;
    max-height: 65dvh;
  }

  .ask-thread__inner {
    padding: var(--space-14) var(--space-16);
  }

  .ask-compose {
    padding: var(--space-14) var(--space-16) var(--space-16);
  }

  .ask-form__row {
    flex-wrap: nowrap;
  }

  .ask-form__submit {
    flex: 0 0 auto;
  }

  .ask-form__suggestions {
    flex-direction: column;
    align-items: flex-start;
  }

  .ask-confirm__actions .button--secondary {
    flex: 1 1 auto;
  }
}

/* Without JavaScript nothing scrolls the thread to the newest answer, so a
   capped thread would open at its oldest message. At every width the thread
   instead grows with its content and the reloaded page's #exchange-N anchor
   scrolls the page itself to the new answer: nothing is hidden, and nothing
   depends on a script. Kept after the mobile rules so it wins there too. */
@media (scripting: none) {
  .ask-thread {
    flex: none;
    max-height: none;
    overflow: visible;
  }
}

/* Wide and narrow copy: the mobile board shortens some copy. Exactly one
   version shows at any width; display: none also hides the other from
   assistive technology, so nothing is read twice. Kept last so it wins. */
@media (width > 640px) {
  .only-narrow {
    display: none;
  }
}

@media (width <= 640px) {
  .only-wide {
    display: none;
  }
}
