/* Shared styling for the public pages (#170).
 *
 * These are plain files under public/, served straight out of dist by nginx,
 * so they are crawlable in a way the app itself is not. One stylesheet rather
 * than a style block per page: ten copies of the same tokens is how they drift.
 *
 * The palette is the app's, lifted from src/styles.css so the marketing pages
 * and the product do not look like two different products.
 */

:root {
  --background: oklch(0.985 0.006 85);
  --foreground: oklch(0.24 0.02 60);
  --muted: oklch(0.95 0.008 85);
  --muted-foreground: oklch(0.44 0.017 65);
  --primary: oklch(0.42 0.05 45);
  --primary-foreground: oklch(0.98 0.01 85);
  --border: oklch(0.9 0.008 85);
  --card: oklch(1 0 0);
  --surface: oklch(0.995 0.004 85);
  --foot-bg: oklch(0.22 0.018 60);
  --foot-fg: oklch(0.97 0.008 85);
  --foot-muted: oklch(0.75 0.012 70);
  --foot-border: oklch(0.32 0.016 60);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: oklch(0.19 0.012 60);
    --foreground: oklch(0.92 0.008 85);
    --muted: oklch(0.25 0.012 60);
    --muted-foreground: oklch(0.68 0.014 70);
    --primary: oklch(0.74 0.06 60);
    --primary-foreground: oklch(0.2 0.02 60);
    --border: oklch(0.31 0.012 60);
    --card: oklch(0.22 0.012 60);
    --surface: oklch(0.22 0.014 60);
    --foot-bg: oklch(0.15 0.012 60);
    --foot-fg: oklch(0.95 0.008 85);
    --foot-muted: oklch(0.70 0.012 70);
    --foot-border: oklch(0.27 0.014 60);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 400 17px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 72ch; margin: 0 auto; padding: 2.5rem 1.25rem 6rem; }
.wrap.narrow { max-width: 68ch; }

/* Header.
 *
 * A band across the full width with its own surface, so it reads as chrome
 * rather than as the first paragraph of the page. The inner row is held to the
 * same measure as the prose.
 *
 * Two actions, not one. Sign in and Create account are different intents and a
 * single "Open Qlemi" made the returning writer and the first-time visitor
 * click the same thing and land in the wrong place.
 */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(140%) blur(6px);
}
.head-inner {
  max-width: 76rem; margin: 0 auto; padding: .85rem 1.5rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.brand {
  display: inline-flex; align-items: baseline; gap: .5rem;
  font-family: "Source Serif 4", Georgia, serif; font-size: 1.3rem;
  color: var(--foreground); text-decoration: none; white-space: nowrap;
}
.brand span { font: 400 .75rem/1 Inter, sans-serif; color: var(--muted-foreground); }
.site-nav { display: flex; gap: 1.4rem; font-size: .93rem; margin-left: auto; }
.site-nav a { color: var(--muted-foreground); text-decoration: none; white-space: nowrap; }
.site-nav a:hover { color: var(--foreground); }
/* The current page is stated in the accent, not only to a screen reader. */
.site-nav a[aria-current="page"] { color: var(--primary); font-weight: 500; }
.head-actions { display: flex; align-items: center; gap: .6rem; }

.btn-solid, .btn-ghost {
  display: inline-block; padding: .5rem 1.05rem; border-radius: 7px;
  font-size: .9rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; transition: opacity .12s, background-color .12s;
}
.btn-solid { background: var(--primary); color: var(--primary-foreground); }
.btn-solid:hover { opacity: .9; }
.btn-ghost { color: var(--foreground); border-color: var(--border); }
.btn-ghost:hover { background: var(--muted); }

/* The hamburger and its panel.
 *
 * A wrapping nav gave the header a different height on every page and pushed
 * the content down. Below 860 the links move into a full-screen panel instead:
 * on a phone a menu that pushes the page down competes with the content it is
 * meant to help you leave.
 *
 * The toggle lives in /js/site.js, not inline, because the CSP is
 * script-src 'self' and an inline handler would never run.
 */
.burger {
  display: none; width: 44px; height: 44px; margin-left: auto;
  align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 8px;
  color: var(--foreground); cursor: pointer;
}
.burger:hover { background: var(--muted); }

.menu-panel {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--background);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease-out;
}
.menu-panel.is-open { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .menu-panel { transition: none; } }

.menu-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
}
.menu-close {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 8px;
  color: var(--foreground); cursor: pointer;
}
.menu-close:hover { background: var(--muted); }

.menu-links {
  flex: 1; display: flex; flex-direction: column; gap: .35rem;
  padding: 1.75rem 1.5rem; overflow-y: auto;
}
.menu-links a {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.85rem; font-weight: 600; line-height: 1.35;
  color: var(--foreground); text-decoration: none;
}
.menu-links a[aria-current="page"] { color: var(--primary); }

