/* ---------------------------------------------------------------------------
   Sway games-integration docs — shared design system.

   Derived from the mobile app's actual values, extracted from source. The
   mobile app has NO theme or token file: every colour is an inline hex literal
   spread across ~30 style files. This stylesheet is the first place those
   values have been consolidated, so treat it as a reference for the real
   tokens, not as an invention.

   Source of the values below:
     apps/mobile/src/app/dashboard/index.tsx      (gradients, chart colours)
     apps/mobile/src/app/dashboard/styles.ts      (text, tabs, bars, cards)
     apps/mobile/src/components/Header/styles.ts  (menu lines, shadow)
     apps/mobile/src/utils/responsive.ts          (spacing, radii, type scale)
     apps/api/prisma/seed/data/trust_categories.json (category colours)
--------------------------------------------------------------------------- */

:root {
  /* Brand ---------------------------------------------------------------- */
  --purple: #7600ff;          /* the single dominant brand colour app-wide   */
  --purple-deep: #700efe;     /* dashboard/index.tsx:1312 compare-tab figure */
  --blue: #4e55fc;
  --cyan: #16cef9;
  --aqua: #00fff8;

  /* The trusted gradient, verbatim from dashboard/index.tsx:49-55.
     TRUSTED_GRADIENT_COLORS with TRUSTED_GRADIENT_LOCATIONS [0,.21,.68,1]. */
  --grad-trusted: linear-gradient(90deg,
    #00fff8 0%, #16cef9 21%, #4e55fc 68%, #7600ff 100%);

  /* Header menu icon lines, Header/styles.ts */
  --grad-menu: linear-gradient(90deg, #00fff8 0%, #4468fc 50%, #7600ff 100%);

  /* Trust levels --------------------------------------------------------- */
  --trusted: #00e230;
  --caution: #ff6700;
  --untrusted: #ff1d25;

  /* Neutrals ------------------------------------------------------------- */
  --ink: #222222;             /* Typography.tsx default text colour          */
  --ink-strong: #050505;
  --ink-soft: #333333;
  --muted: #666666;
  --muted-light: #999999;
  --line: #e0e0e0;
  --surface: #ffffff;
  --surface-alt: #f9f9f9;     /* dashboard/styles.ts cardWrapper             */
  --surface-sunk: #f2f2f2;

  /* Evidence-confidence palette. Not from the app — specific to these docs.
     Deliberately not reusing the trust colours, so a reader never confuses
     "how confident are we in this claim" with "how risky is this content". */
  --confirmed: #0a7d32;
  --confirmed-bg: #e8f6ec;
  --likely: #9a6400;
  --likely-bg: #fdf3e2;
  --unverified: #8a2b2b;
  --unverified-bg: #fbeceb;
  --none-bg: #f0f0f2;
  --none-fg: #5a5a66;

  /* Spacing — responsive.ts responsiveDimensions.spacing ------------------ */
  --s-xs: 4px;
  --s-sm: 8px;
  --s-md: 16px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;

  /* Radii — responsive.ts responsiveDimensions.borderRadius --------------- */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;   /* the app's default card radius */
  --r-xl: 16px;
  --r-round: 9999px;

  /* Type scale — responsive.ts responsiveDimensions.fontSize -------------- */
  --f-xs: 10px;
  --f-sm: 12px;
  --f-md: 14px;
  --f-lg: 16px;
  --f-xl: 18px;
  --f-xxl: 24px;
  --f-xxxl: 32px;

  /* The app ships Noka (a licensed OTF bundled in the binary). It is not
     available to a web page, so this falls back to a system stack with
     similar geometric-humanist proportions. Do not treat the rendering here
     as typographically faithful — weights and letterfit will differ. */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --shadow: 0 4px 8px rgba(0, 0, 0, 0.15);  /* Header/styles.ts dropdown */

  --sidebar-w: 268px;
  --measure: 74ch;
}

/* Dark mode. The mobile app is light-only, so this is a docs-site nicety
   rather than anything derived from the product. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ececf1;
    --ink-strong: #ffffff;
    --ink-soft: #c8c8d0;
    --muted: #a0a0ad;
    --muted-light: #7e7e8c;
    --line: #34343f;
    --surface: #16161c;
    --surface-alt: #1e1e26;
    --surface-sunk: #24242e;
    --confirmed-bg: #10301c;
    --confirmed: #6fdc95;
    --likely-bg: #33270e;
    --likely: #f0c274;
    --unverified-bg: #351a1a;
    --unverified: #f39494;
    --none-bg: #26262f;
    --none-fg: #a0a0ad;
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--f-lg);
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

/* --- Password gate -------------------------------------------------------
   Client-side only. This is a deterrent, not a security control, and the
   page says so out loud rather than implying protection it does not have. */

#gate {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: var(--s-lg);
  background: var(--surface);
}

#gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 420px;
  text-align: left;
}

.gate-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  background: var(--grad-trusted);
  margin-bottom: var(--s-lg);
}

.gate-card h1 {
  font-size: var(--f-xxl);
  margin: 0 0 var(--s-sm);
  letter-spacing: -0.02em;
}

.gate-card p {
  color: var(--muted);
  font-size: var(--f-md);
  margin: 0 0 var(--s-lg);
}

.gate-row { display: flex; gap: var(--s-sm); }

#gate input {
  flex: 1;
  min-width: 0;
  padding: 12px var(--s-md);
  font-size: var(--f-lg);
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

#gate input:focus {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

#gate button {
  padding: 12px var(--s-lg);
  font-size: var(--f-md);
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  background: var(--purple);
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
}

#gate button:hover { background: var(--purple-deep); }

.gate-error {
  margin-top: var(--s-md);
  color: var(--untrusted);
  font-size: var(--f-md);
  min-height: 1.4em;
}

