/*
 * Shared stylesheet for the static crawlable pages in public/*.html
 * (legal, help, safety guides, status, 404). One file for every page;
 * the header / breadcrumbs / footer markup is kept identical across pages by
 * scripts/static-pages.mjs (--check / --write).
 *
 * External file on purpose: the Hosting CSP has style-src-elem 'self' and no
 * 'unsafe-inline', so an inline <style> block would be dropped.
 *
 * Colours are Chathub's own (owner decision 2026-10-31,
 * docs/decisions/CHATHUB_WEB_KEEP_CHATHUB_COLOURS_2026-10-31.md). The values
 * are copied from src/styles/tokens-native.css, which cites the Chathub
 * Android colour name for each one. Change a value there first, then here.
 * Fonts: the system stack (no web fonts, no layout shift from font swap).
 *
 * Theme: light by default; dark when the system asks for it, unless the app's
 * stored choice put `.light` on <html> (public/theme-bootstrap.js runs in
 * <head> before first paint); `.dark` forces dark.
 */
:root {
  --canvas: #f7f5ef; /* surface_canvas */
  --card: #ffffff; /* surface_card */
  --hairline: #c9cbd0; /* hairline_stroke */
  --text: #212121; /* text_primary */
  --text-2: #6e6e6e; /* shade_500 */
  --link: #004085; /* link_color */
  --accent: #0071eb; /* colorAccent */
  --on-accent: #ffffff;
  --danger: #d32f2f; /* colorError = red_500 */
  --success: #34c759; /* primitive_success */
  --warning: #ff9500; /* primitive_warning */
  --outage: #ff3b30; /* primitive_danger */
  --field-border: #757575; /* tab_inactive */
  --shadow: 0 2px 6px rgb(0 0 0 / 0.06);
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --canvas: #121212;
    --card: #1e1e1e;
    --hairline: #3e3e42;
    --text: #ffffff;
    --text-2: #949494;
    --link: #368ce0;
    --danger: #f44336;
    --success: #5ccb78;
    --warning: #ffaa3d;
    --outage: #f45d55;
    --shadow: 0 2px 6px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root.dark {
  --canvas: #121212;
  --card: #1e1e1e;
  --hairline: #3e3e42;
  --text: #ffffff;
  --text-2: #949494;
  --link: #368ce0;
  --danger: #f44336;
  --success: #5ccb78;
  --warning: #ffaa3d;
  --outage: #f45d55;
  --shadow: 0 2px 6px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* ---- Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--canvas);
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 17px/1.6 var(--font);
  overflow-wrap: break-word;
}
img,
svg,
video {
  max-width: 100%;
  height: auto;
}
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-thickness: 2px;
}
a,
code,
dd {
  overflow-wrap: anywhere;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
code {
  font: 0.92em var(--mono);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 0 4px;
  word-break: break-word;
}
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Skip link ---- */
.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 10;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  left: 12px;
}

/* ---- Header ---- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--hairline);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
  white-space: nowrap;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover {
  background: var(--canvas);
}
.site-nav .nav-cta {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: 9px 16px;
  margin-left: 4px;
}
.site-nav .nav-cta:hover {
  background: var(--accent);
  text-decoration: underline;
}
/* App-safe legal pages (scripts/static-pages.mjs `appSafe`) carry a legal-only
   nav (Privacy / Terms / Guidelines) that stays visible on phones; the public
   nav collapses to its "Open the app" button. */
@media (max-width: 640px) {
  .site-nav:not([aria-label='Legal']) a:not(.nav-cta) {
    display: none;
  }
  .site-nav[aria-label='Legal'] a {
    padding: 8px;
    font-size: 14px;
  }
}

