/* Tokens + base - kept here so stub pages (card / letter / privacy / terms)
   can use the brand by linking this file alone. index.html duplicates the
   above-the-fold subset inline for first-paint speed. */
:root {
  --bg:          #0A0908;
  --bg-soft:     #1A1816;
  --text:        #FFFEF5;
  --text-muted:  #B8B0A0;
  --text-faint:  #6A6560;
  --border:      #2A2724;
  --accent-loud: #F5F500;
  --accent-pink: #FF1A8C;
  --sep:         #3A3530;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
  --font-serif:  Georgia, "Times New Roman", serif;
  --font-mono:   ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; min-height: 100dvh; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}
img, svg, canvas, video { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }

.hazard-stripe {
  height: 14px;
  background: repeating-linear-gradient(
    45deg,
    #F5F500 0 14px,
    #0A0908 14px 28px
  );
}
@media (max-width: 540px) {
  .hazard-stripe { height: 10px; }
}

h1 {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
@media (max-width: 540px) {
  h1 { font-size: 24px; }
}
p { margin: 0 0 12px; color: var(--text-muted); }
p:last-child { margin-bottom: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0;
}
.topbar-nav { display: flex; gap: 16px; }
.nav-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.nav-link:hover { color: var(--text); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.brand-icon { color: var(--accent-loud); flex-shrink: 0; }

.wrap {
  flex: 1 1 auto;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 40px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.cta-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 640px;
}
@media (min-width: 540px) {
  .cta-row {
    flex-direction: row;
    justify-content: center;
  }
  .cta-row > * { flex: 1; }
}

.btn-primary,
.btn-ghost {
  font: inherit;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 14px 18px;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.btn-primary {
  background: var(--accent-loud);
  color: var(--bg);
  border: none;
}
.btn-primary:hover { background: #FFFF1F; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--text-muted); }

.helper {
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
  text-align: center;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: 11px;
}
.footer a { color: var(--text-muted); text-decoration: none; }
.footer a:hover { color: var(--text); }

.stub {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}
.stub .actions { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- form inputs (shared across pages) ---------- */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.field > label,
.field > legend {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field select {
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  height: 44px;
  padding: 0 14px;
  margin: 0;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  min-width: 0;
  vertical-align: middle;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent-pink);
  outline-offset: 2px;
}
.field input[type="date"] { color-scheme: dark; }

/* Strip the native <select> chrome so the dropdown box matches input heights
   exactly across browsers, and replace the native arrow with a hand-drawn
   chevron so the field still reads as a dropdown. */
.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%23B8B0A0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 10px 6px;
}
.field select::-ms-expand { display: none; }

.radio-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.radio input { accent-color: var(--accent-pink); }
.radio em {
  margin-left: auto;
  font-style: normal;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.radio:has(input:checked) { border-color: var(--accent-pink); }

.link { color: var(--accent-pink); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--text); }

/* ---------- card page ---------- */
.card-page {
  max-width: 1080px;
  justify-content: flex-start;
  padding-top: 32px;
  padding-bottom: 32px;
  gap: 24px;
}
.page-head { text-align: center; }
.page-head h1 { margin-bottom: 8px; }

.card-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}
.card-form {
  display: grid;
  gap: 12px;
  padding: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.card-form .btn-primary { margin-top: 4px; }

.card-preview {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  overflow: hidden;
}
#card-canvas {
  max-width: 100%;
  height: auto;
  display: block;
  background: var(--bg);
}

.back-link { text-align: center; margin: 0; }

@media (min-width: 900px) {
  .card-layout {
    grid-template-columns: 360px 1fr;
  }
}

/* ---------- letter page ---------- */
.letter-page {
  max-width: 760px;
  justify-content: flex-start;
  padding-top: 32px;
  padding-bottom: 32px;
  gap: 24px;
}

.letter-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.step-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.step-progress .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.step-progress .dot.active { background: var(--accent-pink); }

.steps { display: grid; gap: 14px; }
.step { display: grid; gap: 14px; }

.step-nav {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.step-nav .btn-primary,
.step-nav .btn-ghost { min-width: 140px; }
.step-nav #back-btn { margin-right: auto; }
.step-nav #next-btn,
.step-nav #generate-btn { margin-left: auto; }

.form-msg {
  font-size: 12px;
  color: var(--accent-pink);
  min-height: 16px;
  margin: 0;
  text-align: center;
}

/* ---------- result view ---------- */
.result-view { display: flex; flex-direction: column; gap: 16px; }
.result-head { text-align: center; }
.result-head h2 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--text);
}
.result-subhead {
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.letter-output {
  background: #FFFEF5;
  color: #0A0908;
  border-radius: 12px;
  padding: 40px 36px;
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.55;
  font-family: var(--font-serif);
  transition: opacity 0.2s ease;
  overflow-wrap: break-word;
}
.letter-output.is-rerolling { opacity: 0.35; }

@media (min-width: 720px) {
  .letter-output { padding: 56px 64px; font-size: 17px; }
}

/* Format-specific styling. Defaults above are the "letter" baseline. */
.letter-format-letter,
.letter-format-press,
.letter-format-manifesto { font-family: var(--font-serif); }

.letter-format-card,
.letter-format-review { font-family: var(--font-sans); }

.letter-format-legal {
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.01em;
}
@media (min-width: 720px) {
  .letter-format-legal { font-size: 16px; }
}

.letter-format-chat,
.letter-format-email {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}
@media (min-width: 720px) {
  .letter-format-chat,
  .letter-format-email { font-size: 15px; }
}

.letter-format-verse {
  font-family: var(--font-serif);
  font-style: italic;
  text-align: center;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.result-actions .btn-primary,
.result-actions .btn-ghost { min-width: 180px; }

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.share-actions .btn-ghost {
  padding: 10px 14px;
  font-size: 13px;
  min-width: 0;
}

/* ---------- snapback page ---------- */
.snapback-page {
  max-width: 760px;
  justify-content: flex-start;
  padding-top: 32px;
  padding-bottom: 32px;
  gap: 24px;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 540px) {
  .category-grid { grid-template-columns: 1fr 1fr; }
}

.category-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.category-chip:hover { border-color: var(--accent-pink); }
.category-chip:focus-visible {
  outline: 2px solid var(--accent-pink);
  outline-offset: 2px;
}
.chip-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.chip-desc {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
}

.picker-footer {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* Mock email card on paper-white */
.snapback-result { gap: 16px; display: flex; flex-direction: column; }

.mock-email {
  background: #FFFEF5;
  color: #0A0908;
  border-radius: 12px;
  padding: 28px 28px 24px;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  transition: opacity 0.2s ease;
  overflow-wrap: break-word;
}
.mock-email.is-rerolling { opacity: 0.35; }
@media (min-width: 720px) {
  .mock-email { padding: 40px 44px 32px; font-size: 16px; }
}

.mock-email-head { display: grid; gap: 6px; margin-bottom: 16px; }
.mock-meta {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 13px;
}
.mock-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6A6560;
  font-weight: 500;
  min-width: 64px;
}
.mock-body {
  margin: 0;
  font-family: var(--font-sans);
  color: #0A0908;
}

.mock-divider {
  border: 0;
  height: 3px;
  background: var(--accent-pink);
  margin: 24px 0 18px;
}

.snapback-label {
  margin: 0 0 10px;
  color: var(--accent-pink);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
}
.snapback-text {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.5;
  color: #0A0908;
}
@media (min-width: 720px) {
  .snapback-text { font-size: 22px; }
}

.mock-footer {
  margin: 24px 0 0;
  text-align: right;
  font-family: var(--font-sans);
  font-size: 11px;
  color: #6A6560;
  letter-spacing: 0.04em;
}

/* ---------- launch-notification opt-in (Phase 2a) ---------- */
/* Lives below the fold on index.html per build.md § 4.1.5. The transparency
   blocks above the email field must remain visible body text - they are the
   consent record archived at signup. */
.optin {
  width: 100%;
  max-width: 640px;
  margin: 16px auto 0;
  padding: 28px 24px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.optin-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}
.optin-head .optin-lede {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}
.optin-transparency h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-pink);
}
.optin-transparency p,
.optin-transparency ul,
.optin-transparency ol {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}
.optin-transparency ul,
.optin-transparency ol {
  padding-left: 20px;
}
.optin-transparency li { margin: 2px 0; }
.optin-transparency strong { color: var(--text); font-weight: 500; }

.optin-form { display: flex; flex-direction: column; gap: 8px; }
.optin-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 720px) {
  .optin-fields {
    grid-template-columns: 1fr 1fr auto;
    align-items: stretch;
  }
}

/* Hidden label-row spacer so the submit-column .field has the same internal
   structure (label + control) as the email and curiosity columns. Without
   this, the button cell collapses to the button's height and the row alignment
   gets weird across browsers. Only shown on the desktop 3-column layout. */
.label-spacer { display: none; }
@media (min-width: 720px) {
  .label-spacer {
    display: block;
    font-size: 12px;
    line-height: 1.55;
    visibility: hidden;
  }
}

.optin-fields .btn-primary { width: 100%; }
@media (min-width: 720px) {
  .optin-fields .f-submit .btn-primary {
    width: auto;
    height: 44px;
    padding: 0 18px;
  }
}
.field select {
  font: inherit;
  font-size: 14px;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  min-width: 0;
}
.field select:focus {
  outline: 2px solid var(--accent-pink);
  outline-offset: 2px;
}

.optin-success {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent-pink);
  border-radius: 8px;
  padding: 16px 20px;
}
.optin-success p {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--text);
}

