/* ==========================================================================
   QR & Barcode Scanner - site stylesheet
   Palette derived from the app icon (deep navy -> teal).
   Light and dark themes, responsive, print-friendly, reduced-motion aware.
   ========================================================================== */

:root {
  /* Brand */
  --navy: #0a1f44;
  --navy-deep: #061530;
  --teal: #12d6c4;
  --teal-dark: #00a896;
  --teal-light: #6ff6f6;

  /* Semantic surfaces */
  --bg: #ffffff;
  --bg-alt: #f5f7fb;
  --surface: #ffffff;
  --text: #171a21;
  --text-muted: #555c6d;
  --border: #e0e4ee;
  --border-strong: #c9d0e0;

  /* Status */
  --ok-bg: #e6f7f0;
  --ok-border: #17a06b;
  --ok-text: #0b5c3f;
  --warn-bg: #fff5e6;
  --warn-border: #e89021;
  --warn-text: #7a4b05;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Metrics */
  --maxw: 860px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(10, 31, 68, .06), 0 8px 24px rgba(10, 31, 68, .07);
  --shadow-lg: 0 2px 4px rgba(10, 31, 68, .08), 0 18px 48px rgba(10, 31, 68, .12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08172f;
    --bg-alt: #0d2244;
    --surface: #102a52;
    --text: #e9edf7;
    --text-muted: #a7b2ca;
    --border: #1e3a68;
    --border-strong: #2c4d81;

    --ok-bg: #10301f;
    --ok-border: #2f9c6b;
    --ok-text: #8fe6bb;
    --warn-bg: #33240e;
    --warn-border: #c98724;
    --warn-text: #f3c68a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .45);
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { a { color: var(--teal); } }

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

/* ---------- Skip link (accessibility) ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

main { padding: 44px 0 72px; }

/* ---------- Masthead ---------- */
.masthead {
  background: linear-gradient(135deg, var(--navy) 0%, #0a3468 55%, var(--teal-dark) 100%);
  color: #fff;
  padding: 54px 0 50px;
  position: relative;
  overflow: hidden;
}
.masthead::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(18, 214, 196, .30), transparent 68%);
  pointer-events: none;
}
.masthead .wrap { position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 26px;
}
.brand img {
  width: 60px;
  height: 60px;
  border-radius: 15px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .22);
  padding: 5px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 1.06rem; letter-spacing: -.01em; }
.brand-sub { font-size: .82rem; opacity: .82; display: block; margin-top: 1px; }

.masthead h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 5.2vw, 2.65rem);
  line-height: 1.18;
  letter-spacing: -.022em;
}
.masthead .tagline {
  margin: 0;
  font-size: clamp(1rem, 2.6vw, 1.16rem);
  opacity: .95;
  max-width: 60ch;
}

/* ---------- Doc header (policy pages) ---------- */
.dochero { padding: 42px 0 30px; border-bottom: 1px solid var(--border); }
.dochero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 4.4vw, 2.2rem);
  letter-spacing: -.02em;
}
.dochero .meta {
  margin: 0;
  color: var(--text-muted);
  font-size: .95rem;
}
.dochero .appid {
  font-family: var(--mono);
  font-size: .88rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
}

/* ---------- Typography ---------- */
h2 {
  font-size: 1.3rem;
  margin: 42px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--teal);
  letter-spacing: -.012em;
}
h3 { font-size: 1.06rem; margin: 26px 0 8px; }

p { margin: 0 0 15px; }
ul, ol { margin: 0 0 15px; padding-left: 24px; }
li { margin-bottom: 7px; }

strong { font-weight: 650; }

code {
  font-family: var(--mono);
  font-size: .87em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  word-break: break-word;
}

/* ---------- Callouts ---------- */
.callout {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 20px 0;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.callout:last-child { margin-bottom: 0; }
.callout p:last-child { margin-bottom: 0; }

.callout.draft {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-width: 4px;
  color: var(--warn-text);
}
.callout.draft b { display: block; margin-bottom: 6px; }

.callout.key {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  border-left-width: 4px;
  color: var(--ok-text);
}

.callout.caution {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  border-left-width: 4px;
  color: var(--warn-text);
}

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; }
th {
  background: var(--bg-alt);
  font-weight: 650;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
tbody tr + tr td { border-top: 1px solid var(--border); }

/* ---------- Cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.card p { margin: 0; color: var(--text-muted); font-size: .95rem; }
.card ul { margin: 10px 0 0; padding-left: 20px; font-size: .95rem; }
.card-icon {
  display: inline-block;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  margin-bottom: 12px;
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  border: 1.5px solid transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--teal-dark); color: #fff; }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
@media (prefers-color-scheme: dark) { .btn-secondary { color: var(--text); } }

/* ---------- Contents list ---------- */
.toc {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin: 24px 0 8px;
}
.toc h2 { margin: 0 0 10px; border: 0; padding: 0; font-size: .82rem; text-transform: uppercase;
           letter-spacing: .09em; color: var(--text-muted); }
.toc ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 30px; }
.toc li { margin-bottom: 5px; break-inside: avoid; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--teal-dark); }

/* ---------- Placeholder marker ---------- */
.ph {
  background: var(--warn-bg);
  border-bottom: 1.5px dashed var(--warn-border);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--warn-text);
  font-weight: 600;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 30px 0;
  font-size: .9rem;
  color: var(--text-muted);
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: center;
                     justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 20px; }
.site-footer p { margin: 0; }

/* ---------- Motion / print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .btn:hover { transform: none; }
}

@media print {
  .masthead { background: none; color: #000; padding: 0 0 18px; }
  .masthead::after, .actions, .site-footer nav, .skip-link { display: none; }
  body { font-size: 11pt; }
  h2 { break-after: avoid; }
  .card, .toc, .table-scroll { box-shadow: none; border: 1px solid #ccc; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}