/* ---- Document ---- */
.doc {
  display: block;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 20px 64px;
}
.doc > * {
  max-width: 760px;
}
.crumbs {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-2);
}
.crumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
}
.crumbs li {
  margin: 0;
}
.crumbs li + li::before {
  content: '/';
  margin: 0 8px;
  color: var(--text-2);
}
.crumbs a {
  color: var(--text-2);
}
.crumbs [aria-current] {
  color: var(--text-2);
}
.doc > header {
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 20px;
  margin-bottom: 28px;
}
h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  margin: 0 0 10px;
}
h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 36px 0 12px;
}
h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 24px 0 8px;
}
h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 18px 0 6px;
}
p {
  margin: 0 0 14px;
}
ul,
ol {
  padding-left: 22px;
  margin: 0 0 16px;
}
li {
  margin: 0 0 8px;
}
.sub,
.subtitle,
.meta,
.updated,
.timestamp {
  color: var(--text-2);
  font-size: 15px;
}
.sub,
.subtitle {
  margin: 0;
}
.meta {
  margin: 0 0 20px;
}
.lead {
  font-size: 18px;
}
.no-margin {
  margin: 0;
}
.card,
.tile,
.id-card,
.callout,
.info,
.about,
.incidents {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.card > :last-child,
.tile > :last-child,
.callout > :last-child,
.info > :last-child,
.about > :last-child,
.incidents > :last-child {
  margin-bottom: 0;
}
.callout {
  border-left: 5px solid var(--danger);
}
/* Legal tables (privacy: companies that receive data, legal bases). The
   wrapper scrolls sideways on a narrow phone instead of the page. */
.table-scroll {
  overflow-x: auto;
  margin: 16px 0 20px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
.data-table caption {
  text-align: left;
  color: var(--text-2);
  padding-bottom: 8px;
}
.data-table th,
.data-table td {
  border: 1px solid var(--hairline);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.data-table thead th {
  background: var(--card);
}
.callout h2 {
  color: var(--danger);
  margin-top: 0;
  font-size: 19px;
}
.info {
  border-left: 5px solid var(--accent);
}
.info h2 {
  margin-top: 0;
  font-size: 19px;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin: 16px 0;
}
@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
.grid-2 .tile {
  margin: 0;
}
.tile h3 {
  margin-top: 0;
}
.steps {
  list-style: none;
  padding-left: 0;
  counter-reset: step;
  margin: 16px 0;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 40px;
  margin-bottom: 16px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 12px 0;
}
.step-body {
  min-width: 0;
}
.step-body p {
  margin: 0;
}
.num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
details {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  padding: 0 20px;
  margin: 0 0 10px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  padding: 14px 0;
}
details[open] > summary {
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 12px;
}
details > :last-child {
  padding-bottom: 14px;
}
dl {
  margin: 0 0 16px;
}
dt {
  font-weight: 700;
  margin-top: 12px;
}
dd {
  margin: 2px 0 0;
}
.id-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 4px;
}
.id-card dt {
  color: var(--text-2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.id-card dt:not(:first-child) {
  margin-top: 10px;
}
.id-card dd {
  margin: 0;
}
@media (min-width: 640px) {
  .id-card dl {
    grid-template-columns: 200px minmax(0, 1fr);
    column-gap: 16px;
    row-gap: 12px;
  }
  .id-card dt,
  .id-card dt:not(:first-child) {
    margin-top: 0;
  }
}
.tablewrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
}
th {
  font-weight: 700;
}
.back {
  display: inline-block;
  margin-top: 24px;
  padding: 10px 18px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.back:hover {
  border-color: var(--accent);
}
/* The page's own closing line (contact addresses, copyright). */
.doc-foot {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: 15px;
}

/* ---- 404 ---- */
.doc.not-found {
  text-align: center;
  padding-top: 64px;
}
.doc.not-found > * {
  margin-left: auto;
  margin-right: auto;
}
.code {
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}
.not-found .sub {
  margin: 0 auto 8px;
}

/* ---- Status page ---- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 28px;
  padding: 16px 20px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-left: 5px solid var(--success);
  border-radius: var(--radius-m);
}
.banner.degraded {
  border-left-color: var(--warning);
}
.banner.outage {
  border-left-color: var(--outage);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--success);
}
.banner.degraded .dot {
  background: var(--warning);
}
.banner.outage .dot {
  background: var(--outage);
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin: 0 0 10px;
}
.components {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  overflow: hidden;
  margin-bottom: 12px;
}
.component-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
}
.component-row:last-child {
  border-bottom: none;
}
.component-name {
  font-weight: 500;
  min-width: 0;
}
.component-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.latency {
  font-size: 14px;
  color: var(--text-2);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}
.status-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.status-badge.degraded::before {
  background: var(--warning);
}
.status-badge.outage::before {
  background: var(--outage);
}
.loading {
  color: var(--text-2);
  font-style: italic;
  padding: 18px 20px;
}
.timestamp {
  margin: 0 0 28px;
  min-height: 1.6em;
}
.incidents-empty {
  color: var(--text-2);
}

/* ---- Footer ---- */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--hairline);
  padding: 36px 0 28px;
  font-size: 15px;
}
.foot-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
}
.foot-cols h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 0 0 10px;
}
.foot-cols ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.foot-cols li {
  margin: 0 0 6px;
}
.foot-cols a {
  color: var(--text);
  text-decoration: none;
}
.foot-cols a:hover {
  text-decoration: underline;
}
.foot-legal {
  margin: 28px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--text-2);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---- Print: the document only, black on white, link targets shown ---- */
@media print {
  :root,
  :root.dark {
    --canvas: #fff;
    --card: #fff;
    --text: #000;
    --text-2: #333;
    --link: #000;
    --hairline: #999;
    --shadow: none;
  }
  .skip,
  .site-header,
  .site-footer,
  .crumbs,
  .back {
    display: none !important;
  }
  body {
    font-size: 12pt;
  }
  .doc {
    padding: 0;
  }
  .doc > * {
    max-width: none;
  }
  .doc a[href^='http']::after,
  .doc a[href^='mailto:']::after {
    content: ' (' attr(href) ')';
    font-size: 0.9em;
  }
  details {
    border: 0;
    padding: 0;
  }
  h2,
  h3 {
    break-after: avoid;
  }
}

/* ---- About page (public/about.html, unit B3b) ---- */
.about-hero {
  text-align: left;
}
.about-icon {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: var(--radius-l);
  margin: 0 0 16px;
}
.about-tagline {
  display: block;
  color: var(--accent);
}
.about-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}
.about-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}
.about-cta:hover {
  color: var(--on-accent);
  text-decoration: underline;
}
.about-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.about-badges img {
  display: block;
  height: 45px;
  width: auto;
}
.about-page section {
  margin-top: 40px;
}
.about-page section > h2 {
  margin-bottom: 4px;
}
.about-page section > .sub {
  margin-bottom: 12px;
}
/* The Play badge PNG carries Google's clear-space padding; scale it so its
   artwork matches the App Store badge height. */
.about-badges img[src$='google-play.png'] {
  height: 66px;
  margin: -10px -9px;
}
.about-guides ul {
  padding-left: 20px;
}

/* ---- One-time service notice (src/config/resetNotice.ts) ---- */
.site-notice {
  background: var(--card);
  border-bottom: 1px solid var(--hairline);
}
.site-notice p {
  margin: 0;
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}
.site-notice a {
  color: var(--link);
  font-weight: 600;
}

/* Scrollbars: none, anywhere on chathubapp.com (owner 2026-11-07; same rule as
   src/styles/globals.css). Only the bar is hidden: wide tables and code
   blocks still scroll by wheel, touch, trackpad and keyboard. */
* {
  scrollbar-width: none;
}
::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
