/*
 * Page styles for pricing, request access, the account page and the legal
 * pages. Tokens and shared components live in site.css; nothing here defines
 * a color, a radius or a font size of its own.
 */

/* --------------------------------------------------------------- pricing */

.tier-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}

.tier-grid .tier-price small {
  margin-left: 2px;
}

@media (min-width: 640px) {
  .tier-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Five cards in full rows: two and two with the last one wide, then three
   over two. No card is left alone on a row. */
@media (min-width: 640px) and (max-width: 899px) {
  .tier-grid > .tier:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) and (max-width: 1119px) {
  .tier-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .tier-grid > .tier {
    grid-column: span 2;
  }

  .tier-grid > .tier:nth-child(n + 4) {
    grid-column: span 3;
  }
}

@media (min-width: 1120px) {
  .tier-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .tier-grid > .tier {
    padding: var(--space-4);
  }

  .tier-grid > .tier.is-featured {
    padding: calc(var(--space-4) - 1px);
  }

  /* Five narrow cards: "20,000 credits per month" takes two lines and
     "Custom" takes one. Every card holds two lines for it, so the feature
     lists under it all start on the same line. */
  .tier-grid > .tier > .tier-credits {
    min-height: 52px;
    min-height: 2lh;
  }
}

.credits-layout {
  display: grid;
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 900px) {
  .credits-layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

.credit-rules {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.credit-rules li {
  padding-left: var(--space-4);
  border-left: 2px solid var(--accent);
}

.credits-layout .table-wrap {
  margin: 0;
}

.faq {
  display: grid;
  gap: var(--space-5) var(--space-7);
}

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

.faq-item h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
}

.faq-item p {
  margin: 0;
  color: var(--muted);
}

/* -------------------------------------------------------- request access */

/* One centered column: the heading, then the form as a single card. */
.request-access > .form-error,
.request-access > .form,
.request-alt,
.request-received {
  max-width: 520px;
  margin-inline: auto;
}

.request-form {
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.request-form .button-row > .button {
  flex: 1;
}

.request-access fieldset.field,
.account fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0 var(--space-4);
}

.county-field .field-label {
  margin-top: var(--space-2);
}

.request-alt {
  margin-top: var(--space-5);
  text-align: center;
}

.request-received {
  padding: var(--space-6);
  border: 1px solid color-mix(in srgb, var(--ok-text) 35%, transparent);
  border-radius: var(--radius-card);
  background: var(--ok-bg);
  color: var(--ok-text);
  text-align: center;
}

.request-received h2 {
  color: inherit;
  font-size: var(--text-xl);
}

.request-received p {
  overflow-wrap: anywhere;
}

.request-received .button-row {
  justify-content: center;
}

@media (max-width: 479px) {
  .request-form,
  .request-received {
    padding: var(--space-5);
  }
}

/* ---------------------------------------------------------------- account */

/*
 * Signing in and signing up are one centered column: a short heading, one
 * line, one card. The section holds the screen's height under the header, so
 * the footer starts at the fold and never jumps when the session check
 * answers, and a short card leaves no extra scroll.
 */
.account {
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100svh - var(--header-height));
}

/* One space above the heading on every form page (sign in, sign up, the
   request form). It grows with the window, so on a tall desktop screen the
   short sign-in card sits nearer the middle and not under a wide gap. */
.section.account,
.section.request-access {
  padding-top: var(--form-top-space);
}

.section.account {
  padding-bottom: clamp(var(--space-7), 8vh, var(--space-9));
}

.account-intro {
  max-width: 520px;
  margin: 0 auto var(--space-6);
  text-align: center;
}

.account-intro h1 {
  margin-bottom: var(--space-3);
  font-size: var(--text-2xl);
}

.account-intro h1:focus {
  outline: none;
}

.account-intro .lede {
  margin: 0 auto;
}

.account > .card,
.account > .banner-error,
.account > .form-error,
.account > .muted {
  max-width: 440px;
  margin-inline: auto;
}

.account > .muted {
  text-align: center;
}

/*
 * Signed in, the page is a settings page, not a card: the heading and the
 * sections line up on the left edge. account.js only un-hides the session
 * block; this rule does the rest.
 */
.account:has(> #account-session:not([hidden])) > .account-intro {
  max-width: none;
  margin-inline: 0;
  margin-bottom: var(--space-5);
  text-align: left;
}

.account:has(> #account-session:not([hidden]))
  > :is(.banner-error, .form-error) {
  margin-inline: 0;
}

.auth-card .form {
  max-width: none;
}

/* A card with one action: the button fills the card. */
.auth-card > .button-row > .button {
  flex: 1;
}

.auth-card .note {
  margin: 0;
}

.auth-card > .note {
  margin-bottom: var(--space-4);
}

.auth-aside {
  margin: 0;
  font-size: var(--text-sm);
}

.auth-card > .auth-aside {
  margin-top: var(--space-4);
  text-align: center;
}

/* The legal line under the form needs air above it. */
.auth-card > .field-help {
  margin-top: var(--space-4);
  text-align: center;
}

@media (max-width: 479px) {
  .auth-card {
    padding: var(--space-5);
  }
}

.link-button {
  min-height: 44px;
  margin: calc(var(--space-2) * -1) 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.google-button {
  width: 100%;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--ok-text);
  font-size: var(--text-sm);
  line-height: 20px;
}

.form-status:empty {
  display: none;
}

.account-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.account-head p {
  margin: 0;
  overflow-wrap: anywhere;
}

.account-name {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 28px;
}

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

.account-nav .chip {
  height: 44px;
}

.account-section {
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  scroll-margin-top: 88px;
}

.account-section > :last-child {
  margin-bottom: 0;
}

.account-section > h2 {
  font-size: var(--text-xl);
  line-height: 28px;
}

.key-form {
  margin-bottom: var(--space-5);
}

.key-form .button {
  justify-self: start;
}

.key-panel {
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-card);
  background: var(--warn-bg);
}

.key-panel > h3,
.key-panel > p:not(.form-status) {
  color: var(--warn-text);
}

.key-panel .field {
  margin-bottom: var(--space-4);
  color: var(--warn-text);
}

.key-panel .button-row {
  margin-bottom: var(--space-4);
}

.key-panel .form-status {
  margin-bottom: var(--space-3);
  color: var(--warn-text);
}

.key-panel .code-frame {
  margin-bottom: 0;
}

.key-try {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
}

.key-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.keys-list-title {
  margin-bottom: var(--space-3);
  font-size: var(--text-base);
}

.key-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--line);
}

