/* Reinvention CC docs site: First Contact manual.
   Palette and type follow the main UI (web/tailwind.config.js and web/src/index.css):
   navy #1d3557 / #14283f / #0f1f33, page #e9edf2, blue #1d4ed8, focus amber #f59e0b, ink #1f2937, muted #4b5563,
   line #cbd2dc, radius 10 px cards and 6 to 8 px controls. Dark theme uses the navy family from web/src/officer/theme.css.
   No external loads: system fonts only. */

/* ---------- Tokens ---------- */
:root {
  --page: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --text: #1f2937;
  --heading: #14283f;
  --muted: #4b5563;
  --line: #cbd2dc;
  --line-strong: #9aa5b4;
  --navy: #1d3557;
  --navy-deep: #0f1f33;
  --topbar: #1d3557;
  --accent: #1d4ed8;
  --accent-tint: #e6eefc;
  --focus: #f59e0b;
  --mark: rgba(245, 158, 11, 0.38);
  --note-bg: #e6eefc;
  --note-line: #1d4ed8;
  --note-text: #1d3557;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --warn-text: #78350f;
  --tip-bg: #f0fdf4;
  --tip-line: #15803d;
  --tip-text: #14532d;
  --ring: #f59e0b;
  --shadow: 0 2px 10px rgba(15, 31, 51, 0.12);
  --font: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
  --radius-card: 10px;
  --radius-ctl: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0b1828;
    --surface: #14283f;
    --surface-2: #1b3150;
    --text: #e6edf7;
    --heading: #dbe7f5;
    --muted: #b4c3d8;
    --line: #2a4262;
    --line-strong: #41597a;
    --navy: #1d3557;
    --navy-deep: #0f1f33;
    --topbar: #0f1f33;
    --accent: #60a5fa;
    --accent-tint: rgba(96, 165, 250, 0.16);
    --mark: rgba(245, 158, 11, 0.45);
    --note-bg: rgba(96, 165, 250, 0.12);
    --note-line: #60a5fa;
    --note-text: #cfe3ff;
    --warn-bg: rgba(146, 64, 14, 0.35);
    --warn-line: #f59e0b;
    --warn-text: #fde68a;
    --tip-bg: rgba(21, 128, 61, 0.22);
    --tip-line: #4ade80;
    --tip-text: #bbf7d0;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #0b1828;
  --surface: #14283f;
  --surface-2: #1b3150;
  --text: #e6edf7;
  --heading: #dbe7f5;
  --muted: #b4c3d8;
  --line: #2a4262;
  --line-strong: #41597a;
  --navy: #1d3557;
  --navy-deep: #0f1f33;
  --topbar: #0f1f33;
  --accent: #60a5fa;
  --accent-tint: rgba(96, 165, 250, 0.16);
  --mark: rgba(245, 158, 11, 0.45);
  --note-bg: rgba(96, 165, 250, 0.12);
  --note-line: #60a5fa;
  --note-text: #cfe3ff;
  --warn-bg: rgba(146, 64, 14, 0.35);
  --warn-line: #f59e0b;
  --warn-text: #fde68a;
  --tip-bg: rgba(21, 128, 61, 0.22);
  --tip-line: #4ade80;
  --tip-text: #bbf7d0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
}

/* clip (not hidden) so that position: sticky still works for the top bar and the index. */
body { overflow-x: clip; }

[hidden] { display: none !important; }

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

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

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-ctl);
  text-decoration: none;
}
.skip:focus { top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--topbar);
  color: #ffffff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(15, 31, 51, 0.18);
}

