/* Cloudflare FinServ Strategy Intern Dossier — styles */

:root {
  --cf-orange: #f38020;
  --cf-orange-dark: #c46414;
  --cf-orange-light: #ffeada;
  --ink: #0c1b2b;
  --ink-soft: #2b3a4a;
  --muted: #5b6b7c;
  --rule: #e5e7eb;
  --bg: #fafaf7;
  --card: #ffffff;
  --card-tint: #fbf9f5;
  --good: #1f7a3a;
  --warn: #c46414;
  --danger: #b3261e;
  --serif: ui-serif, "Iowan Old Style", "Charter", Georgia, Cambria, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(12, 27, 43, .06), 0 1px 1px rgba(12, 27, 43, .04);
  --shadow-md: 0 4px 14px rgba(12, 27, 43, .08), 0 2px 4px rgba(12, 27, 43, .04);
  --max-content: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1f4f8;
    --ink-soft: #d5dde6;
    --muted: #94a3b3;
    --rule: #1f2a37;
    --bg: #0b121a;
    --card: #131c27;
    --card-tint: #182230;
    --cf-orange-light: #2a1a0d;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 6px 18px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

/* Reading progress bar — width driven by JS via --progress */
#progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 200;
  pointer-events: none;
}
#progress::after {
  content: "";
  display: block;
  height: 100%;
  width: calc(var(--progress, 0) * 100%);
  background: linear-gradient(90deg, var(--cf-orange), #ff9c4a);
  transition: width .08s linear;
}

/* Mobile hamburger button — visible only ≤900px */
#nav-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 110;
  width: 44px;
  height: 44px;
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
}
#nav-toggle span,
#nav-toggle span::before,
#nav-toggle span::after {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  position: relative;
  transition: transform .2s, opacity .2s;
}
#nav-toggle span::before,
#nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}
#nav-toggle span::before { top: -6px; }
#nav-toggle span::after { top: 6px; }
body.nav-open #nav-toggle span { background: transparent; }
body.nav-open #nav-toggle span::before { transform: translateY(6px) rotate(45deg); }
body.nav-open #nav-toggle span::after { transform: translateY(-6px) rotate(-45deg); }

#nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 27, 43, .45);
  z-index: 99;
  opacity: 0;
  transition: opacity .2s;
}
body.nav-open #nav-backdrop { display: block; opacity: 1; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 64px 18px 80px; }
}
@media (max-width: 480px) {
  .layout { padding: 64px 14px 80px; }
}

/* ---------- Sticky Nav ---------- */
.sidenav {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  font-size: 14px;
  padding-right: 8px;
}
.sidenav .brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -.01em;
}
.sidenav .brand .accent { color: var(--cf-orange); }
.sidenav .subbrand {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.sidenav ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: section;
}
.sidenav li { margin: 4px 0; }
.sidenav a {
  display: block;
  padding: 6px 10px 6px 28px;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: 6px;
  position: relative;
  border-left: 2px solid transparent;
  margin-left: 4px;
  transition: background-color .15s, color .15s, border-color .15s;
}
.sidenav a::before {
  counter-increment: section;
  content: counter(section, decimal-leading-zero);
  position: absolute;
  left: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.sidenav a:hover { background: var(--card-tint); color: var(--ink); }
.sidenav a.active {
  color: var(--cf-orange-dark);
  background: var(--cf-orange-light);
  border-left-color: var(--cf-orange);
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .sidenav a.active { color: #ffb070; }
}
@media (max-width: 900px) {
  #nav-toggle { display: flex; }
  body { padding-top: 0; }
  .sidenav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    max-height: 100vh;
    margin: 0;
    padding: 64px 20px 20px;
    background: var(--bg);
    border-right: 1px solid var(--rule);
    box-shadow: 4px 0 20px rgba(12, 27, 43, .12);
    transform: translateX(-105%);
    transition: transform .25s ease-out;
    z-index: 100;
    overflow-y: auto;
  }
  body.nav-open .sidenav { transform: translateX(0); }
  .sidenav .brand { font-size: 18px; }
  .sidenav a {
    padding: 10px 12px 10px 32px;
    min-height: 44px;
    font-size: 15px;
    display: flex;
    align-items: center;
  }
  .sidenav a::before { top: 50%; transform: translateY(-50%); left: 10px; }
}

/* ---------- Content ---------- */
main { max-width: var(--max-content); }
section { padding: 28px 0 12px; scroll-margin-top: 16px; }
section + section { border-top: 1px solid var(--rule); }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--ink);
  line-height: 1.2;
}
h1 { font-size: clamp(28px, 5vw + 1rem, 42px); margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: clamp(22px, 3vw + 1rem, 30px); margin: 4px 0 12px; }
h3 { font-size: clamp(19px, 2vw + .8rem, 22px); margin: 28px 0 8px; }
h4 { font-size: 17px; margin: 18px 0 4px; font-family: var(--sans); letter-spacing: 0; }
p { margin: 10px 0; }
a { color: var(--cf-orange-dark); }
a:hover { color: var(--cf-orange); }
@media (prefers-color-scheme: dark) {
  a { color: #ffb070; }
  a:hover { color: #ffc999; }
}
strong { color: var(--ink); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 700;
  color: var(--cf-orange);
  margin-bottom: 8px;
}

ul, ol { padding-left: 22px; margin: 8px 0; }
li { margin: 4px 0; }
li > strong:first-child { color: var(--ink); }

blockquote {
  border-left: 3px solid var(--cf-orange);
  margin: 16px 0;
  padding: 4px 0 4px 16px;
  font-style: italic;
  color: var(--ink-soft);
}

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--card-tint);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--rule);
}

