/*
 * Chronoptica website styles. One file, no build step, no fonts fetched from anywhere:
 * the pages use the reader's system faces (SF Pro and New York on Apple devices), which are
 * the faces the app uses, so nothing about a visit reaches a font host.
 *
 * Colors are the app's own tokens: paper and night from CanvasPalette.swift, the navy
 * surround (the same in light and dark appearance, as in the app), and the five color
 * families of data/design/tokens.json. Every text pair below meets WCAG AA (body text at
 * 7:1 or better; the smallest secondary text at 4.5:1 or better).
 */

:root {
  color-scheme: light dark;

  --surround: #0B0F1A;      /* canvas.surround and the app icon's ground */
  --paper: #F4EEE2;         /* CanvasPalette.paper */
  --night: #0B0F1A;         /* CanvasPalette.night */
  --on-surround: #F2F4F8;   /* CanvasPalette.lightInk: 17.4:1 on the surround */
  --on-surround-2: #C9CFDB; /* 12.2:1 on the surround */

  --atlantic-blue: #2F5D8A;
  --lacquer-gold: #B8862B;
  --malachite: #17663F;
  --tyrian-purple: #932C76;
  --cinnabar: #9E2B25;

  --bg: var(--paper);
  --surface: #FBF8F2;
  --ink: #1B1E26;           /* CanvasPalette.darkInk: 14.4:1 on paper */
  --ink-2: #4A4F5C;         /* 7.1:1 on paper */
  --link: #2B5580;          /* Atlantic blue, darkened to 6.7:1 on paper */
  --rule: rgb(27 30 38 / 0.14);
  --now: #A85A00;           /* CanvasPalette.paperNow */
  --draft-bg: #F6E7BF;
  --draft-ink: #3A2E12;

  --font-ui: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-thai: "Sukhumvit Set", Thonburi, "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;

  --measure: 42rem;
  --wide: 72rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--night);
    --surface: #141A28;
    --ink: #F2F4F8;         /* 17.4:1 on night */
    --ink-2: #AEB4C2;       /* 9.2:1 on night */
    --link: #9CC0E6;        /* 10.1:1 on night */
    --rule: rgb(242 244 248 / 0.14);
    --now: #FF9F0A;         /* CanvasPalette.nightNow */
    --draft-bg: #3A2E12;
    --draft-ink: #F6E7BF;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "kern";
}

:lang(th) body,
body:lang(th) {
  font-family: var(--font-ui), var(--font-thai);
  line-height: 1.85; /* room for Thai stacked vowels and tone marks */
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

:lang(th) h1, :lang(th) h2, :lang(th) h3 {
  font-family: var(--font-ui), var(--font-thai);
  line-height: 1.45;
  letter-spacing: 0;
}

p, li { text-wrap: pretty; }

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 0.06em; }
a:hover { text-decoration-thickness: 0.12em; }

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
  border-radius: 4px;
}

img, svg { max-width: 100%; }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
}
.skip-link:focus { top: 0.75rem; }

.wrap {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.prose { max-width: var(--measure); }
.wrap.prose { max-width: calc(var(--measure) + 2 * var(--gutter)); } /* a document column, centered */

/* Header and footer sit on the navy surround, as the app's lanes do. */

.site-header,
.hero,
.site-footer {
  background: var(--surround);
  color: var(--on-surround);
}

.site-header a,
.hero a,
.site-footer a { color: var(--on-surround); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}
.brand svg { width: 1.75rem; height: 1.75rem; flex: none; }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a { text-decoration: none; color: var(--on-surround-2); }
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--on-surround); text-decoration: underline; }

.site-header :focus-visible,
.hero :focus-visible,
.site-footer :focus-visible { outline-color: var(--on-surround); }

/* Landing page */

.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 clamp(2.5rem, 6vw, 4rem); }

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 6vw, 4rem);
  max-width: 20ch;
}
:lang(th) .hero h1 { max-width: 26ch; font-size: clamp(2rem, 5.5vw, 3.5rem); }

.hero .lede {
  margin: 0 0 1.5rem;
  max-width: 38rem;
  font-size: clamp(1.125rem, 2.2vw, 1.3rem);
  color: var(--on-surround-2);
}

.status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin: 0 0 clamp(2rem, 5vw, 3rem);
  padding: 0.55rem 1rem;
  border: 1px solid rgb(242 244 248 / 0.28);
  border-radius: 1.25rem;
  font-weight: 600;
}
.status .free { color: var(--on-surround-2); font-weight: 400; }

.figure { margin: 0; }

