/*
 * The public site: the landing (/), plans (/pricing) and docs (/docs). /login redirects into the app's sign-in route.
 * Uses the shared tokens in tokens.css (UI spec v4, "Visual tokens"). No animation, so nothing needs a reduced-motion rule.
 * Breakpoints follow the spec frame grid: 360 and 390 px single column, 768 px two columns, 1024 px and up the full layout.
 * The page itself never scrolls sideways: every block wraps and no fixed width exceeds the viewport.
 */

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body-large);
  line-height: 24px;
  font-weight: var(--weight-regular);
  -webkit-text-size-adjust: 100%;
}

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

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

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

.skip-link {
  position: absolute; left: var(--space-16); top: var(--space-8);
  transform: translateY(-200%);
  background: var(--color-surface-raised); color: var(--color-text); padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-button); border: 1px solid var(--color-border); text-decoration: none; z-index: 10;
}
.skip-link:focus { transform: translateY(0); }

.site-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--space-16); }

/* Header: brand and the links, wrapping on a phone. */
.site-header { border-bottom: 1px solid var(--color-divider); }
.site-header .site-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-8) var(--space-16); min-height: var(--row-default); padding-top: var(--space-8); padding-bottom: var(--space-8); }
.brand { font-size: var(--text-section); line-height: 24px; font-weight: var(--weight-semibold); color: var(--color-text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-16); }
.site-nav a { display: inline-flex; align-items: center; min-height: var(--target-touch); color: var(--color-text); text-decoration: none; font-size: var(--text-body); }
.site-nav a:hover { text-decoration: underline; }
.site-nav a.btn { color: var(--color-on-primary); min-height: var(--target-touch); }
.site-nav a[aria-current="page"] { font-weight: var(--weight-semibold); }

/* Buttons: the spec's 48 px button on a phone (see the phone rules below), 6 px radius. Links styled as buttons. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--target-touch); padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-button); border: 1px solid var(--color-primary);
  font: inherit; font-size: var(--text-body-large); font-weight: var(--weight-semibold);
  text-decoration: none; cursor: pointer; background: var(--color-primary); color: var(--color-on-primary);
}
.btn:hover { text-decoration: underline; }
.btn-secondary { background: var(--color-surface-raised); color: var(--color-text); border-color: var(--color-border); }
.btn-small { font-size: var(--text-body); min-height: var(--target-touch); padding: var(--space-8) var(--space-16); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-12); align-items: center; }
.mt-24 { margin-top: var(--space-24); }

/* Hero: the headline is the spec's onboarding size, 28/36. */
.hero { padding: var(--space-48) 0 var(--space-32); }
.hero h1 { font-size: var(--text-onboarding); line-height: 36px; font-weight: var(--weight-semibold); max-width: 20ch; }
.lede { margin-top: var(--space-16); max-width: 46ch; color: var(--color-text-secondary); font-size: var(--text-body-large); }
.hero .btn-row { margin-top: var(--space-24); }

section.block { padding: var(--space-32) 0; border-top: 1px solid var(--color-divider); }
section.block h2 { font-size: var(--text-page); line-height: 28px; font-weight: var(--weight-semibold); }
section.block .intro { margin-top: var(--space-8); color: var(--color-text-secondary); max-width: 60ch; }

/* Cards: 8 px radius, a surface and a divider border, the same in both themes. */
.cards { display: grid; gap: var(--space-16); grid-template-columns: 1fr; margin-top: var(--space-24); }
.card { background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-card); padding: var(--space-24); }
.card h3 { font-size: var(--text-section); line-height: 24px; font-weight: var(--weight-semibold); }
.card p { margin-top: var(--space-8); color: var(--color-text-secondary); font-size: var(--text-body); line-height: 20px; }
.card .step { font-size: var(--text-caption); line-height: 16px; color: var(--color-text-secondary); font-weight: var(--weight-semibold); }

