@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design tokens ────────────────────────────────────────────────────────
   Light ("Clean light") is the default; dark ("Midnight") values come from
   light-dark(). The effective scheme follows the system preference unless
   the user picks one explicitly — theme.js then sets data-theme on <html>,
   which forces color-scheme below. */

/* Hues mirror the Kiroku app palette exactly (app repo:
   src/styles/theme/colors.ts + themes/{light,dark}.ts):
   bg=appBG, surface=cardBG, text-strong=text, text=textSupporting,
   muted/faint=icon, border=border, accent=appColor (yellowStrong),
   link/link-hover=link/linkHover. Keep them in sync with the app. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0d1117);
  --surface: light-dark(#f6f8fa, #151b23);
  --text-strong: light-dark(#1f2329, #f0f6fc);
  --text: light-dark(#2f3339, #e1e7ed);
  --muted: light-dark(#59636e, #9198a1);
  --faint: light-dark(#59636e, #9198a1);
  --border: light-dark(#d0d9e0, #3d444d);
  --accent: #f5c400;
  --link: light-dark(#0164bf, #5ab0ff);
  --link-hover: light-dark(#0676de, #b0d9ff);
}

html[data-theme='light'] {
  color-scheme: light;
}

html[data-theme='dark'] {
  color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* fallbacks for browsers without light-dark() support */
  background: #ffffff;
  color: #2f3339;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  width: 100%;
}

h1,
h2,
h3 {
  color: var(--text-strong);
  line-height: 1.25;
}

h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 26px 0 8px;
}

p,
ul,
ol {
  margin: 0 0 16px;
}

ul,
ol {
  padding-left: 22px;
}

li {
  margin-bottom: 8px;
}

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

a:hover {
  color: var(--link-hover);
}

strong {
  color: var(--text-strong);
  font-weight: 600;
}

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

/* ── Top bar (brand · language switch · theme toggle) ─────────────────── */

.topbar {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 20px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-strong);
  font-weight: 600;
  font-size: 15px;
}

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: block;
}

.lang-switch {
  font-size: 13px;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  padding: 2px 4px;
}

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

.lang-switch a[aria-current='page'] {
  color: var(--text-strong);
  font-weight: 600;
}

.lang-switch span {
  color: var(--border);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text-strong);
  border-color: var(--muted);
}

.theme-toggle svg {
  display: block;
}

/* Sun shows in light, moon in dark — both for explicit choice (data-theme)
   and for the system default (no data-theme). */
.theme-toggle .icon-moon {
  display: none;
}

html[data-theme='dark'] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme='dark'] .theme-toggle .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-toggle .icon-sun {
    display: none;
  }

  html:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
  }
}

/* ── Homepage hero ────────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 20px 40px;
}

.app-logo {
  width: 96px;
  border-radius: 22%;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: 2.4rem;
  margin: 0;
}

.hero h1::after {
  content: '';
  display: block;
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  margin: 16px auto 0;
}

.hero p {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 14px 0 32px;
  max-width: 30em;
}

.download-badges {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.badge {
  width: 160px;
  display: block;
  transition: transform 0.15s ease;
}

.badge:hover {
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .badge {
    transition: none;
  }
}

/* ── Document pages (legal, support, …) ───────────────────────────────── */

main.doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

main.doc header {
  margin: 16px 0 32px;
}

main.doc header p {
  color: var(--faint);
  font-size: 14px;
  margin: 8px 0 0;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 28px 20px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: center;
  margin-bottom: 10px;
}

footer nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
}

footer nav a:hover {
  color: var(--text-strong);
}

footer p {
  color: var(--faint);
  margin: 0;
  font-size: 12.5px;
}

/* ── Download / QR page ───────────────────────────────────────────────── */

body.download main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.download .hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 28px;
  max-width: 380px;
  width: 100%;
}
