/* Retirement Planner user guide styles. Light by default, dark when the
   reader's system is in dark mode. */

:root {
  color-scheme: light dark;
  --bg: #FFFFFF;
  --surface: #F6F6F7;
  --border: #E3E3E6;
  --text: #1D1D1F;
  --text-2: #3F4047;
  --muted: #5F6068;
  --link: #A85400;
  --accent: #E8801F;
  --strong: #B35A00;   /* orange that carries white text at 4.5:1 */
  --selected: #FFF0E0;
  --kbd-bg: #F1F1F3;
  --tip-bg: #FFF5EB;
  --tip-border: #F3C08C;
  --note-bg: #EEF4FB;
  --note-border: #A9C8EA;
  --note-icon: #2F6DB5;
  --plan-bg: #F3F0FA;
  --plan-border: #C9BCE8;
  --plan-icon: #6A4FB3;
  --shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C1E;
    --surface: #242427;
    --border: #38383C;
    --text: #ECECEE;
    --text-2: #C8C8CD;
    --muted: #A3A4AA;
    --link: #FFB066;
    --selected: rgba(232, 128, 31, 0.18);
    --kbd-bg: #2C2C30;
    --tip-bg: rgba(232, 128, 31, 0.12);
    --tip-border: rgba(232, 128, 31, 0.45);
    --note-bg: rgba(90, 150, 230, 0.12);
    --note-border: rgba(90, 150, 230, 0.45);
    --note-icon: #8DBDF0;
    --plan-bg: rgba(150, 120, 230, 0.12);
    --plan-border: rgba(150, 120, 230, 0.45);
    --plan-icon: #BBA6F2;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  }
}

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

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

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

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.skip-link:focus { left: 16px; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header .bar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.bar .spacer { flex: 1; }
.version { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lang {
  font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text);
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
}
.lang:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

.search { position: relative; flex: 0 1 340px; min-width: 200px; }
.search label {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
}
.search svg { flex: 0 0 auto; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 14px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search .key { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 30;
  max-height: 70vh; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.search-results[hidden] { display: none; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.active { background: var(--selected); text-decoration: none; }
.search-results .r-title { display: block; font-weight: 650; font-size: 14px; }
.search-results .r-where { display: block; font-size: 12.5px; color: var(--muted); }
.search-results .r-empty { padding: 10px; font-size: 14px; color: var(--muted); }

/* ---------- Page layout ---------- */

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.chapters {
  flex: 0 0 230px;
  position: sticky;
  top: 63px;
  max-height: calc(100vh - 63px);
  overflow-y: auto;
  padding: 24px 0 40px;
  font-size: 14px;
}
.chapters summary { display: none; }
.chapters ul { list-style: none; margin: 0; padding: 0; }
.chapters .group { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; padding: 14px 10px 4px; }
.chapters .group:first-child { padding-top: 0; }
.chapters a { display: block; padding: 5px 10px; border-radius: 8px; color: var(--text); }
.chapters a:hover { background: var(--surface); text-decoration: none; }
.chapters a[aria-current="page"] { background: var(--selected); font-weight: 650; }

.article {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 880px;
  padding: 32px 0 64px;
}

.toc {
  flex: 0 0 190px;
  position: sticky;
  top: 63px;
  padding: 36px 0;
  font-size: 13.5px;
}
.toc h2 { margin: 0 0 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.toc a { color: var(--muted); }
.toc a.active { color: var(--link); }

@media (max-width: 1280px) {
  .toc { display: none; }
}

@media (max-width: 820px) {
  .layout { flex-direction: column; gap: 0; padding: 0 16px; }
  .site-header .bar { padding: 10px 16px; }
  .search { flex: 1 1 100%; order: 3; }
  .chapters {
    position: static; max-height: none; width: 100%; flex: none;
    padding: 12px 0 0;
  }
  .chapters summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); font-weight: 650; cursor: pointer; list-style: none;
  }
  .chapters summary::-webkit-details-marker { display: none; }
  .chapters ul { padding: 8px 0; }
  .article { padding-top: 20px; }
}

/* ---------- Article content ---------- */

.breadcrumb { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.breadcrumb a { color: var(--muted); }

.article h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.2; font-weight: 750; letter-spacing: -0.01em; }
.article .lead { margin: 0 0 20px; font-size: 18px; color: var(--muted); }
.article h2 { margin: 40px 0 12px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 24px; line-height: 1.3; font-weight: 700; }
.article h3 { margin: 28px 0 8px; font-size: 18px; font-weight: 700; }
.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 16px; padding-left: 24px; }
.article li { margin: 0 0 6px; }
.article li > ul, .article li > ol { margin: 6px 0 0; }
.article strong { font-weight: 650; }

@media (max-width: 820px) {
  .article h1 { font-size: 28px; }
  .article .lead { font-size: 17px; }
  .article h2 { font-size: 21px; }
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 5px;
  margin: 0 1px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--kbd-bg);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  white-space: nowrap;
}

code { font-family: var(--mono); font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: var(--kbd-bg); }

.ui { font-weight: 650; }

.table-wrap { overflow-x: auto; margin: 0 0 18px; }
.article table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.article th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); font-size: 13px; color: var(--muted); font-weight: 700; }
.article td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* Tip, note and plan boxes */
.callout-box {
  display: flex; gap: 12px;
  margin: 0 0 18px; padding: 14px 16px;
  border-radius: 12px; font-size: 15px;
}
.callout-box svg { flex: 0 0 auto; margin-top: 2px; }
.callout-box > div > :last-child { margin-bottom: 0; }
.callout-box.tip { background: var(--tip-bg); border: 1px solid var(--tip-border); }
.callout-box.tip svg { color: var(--link); }
.callout-box.note { background: var(--note-bg); border: 1px solid var(--note-border); }
.callout-box.note svg { color: var(--note-icon); }
.callout-box.plan { background: var(--plan-bg); border: 1px solid var(--plan-border); }
.callout-box.plan svg { color: var(--plan-icon); }

