/*
 * The phone's pairing pages (Paper "M15 Pairing · phone" a–c). Colors, faces, tracking,
 * radii and spacing are the Mac's tokens (tokens.css, served as is); type uses the touch
 * tokens (SPEC.md 11.6).
 */

:root {
  --focus-gap: var(--color-panel);
  -webkit-text-size-adjust: 100%;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--color-panel);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-touch-base);
  line-height: var(--leading-touch-base);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* The one focus treatment: 2px outline, 2px gap in the surface color, 32% halo. */
:focus {
  outline: none;
}

:focus-visible {
  box-shadow:
    0 0 0 var(--spacing-focus-offset) var(--focus-gap),
    0 0 0 4px var(--color-focus),
    0 0 0 7px var(--color-focus-ring);
}

/* One column, 16 apart, as on every M15 board. The pairing screen starts 32 down; the
   code and expired screens 48. */
.page,
.page > section,
.codeForm {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-16);
}

/* Spacing is measured from the edge iOS leaves free, so it adds to the safe-area insets:
   folded, the Duo's 84 pt status strip is the right inset, and the column stays 342 wide
   beside it as drawn. */
.page {
  max-width: 560px;
  padding: calc(env(safe-area-inset-top) + var(--spacing-48)) calc(env(safe-area-inset-right) + var(--spacing-20))
    calc(env(safe-area-inset-bottom) + var(--spacing-32)) calc(env(safe-area-inset-left) + var(--spacing-20));
}

/* M15(a) and the signed-in placeholder start with the "Paired with" line, 32 down. */
body[data-page='paired'] .page,
.page:has(> #state-home:not([hidden])) {
  padding-top: calc(env(safe-area-inset-top) + var(--spacing-32));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon {
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 9px;
}

.iconLarge {
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.meta {
  min-width: 0;
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  font-size: var(--text-touch-meta);
  line-height: var(--leading-touch-meta);
}

.title {
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--text-touch-title);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-touch-title);
}

.lede {
  margin: 0;
  color: var(--color-ink-muted);
  font-size: var(--text-touch-body);
  line-height: var(--leading-touch-body);
}

.foot {
  margin: 0;
  color: var(--color-ink-muted);
  font-size: var(--text-touch-meta);
  line-height: var(--leading-touch-meta);
}

.problem {
  margin: 0;
  color: var(--color-state-qa-fail);
  font-size: var(--text-touch-meta);
  line-height: var(--leading-touch-meta);
}

/* Add to Home Screen steps: fixed lanes for the number and the trailing icon. */
.steps {
  margin: 0;
  padding: 0;
  border-radius: 10px;
  background: var(--color-ground);
  box-shadow: inset 0 0 0 1px var(--color-rule);
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
  gap: var(--spacing-12);
  min-height: 56px;
  /* Inside the 56 for one or two lines (the second row's rule included), as drawn. */
  padding: 6px 14px;
}

.step + .step {
  border-top: 1px solid var(--color-rule-subtle);
}

.number {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--color-sunken);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  line-height: 14px;
}

.stepText {
  flex-grow: 1;
  min-width: 0;
  color: var(--color-ink);
  font-size: var(--text-touch-base);
  line-height: var(--leading-touch-base);
}

.stepText strong {
  font-weight: 600;
}

.stepIcon,
.tile svg {
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stepIcon {
  width: 20px;
  height: 20px;
  color: var(--color-navy);
  stroke-width: 1.4;
}

/* Expired: the stopwatch tile in the Stuck color. */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--color-state-stuck-edge);
}

.tileStuck {
  background: var(--color-state-stuck-tint);
  color: var(--color-state-stuck);
}

.tile svg {
  width: 28px;
  height: 28px;
  stroke-linejoin: miter;
  stroke-width: 1.3;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-12) 14px;
  border-radius: 10px;
  background: var(--color-ground);
  box-shadow: inset 0 0 0 1px var(--color-rule);
}

.cardLabel {
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  font-size: var(--text-touch-label);
  letter-spacing: var(--tracking-label);
  line-height: var(--leading-touch-label);
  text-transform: uppercase;
}

.cardText {
  color: var(--color-ink);
  font-size: var(--text-touch-base);
  line-height: var(--leading-touch-base);
}

/* Buttons: 48 tall, full width (44 pt targets and more), 24 below what comes before
   (the 16 gap plus 8). */
.primary,
.secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: var(--spacing-8);
  padding: 0 var(--spacing-16);
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: var(--text-touch-base);
  line-height: var(--leading-touch-base);
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--color-action);
  color: var(--color-on-action);
  font-weight: 600;
}

.primary:disabled {
  opacity: var(--opacity-disabled);
  cursor: default;
}

.secondary {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--color-rule);
  color: var(--color-ink);
  font-weight: var(--font-weight-medium);
}

.secondary:active {
  background: var(--color-sunken);
}

/* The code: one input drawn as six 48 by 56 boxes. */
.codeBoxes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 48px);
  gap: var(--spacing-8);
  padding-top: var(--spacing-4);
}

.codeInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0;
}

.codeInput::selection {
  background: transparent;
}

.codeInput:focus-visible {
  box-shadow: none;
}

.codeBox {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  border-radius: 8px;
  background: var(--color-ground);
  box-shadow: inset 0 0 0 1px var(--color-rule);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: var(--font-weight-bold);
  line-height: 28px;
  pointer-events: none;
}

/* Text fields put the ring on the border; an empty current box shows the caret. */
.codeBox[data-current] {
  background: var(--color-panel);
  box-shadow:
    inset 0 0 0 2px var(--color-focus),
    0 0 0 3px var(--color-focus-ring);
}

.codeBox[data-current]:empty::after {
  content: '';
  width: 2px;
  height: 26px;
  background: var(--color-focus);
}

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