.gate-note {
  margin-top: var(--s-xl);
  padding: var(--s-md);
  border-left: 3px solid var(--likely);
  background: var(--likely-bg);
  color: var(--likely);
  font-size: var(--f-sm);
  line-height: 1.5;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* --- Layout -------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  padding: var(--s-lg) var(--s-md);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface-alt);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--s-xl);
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--grad-trusted);
  flex: none;
}

.brand-text { font-weight: 700; font-size: var(--f-md); letter-spacing: -0.01em; }
.brand-sub { display: block; font-weight: 400; font-size: var(--f-xs); color: var(--muted); }

.nav-group { margin-bottom: var(--s-lg); }

.nav-label {
  font-size: var(--f-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  margin-bottom: var(--s-sm);
  padding-left: var(--s-sm);
}

.nav a {
  display: block;
  padding: 7px var(--s-sm);
  border-radius: var(--r-md);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--f-md);
  border-left: 3px solid transparent;
}

.nav a:hover { background: var(--surface-sunk); }

.nav a.active {
  color: var(--purple);
  font-weight: 600;
  border-left-color: var(--purple);
  background: var(--surface-sunk);
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--s-xl) var(--s-xl) 96px;
}

.page { max-width: var(--measure); }

/* --- Typography ---------------------------------------------------------- */

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.02em; }

h1 { font-size: var(--f-xxxl); margin: 0 0 var(--s-sm); }
h2 {
  font-size: var(--f-xxl);
  margin: var(--s-xxl) 0 var(--s-md);
  padding-top: var(--s-lg);
  border-top: 1px solid var(--line);
}
h3 { font-size: var(--f-xl); margin: var(--s-xl) 0 var(--s-sm); }
h4 { font-size: var(--f-lg); margin: var(--s-lg) 0 var(--s-xs); }

.lede {
  font-size: var(--f-xl);
  color: var(--muted);
  margin: 0 0 var(--s-xl);
  line-height: 1.5;
}

p, li { max-width: var(--measure); }

code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--surface-sunk);
  padding: 2px 5px;
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
}

pre {
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-md);
  overflow-x: auto;
  font-size: var(--f-sm);
  line-height: 1.55;
}

pre code { background: none; padding: 0; }

a { color: var(--purple); }

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin: var(--s-md) 0 var(--s-lg);
  -webkit-overflow-scrolling: touch;
}

table { border-collapse: collapse; width: 100%; font-size: var(--f-md); }

th, td {
  text-align: left;
  padding: 10px var(--s-md);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: var(--f-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-alt);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-alt); }

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: var(--f-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  white-space: nowrap;
}

.b-confirmed  { color: var(--confirmed);  background: var(--confirmed-bg); }
.b-likely     { color: var(--likely);     background: var(--likely-bg); }
.b-unverified { color: var(--unverified); background: var(--unverified-bg); }

.b-yes  { color: var(--confirmed);  background: var(--confirmed-bg); }
.b-part { color: var(--likely);     background: var(--likely-bg); }
.b-no   { color: var(--none-fg);    background: var(--none-bg); }

/* --- Callouts ------------------------------------------------------------ */

.callout {
  border-left: 3px solid var(--purple);
  background: var(--surface-alt);
  padding: var(--s-md) var(--s-lg);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  margin: var(--s-lg) 0;
}

.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.callout.warn   { border-left-color: var(--caution);   background: var(--likely-bg); }
.callout.danger { border-left-color: var(--untrusted); background: var(--unverified-bg); }
.callout.good   { border-left-color: var(--trusted);   background: var(--confirmed-bg); }

.callout-title {
  font-weight: 700;
  font-size: var(--f-md);
  margin-bottom: var(--s-xs);
  display: block;
}

/* --- Cards / stat grid --------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--s-md);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: var(--s-lg) 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-md);
  background: var(--surface-alt);
}

.card h4 { margin: 0 0 var(--s-xs); }
.card p { margin: 0; font-size: var(--f-md); color: var(--muted); }

.stat { font-size: var(--f-xxxl); font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; }
.stat-label { font-size: var(--f-sm); color: var(--muted); }

/* --- Diagrams ------------------------------------------------------------ */

.diagram {
  margin: var(--s-lg) 0;
  padding: var(--s-md);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  overflow-x: auto;
}

.diagram svg { display: block; min-width: 520px; width: 100%; height: auto; }

.diagram figcaption {
  font-size: var(--f-sm);
  color: var(--muted);
  margin-top: var(--s-sm);
  padding-top: var(--s-sm);
  border-top: 1px solid var(--line);
}

/* --- Footer -------------------------------------------------------------- */

.page-foot {
  margin-top: var(--s-xxl);
  padding-top: var(--s-lg);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: var(--s-md);
  flex-wrap: wrap;
  font-size: var(--f-md);
}

.page-foot a { text-decoration: none; font-weight: 600; }

/* --- Mobile -------------------------------------------------------------- */

.menu-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  padding: 10px 9px;
  flex-direction: column;
  justify-content: space-between;
}

.menu-btn span { display: block; height: 3px; border-radius: 2px; background: var(--grad-menu); }

@media (max-width: 860px) {
  .menu-btn { display: flex; }

  .sidebar {
    position: fixed;
    z-index: 55;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }

  .shell.nav-open .sidebar { transform: translateX(0); }

  .main { padding: 64px var(--s-md) 80px; }

  h1 { font-size: var(--f-xxl); }
  h2 { font-size: var(--f-xl); }

  body { font-size: var(--f-md); }
}

@media print {
  .sidebar, .menu-btn, #gate { display: none !important; }
  .main { padding: 0; }
  .table-wrap { overflow: visible; }
}
