/*
  Design tokens for the "Source & Canvas" direction: the page presents itself
  as an actual Xcode window. Values are Xcode's own real theme colors — the
  Default Light theme's editor palette in light mode, Default Dark in dark
  mode — not invented marketing colors, since the whole conceit is "this is
  what building it in Swift actually looks like."
*/
:root {
  color-scheme: light dark;

  --bg: #FFFFFF;
  --panel: #F7F7F7;
  --ink: #262626;
  --muted: #5E7B54;
  --line: #E3E3E3;

  --keyword: #9B2393;
  --type: #0F68A0;
  --string: #C41A16;

  --diff-add-bg: #E6F4E6;
  --diff-add-ink: #1E7A38;
  --diff-rem-bg: #FBE9E7;
  --diff-rem-ink: #B3261E;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1F1F24;
    --panel: #29292F;
    --ink: #DFDFE0;
    --muted: #7C8994;
    --line: #38383F;

    --keyword: #FC5FA3;
    --type: #5DD8FF;
    --string: #FC6A5D;

    --diff-add-bg: #14301F;
    --diff-add-ink: #6FCB84;
    --diff-rem-bg: #331A18;
    --diff-rem-ink: #FF8A80;
  }
}

/* Reset, window chrome, type scale, and the CTA form — everything that isn't specific to the board demo or pricing/comparison. */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--type);
  outline-offset: 2px;
}

.window {
  max-width: 44rem;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  overflow: hidden;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.35);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-ui);
}

.dot { width: 0.6875rem; height: 0.6875rem; border-radius: 999px; }
.dot.r { background: #FF5F57; }
.dot.y { background: #FEBC2E; }
.dot.g { background: #28C840; }

.tab {
  margin-left: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

main {
  padding: 1.75rem 1.75rem 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* MARK comments are a real Xcode/Swift convention (they populate the jump bar) — used here as section eyebrows instead of generic labels. */
.mark {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-bottom: 0.875rem;
}

h1 {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.5vw, 2.125rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.subhead {
  margin-top: 0.75rem;
  color: var(--ink);
  opacity: 0.72;
  font-size: 0.9375rem;
  max-width: 30rem;
}

.snippet {
  margin-top: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow-x: auto;
}

.snippet code { font-size: 0.8125rem; white-space: pre; }
.kw { color: var(--keyword); }
.ty { color: var(--type); }
.str { color: var(--string); }
.cm { color: var(--muted); }

.copy-btn {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}

.copy-btn:hover { border-color: var(--type); color: var(--type); }

/* CTA form, styled as a terminal prompt line. */
.cta-subhead { margin-top: 0; }

form {
  display: flex;
  gap: 0.625rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
  font-family: var(--font-ui);
}

.prompt {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 12rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  padding: 0 0.75rem;
}

.prompt-glyph {
  color: var(--type);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  margin-right: 0.375rem;
}

.prompt input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--ink);
  padding: 0.625rem 0;
  outline: none;
}

button[type="submit"] {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--diff-rem-ink);
  border: none;
  border-radius: 0.375rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
}

button[type="submit"]:disabled { opacity: 0.6; cursor: default; }

.form-status {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  margin-top: 0.625rem;
  min-height: 1.1rem;
}

.form-status[data-state="success"] { color: var(--diff-add-ink); }
.form-status[data-state="error"] { color: var(--diff-rem-ink); }

.statusbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
}

.statusbar .ok { color: var(--diff-add-ink); }
.statusbar-sep { opacity: 0.6; }

/* Signature: code + live preview split pane, mirroring Xcode's own Canvas. Load-in and vote-click animation live in motion.css, gated by prefers-reduced-motion. */
.split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
}

@media (max-width: 34rem) {
  .split { grid-template-columns: 1fr; }
}

.pane {
  background: var(--bg);
  padding: 1rem 1.125rem;
}

.pane-label {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.code-pane pre {
  font-size: 0.8125rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.gutter {
  color: var(--muted);
  opacity: 0.5;
  display: inline-block;
  width: 1.25rem;
  user-select: none;
}

.preview-list { list-style: none; }

.preview-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--line);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
}

.preview-row:last-child { border-bottom: none; }

.vote-btn {
  flex-shrink: 0;
  width: 1.75rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--type);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  padding: 0.15rem 0;
  cursor: pointer;
}

.vote-btn:hover { border-color: var(--type); }

.preview-title { flex: 1; }

.preview-status {
  font-size: 0.6875rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-weight: 600;
}

.status-planned { background: var(--diff-rem-bg); color: var(--keyword); }
.status-shipped { background: var(--diff-add-bg); color: var(--diff-add-ink); }

/* Pricing tiers (Free + Pro only) and the git-diff-styled comparison. */
.plans {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 26rem) {
  .plans { grid-template-columns: 1fr; }
}

.plan {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 0.375rem;
  padding: 1rem;
  font-family: var(--font-ui);
}

.plan.pro { border-left-color: var(--keyword); }

.plan h3 { font-family: var(--font-mono); font-size: 0.9375rem; }

.kw-label {
  font-size: 0.6875rem;
  color: var(--keyword);
  font-family: var(--font-mono);
}

.price {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0.375rem 0 0.625rem;
  font-variant-numeric: tabular-nums;
}

.price span { font-size: 0.75rem; font-weight: 400; color: var(--muted); }

.plan ul {
  list-style: none;
  font-size: 0.8125rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.plan ul li::before { content: "// "; color: var(--muted); opacity: 0.6; }

/* Comparison as a git diff: real dev vocabulary for "old way removed, new way added." */
.diff {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  overflow: hidden;
}

.diff-line { padding: 0.5rem 0.875rem; display: flex; gap: 0.625rem; }
.diff-rem { background: var(--diff-rem-bg); color: var(--diff-rem-ink); }
.diff-add { background: var(--diff-add-bg); color: var(--diff-add-ink); }
.diff-line + .diff-line { border-top: 1px solid var(--line); }

/* All keyframe animation lives here, gated by prefers-reduced-motion so motion-sensitive visitors get an instant, static page. */
@media (prefers-reduced-motion: no-preference) {
  .preview-row {
    animation: rise 0.4s ease backwards;
  }

  .preview-row:nth-child(1) { animation-delay: 0.05s; }
  .preview-row:nth-child(2) { animation-delay: 0.12s; }
  .preview-row:nth-child(3) { animation-delay: 0.19s; }

  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .vote-btn.just-voted .vote-count {
    display: inline-block;
    animation: bounce 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes bounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
  }
}
