/* Clippy portal styles. Design standard: docs/ENGINEERING_STANDARD.md §10a; every value
   comes from tokens.css. Direction: archival stationery (paper, ink, one paper clip). */

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* Paper texture from gradients: no image requests. */
  background-image:
    radial-gradient(circle at 18% 12%, var(--grain-b), transparent 42%),
    radial-gradient(circle at 85% 90%, var(--grain-a), transparent 38%),
    repeating-linear-gradient(0deg, var(--grain-a) 0 1px, transparent 1px 3px);
}

/* Skip link and focus: always visible, never removed. */
.skip {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  padding: var(--space-2) var(--space-3);
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  z-index: 10;
}
.skip:focus {
  top: var(--space-4);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Page frame: an index-card column beside a large typographic margin. */
.frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 28rem);
  gap: var(--space-7);
  align-items: center;
  max-width: 72rem;
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.masthead {
  padding-left: var(--space-6);
  border-left: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.brand svg {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--clip);
}
.masthead h1 {
  margin: var(--space-4) 0 var(--space-4);
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.masthead h1 em {
  font-style: italic;
  color: var(--accent);
}
.lede {
  max-width: 34ch;
  margin: 0;
  color: var(--ink-soft);
}

/* Numbered steps set like a document index. */
.steps {
  counter-reset: step;
  list-style: none;
  margin: var(--space-6) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  align-items: baseline;
  color: var(--ink-soft);
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--clip);
}
.steps strong {
  color: var(--ink);
  font-weight: 600;
}

/* The card, with its paper clip. */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: var(--space-6) var(--space-5) var(--space-5);
}
.card .clip {
  position: absolute;
  top: -1.1rem;
  right: 2.25rem;
  width: 1.5rem;
  height: 3.25rem;
  color: var(--clip);
  transform: rotate(8deg);
}
.card h2 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
}
/* A second section in the same card (a form, then a new heading) gets room and a rule. */
.card form + h2 {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--rule);
}
/* :where keeps this at class specificity, so .status and .fine below override it. */
.card :where(p) {
  margin: 0 0 var(--space-5);
  color: var(--ink-soft);
}

/* Forms */
.field {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
label,
.choices legend {
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.02em;
}
.hint {
  font-size: var(--step--1);
  color: var(--ink-soft);
}
input:not([type="radio"], [type="checkbox"]) {
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
}
input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* A group of radio choices; a choice may hold its own small number field. */
.choices {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  border: 0;
}
.choices legend {
  margin-bottom: var(--space-1);
  padding: 0;
}
/* A choice: a radio or checkbox, its label and maybe its own number, in body text, not
   label style. */
.choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
}
.choice label {
  font-weight: 400;
  font-size: var(--step-0);
  letter-spacing: 0;
}
.choice input:is([type="radio"], [type="checkbox"]) {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent);
}
.choice .count {
  width: 6.5rem;
}
.choice + .button {
  margin-top: var(--space-3);
}
/* The passkeys page's list: one passkey per row, its facts beneath. */
.keys {
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
}
.keys li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px dashed var(--rule);
}
.keys .hint {
  flex-basis: 100%;
}
.tag {
  padding: 0 var(--space-2);
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: var(--step--1);
}
.button.add-passkey {
  margin-bottom: var(--space-3);
}
/* Devices a PIN lockout stops (the PIN page). */
.locked {
  margin: 0 0 var(--space-5);
  padding-left: var(--space-5);
  color: var(--ink-soft);
}

/* Text links, at zero specificity: any class (a button, the skip link) keeps its own
   colours. */
:where(a) {
  color: var(--accent);
  text-underline-offset: 0.2em;
}
:where(a:hover) {
  color: var(--accent-hover);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms ease, transform 150ms ease;
}
.button:hover {
  background: var(--accent-hover);
}
.button:active {
  transform: translateY(1px);
}
.button[disabled] {
  cursor: not-allowed;
  opacity: 0.7;
}
.button[aria-busy="true"] {
  cursor: progress;
}
.button svg {
  width: 1.15rem;
  height: 1.15rem;
}
.button.quiet {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink-soft);
}
.button.quiet:hover {
  background: var(--paper-deep);
}

/* Theme toggle: a small text button beside the brand (shown once theme.js runs). */
.brandline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.theme {
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--step--1);
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
}
.theme:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

/* Status line: announced to screen readers (aria-live in the markup). */
.status {
  min-height: 1.5rem;
  margin: var(--space-4) 0 0;
  font-size: var(--step--1);
}
.status[data-kind="error"] {
  color: var(--danger);
}
.status[data-kind="ok"] {
  color: var(--ok);
}

.fine {
  margin: var(--space-5) 0 0;
  padding-top: var(--space-4);
  border-top: 1px dashed var(--rule);
  font-size: var(--step--1);
}

[hidden] {
  display: none !important;
}

/* One calm entrance: margin first, card after. */
@media (prefers-reduced-motion: no-preference) {
  .masthead > *,
  .card {
    animation: rise 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .masthead > :nth-child(2) {
    animation-delay: 60ms;
  }
  .masthead > :nth-child(3) {
    animation-delay: 120ms;
  }
  .masthead > :nth-child(4) {
    animation-delay: 180ms;
  }
  .card {
    animation-delay: 240ms;
  }
  .card .clip {
    animation: clip-in 600ms 520ms cubic-bezier(0.3, 1.4, 0.5, 1) both;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.6rem);
  }
}
@keyframes clip-in {
  from {
    opacity: 0;
    transform: translateY(-0.8rem) rotate(-10deg);
  }
}

/* Narrow screens (down to 360 px): stack, keep the rule as a top border. */
@media (max-width: 52rem) {
  .frame {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
    align-content: start; /* rows keep their height instead of sharing the 100vh */
    padding: var(--space-5) var(--space-4);
  }
  .masthead {
    padding-left: 0;
    padding-top: var(--space-4);
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
  .steps {
    margin-top: var(--space-5);
  }
  .card {
    padding: var(--space-5) var(--space-4) var(--space-4);
  }
}