/* ---------- Cover ---------- */
.cover {
  padding-top: 8px;
}
.cover .meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}
.cover .meta span strong { color: var(--ink); }
.cover .tldr {
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--cf-orange);
  padding: 18px 22px;
  border-radius: 8px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}
.cover .tldr h3 { margin-top: 0; }
.cover .tldr ol { padding-left: 22px; }
.cover .tldr li { margin: 8px 0; }

/* ---------- Cards / boxes ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 18px 22px;
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
}
.card.tint { background: var(--card-tint); }
.callout {
  background: var(--cf-orange-light);
  border-left: 3px solid var(--cf-orange);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 14px 0;
  font-size: 15px;
}
.callout strong { color: var(--cf-orange-dark); }
.warn-box {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warn);
  background: var(--card-tint);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 14px 0;
  font-size: 14.5px;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 16px -4px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
th, td {
  text-align: left;
  padding: 10px 14px;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
th {
  background: var(--card-tint);
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tr:last-child td { border-bottom: 0; }

/* ---------- Product cards (the most-repeated component) ---------- */
.product {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
}
.product h4 {
  margin: 0 0 6px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 0;
}
.product .product-tag {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--cf-orange-light);
  color: var(--cf-orange-dark);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: 700;
}
.product dl {
  margin: 6px 0 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 4px 14px;
  font-size: 14.5px;
}
.product dt {
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  padding-top: 2px;
}
.product dd { margin: 0; }
.product.featured {
  border-left: 3px solid var(--cf-orange);
}
@media (max-width: 600px) {
  .product dl { grid-template-columns: 1fr; }
  .product dt { padding-top: 8px; }
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  margin: 14px 0;
  padding-left: 22px;
  border-left: 2px solid var(--rule);
}
.timeline .event {
  position: relative;
  padding: 6px 0 14px 16px;
}
.timeline .event::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 14px;
  width: 10px;
  height: 10px;
  background: var(--cf-orange);
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.timeline .event .date {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--cf-orange-dark);
  font-size: 13px;
  letter-spacing: .02em;
}
@media (prefers-color-scheme: dark) {
  .timeline .event .date { color: #ffb070; }
}
.timeline .event .title {
  font-weight: 600;
  color: var(--ink);
  margin: 2px 0;
}
.timeline .event .body { color: var(--ink-soft); font-size: 14.5px; }

/* ---------- Leader cards ---------- */
.leaders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.leader {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.leader.flagged {
  border-left: 3px solid var(--cf-orange);
  background: var(--cf-orange-light);
}
@media (prefers-color-scheme: dark) {
  .leader.flagged { background: #2a1a0d; }
}
.leader .name {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 2px;
}
.leader .role {
  font-size: 13px;
  color: var(--cf-orange-dark);
  font-weight: 600;
  margin-bottom: 8px;
}
.leader .bio { font-size: 14px; color: var(--ink-soft); }

/* ---------- Week-by-week plan ---------- */
.weeks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0;
}
.week {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
}
.week .label {
  font-weight: 700;
  color: var(--cf-orange-dark);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) {
  .week .label { color: #ffb070; }
}
.week .label .dates { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.week .body { font-size: 14.5px; color: var(--ink-soft); }
.week .body strong { color: var(--ink); }

/* ---------- Glossary ---------- */
.glossary { columns: 2; column-gap: 32px; }
.glossary dt { font-weight: 700; color: var(--ink); margin-top: 8px; }
.glossary dd { margin: 0 0 8px; color: var(--ink-soft); font-size: 14.5px; break-inside: avoid; }
@media (max-width: 700px) { .glossary { columns: 1; } }

/* ---------- Chat widget ---------- */
#chat-launcher {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  right: calc(22px + env(safe-area-inset-right, 0px));
  background: var(--cf-orange);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 44px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: flex;
  gap: 8px;
  align-items: center;
}
#chat-launcher:hover { background: var(--cf-orange-dark); }
#chat-launcher .dot {
  width: 8px; height: 8px;
  background: white;
  border-radius: 50%;
  display: inline-block;
}
#chat-panel {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  right: calc(22px + env(safe-area-inset-right, 0px));
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}
@media (max-width: 600px) {
  #chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    max-height: min(70vh, calc(100vh - 140px));
  }
}
#chat-panel.open { display: flex; }
#chat-panel header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#chat-panel header .close {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  line-height: 1;
}
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
}
#chat-log .msg { margin-bottom: 14px; }
#chat-log .msg.user {
  background: var(--cf-orange-light);
  padding: 8px 12px;
  border-radius: 10px;
  display: inline-block;
  max-width: 90%;
  color: var(--cf-orange-dark);
}
#chat-log .msg.bot { color: var(--ink-soft); }
#chat-log .msg.bot strong { color: var(--ink); }
#chat-log .msg.bot p { margin: 0 0 8px; }
#chat-log .msg.bot p:last-child { margin-bottom: 0; }
#chat-log .msg.bot ul, #chat-log .msg.bot ol { margin: 6px 0; padding-left: 22px; }
#chat-log .msg.bot li { margin: 2px 0; }
#chat-log .msg.bot code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--card-tint);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--rule);
}
#chat-log .typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
#chat-log .typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
#chat-log .typing span:nth-child(2) { animation-delay: .15s; }
#chat-log .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

