/* Kopiyka Budget — promo site
   Hand-written, no framework, no external fonts, no external scripts. */

:root {
  /* The colours (--bg, --card, --text, --muted, --accent, --on-accent, --border, --red, --green,
     --orange) come from themes.css, which build.mjs generates from packages/core/src/themes.ts —
     never write a hex value here. --rule is the thin decorative line above each heading: the
     theme's accent, except in the default Graphite theme, which keeps the site's warm gold. */
  --rule: var(--accent);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  --maxw: 1120px;
}

:root:not([data-theme]),
:root[data-theme="graphite"] {
  --rule: #c8a96a;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--border);
}

a:hover {
  text-decoration-color: var(--accent);
}

/* The text colour, not the accent: the focus ring has to clear 3:1 against the
   page, and several themes' accents (and Graphite's gold rule) do not. */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  letter-spacing: -0.022em;
  line-height: 1.1;
  margin: 0 0 0.4em;
  font-weight: 800;
}

h1 {
  font-size: clamp(2.1rem, 7vw, 3.6rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
}

h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1em;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 100;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

@supports not (backdrop-filter: blur(1px)) {
  .site-header {
    background: var(--bg);
  }
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-block: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
  font-size: 1.0625rem;
  white-space: nowrap;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  opacity: 0.86;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

/* The language switcher: two quiet links in the header, the current one on the accent. */
.brand-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-switch {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 9px;
  border-radius: 999px;
  line-height: 1.2;
}

.lang-switch a:hover {
  color: var(--text);
}

.lang-switch a[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* The header button says "App Store" on a phone; the full label everywhere else. */
.btn .short {
  display: none;
}

/* ---------- sections ---------- */

section {
  padding-block: clamp(48px, 8vw, 88px);
  border-top: 1px solid var(--border);
}

section:first-of-type {
  border-top: 0;
}

.eyebrow {
  display: block;
  width: 56px;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  margin-bottom: 22px;
}

.lede {
  font-size: clamp(1.0625rem, 2.2vw, 1.3125rem);
  color: var(--muted);
  max-width: 40ch;
}

.section-intro {
  max-width: 62ch;
  color: var(--muted);
}

/* ---------- hero ---------- */

.hero {
  padding-top: clamp(40px, 7vw, 76px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
}

.hero-grid > * {
  min-width: 0;
}

.hero h1 {
  max-width: 12ch;
  overflow-wrap: break-word;
}

/* The shots are bare devices on a transparent canvas, so they get no card
   chrome of their own — a border round a photo of a phone is a border too many. */
.hero-shot {
  max-width: 340px;
  margin-left: auto;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.quiet {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- why ---------- */

/* A reading column that sits inside a .wrap, so it starts on the same left
   edge as every other section instead of centring itself. */
.prose-narrow {
  max-width: 68ch;
}

.prose-narrow p {
  font-size: 1.0625rem;
}

/* ---------- features ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card .glyph {
  display: block;
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  color: var(--text);
}

.card .glyph svg {
  width: 100%;
  height: 100%;
  display: block;
}

.card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ---------- highlights ---------- */

/* One row per thing the app is best at: the words on one side, its screen on the
   other, swapping sides down the page. On a phone the screen sits under the words. */
.highlights {
  display: grid;
  gap: clamp(40px, 7vw, 88px);
  margin-top: 40px;
}

.highlight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
  gap: clamp(24px, 6vw, 72px);
  align-items: center;
}

.highlight:nth-child(even) {
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
}

.highlight:nth-child(even) img {
  order: -1;
}

.highlight h3 {
  font-size: clamp(1.375rem, 3vw, 1.875rem);
  line-height: 1.2;
}

.highlight p {
  color: var(--muted);
  font-size: 1.0625rem;
  max-width: 46ch;
}

.highlight .beta,
.card .beta {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- screenshot strip ---------- */

.strip-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.strip-controls {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.strip-controls button {
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

.strip-controls button:hover {
  border-color: var(--accent);
}

.strip {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 20px;
  padding: 28px 20px 22px;
  margin-inline: -20px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.slide {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: 250px;
  margin: 0;
}

.slide img {
  width: 250px;
}

.slide figcaption {
  margin-top: 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- watch ---------- */

.watch-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 26px 20px 18px;
  margin-inline: -20px;
  scroll-padding-inline: 20px;
}

/* 144px keeps all seven shots inside the 1120px column on a desktop; narrower
   viewports scroll the row instead. */
.watch-shot {
  flex: 0 0 auto;
  width: 144px;
  margin: 0;
  scroll-snap-align: center;
  text-align: center;
}

.watch-shot img {
  width: 144px;
}

.watch-shot figcaption {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---------- iPad ---------- */

.ipad-row {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 26px 20px 18px;
  margin-inline: -20px;
  scroll-padding-inline: 20px;
}

/* Three at 340px fill the 1120px column; narrower viewports scroll the row. */
.ipad-shot {
  flex: 0 0 auto;
  width: 340px;
  margin: 0;
  scroll-snap-align: center;
}

.ipad-shot img {
  width: 340px;
}

.ipad-shot figcaption {
  margin-top: 14px;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- privacy / migrate / open source ---------- */

.linkrow {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ---------- themes ---------- */

/* The footer's swatches: each theme's accent on its background, in the
   current light or dark side. The ring round the chosen one is the page's. */
.theme-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.theme-switch[hidden] {
  display: none;
}

.swatch {
  width: 28px;
  height: 28px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: radial-gradient(circle, var(--accent) 0 34%, var(--bg) 36%);
  border: 1px solid var(--border);
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--text);
}

.theme-grid {
  list-style: none;
  padding: 0;
  margin: 30px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.theme-tile {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  cursor: pointer;
}

.theme-tile:hover {
  border-color: var(--muted);
}

.theme-tile[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}

.theme-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-name {
  display: block;
  margin-top: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* A screen in miniature, drawn only from the palette it sits in. */
.mini {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.mini i {
  display: block;
  border-radius: 999px;
}

.mini-title {
  width: 55%;
  height: 7px;
  border-radius: 999px;
  background: var(--text);
}

.mini-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.mini-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-dot {
  width: 7px;
  height: 7px;
  flex: none;
}

.mini-dot.red {
  background: var(--red);
}

.mini-dot.green {
  background: var(--green);
}

.mini-dot.orange {
  background: var(--orange);
}

.mini-line {
  flex: 1;
  height: 4px;
  background: var(--muted);
  opacity: 0.7;
}

.mini-amount {
  width: 22%;
  height: 4px;
  background: var(--text);
}

.mini-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 15px;
  border-radius: 999px;
  background: var(--accent);
}

.mini-btn i {
  width: 36%;
  height: 4px;
  background: var(--on-accent);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 34px 46px;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer .wrap {
  display: flex;
  gap: 10px 20px;
  flex-wrap: wrap;
  align-items: center;
}

.site-footer a {
  color: var(--muted);
}

.site-footer .sep {
  opacity: 0.45;
}

.site-footer .made {
  margin-left: auto;
}

/* ---------- doc pages ---------- */

.doc {
  padding-block: clamp(36px, 6vw, 64px);
  border-top: 0;
}

.doc .wrap {
  max-width: 68ch;
}

.doc h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin-bottom: 0.5em;
}

.doc h2 {
  font-size: 1.3125rem;
  margin-top: 2em;
  padding-top: 0.9em;
  border-top: 1px solid var(--border);
}

.doc h3 {
  margin-top: 1.6em;
}

.doc p,
.doc li {
  color: var(--text);
}

.doc em {
  color: var(--muted);
}

.doc ul,
.doc ol {
  padding-left: 1.25em;
}

.doc li {
  margin-bottom: 0.5em;
}

.doc blockquote {
  margin: 1.4em 0;
  padding-left: 1em;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
}

.doc th,
.doc td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}

.doc th {
  background: var(--card);
  font-weight: 700;
}

.doc code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.doc pre {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0;
}

.doc pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

.doc hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.codeblock {
  position: relative;
  margin: 1.6em 0;
}

/* Room for the Copy button, and a smaller face so more of the prompt fits
   before the block has to scroll sideways. */
.codeblock pre {
  padding-top: 48px;
  font-size: 0.75rem;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

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

.doc-back {
  display: inline-block;
  margin-bottom: 22px;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .highlight,
  .highlight:nth-child(even) {
    grid-template-columns: minmax(0, 1fr);
  }

  .highlight img,
  .highlight:nth-child(even) img {
    order: 0;
    max-width: 260px;
    margin: 0 auto;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero h1 {
    max-width: none;
  }

  .hero-shot {
    max-width: 320px;
    margin-left: 0;
  }

  .site-footer .made {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .wrap {
    padding-inline: 18px;
  }

  .site-header .wrap {
    gap: 8px;
    padding-block: 10px;
  }

  .brand {
    font-size: 1rem;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }

  .site-nav {
    width: 100%;
    margin-left: 0;
    gap: 16px;
    order: 3;
  }

  .brand-actions {
    margin-left: auto;
  }

  /* "Download on the App Store" does not fit beside the wordmark on a phone;
     the header button becomes "App Store" and the hero keeps the full label. */
  .brand-actions .btn {
    font-size: 0.8125rem;
    padding: 7px 14px;
  }

  .brand-actions {
    gap: 8px;
  }

  .brand-actions .btn .long {
    display: none;
  }

  .brand-actions .btn .short {
    display: inline;
  }

  .lang-switch a {
    padding: 3px 7px;
  }

  .strip,
  .watch-row,
  .ipad-row {
    margin-inline: -18px;
    padding-inline: 18px;
    scroll-padding-inline: 18px;
  }

  .slide,
  .slide img {
    width: 208px;
  }

  .ipad-shot,
  .ipad-shot img {
    width: 260px;
  }

  .strip-controls {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header,
  .lang-switch,
  .theme-switch,
  .strip-controls,
  .copy-btn {
    display: none;
  }
}