/* A command block: mono type, 12 px caption size for the label, the surface as its background. */
.code {
  margin: var(--space-16) 0 0; padding: var(--space-16); overflow-x: auto;
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-card);
  font-family: var(--font-mono); font-size: var(--text-small); line-height: 20px; white-space: pre;
}

/* Plans: each plan is a card with its limits and one button. The plan name is a card heading, so it takes no docs margin. */
.plan h2 { font-size: var(--text-section); line-height: 24px; font-weight: var(--weight-semibold); }
.doc .plan h2 { margin-top: 0; }
.plan dl { margin: var(--space-16) 0 0; display: grid; gap: var(--space-8); }
.plan dt { font-size: var(--text-caption); line-height: 16px; color: var(--color-text-secondary); }
.plan dd { margin: 0; font-size: var(--text-body-large); line-height: 24px; font-weight: var(--weight-semibold); }
.plan .btn { margin-top: var(--space-24); width: 100%; }
.note { margin-top: var(--space-16); color: var(--color-text-secondary); font-size: var(--text-small); line-height: 20px; }

/* Footer. */
.site-footer { border-top: 1px solid var(--color-divider); padding: var(--space-24) 0 var(--space-48); color: var(--color-text-secondary); font-size: var(--text-small); line-height: 20px; }
.site-footer .site-wrap { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-24); justify-content: space-between; }
.site-footer a { color: var(--color-text-secondary); }

/* Docs: a readable column with a table of commands. */
.doc { padding: var(--space-32) 0 var(--space-48); }
.doc h1 { font-size: var(--text-page); line-height: 28px; font-weight: var(--weight-semibold); }
.doc h2 { margin-top: var(--space-48); font-size: var(--text-section); line-height: 24px; font-weight: var(--weight-semibold); }
.doc p { margin-top: var(--space-12); max-width: 68ch; }
.doc .lede { max-width: 68ch; }
.table-wrap { margin-top: var(--space-16); overflow-x: auto; border: 1px solid var(--color-divider); border-radius: var(--radius-card); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: var(--text-small); line-height: 20px; }
.table-wrap th, .table-wrap td { text-align: left; padding: var(--space-12) var(--space-16); border-bottom: 1px solid var(--color-divider); vertical-align: top; }
.table-wrap th { color: var(--color-text-secondary); font-weight: var(--weight-semibold); }
.table-wrap td code, .doc p code, .doc li code { font-family: var(--font-mono); font-size: var(--text-small); }
.doc ul { margin: var(--space-12) 0 0; padding-left: var(--space-24); max-width: 68ch; }
.doc li + li { margin-top: var(--space-8); }

/* 768 px: two columns for the steps, the roles and the plans. */
@media (min-width: 768px) {
  .site-wrap { padding: 0 var(--space-24); }
  .hero { padding: var(--space-64) 0 var(--space-48); }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

/* From 768 to 1023 px a row of three is two cards and the third card centred under them. */
@media (min-width: 768px) and (max-width: 1023px) {
  .cards.three > .card:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - var(--space-8)); }
}

/* 1024 px: three columns for the steps, the roles and the plans. */
@media (min-width: 1024px) {
  .cards.steps, .cards.roles { grid-template-columns: repeat(3, 1fr); }
  .cards.three { grid-template-columns: repeat(3, 1fr); }
  .site-wrap { padding: 0 var(--space-32); }
}

/* Phone (under 768 px): a long command wraps inside its block, header, brand and footer links are 44 px touch targets,
   and every button is the spec's 48 px. */
@media (max-width: 767px) {
  .code { white-space: pre-wrap; overflow-wrap: anywhere; }
  .site-footer a, .brand, .site-nav a:not(.btn) { display: inline-flex; align-items: center; min-height: var(--target-touch); padding-inline: var(--space-8); }
  .btn, .site-nav a.btn { min-height: 48px; }
}

/* A phone with a narrow column still shows the header links on one line where they fit. */
@media (max-width: 389px) {
  .site-nav { gap: var(--space-4) var(--space-12); }
  .hero h1 { font-size: var(--text-page); line-height: 28px; }
}