.lanes-figure { display: block; width: 100%; height: auto; }
.lanes-figure--narrow { display: none; }

@media (max-width: 40rem) {
  .lanes-figure--wide { display: none; }
  .lanes-figure--narrow { display: block; }
}

.figure figcaption {
  margin-top: 0.9rem;
  max-width: 44rem;
  font-size: 0.95rem;
  color: var(--on-surround-2);
}

/* The figure echoes the canvas: paper lanes on the navy surround in both appearances. */
.fig-surround { fill: var(--surround); }
.fig-lane { fill: var(--paper); }
.fig-grid { stroke: rgb(27 30 38 / 0.10); stroke-width: 1; }
.fig-tick { stroke: var(--on-surround-2); stroke-width: 1; }
.lanes-figure text { font-family: var(--font-ui), var(--font-thai); }
.fig-ruler { fill: var(--on-surround-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.lanes-figure--narrow .fig-ruler { font-size: 11px; }
.fig-lane-name { fill: #1B1E26; font-weight: 700; letter-spacing: 0.01em; }
.fig-label { fill: #1B1E26; }
.fig-label-strong { font-weight: 600; }
.fig-now { stroke: #FF9F0A; stroke-width: 1.5; }
.fig-now-label { fill: #FF9F0A; font-size: 12px; font-weight: 600; }
.lanes-figure--narrow .fig-now-label { font-size: 11px; }

@media (prefers-reduced-motion: no-preference) {
  .fig-lane-group { animation: ink-in 900ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .fig-lane-th { animation-delay: 120ms; }
  .fig-lane-eg { animation-delay: 240ms; }
  .fig-lane-bible { animation-delay: 360ms; }
  .fig-lane-cn { animation-delay: 480ms; }
  .fig-now { animation: ink-in 600ms 800ms ease-out both; }
}

@keyframes ink-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section + .section { border-top: 1px solid var(--rule); }

.section h2 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1.75rem 2.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.features h3 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* A short colored rule before each heading, one color family each, as a lane's mark. */
.features h3::before {
  content: "";
  flex: none;
  width: 1.4rem;
  height: 0.45rem;
  border-radius: 0.25rem;
  background: var(--mark, var(--atlantic-blue));
}
.features li:nth-child(5n + 2) { --mark: var(--lacquer-gold); }
.features li:nth-child(5n + 3) { --mark: var(--malachite); }
.features li:nth-child(5n + 4) { --mark: var(--tyrian-purple); }
.features li:nth-child(5n + 5) { --mark: var(--cinnabar); }

.features p { margin: 0; color: var(--ink-2); }

.platforms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.platforms li {
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
}
.platforms h3 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.platforms p { margin: 0; color: var(--ink-2); font-size: 0.98rem; }

.note { color: var(--ink-2); font-size: 0.95rem; }

.callout {
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 0.4rem solid var(--malachite);
  border-radius: 12px;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

/* Document pages: privacy, support, 404 */

.page-head {
  background: var(--surround);
  color: var(--on-surround);
  padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(1.75rem, 4vw, 2.75rem);
}
.page-head h1 { margin: 0 0 0.5rem; font-size: clamp(2rem, 5vw, 3rem); }
.page-head p { margin: 0; color: var(--on-surround-2); }

.doc { padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 7vw, 5rem); }
.doc h2 { margin: 2.5rem 0 0.75rem; font-size: clamp(1.35rem, 3vw, 1.7rem); }
.doc h3 { margin: 1.75rem 0 0.5rem; font-size: 1.15rem; }
.doc ul { padding-left: 1.25rem; }
.doc li + li { margin-top: 0.35rem; }

.summary {
  margin: 0 0 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
}
.summary h2 { margin-top: 0; }
.summary ul { margin-bottom: 0; }

.faq details {
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  list-style-position: outside;
}
.faq details > :not(summary) { margin: 0.6rem 0 0; color: var(--ink); }

.contact-email {
  font-size: 1.2rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.draft-note {
  margin: 0;
  padding: 0.75rem var(--gutter);
  background: var(--draft-bg);
  color: var(--draft-ink);
  font-size: 0.95rem;
  text-align: center;
}

.site-footer { padding: 2rem 0 2.5rem; font-size: 0.95rem; }
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
}
.site-footer p { margin: 0; color: var(--on-surround-2); }
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .features h3::before { background: CanvasText; }
  .status { border-color: CanvasText; }
}

@media print {
  .site-header, .site-footer, .skip-link, .hero .figure { display: none; }
  .page-head, .hero { background: none; color: #000; }
  body { background: #fff; color: #000; }
}
