/* ==========================================================================
   Digital Specialist — Shared Stylesheet
   M3 Blue Theme · Light + Dark (follows the device setting)
   Used by every page under /static: guides, consent, privacy, deletion.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Variables — Color, Typography & Layout Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Both schemes declared, so Chrome's auto-dark doesn't repaint the page. */
  color-scheme: light dark;

  /* Primary */
  --md-primary: #1565C0;
  --md-primary-container: #D4E3FF;
  --md-on-primary-container: #001C3A;

  /* Surface */
  --md-surface: #FFFFFF;
  --md-on-surface: #1B1B1F;
  --md-on-surface-variant: #44474E;
  --md-surface-container-low: #F3F3F6;
  --md-surface-container: #EEEEF1;
  --md-surface-container-high: #E8E8EB;

  /* Outline */
  --md-outline-variant: #C4C6CF;

  /* Callouts — accent is the left border; bg/fg paint the box */
  --md-tip: #006D3B;
  --md-tip-bg: #D4F5DF;
  --md-tip-fg: #00210E;
  --md-warning: #7D5800;
  --md-warning-bg: #FFDEA6;
  --md-warning-fg: #281900;

  /* Typography */
  --md-font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --md-font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Layout — ~80 characters a line (860px gave ~100); rem keeps it when the
     reader enlarges the font. */
  --md-content-max-width: 42.5rem;
  --md-content-padding: 24px;
  --md-border-radius-sm: 8px;
  --md-border-radius-md: 12px;
}

/* Screen only: a dark background must never reach the printer. */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --md-primary: #A8C8FF;
    --md-primary-container: #1B2D4A;
    --md-on-primary-container: #D4E3FF;

    --md-surface: #121316;
    --md-on-surface: #E3E2E6;
    --md-on-surface-variant: #C4C6CF;
    --md-surface-container-low: #1A1B1F;
    --md-surface-container: #1F2024;
    --md-surface-container-high: #292A2E;

    --md-outline-variant: #44474E;

    --md-tip: #7DDA9B;
    --md-tip-bg: #12301F;
    --md-tip-fg: #C9F2D6;
    --md-warning: #F8BD49;
    --md-warning-bg: #372A08;
    --md-warning-fg: #FFDEA6;
  }
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* rem throughout: respects the reader's browser font size. */
body {
  font-family: var(--md-font-family);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  margin: 0;
  padding: 0;
  background-color: var(--md-surface);
  color: var(--md-on-surface);
  /* Long e-mails and URLs wrap instead of widening the page. */
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Underlined: the blue alone is under 3:1 against body text (WCAG 1.4.1).
   Navigation links opt out (section 9). */
a {
  color: var(--md-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* A paragraph whose whole content is one link is a standalone control, not a link
   inside a sentence, so WCAG 2.5.5's "inline" exception does not cover it.
   inline-flex + min-height enlarges the tap target only; the painted text is
   unchanged. Covers .breadcrumb, .back-to-top and the bare CTA links in the guides. */
p > a:only-child {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  min-height: 44px;
}

/* Anchor jumps from the app (UserGuide.html#inventory) keep a gap above. */
[id] {
  scroll-margin-top: 16px;
}

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
  color: var(--md-on-surface);
  text-wrap: balance;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.75em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--md-outline-variant);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--md-on-surface-variant);
}

p {
  margin: 0 0 1em;
}

p, li {
  text-wrap: pretty;
}

ul, ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.35em;
}

li > ul, li > ol {
  margin-top: 0.35em;
  margin-bottom: 0;
}

strong {
  font-weight: 600;
}

.subtitle {
  font-size: 1.0625rem;
  color: var(--md-on-surface-variant);
  margin-top: -0.25em;
  margin-bottom: 1.5em;
}

/* Small print on the legal pages ("Last updated …"). */
.doc-meta {
  font-size: 0.875rem;
  color: var(--md-on-surface-variant);
}

/* --------------------------------------------------------------------------
   4. Layout
   -------------------------------------------------------------------------- */

.page-container {
  max-width: var(--md-content-max-width);
  margin: 0 auto;
  padding: var(--md-content-padding);
}

.page-header {
  margin-bottom: 2em;
}

.page-header h1 {
  margin-bottom: 0.15em;
}

/* --------------------------------------------------------------------------
   5. Table of Contents
   -------------------------------------------------------------------------- */

.toc {
  background-color: var(--md-primary-container);
  border-radius: var(--md-border-radius-md);
  padding: 20px 24px;
  margin-bottom: 2.5em;
}

.toc-category {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--md-on-primary-container);
  margin: 1em 0 0.35em;
}

.toc-category:first-child {
  margin-top: 0;
}

/* Columns: as one list, 28 entries filled two phone screens. */
.toc-links {
  list-style: none;
  padding-left: 0;
  margin: 0 0 0.25em;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr));
  /* 8px between adjacent tap targets (WCAG 2.5.8 spacing) */
  gap: 8px 16px;
}

.toc-links li {
  margin: 0;
}