.menu-actions {
  display: grid; gap: .6rem; padding: 1.25rem 1.5rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
.menu-actions .btn-solid, .menu-actions .btn-ghost {
  display: block; text-align: center; padding: .75rem 1rem; font-size: .98rem;
}

@media (max-width: 860px) {
  .head-inner { padding: .7rem 1.1rem; gap: 1rem; }
  .site-nav, .head-actions { display: none; }
  .burger { display: flex; }
}
@media (min-width: 861px) {
  .menu-panel { display: none; }
}

/* Typography */
h1 {
  font-family: "Source Serif 4", Georgia, serif; font-weight: 600;
  font-size: clamp(2rem, 6vw, 2.7rem); line-height: 1.12; margin: 1.5rem 0 .6rem;
}
h1.hero { font-size: clamp(2.3rem, 7vw, 3.4rem); }
h2 {
  font-family: "Source Serif 4", Georgia, serif; font-weight: 600;
  font-size: 1.45rem; line-height: 1.25; margin: 3.25rem 0 .6rem;
}
h3 { font-size: 1rem; font-weight: 600; margin: 1.75rem 0 .35rem; }
a { color: var(--primary); text-underline-offset: 3px; }
.lede { font-size: 1.15rem; color: var(--muted-foreground); margin: 0 0 1.25rem; }
.updated { font-size: .85rem; color: var(--muted-foreground); }
ul, ol { padding-left: 1.15rem; }
li { margin: .35rem 0; }

/* Call to action */
.cta { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.75rem 0; }
.btn {
  display: inline-block; padding: .7rem 1.3rem; border-radius: 8px;
  font-size: .98rem; font-weight: 500; text-decoration: none; border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-secondary { border-color: var(--border); color: var(--foreground); }
.btn:hover { opacity: .9; }
.cta-note { font-size: .88rem; color: var(--muted-foreground); margin: -.5rem 0 0; }

/* Blocks */
.note {
  border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: 8px; padding: 1rem 1.15rem; margin: 1.75rem 0;
}
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1rem; margin: 1.5rem 0; }
@media (min-width: 620px) { .grid { grid-template-columns: 1fr 1fr; } }
.card { border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.25rem; }
.card.filled { background: var(--muted); }
.card h3 { margin: 0 0 .35rem; font-size: 1rem; }
.card p { margin: 0; font-size: .95rem; color: var(--muted-foreground); }
.card ul { margin: 0; padding-left: 1.1rem; font-size: .95rem; }
.card h4 {
  margin: 0 0 .6rem; font-size: .78rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted-foreground);
}

/* Numbered steps */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 1.5rem 0; }
.steps li { counter-increment: s; position: relative; padding-left: 2.4rem; margin: 1.4rem 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: .05rem;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  border: 1px solid var(--border); background: var(--muted); color: var(--muted-foreground);
  font-size: .82rem; font-weight: 600; display: grid; place-items: center;
}
.steps strong { display: block; }

/* Media */
figure { margin: 2rem 0; }
figure img { width: 100%; height: auto; display: block; border: 1px solid var(--border); border-radius: 10px; }
figcaption { font-size: .85rem; color: var(--muted-foreground); margin-top: .6rem; }

/* Tables scroll rather than pushing the page sideways on a phone */
.scroll { overflow-x: auto; margin: 1.25rem 0; }
table { border-collapse: collapse; width: 100%; min-width: 32rem; font-size: .93rem; }
th, td { text-align: left; vertical-align: top; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
td:first-child { font-weight: 500; }
.tag {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; padding: .1rem .45rem; border-radius: 4px;
  border: 1px solid var(--border); color: var(--muted-foreground); white-space: nowrap;
}
code { font-size: .88em; background: var(--muted); padding: .1rem .3rem; border-radius: 4px; }

/* Article lists */
.posts { list-style: none; padding: 0; margin: 1.5rem 0; }
.posts li { margin: 0; border-bottom: 1px solid var(--border); }
.posts a { display: block; padding: 1rem 0; text-decoration: none; color: var(--foreground); }
.posts a:hover .posts-title { text-decoration: underline; }
.posts-title { font-family: "Source Serif 4", Georgia, serif; font-size: 1.15rem; }
.posts p { margin: .2rem 0 0; font-size: .93rem; color: var(--muted-foreground); }

/* Changelog */
.release { border-left: 2px solid var(--border); padding-left: 1.25rem; margin: 2rem 0; }
.release h3 { margin-top: 0; }
.release .when { font-size: .82rem; color: var(--muted-foreground); }

/* Footer.
 *
 * Dark and full width, so the page visibly ends. On the same cream as the
 * prose it read as one more section of content, which is what it looked like
 * and what it was.
 */
footer.site-foot {
  margin-top: 5rem;
  background: var(--foot-bg);
  color: var(--foot-muted);
  font-size: .93rem;
}
.foot-inner { max-width: 76rem; margin: 0 auto; padding: 3.5rem 1.5rem 2rem; }
.foot-top { display: grid; gap: 2.5rem; }
@media (min-width: 900px) { .foot-top { grid-template-columns: 20rem 1fr; gap: 4rem; } }

.foot-brand .foot-mark {
  font-family: "Source Serif 4", Georgia, serif; font-size: 1.5rem;
  color: var(--foot-fg); display: block; margin-bottom: .6rem;
}
.foot-brand p { margin: 0 0 1.25rem; max-width: 34ch; line-height: 1.55; }
/* The accent is a dark brown, which on the dark footer is nearly invisible.
   A light button on a dark surface, the inverse of the one in the header. */
.foot-brand .btn-solid { background: var(--foot-fg); color: var(--foot-bg); }
.foot-brand .btn-solid:hover { opacity: .88; }

.foot-cols { display: grid; gap: 2rem 1.5rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) { .foot-cols { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 330px) { .foot-cols { grid-template-columns: 1fr; } }
.foot-cols h2 {
  font-family: Inter, system-ui, sans-serif;
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--foot-fg); margin: 0 0 .75rem;
}
.foot-cols ul { list-style: none; margin: 0; padding: 0; }
.foot-cols li { margin: .4rem 0; }
.foot-cols a, .foot-legal a { color: var(--foot-muted); text-decoration: none; }
.foot-cols a:hover, .foot-legal a:hover { color: var(--foot-fg); }

.foot-end {
  margin-top: 3rem; padding-top: 1.5rem;
  border-top: 1px solid var(--foot-border);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1.5rem;
  font-size: .86rem;
}
.foot-end p { margin: 0; }
.foot-legal { display: flex; gap: 1.25rem; }