#chat-log .suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
#chat-log .suggestions button {
  background: var(--card-tint);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  text-align: left;
  min-height: 36px;
  line-height: 1.3;
}
#chat-log .suggestions button:hover {
  background: var(--cf-orange-light);
  color: var(--cf-orange-dark);
  border-color: var(--cf-orange);
}
#chat-log .empty-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
#chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--rule);
  background: var(--card-tint);
}
#chat-input {
  flex: 1;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 16px; /* ≥16px prevents iOS Safari auto-zoom on focus */
  background: var(--card);
  color: var(--ink);
  min-height: 44px;
}
#chat-input:focus { outline: 2px solid var(--cf-orange); outline-offset: -1px; }
#chat-send {
  background: var(--cf-orange);
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 6px 14px;
  min-height: 44px;
  min-width: 60px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
#chat-send:disabled { background: var(--muted); cursor: not-allowed; }
.chat-hint { font-size: 12px; color: var(--muted); padding: 0 16px 8px; }

/* ---------- Footer ---------- */
footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
}
footer code { font-size: .85em; }

/* ---------- Print ---------- */
@media print {
  body { background: white; color: black; font-size: 11pt; }
  .layout { display: block; max-width: none; padding: 0; }
  .sidenav, #chat-launcher, #chat-panel { display: none !important; }
  main { max-width: none; }
  section { page-break-inside: auto; border-top: 1px solid #ddd; padding: 12pt 0; }
  h1 { font-size: 22pt; }
  h2 { font-size: 16pt; margin-top: 12pt; }
  h3 { font-size: 13pt; }
  h4 { font-size: 11pt; }
  a { color: black; text-decoration: none; }
  .card, .product, .leader, .week { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .timeline .event::before { background: #888; }
  .cover .tldr { border-left: 3pt solid #888; }
}

/* ---------- Tag chips ---------- */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--card-tint);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  margin-right: 4px;
}
.chip.warn { background: #fff4e0; color: var(--warn); border-color: #f4d9a8; }
.chip.good { background: #e6f4ec; color: var(--good); border-color: #b7dec5; }
.chip.cf { background: var(--cf-orange-light); color: var(--cf-orange-dark); border-color: #f4d9a8; }
@media (prefers-color-scheme: dark) {
  .chip.warn, .chip.good, .chip.cf { background: var(--card-tint); border-color: var(--rule); }
}
