/* flopshop design tokens: the ONE place colours, type, spacing and radius are defined.
   Consumers: the public site (served as the head of /site.css) and the portal SPA (the Dockerfile
   copies this file to frontend/src/tokens.css; theme.ts maps the Mantine theme onto it).
   Never write a hex value anywhere else. See frontend/DESIGN.md.

   Light and dark come from light-dark(): it follows `color-scheme`, which is the OS preference
   here and Mantine's toggle in the portal (Mantine sets color-scheme on :root). */

:root {
  color-scheme: light dark;

  /* Neutrals for light surfaces: 0 lightest, 9 text. */
  --fs-white: #ffffff;
  --fs-gray-0: #f7f8fa;
  --fs-gray-1: #f0f2f5;
  --fs-gray-2: #e6e9ed;
  --fs-gray-3: #dadee4;
  --fs-gray-4: #c9ced6;
  --fs-gray-5: #a3abb6;
  --fs-gray-6: #5d6673;
  --fs-gray-7: #454c57;
  --fs-gray-8: #2d333b;
  --fs-gray-9: #181b20;

  /* Neutrals for dark surfaces: 0 text, 7 page background, 9 darkest. */
  --fs-dark-0: #e3e6eb;
  --fs-dark-1: #c3c8d0;
  --fs-dark-2: #9ba3af;
  --fs-dark-3: #6d7582;
  --fs-dark-4: #333944;
  --fs-dark-5: #262b33;
  --fs-dark-6: #1b1f26;
  --fs-dark-7: #111418;
  --fs-dark-8: #0c0e11;
  --fs-dark-9: #08090b;

  /* The one accent. 8 is the solid (white text on it), 9 its hover, 4 is accent text on dark. */
  --fs-accent-0: #f0f2ff;
  --fs-accent-1: #e0e5ff;
  --fs-accent-2: #c2cbfb;
  --fs-accent-3: #a3b0f7;
  --fs-accent-4: #8a99f3;
  --fs-accent-5: #7384ee;
  --fs-accent-6: #5f70e6;
  --fs-accent-7: #5062dd;
  --fs-accent-8: #3f4fcf;
  --fs-accent-9: #3441b0;

  /* Semantic colours: use these, not the ramps. */
  --fs-bg: light-dark(var(--fs-white), var(--fs-dark-7));
  --fs-surface: light-dark(var(--fs-gray-0), var(--fs-dark-6));
  --fs-surface-hover: light-dark(var(--fs-gray-1), var(--fs-dark-5));
  --fs-fg: light-dark(var(--fs-gray-9), var(--fs-dark-0));
  --fs-muted: light-dark(var(--fs-gray-6), var(--fs-dark-2));
  --fs-line: light-dark(var(--fs-gray-3), var(--fs-dark-4));
  --fs-accent: light-dark(var(--fs-accent-8), var(--fs-accent-4));
  --fs-accent-solid: var(--fs-accent-8);
  --fs-accent-solid-hover: var(--fs-accent-9);
  --fs-on-accent: var(--fs-white);

  /* Type: system stacks only, nothing is downloaded. */
  --fs-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-text-xs: 0.75rem;
  --fs-text-sm: 0.8125rem;
  --fs-text-md: 0.9375rem;
  --fs-text-lg: 1.0625rem;
  --fs-text-xl: 1.25rem;
  --fs-text-h1: 1.75rem;
  --fs-text-h2: 1.3125rem;
  --fs-text-h3: 1.0625rem;
  --fs-text-h4: 0.9375rem;
  --fs-leading: 1.55;
  --fs-leading-tight: 1.25;
  --fs-weight-strong: 600;
  /* The wordmark: lowercase "flopshop" set in the mono stack. */
  --fs-wordmark-font: 600 1.0625rem/1 var(--fs-font-mono);
  --fs-wordmark-tracking: -0.03em;

  /* Spacing. */
  --fs-space-xs: 0.5rem;
  --fs-space-sm: 0.75rem;
  --fs-space-md: 1rem;
  --fs-space-lg: 1.5rem;
  --fs-space-xl: 2.5rem;

  /* Radius. */
  --fs-radius-sm: 0.25rem;
  --fs-radius-md: 0.375rem;
  --fs-radius-lg: 0.5rem;

  /* Layout shared by the portal shell and the public site. */
  --fs-header-height: 3.25rem;
  --fs-content-width: 60rem;
  --fs-prose-width: 46rem;
}

/* The public site skin. Served after tokens.css in one response (/site.css), so every colour,
   size and radius here is a --fs-* token: no literals. Same header, wordmark and footer feel as
   the portal shell (frontend/src/shell.tsx). No JS, no fonts or assets from elsewhere. */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--fs-bg);
  color: var(--fs-fg);
  font: var(--fs-text-md) / var(--fs-leading) var(--fs-font-sans);
  overflow-wrap: break-word;
}

a {
  color: var(--fs-accent);
  text-underline-offset: 0.15em;
}

a:focus-visible {
  outline: 2px solid var(--fs-accent);
  outline-offset: 2px;
  border-radius: var(--fs-radius-sm);
}

/* Header: wordmark left, nav right; full-width rule, content on the same column as the page. */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--fs-space-md);
  min-height: var(--fs-header-height);
  padding: 0 max(var(--fs-space-md), calc((100% - var(--fs-prose-width)) / 2));
  border-bottom: 1px solid var(--fs-line);
}