.key-row.is-inactive {
  color: var(--muted);
}

.key-meta {
  min-width: 0;
}

.key-meta p {
  margin: 0;
  overflow-wrap: anywhere;
}

.key-name {
  font-weight: 600;
}

.key-detail {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 22px;
}

.key-confirm {
  max-width: 420px;
}

.key-confirm p {
  margin: 0 0 var(--space-3);
  color: var(--error-text);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 20px;
}

.assistant-setup-grid {
  display: grid;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.assistant-option h3 {
  margin-bottom: var(--space-1);
  font-size: var(--text-lg);
}

.assistant-option .code-frame,
.assistant-setup .code-frame {
  margin-bottom: var(--space-3);
}

.assistant-setup .button-row {
  margin-bottom: var(--space-3);
}

.assistant-prompt {
  white-space: pre-wrap;
}

.settings-grid {
  display: grid;
  gap: 0 var(--space-5);
  align-items: start;
}

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

.settings-grid .form {
  max-width: none;
}

.settings-grid .form .button {
  justify-self: start;
}

.billing-interval {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
}

.billing-interval legend {
  width: 100%;
}

@media (max-width: 479px) {
  .account-section,
  .key-panel {
    padding: var(--space-4);
  }

  .key-actions,
  .key-actions > .button,
  .key-form .button,
  .settings-grid .form .button {
    width: 100%;
  }
}

/* ------------------------------------------------------------------ legal */

.legal {
  max-width: none;
}

.legal-head {
  margin-bottom: var(--space-5);
}

.legal-head h1 {
  font-size: var(--text-2xl);
  line-height: 1.2;
}

.legal-meta {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.legal-toc {
  margin-bottom: var(--space-6);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.legal-toc h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
}

.legal-toc ol {
  margin: 0;
  padding: 0;
  columns: 2 220px;
  column-gap: var(--space-6);
  font-size: var(--text-sm);
  line-height: 20px;
  list-style: none;
}

.legal-toc li {
  break-inside: avoid;
}

.legal-toc a {
  display: block;
  padding: 6px 0;
}

.legal-body h2 {
  margin-top: var(--space-6);
  font-size: var(--text-xl);
  line-height: 28px;
  scroll-margin-top: 88px;
}

.legal-body ul {
  padding-left: var(--space-5);
}

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

.legal-body .table-wrap {
  margin-top: var(--space-4);
}

/* On a phone each row of a legal table is a small card (table-stack in
   site.css), so a cookie name is never broken and no column is cut. */

/* --------------------------------------------------------------- sign up */

.signup-progress {
  display: flex;
  gap: var(--space-2);
  max-width: 440px;
  margin: 0 auto var(--space-4);
  padding: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  list-style: none;
}

.signup-progress > li {
  flex: 1;
  padding-top: var(--space-2);
  border-top: 2px solid var(--line);
}

.signup-progress > [aria-current="step"] {
  border-top-color: var(--accent);
  color: var(--text);
}

.signup-card > .google-button {
  width: 100%;
}

.signup-code-input {
  max-width: 14ch;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  letter-spacing: 0.3em;
}

/* The key, then the one thing to do with it. Wider than the form card so
   the key and the prompt each fit on a line where the screen allows. */
.signup-done {
  max-width: 560px;
  margin-inline: auto;
}

.signup-done > .banner {
  justify-content: flex-start;
  margin-bottom: var(--space-4);
  padding-inline: var(--space-4);
  border-style: solid;
  border-width: 1px;
  border-radius: var(--radius-control);
}

.signup-next {
  margin-top: var(--space-6);
}

.signup-next h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  line-height: 1.3;
}

.signup-next .code-block {
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