.brand {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.15;
  color: #ffffff;
  text-decoration: none;
}
.brand-name {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9fb0cc;
}
.brand-doc {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill-btn {
  flex: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.pill-btn:hover { background: rgba(255, 255, 255, 0.12); }

.menu-btn {
  display: none;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-ctl);
  background: transparent;
  cursor: pointer;
  position: relative;
}
.menu-btn:hover { background: rgba(255, 255, 255, 0.1); }
.menu-btn .bars,
.menu-btn .bars::before,
.menu-btn .bars::after {
  content: "";
  position: absolute;
  left: 11px;
  width: 18px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.menu-btn .bars { top: 19px; }
.menu-btn .bars::before { top: -6px; left: 0; }
.menu-btn .bars::after { top: 6px; left: 0; }
.menu-btn[aria-expanded="true"] .bars { background: transparent; }
.menu-btn[aria-expanded="true"] .bars::before { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .bars::after { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Shell: index + content ---------- */
.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
}

/* Index (sidebar). Desktop: sticky column. Phone: slide-in drawer. */
.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.search { margin-bottom: 12px; }

.search-box input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 10px 12px;
}
.search-box input[type="search"]::placeholder { color: var(--muted); opacity: 0.85; }

.search-hint {
  margin: 6px 2px 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.results { display: flex; flex-direction: column; gap: 8px; }

.result-count {
  margin: 4px 2px 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.result:hover,
.result:focus-visible { border-color: var(--accent); }
.result .r-chap {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.result .r-title {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-top: 2px;
}
.result .r-snip {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

mark {
  background: var(--mark);
  color: inherit;
  border-radius: 3px;
  padding: 0 0.12em;
}

/* Chapter and section index */
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-chapter { margin-bottom: 2px; }

.nav-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-link:hover { background: var(--surface-2); }

.nav-chap {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 10px;
}

.nav-toggle {
  flex: none;
  width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.nav-toggle[aria-expanded="true"]::before { transform: rotate(45deg) translate(-2px, -2px); }

.nav-sub {
  list-style: none;
  margin: 2px 0 10px 12px;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--line);
}
.nav-sub .nav-link {
  font-size: 0.86rem;
  padding: 5px 8px;
  color: var(--muted);
}

.nav-link[aria-current="true"] {
  background: var(--accent-tint);
  color: var(--heading);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-foot {
  margin: 18px 4px 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.scrim { display: none; }

/* ---------- Content ---------- */
.content {
  min-width: 0;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3.2vw, 44px) 80px;
}

.hero {
  margin: 28px 0 8px;
  padding: 36px clamp(20px, 4vw, 40px);
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(160deg, #0f1f33 0%, #1d3557 60%, #1d4ed8 100%);
  box-shadow: var(--shadow);
}
.kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9fb0cc;
}
.hero-title {
  margin: 10px 0 8px;
  font-size: clamp(2.1rem, 6vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 0;
  max-width: 40em;
  font-size: 1.1rem;
  color: #d7e2f2;
}
.hero-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.88rem;
}
.hero-meta div { margin: 0; }
.hero-meta dt {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9fb0cc;
}
.hero-meta dd { margin: 2px 0 0; color: #ffffff; }
.hero-tip {
  margin: 18px 0 0;
  font-size: 0.85rem;
  color: #c7d6ea;
}

.chapter {
  scroll-margin-top: 0;
  padding-top: 8px;
}
.chapter + .chapter {
  margin-top: 56px;
  padding-top: 48px;
  border-top: 1px solid var(--line);
}

.unit {
  scroll-margin-top: 72px;
  margin: 0 0 44px;
  outline: none;
}
.unit:last-child { margin-bottom: 0; }

.chapter-title {
  margin: 0 0 14px;
  font-size: clamp(1.6rem, 4vw, 2.05rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--heading);
}

.unit-title {
  margin: 0 0 12px;
  font-size: 1.22rem;
  line-height: 1.3;
  color: var(--heading);
}

h2, h3 { scroll-margin-top: 72px; }

p { margin: 0 0 14px; }
.lede {
  font-size: 1.08rem;
  color: var(--muted);
  margin-bottom: 22px;
}
.source {
  font-size: 0.86rem;
  color: var(--muted);
}
.cont { font-weight: 400; color: var(--muted); }
.url-note {
  font-size: 0.88rem;
  color: var(--muted);
}

ul { padding-left: 1.3em; margin: 0 0 16px; }
li { margin-bottom: 6px; }

/* Steps: numbered badge beside the text */
.step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  margin: 0 0 26px;
}
.badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #ffffff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  box-shadow: 0 0 0 4px var(--accent-tint);
}
.step > div:last-child { min-width: 0; }

/* Figures and screenshots */
figure {
  margin: 18px 0 22px;
  min-width: 0;
}
figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.shot,
.zoom-frame {
  position: relative;
  max-width: 100%;
}
.shot > img,
.zoom-frame > img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.shot > img:hover,
.zoom-frame > img:hover { border-color: var(--accent); }

.ring {
  position: absolute;
  pointer-events: none;
  border: 2.5px solid var(--ring);
  border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}

.zoom {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 14px 0 24px;
}
.zoom > div:first-child { min-width: 0; }
.zoom > figure { margin: 0; }
.zoom-label {
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.zoom-frame { max-width: 420px; }

/* Callout boxes */
.box {
  margin: 18px 0;
  padding: 14px 16px 14px 18px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  border-left-width: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.97rem;
}
.box .label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.box.note { background: var(--note-bg); border-left-color: var(--note-line); color: var(--note-text); }
.box.note .label { color: var(--note-line); }
.box.warn { background: var(--warn-bg); border-left-color: var(--warn-line); color: var(--warn-text); }
.box.warn .label { color: var(--warn-line); }
.box.tip { background: var(--tip-bg); border-left-color: var(--tip-line); color: var(--tip-text); }
.box.tip .label { color: var(--tip-line); }

/* Tables: scroll inside their own box on a phone, never the page */
.table-wrap {
  margin: 16px 0 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
th {
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--heading);
}
tr:last-child td { border-bottom: 0; }
td.name { font-weight: 600; white-space: nowrap; }
td.url {
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}
tr.self td { background: var(--accent-tint); }
table.opt td:first-child { font-weight: 600; }

/* The flow diagram in chapter 8 */
.diagram {
  margin: 22px 0 26px;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.diagram svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}
.diagram text {
  font-family: var(--font);
  fill: var(--text);
}
.diagram .title { font-size: 15px; font-weight: 700; fill: var(--heading); }
.diagram .small { font-size: 12.5px; fill: var(--muted); }
.diagram .node { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.5; }
.diagram .node.hi { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 2; }
.diagram .node-text { font-size: 15px; font-weight: 700; fill: var(--heading); }
.diagram .hi-text { fill: var(--accent); }
.diagram .arrow { fill: none; stroke: var(--muted); stroke-width: 2; }

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Lightbox ---------- */
.lightbox {
  width: min(96vw, 1180px);
  max-width: 96vw;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 16, 28, 0.8); }
.lightbox[open] { animation: lb-in 0.18s ease-out; }
@keyframes lb-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

.lb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.lb-title {
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-close {
  flex: none;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 6px 12px;
  cursor: pointer;
}
.lb-close:hover { border-color: var(--accent); }
kbd {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
}
.lb-body {
  max-height: calc(94vh - 130px);
  overflow: auto;
  padding: 14px;
  background: var(--surface-2);
}
.lb-frame {
  position: relative;
  width: 100%;
}
.lb-frame > img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: var(--surface);
}
.lb-caption {
  margin: 0;
  padding: 10px 14px 14px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Wide screens: index beside the content ---------- */
@media (min-width: 900px) {
  .scrim { display: none !important; }
}

/* ---------- Phone and small tablet: index becomes a slide-in drawer ---------- */
@media (max-width: 899px) {
  .menu-btn { display: inline-block; }

  .shell { display: block; }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(86vw, 330px);
    height: auto;
    transform: translateX(-104%);
    transition: transform 0.26s ease;
    box-shadow: 0 0 32px rgba(0, 0, 0, 0.35);
    padding: 16px 14px 28px;
  }
  .sidebar.open { transform: none; }

  .scrim {
    display: block;
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    background: rgba(8, 16, 28, 0.5);
    animation: fade-in 0.2s ease;
  }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

  .content { padding: 0 16px 64px; }
  .hero { margin-top: 20px; padding: 26px 20px; }
  .hero-meta { grid-template-columns: 1fr; gap: 10px; }
  .zoom { grid-template-columns: 1fr; }
  .zoom-frame { max-width: 100%; }
  .step { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; }
  .badge { width: 30px; height: 30px; font-size: 0.85rem; box-shadow: none; }

  /* On a phone the screenshots fill the column. Inline widths set for desktop would make them tiny. */
  .shot[style],
  figure .shot img[style] { width: 100% !important; }
  .shot > img[style] { width: 100% !important; }
  .shot[style] { max-width: 100%; }

  /* The URL table has three columns: stack each row so the addresses have room on a phone. */
  table.url-table thead { display: none; }
  table.url-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.url-table tr:last-child { border-bottom: 0; }
  table.url-table td { display: block; border: 0; padding: 2px 0; white-space: normal; }
  table.url-table td.name { white-space: normal; }
  table.url-table td.url { margin-top: 4px; }
  table.url-table tr.self { background: var(--accent-tint); }
  table.url-table tr.self td { background: transparent; }

  .lightbox { width: 96vw; }
  .lb-body { max-height: calc(94vh - 120px); }
  .topbar { padding: 0 10px 0 8px; }
}

@media (max-width: 380px) {
  .hero-title { font-size: 2rem; }
  .pill-btn { padding: 6px 10px; }
}

/* ---------- Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
