/**
 * @file Styles for adiutor.dev: the app's own colours and fonts, light and dark following the
 * system setting, and the one animation, the example request in the hero playing its lifecycle.
 *
 * Every colour is a `light-dark()` pair from the app's theme (`src/styles/theme.css`), so text meets
 * WCAG AA in both modes. Line heights follow the brand rule: font size plus 8px.
 */

/** Inter, the brand's text face (variable, latin). */
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
}

/** JetBrains Mono, for request numbers and code, as in the app (variable, latin). */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
}

/** Colour tokens, fonts and measures. */
:root {
  color-scheme: light dark;

  /** Brand colours, for the hero's rail only. */
  --brand-teal: #0e5655;
  --brand-green: #25dc89;

  /** Page, cards and subtle fills. */
  --background: light-dark(#f7f7f9, #0b0b22);
  --surface: light-dark(#fff, #14143a);
  --muted: light-dark(#f1f1f4, #1c1c47);
  --border: light-dark(#e4e4e9, #2a2a58);
  --border-strong: light-dark(#8c8ca3, #70709f);

  /** Text. */
  --foreground: light-dark(#0e0e2d, #f1f1f6);
  --muted-foreground: light-dark(#55556d, #a3a3c2);

  /** Actions, links and focus. */
  --primary: light-dark(#0e5655, #25dc89);
  --primary-hover: light-dark(#0b4544, #4ae39e);
  --primary-foreground: light-dark(#fff, #0e0e2d);
  --ring: light-dark(#0e5655, #25dc89);

  /** Status chips of the example request. */
  --progress: light-dark(#0e5655, #5fe0cf);
  --progress-soft: light-dark(#e2efee, #12333a);
  --warning: light-dark(#8a5000, #ffc266);
  --warning-soft: light-dark(#fcf1dc, #3a2e18);
  --success: light-dark(#0b6b4c, #4ae39e);
  --success-soft: light-dark(#e3f6ee, #0f3330);

  /** The one shadow, under the example request. */
  --shadow: light-dark(rgb(14 14 45 / 14%), rgb(0 0 0 / 45%));

  --font-sans:
    Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  /** Content width and side padding. */
  --container: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2rem);
}

/* Base ------------------------------------------------------------------------------------------ */

/** A predictable box model everywhere. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/** Smooth in-page jumps, unless reduced motion is asked for. */
html {
  scroll-padding-top: 1.5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/** Body text: 16px on 24px. */
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5rem;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/** Headings and paragraphs start without margins; sections set their own spacing. */
h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure,
pre {
  margin: 0;
}

/** Images never overflow their column. */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/** Links in running text: the primary colour, underlined. */
a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--primary-hover);
  text-decoration-thickness: 2px;
}

/** A visible focus ring on everything the keyboard reaches. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
  border-radius: 4px;
}

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

/** The first stop for the keyboard; shown only while focused. */
.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  color: var(--foreground);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 0 0 1px var(--border);
  translate: 0 -200%;
}

.skip-link:focus-visible {
  translate: 0 0;
}

/** The centred content column. */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header ---------------------------------------------------------------------------------------- */

/** Logo and navigation; the navigation moves under the logo on narrow screens. */
.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.5rem;
}

.brand {
  display: inline-block;
  border-radius: 4px;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding-block: 0.5rem;
  color: var(--foreground);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/** On phones, the bar keeps only "Run it yourself" and "GitHub", so it fits beside the logo. */
@media (max-width: 39.99rem) {
  .site-header-inner {
    column-gap: 1rem;
  }

  .site-nav ul {
    gap: 0.25rem 1rem;
  }

  .nav-optional {
    display: none;
  }
}

/* Buttons --------------------------------------------------------------------------------------- */

/** A row of buttons that wraps on narrow screens. */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/** Links shaped as buttons, 44px tall. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5rem;
  text-decoration: none;
  transition:
    background-color 120ms ease-out,
    border-color 120ms ease-out;
}

.button:hover {
  text-decoration: none;
}

/** The main action. */
.button-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

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

/** The other action. */
.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--foreground);
}

.button-secondary:hover {
  background: var(--muted);
  color: var(--foreground);
}

/* Hero ------------------------------------------------------------------------------------------ */

/** Headline and actions beside the example request; stacked below 960px. */
.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3.5rem;
  align-items: center;
  padding-block: clamp(2.5rem, 6vw, 5rem) clamp(4rem, 9vw, 7.5rem);
}

@media (min-width: 60rem) {
  .hero-inner {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 4rem;
  }
}

/**
 * Where Adiutor stands, above the headline: a pill in the colours of the example request's
 * "In progress" status, with a dot like a status light.
 */
.pill {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem 0.875rem 0.25rem 0.75rem;
  border: 1px solid light-dark(#b9d6d3, #1f4f57);
  border-radius: 999px;
  background: var(--progress-soft);
  color: var(--progress);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.375rem;
}

.pill::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentcolor;
}

/** The headline: 36px up to 60px, tight and heavy, the size plus 8px between lines. */
.hero h1 {
  font-size: clamp(2.25rem, 1.5rem + 3vw, 3.75rem);
  font-weight: 700;
  line-height: calc(1em + 8px);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lede {
  max-width: 34rem;
  margin-top: 1.5rem;
  color: var(--muted-foreground);
  font-size: 1.25rem;
  line-height: 1.75rem;
  text-wrap: pretty;
}

.hero .actions {
  margin-top: 2rem;
}

.hero-note {
  margin-top: 1.25rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.375rem;
}

/* The example request ------------------------------------------------------------------------- */

.demo {
  width: 100%;
  max-width: 36rem;
  justify-self: center;
}

@media (min-width: 60rem) {
  .demo {
    justify-self: end;
  }
}

/** The request card, drawn like a card in the app. */
.request {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow:
    0 1px 2px var(--shadow),
    0 24px 48px -24px var(--shadow);
}

.request-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.request-number {
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.375rem;
}

.request-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.625rem;
  letter-spacing: -0.01em;
}

/** The status chips share one place; only the current one shows. */
.status-stack {
  display: grid;
  justify-items: end;
}

.chip {
  grid-area: 1 / 1;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  white-space: nowrap;
}

.chip-open {
  background: var(--muted);
  color: var(--foreground);
}

.chip-progress {
  background: var(--progress-soft);
  color: var(--progress);
}

.chip-approval {
  background: var(--warning-soft);
  color: var(--warning);
}

.chip-done {
  background: var(--success-soft);
  color: var(--success);
}

/** Without animation, the request shows where it ended: Done. */
.chip-open,
.chip-progress,
.chip-approval {
  visibility: hidden;
}

/** The conversation, with a rail through its avatars. */
.thread {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
  list-style: none;
}

.entry {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.375rem;
}

/**
 * The rail: a segment from each entry's mark down to the next one's (the thread's gap is 1.25rem,
 * a mark's centre 1rem from its entry's top), so it starts and ends on a mark.
 */
.entry:not(:last-child)::before,
.entry:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 1rem;
  bottom: calc(-1.25rem - 1rem);
  left: calc(1rem - 1px);
  width: 2px;
}

.entry:not(:last-child)::before {
  background: var(--border);
}

/**
 * The segments fill with the brand gradient, teal to green across the whole rail, as the request
 * moves on. The two colours between are the gradient's thirds.
 */
.entry:not(:last-child)::after {
  transform-origin: top;
}

.entry-1::after {
  background: linear-gradient(to bottom, var(--brand-teal), #168366);
}

.entry-2::after {
  background: linear-gradient(to bottom, #168366, #1daf78);
}

.entry-3::after {
  background: linear-gradient(to bottom, #1daf78, var(--brand-green));
}

/** Initials, as the app shows people: the company's on a muted square, the staff's on primary. */
.avatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.avatar-staff {
  background: var(--primary);
  color: var(--primary-foreground);
}

/** A ringed dot for changes, like the app's status entries. */
.event-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
}

.event-mark::after {
  content: '';
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--muted-foreground);
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  min-height: 2rem;
}

.person {
  color: var(--primary);
  font-weight: 500;
}

.staff-badge {
  padding: 0 0.375rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
}

.when {
  color: var(--muted-foreground);
}

.bubble {
  margin-top: 0.25rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  background: var(--muted);
  text-wrap: pretty;
}

.event-text {
  color: var(--muted-foreground);
}

.solution-label {
  display: inline-block;
  margin-bottom: 0.375rem;
  padding: 0 0.375rem;
  border-radius: 4px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
}

.demo figcaption {
  margin-top: 1rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.375rem;
  text-align: center;
}

/**
 * The lifecycle, played once on load: each entry arrives, the status moves with it and the rail
 * fills. Only when motion is welcome; otherwise the finished request above is what shows.
 */
@media (prefers-reduced-motion: no-preference) {
  .entry {
    opacity: 0;
    animation: entry-in 450ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }

  .entry-1 {
    animation-delay: 300ms;
  }

  .entry-2 {
    animation-delay: 1400ms;
  }

  .entry-3 {
    animation-delay: 2600ms;
  }

  .entry-4 {
    animation-delay: 3900ms;
  }

  .entry:not(:last-child)::after {
    scale: 1 0;
  }

  .entry-1::after {
    animation: rail-fill 700ms cubic-bezier(0.45, 0, 0.25, 1) 700ms forwards;
  }

  .entry-2::after {
    animation: rail-fill 700ms cubic-bezier(0.45, 0, 0.25, 1) 1900ms forwards;
  }

  .entry-3::after {
    animation: rail-fill 700ms cubic-bezier(0.45, 0, 0.25, 1) 3200ms forwards;
  }

  .chip-open,
  .chip-progress,
  .chip-approval {
    visibility: visible;
  }

  .chip-progress,
  .chip-approval,
  .chip-done {
    opacity: 0;
  }

  .chip-open {
    animation: chip-out 200ms ease-out 1400ms forwards;
  }

  .chip-progress {
    animation:
      chip-in 250ms ease-out 1400ms forwards,
      chip-out 200ms ease-out 2600ms forwards;
  }

  .chip-approval {
    animation:
      chip-in 250ms ease-out 2600ms forwards,
      chip-out 200ms ease-out 3900ms forwards;
  }

  .chip-done {
    animation: chip-in 250ms ease-out 3900ms forwards;
  }
}

@keyframes entry-in {
  from {
    opacity: 0;
    translate: 0 0.5rem;
  }

  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes rail-fill {
  from {
    scale: 1 0;
  }

  to {
    scale: 1 1;
  }
}

@keyframes chip-in {
  from {
    opacity: 0;
    scale: 0.92;
  }

  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes chip-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* Sections -------------------------------------------------------------------------------------- */

/** Space between sections, and a line that marks where each starts. */
.section {
  padding-block: clamp(3.5rem, 8vw, 6rem);
  border-top: 1px solid var(--border);
}

/** Section headings: 30px up to 36px. */
.section h2 {
  font-size: clamp(1.875rem, 1.6rem + 1vw, 2.25rem);
  font-weight: 700;
  line-height: calc(1em + 8px);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.625rem;
  letter-spacing: -0.01em;
}

/** A heading and short introduction beside the section's content; stacked below 960px. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

@media (min-width: 60rem) {
  .split {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    gap: 4rem;
  }
}

.split-intro p {
  max-width: 28rem;
  margin-top: 1rem;
  color: var(--muted-foreground);
  font-size: 1.125rem;
  line-height: 1.625rem;
}

/** Why Adiutor: six short points in two columns. */
.points {
  display: grid;
  gap: 2rem 3rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .points {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.points li {
  padding-top: 1.25rem;
  border-top: 2px solid var(--foreground);
}

.points p {
  margin-top: 0.5rem;
  color: var(--muted-foreground);
}

/** Screenshots, full width, each with its caption. */
.shot {
  margin-top: 2.5rem;
}

.shot picture {
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.shot figcaption {
  max-width: 40rem;
  margin-top: 0.875rem;
  color: var(--muted-foreground);
}

/** What it does today: terms and descriptions in two columns. */
.features {
  display: grid;
  gap: 1.75rem 3rem;
}

@media (min-width: 40rem) {
  .features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.features dt {
  font-weight: 600;
}

.features dd {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
}

/** Run it yourself: commands, what's needed, and the guide. */
.code {
  overflow-x: auto;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.625rem;
}

.run-after {
  margin-top: 1rem;
  color: var(--muted-foreground);
}

.run h3 {
  margin-top: 2rem;
}

.needs {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-left: 1.25rem;
  color: var(--muted-foreground);
}

.needs li::marker {
  color: var(--primary);
}

.run .actions {
  margin-top: 2rem;
}

/* Footer ---------------------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted-foreground);
  font-size: 0.875rem;
  line-height: 1.375rem;
}

.site-footer-inner {
  display: grid;
  gap: 1.5rem;
  padding-block: 2.5rem 3rem;
}

@media (min-width: 60rem) {
  .site-footer-inner {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    gap: 4rem;
  }
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-notes {
  display: grid;
  gap: 0.5rem;
  max-width: 44rem;
}

/* Page not found -------------------------------------------------------------------------------- */

/** The 404 page's message. */
.not-found {
  padding-block: clamp(4rem, 12vw, 9rem);
}

.not-found h1 {
  font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem);
  font-weight: 700;
  line-height: calc(1em + 8px);
  letter-spacing: -0.03em;
}

.not-found p {
  max-width: 32rem;
  margin-top: 1rem;
  color: var(--muted-foreground);
  font-size: 1.125rem;
  line-height: 1.625rem;
}

.not-found .actions {
  margin-top: 2rem;
}