header .brand {
  font: var(--fs-wordmark-font);
  letter-spacing: var(--fs-wordmark-tracking);
  text-transform: lowercase;
  text-decoration: none;
  color: var(--fs-fg);
}

header nav {
  display: flex;
  align-items: center;
  gap: var(--fs-space-xs);
  min-height: var(--fs-header-height);
}

header nav a {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 var(--fs-space-xs);
  border-block: 2px solid transparent;
  color: var(--fs-muted);
  font-size: var(--fs-text-sm);
  text-decoration: none;
}

header nav a:hover {
  color: var(--fs-fg);
}

header nav a[aria-current="page"] {
  border-bottom-color: var(--fs-accent-solid);
  color: var(--fs-fg);
  font-weight: var(--fs-weight-strong);
}

/* Sign in, the last nav item: the portal's default button. */
header nav a:last-child {
  align-self: center;
  margin-left: var(--fs-space-xs);
  padding: 0.3rem var(--fs-space-sm);
  border: 1px solid var(--fs-line);
  border-radius: var(--fs-radius-md);
  color: var(--fs-fg);
}

header nav a:last-child:hover {
  background: var(--fs-surface-hover);
}

main,
footer {
  max-width: calc(var(--fs-prose-width) + 2 * var(--fs-space-md));
  margin: 0 auto;
  padding: var(--fs-space-md);
}

h1,
h2,
h3 {
  line-height: var(--fs-leading-tight);
  font-weight: var(--fs-weight-strong);
}

h1 {
  font-size: var(--fs-text-h1);
  letter-spacing: -0.01em;
  margin: var(--fs-space-lg) 0 var(--fs-space-md);
}

h2 {
  font-size: var(--fs-text-h2);
  margin: var(--fs-space-xl) 0 var(--fs-space-xs);
}

h3 {
  font-size: var(--fs-text-h3);
  margin: var(--fs-space-lg) 0 var(--fs-space-xs);
}

p,
ul,
ol {
  margin: 0 0 var(--fs-space-md);
}

ul,
ol {
  padding-left: 1.25rem;
}

li + li {
  margin-top: var(--fs-space-xs);
}

/* The lead under the hero. */
main > h1 + p {
  color: var(--fs-muted);
  font-size: var(--fs-text-lg);
}

/* The two calls to action under the hero: the last paragraph before the first h2. */
main > h1 + p + p a {
  display: inline-block;
  margin: 0 var(--fs-space-xs) var(--fs-space-xs) 0;
  padding: 0.45rem var(--fs-space-md);
  border: 1px solid var(--fs-line);
  border-radius: var(--fs-radius-md);
  color: var(--fs-fg);
  font-size: var(--fs-text-sm);
  font-weight: var(--fs-weight-strong);
  text-decoration: none;
}

main > h1 + p + p a:hover {
  background: var(--fs-surface-hover);
}

main > h1 + p + p a:first-child {
  border-color: var(--fs-accent-solid);
  background: var(--fs-accent-solid);
  color: var(--fs-on-accent);
}

main > h1 + p + p a:first-child:hover {
  border-color: var(--fs-accent-solid-hover);
  background: var(--fs-accent-solid-hover);
}

code,
pre {
  font-family: var(--fs-font-mono);
  font-size: var(--fs-text-sm);
}

code {
  padding: 0.1em 0.3em;
  border-radius: var(--fs-radius-sm);
  background: var(--fs-surface-hover);
  overflow-wrap: anywhere;
}

pre {
  overflow-x: auto;
  margin: 0 0 var(--fs-space-md);
  padding: var(--fs-space-sm) var(--fs-space-md);
  border: 1px solid var(--fs-line);
  border-radius: var(--fs-radius-md);
  background: var(--fs-surface);
}

pre code {
  padding: 0;
  background: none;
  overflow-wrap: normal;
}

/* A wide table scrolls inside itself, never the page. */
table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-text-sm);
}

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

thead th {
  color: var(--fs-muted);
  font-weight: var(--fs-weight-strong);
  white-space: nowrap;
}

/* Cells keep a readable measure; on a phone the table scrolls instead of crushing them. */
td code {
  overflow-wrap: normal;
  white-space: nowrap;
}

td:last-child {
  min-width: 14rem;
}

td.num {
  font-family: var(--fs-font-mono);
  text-align: right;
  white-space: nowrap;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--fs-space-xs) var(--fs-space-md);
  margin-top: var(--fs-space-xl);
  padding-top: var(--fs-space-md);
  padding-bottom: var(--fs-space-lg);
  border-top: 1px solid var(--fs-line);
  color: var(--fs-muted);
  font-size: var(--fs-text-sm);
}

footer p {
  margin: 0;
}

footer a {
  margin-right: var(--fs-space-md);
  color: var(--fs-muted);
}

footer a:hover {
  color: var(--fs-fg);
}

footer p:last-child a:last-child {
  margin-right: 0;
}

.notice {
  margin: var(--fs-space-md) 0 0;
  padding: var(--fs-space-sm) var(--fs-space-md);
  border: 1px solid var(--fs-line);
  border-radius: var(--fs-radius-md);
  background: var(--fs-surface);
}