/* Screenshots */
.shot { margin: 8px 0 20px; }
.shot .frame { position: relative; display: block; width: fit-content; max-width: 100%; margin: 0 auto; }
.shot a.frame { cursor: zoom-in; }
.shot img { display: block; border-radius: 10px; filter: drop-shadow(var(--shadow)); }
.shot.small img { border-radius: 8px; }
.shot figcaption { margin-top: 10px; font-size: 13.5px; color: var(--muted); text-align: center; }
.shot .marker {
  position: absolute;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: var(--strong); color: #FFFFFF;
  font-size: 13px; font-weight: 700; line-height: 26px; text-align: center;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.92), 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.shot .pending {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 8 / 5; border: 2px dashed var(--border); border-radius: 10px;
  color: var(--muted); font-size: 14px; padding: 16px; text-align: center;
}
@media (max-width: 560px) {
  .shot .marker { width: 20px; height: 20px; margin: -10px 0 0 -10px; font-size: 11px; line-height: 20px; }
}

ol.legend { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px 24px; }
ol.legend li { display: flex; gap: 10px; font-size: 15px; margin: 0; }
ol.legend .n {
  width: 22px; height: 22px; flex: 0 0 auto; margin-top: 2px;
  border-radius: 50%; background: var(--strong); color: #FFFFFF;
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}

/* Steps */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 36px; margin-bottom: 10px; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 700; line-height: 21px; text-align: center; color: var(--text-2);
}

/* Previous / next */
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 40px; }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); }
.pager a:hover { border-color: var(--link); text-decoration: none; }
.pager .dir { font-size: 12.5px; color: var(--muted); }
.pager .name { font-weight: 650; color: var(--link); }
.pager .next { grid-column: 2; text-align: right; }

/* ---------- Guide home ---------- */