/* ---------- about page ---------- */
.about-page {
  max-width: 720px;
  justify-content: flex-start;
  padding-top: 32px;
  padding-bottom: 32px;
  gap: 28px;
}

.about-hero { text-align: center; }
.about-eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--accent-pink);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}
.about-hero h1 {
  margin: 0 0 10px;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
@media (max-width: 540px) {
  .about-hero h1 { font-size: 30px; }
}
.about-hero .about-lede {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
  font-size: 18px;
  margin: 0;
}

.about-block {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
.about-block h2 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}
.about-block p {
  font-size: 15px;
  color: var(--text-muted);
}
.about-block strong { color: var(--text); font-weight: 500; }

.about-block-quiet {
  background: transparent;
  border-color: transparent;
  text-align: center;
  padding: 8px 0 0;
}
.about-block-quiet h2 { font-size: 16px; }
.about-block-quiet p { font-size: 13px; color: var(--text-faint); }

.about-tool-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.about-tool-links .btn-ghost {
  padding: 10px 14px;
  font-size: 13px;
}

/* ---------- mobile tightening ----------
   Reduce side padding, give form controls full width, and make sure the
   layout never demands more horizontal space than the viewport offers.
   Defensive against iOS Safari sometimes computing an over-wide initial
   layout when intrinsic-sized children (canvas, etc.) exist on the page. */
@media (max-width: 540px) {
  .topbar  { padding: 18px 16px 0; gap: 12px; }
  .footer  { padding: 20px 16px; }
  .wrap    { padding: 20px 16px; gap: 28px; }
  .card-page,
  .letter-page,
  .snapback-page,
  .about-page {
    padding: 20px 16px;
    max-width: 100%;
  }

  /* Form controls: fill the cell, never push it wider. */
  .field input[type="text"],
  .field input[type="email"],
  .field input[type="date"],
  .field select,
  .share-row input,
  .optin-fields .btn-primary {
    width: 100%;
    min-width: 0;
  }
  .share-row input { min-width: 0; }

  /* Optin card and about-blocks: tighter inner padding so 16px outer + 16px
     inner = 32px from screen edge, instead of 24+24 = 48px which felt cramped. */
  .optin                 { padding: 20px 16px; max-width: 100%; }
  .about-block           { padding: 18px 16px; }
  .about-block-quiet     { padding: 4px 0 0; }

  /* Generator pages: smaller paper-card padding so the letter and snapback
     bodies don't get crushed against narrow margins. */
  .letter-output { padding: 28px 22px; }
  .mock-email    { padding: 22px 18px 18px; }

  /* About hero: drop one notch smaller for the smallest phones. */
  .about-hero h1 { font-size: 26px; }

  /* Card preview area: edge-to-edge inside its container so the rendered
     1080-wide canvas scales as large as possible on screen. */
  .card-preview { padding: 10px; }

  /* Topbar nav text can crowd the brand wordmark on the narrowest phones;
     drop the link size a notch. */
  .nav-link, .brand-text { font-size: 12px; }
  .brand { gap: 6px; }
}

/* Per-orientation safe-area handling for iPhone notch / Dynamic Island in
   landscape. Portrait insets are 0 so this is a no-op then; in landscape
   it keeps content off the curved corners. */
@supports (padding: max(0px)) {
  .topbar, .footer, .wrap {
    padding-left:  max(env(safe-area-inset-left),  16px);
    padding-right: max(env(safe-area-inset-right), 16px);
  }
}
