/* Generator page. Tokens live in tokens.css. */

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

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
a:hover { color: var(--muted); }

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

code { font-family: var(--font-mono); }

button, input, textarea { font: inherit; color: inherit; border-radius: 0; }

button { cursor: pointer; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}
.icon-sm { width: 14px; height: 14px; stroke-width: 2.2; }
.icon-md { width: 20px; height: 20px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Page frame ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.rule-bottom { border-bottom: var(--border); }
.rule-top { border-top: var(--border); }

.header {
  padding-top: 18px;
  padding-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.logo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  width: 18px;
  height: 18px;
}
.logo > span { background: var(--ink); }
.logo > span:last-child { background: var(--accent); }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.nav a { text-decoration: none; padding: 12px 0; }

.nav-mobile {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 13px;
}

.main {
  flex-grow: 1;
  padding-top: clamp(28px, 6vw, 64px);
  padding-bottom: clamp(48px, 8vw, 96px);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.footer {
  padding-top: 22px;
  padding-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

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

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 64px;
  align-items: start;
}

.hero-main {
  display: flex;
  flex-direction: column;
  gap: 40px;
  min-width: 0;
}

.intro {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: var(--fs-h1);
  line-height: 0.92;
  letter-spacing: -0.05em;
  font-weight: 600;
}

.accent { color: var(--accent); }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--muted);
  max-width: 30em;
}

.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--fs-input);
  line-height: 1.45;
  padding: 16px 18px;
  border: var(--border);
  background: var(--paper);
  resize: vertical;
}
textarea::placeholder { color: var(--muted); }

.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 28px 40px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  padding: 0;
  margin-bottom: 10px;
}

.segmented {
  display: flex;
  border: var(--border);
}

.segmented button {
  font-family: var(--font-mono);
  font-size: 14px;
  min-width: 64px;
  height: 44px;
  padding: 0 14px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}
.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.swatches {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  padding: 4px;
  border: 2px solid var(--hairline);
  background: var(--paper);
  flex-shrink: 0;
}
.swatch[aria-pressed="true"] { border-color: var(--accent); }

.swatch-fill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.swatch-custom {
  cursor: pointer;
  border-style: dashed;
  border-color: var(--dashed);
}
.swatch-custom .swatch-fill { background: var(--paper); color: var(--ink); }
.swatch-custom svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}
.swatch-custom.is-active {
  border-style: solid;
  border-color: var(--accent);
}
.swatch-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.swatch-custom:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ink-hex {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
  text-transform: uppercase;
}

.ink-warning {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: var(--border);
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-outline { background: var(--paper); color: var(--ink); }
a.btn-outline:hover { color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #2A2A2D; }
.btn-outline:hover:not(:disabled) { background: var(--code-bg); }

.btn-lg { height: var(--btn-h-primary); padding: 0 26px; font-size: 16px; }
.btn-md { height: var(--tap); padding: 0 18px; font-size: 15px; gap: 8px; }

.btn:disabled,
.segmented button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Preview ---------- */

.preview {
  width: 100%;
  max-width: 580px;
  justify-self: end;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-frame {
  position: relative;
  border: var(--border);
  padding: 36px;
  background: var(--paper);
}

.preview-qr {
  aspect-ratio: 1 / 1;
  width: 100%;
}
.preview-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.preview-qr.is-faded { opacity: 0.12; }

.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.preview-overlay[hidden] { display: none; }

.pill {
  background: var(--paper);
  border: var(--border);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: center;
}

.caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
}

/* ---------- Share ---------- */

.share {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.share-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  border-bottom: var(--border);
  padding-bottom: 16px;
}
.share-head p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

h2 {
  font-size: var(--fs-h2);
  letter-spacing: -0.03em;
  font-weight: 600;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 24px;
}

.card {
  border: var(--border);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-head p {
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--muted);
}
.card-head code { color: var(--ink); }

.codebox {
  display: block;
  background: var(--code-bg);
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.note {
  background: var(--ink);
  color: var(--paper);
  padding: 26px 28px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.note-icon { width: 22px; height: 22px; margin-top: 2px; }
.note p {
  font-size: 15px;
  line-height: 1.6;
  max-width: 62em;
}
.note strong { font-weight: 600; }

/* ---------- Mobile action bar ---------- */

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  background: var(--paper);
  border-top: var(--border);
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
}
.action-bar-download {
  flex: 1;
  height: 52px;
  font-size: 16px;
}
.action-bar-share {
  width: 52px;
  height: 52px;
  padding: 0;
  flex-shrink: 0;
}

/* ---------- Breakpoints ---------- */

@media (min-width: 768px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 767px) {
  .desktop-only { display: none !important; }

  .header {
    height: 56px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .brand { gap: 9px; font-size: 17px; }
  .logo { width: 16px; height: 16px; }

  .main {
    padding-top: 28px;
    padding-bottom: 40px;
    gap: 48px;
  }

  .footer {
    padding-top: 18px;
    padding-bottom: 18px;
    font-size: 12px;
  }

  /* Preview moves above the input; the left column dissolves into the hero
     so its children can be reordered. The preview is not focusable, so tab
     order still follows the visual order. */
  .hero {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 28px;
  }
  .hero-main { display: contents; }
  .intro { order: 1; gap: 12px; }
  .preview { order: 2; max-width: none; gap: 10px; }
  .field { order: 3; gap: 8px; }
  .options { order: 4; flex-direction: column; gap: 28px; }

  .eyebrow { font-size: 12px; }
  h1 { line-height: 0.94; }

  .preview-frame { padding: 22px; }
  .preview-overlay { padding: 24px; }
  .pill { padding: 12px 16px; font-size: 13px; }
  .caption { flex-wrap: nowrap; gap: 12px; }

  textarea { padding: 14px 16px; }

  .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .segmented button { height: 48px; font-size: 15px; min-width: 0; }

  .swatches { flex-wrap: wrap; gap: 0 10px; }
  .swatch { width: 48px; height: 48px; }
  .swatch-custom svg { width: 18px; height: 18px; }
  .ink-hex { width: 100%; margin: 8px 0 0; }

  .share { gap: 18px; padding-top: 0; }
  .share-head { padding-bottom: 12px; }

  .card { padding: 20px; gap: 14px; }
  .card-head { gap: 4px; }
  .codebox { padding: 14px; font-size: 13px; }
  .card-actions-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .card .btn { height: 48px; }
  .card .btn-primary { background: var(--paper); color: var(--ink); }
  .card .btn-primary:hover:not(:disabled) { background: var(--code-bg); }
  .btn-block-mobile { width: 100%; }
  .cards { gap: 18px; }

  .note {
    padding: 20px;
    flex-direction: column;
    gap: 10px;
  }
  .note-icon { margin-top: 0; }
  .note p { font-size: 14px; }
}

/* On the dark note bar the focus ring is white. */
.note :focus-visible { outline-color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