.home { max-width: 1180px; margin: 0 auto; padding: 48px 24px 64px; display: flex; flex-direction: column; gap: 56px; }
.hero { display: flex; flex-wrap: wrap; gap: 40px; align-items: center; }
.hero .intro { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.hero .eyebrow { font-size: 13px; font-weight: 600; color: var(--link); letter-spacing: 0.04em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: 40px; line-height: 1.15; font-weight: 750; letter-spacing: -0.01em; }
.hero p { margin: 0; font-size: 18px; color: var(--muted); }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.button { display: inline-block; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 15px; }
.button:hover { text-decoration: none; }
.button.primary { background: var(--strong); color: #FFFFFF; }
.button.primary:hover { background: #994C00; }
.button.secondary { border: 1px solid var(--border); color: var(--text); }
.button.secondary:hover { border-color: var(--link); }
.hero figure { flex: 1 1 520px; min-width: 0; margin: 0; }
.hero figure img { display: block; border-radius: 10px; filter: drop-shadow(var(--shadow)); }

.home h2 { margin: 0 0 16px; font-size: 22px; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.card:hover { border-color: var(--link); text-decoration: none; }
.card .step { font-size: 12px; font-weight: 700; color: var(--link); }
.card .title { font-size: 16px; font-weight: 650; }
.card .detail { font-size: 14px; color: var(--muted); }

.chapter-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 28px 32px; }
.chapter-groups .group-name { display: block; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.chapter-groups ul { list-style: none; margin: 0; padding: 0; }
.chapter-groups a { display: flex; flex-direction: column; gap: 1px; padding: 6px 0; }
.chapter-groups a:hover { text-decoration: none; }
.chapter-groups a:hover .t { text-decoration: underline; }
.chapter-groups .t { font-size: 15px; font-weight: 600; color: var(--link); }
.chapter-groups .d { font-size: 13.5px; color: var(--muted); }

.banner { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 20px 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.banner .text { flex: 1 1 360px; display: flex; flex-direction: column; gap: 4px; }
.banner strong { font-size: 16px; font-weight: 650; }
.banner span { font-size: 14px; color: var(--muted); }

@media (max-width: 820px) {
  .home { padding: 28px 16px 48px; gap: 40px; }
  .hero h1 { font-size: 32px; }
}

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--border); }
.site-footer .bar { max-width: 1400px; margin: 0 auto; padding: 20px 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 13px; color: var(--muted); }
.site-footer .spacer { flex: 1; }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.lightbox button {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.16); color: #FFFFFF;
  font-size: 22px; cursor: pointer;
}

/* ---------- Print ---------- */

@media print {
  .site-header, .chapters, .toc, .pager, .site-footer, .skip-link { display: none !important; }
  .layout { display: block; padding: 0; }
  .article { max-width: none; padding: 0; }
  .shot img { filter: none; border: 1px solid #CCCCCC; }
  .article h2 { break-after: avoid; }
  .shot, .callout-box, table { break-inside: avoid; }
  a { color: inherit; }
}

/* ---------- Plan badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 1.5; letter-spacing: 0.01em;
  vertical-align: 0.15em; white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge.pro { background: #FFF0E0; color: #8A4500; }
.badge.adv { background: #ECEFFD; color: #3446A8; }
@media (prefers-color-scheme: dark) {
  .badge.pro { background: rgba(232, 128, 31, 0.18); color: #FFB066; }
  .badge.adv { background: rgba(110, 140, 240, 0.2); color: #A9BBFF; }
}
.article h1 .badge { font-size: 13px; vertical-align: 0.4em; margin-left: 6px; }
.chapters .badge { margin-left: 6px; padding: 0 6px; font-size: 10.5px; vertical-align: 0.1em; }
.chapter-groups .t .badge { margin-left: 8px; }
.legend-badges { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin: -8px 0 18px; }
.legend-badges span { display: inline-flex; align-items: center; gap: 6px; }

/* Disclaimer on the home page */
.home .callout-box { margin: 0; }