.toc-links a {
  color: var(--md-on-primary-container);
  font-size: 0.9375rem;
  line-height: 1.35;
  /* Enlarges the tap target only (28px; 44px on touch, below). min-width
     covers short entries ("Chat", "Map"). */
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  min-width: 44px;
}

/* --------------------------------------------------------------------------
   6. Tables
   -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0 1.5em;
  font-size: 0.9375rem;
}

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

th {
  background-color: var(--md-surface-container-high);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background-color: var(--md-surface-container-low);
}

tr:last-child td {
  border-bottom: none;
}

/* Frame + horizontal scroll on narrow screens; every table sits in one. */
.table-wrapper {
  overflow-x: auto;
  margin: 1.25em 0 1.5em;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-border-radius-sm);
}

.table-wrapper table {
  margin: 0;
}

/* --------------------------------------------------------------------------
   7. Code Blocks
   -------------------------------------------------------------------------- */

code {
  font-family: var(--md-font-mono);
  font-size: 0.875em;
  background-color: var(--md-surface-container);
  color: var(--md-primary);
  padding: 2px 6px;
  border-radius: 4px;
}

pre {
  font-family: var(--md-font-mono);
  font-size: 0.875rem;
  background-color: var(--md-surface-container);
  color: var(--md-on-surface);
  padding: 16px 20px;
  border-radius: var(--md-border-radius-sm);
  overflow-x: auto;
  overflow-wrap: normal;
  line-height: 1.5;
  margin: 1em 0 1.5em;
  border: 1px solid var(--md-outline-variant);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.code-block {
  display: block;
  white-space: pre;
}

/* --------------------------------------------------------------------------
   8. Callout Boxes
   -------------------------------------------------------------------------- */

.callout {
  padding: 14px 18px;
  border-radius: var(--md-border-radius-sm);
  border-left: 4px solid;
  margin: 1.25em 0;
  font-size: 0.9375rem;
  line-height: 1.6;
}

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

/* Primary blue is under 4.5:1 on tinted fills; the underline marks links. */
.callout a {
  color: inherit;
}

/* Tip — green */
.callout-tip {
  border-left-color: var(--md-tip);
  background-color: var(--md-tip-bg);
  color: var(--md-tip-fg);
}

/* Warning — amber */
.callout-warning {
  border-left-color: var(--md-warning);
  background-color: var(--md-warning-bg);
  color: var(--md-warning-fg);
}

/* Note — blue */
.callout-note {
  border-left-color: var(--md-primary);
  background-color: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

/* --------------------------------------------------------------------------
   9. Navigation
   -------------------------------------------------------------------------- */

.toc a,
.back-to-top a,
.breadcrumb a,
.page-nav a {
  text-decoration: none;
}

.toc a:hover,
.back-to-top a:hover,
.breadcrumb a:hover,
.page-nav a:hover {
  text-decoration: underline;
}

.back-to-top {
  text-align: right;
  margin: 1.5em 0 0.5em;
  font-size: 0.875rem;
}

.back-to-top a {
  color: var(--md-on-surface-variant);
}

.back-to-top a:hover {
  color: var(--md-primary);
}

.breadcrumb {
  font-size: 0.875rem;
  margin-bottom: 1.5em;
  color: var(--md-on-surface-variant);
}

.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5em;
  margin-top: 2em;
  border-top: 1px solid var(--md-outline-variant);
  font-size: 0.9375rem;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* --------------------------------------------------------------------------
   10. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .page-container {
    padding: 16px;
  }

  h1 {
    font-size: 1.625rem;
  }

  h2 {
    font-size: 1.3125rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  .toc {
    padding: 16px 18px;
  }

  th, td {
    padding: 8px 10px;
    font-size: 0.875rem;
  }
}

/* Full 44px tap targets wherever a finger is used: narrow widths, and any
   coarse pointer (a 1024px tablet needs the same rows a 375px phone does). */
@media (max-width: 768px), (pointer: coarse) {
  .toc-links a {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .page-container {
    padding: 12px;
  }

  h1 {
    font-size: 1.4375rem;
  }

  h2 {
    font-size: 1.1875rem;
  }

  /* Two columns still fit a 360px phone. */
  .toc {
    padding: 14px;
  }

  .toc-links {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr));
    gap: 0 12px;
  }

  pre {
    padding: 12px 14px;
    font-size: 0.8125rem;
  }

  .callout {
    padding: 12px 14px;
    font-size: 0.875rem;
  }

  .page-nav {
    flex-direction: column;
    gap: 0.75em;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   11. Print — the legal pages get saved as PDF
   -------------------------------------------------------------------------- */

@media print {
  :root {
    color-scheme: light;
  }

  body {
    font-size: 11pt;
    line-height: 1.5;
  }

  .page-container {
    max-width: none;
    padding: 0;
  }

  .toc,
  .back-to-top,
  .breadcrumb,
  .page-nav {
    display: none;
  }

  h2, h3, h4 {
    break-after: avoid;
  }

  pre, tr, .callout {
    break-inside: avoid;
  }

  .table-wrapper {
    overflow: visible;
  }
}
