/* Khetta Rewards Guide.
   Change the colours in :root to restyle the whole site. */
:root {
  --navy: #132b45;
  --navy-2: #1c3a5b;
  --accent: #0b6b8a;
  --accent-soft: #e4f1f5;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #1b2733;
  --muted: #5b6875;
  --line: #dde2e7;
  --code-bg: #eef1f4;
  --tip: #1f7a4d;
  --tip-bg: #e8f4ed;
  --note: #0b6b8a;
  --note-bg: #e4f1f5;
  --careful: #a24a12;
  --careful-bg: #fbeee2;
  --radius: 8px;
  --header-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 220px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a26;
    --surface: #152333;
    --text: #e4eaf0;
    --muted: #9aa8b6;
    --line: #26384b;
    --accent: #5cb8d3;
    --accent-soft: #17313f;
    --code-bg: #1b2d3f;
    --tip: #6fcf9c;
    --tip-bg: #15322a;
    --note: #5cb8d3;
    --note-bg: #17313f;
    --careful: #f0a56a;
    --careful-bg: #3a2a1c;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1a26;
  --surface: #152333;
  --text: #e4eaf0;
  --muted: #9aa8b6;
  --line: #26384b;
  --accent: #5cb8d3;
  --accent-soft: #17313f;
  --code-bg: #1b2d3f;
  --tip: #6fcf9c;
  --tip-bg: #15322a;
  --note: #5cb8d3;
  --note-bg: #17313f;
  --careful: #f0a56a;
  --careful-bg: #3a2a1c;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--navy);
  color: #fff;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  background: transparent; color: inherit; border: 0; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }
.menu-btn { display: none; margin-left: -8px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; border: 2px solid #fff; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 6px; top: 3px; width: 7px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(40deg); }
.brand-name { font-weight: 650; font-size: 17px; letter-spacing: .1px; }
.brand-sub { font-size: 12.5px; color: rgba(255,255,255,.7); border-left: 1px solid rgba(255,255,255,.3); padding-left: 10px; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; height: 40px; padding: 0 40px 0 38px;
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px;
  background: rgba(255,255,255,.1); color: #fff; font: inherit; font-size: 15px;
}
.search input::placeholder { color: rgba(255,255,255,.7); }
.search input:focus { background: #fff; color: var(--text); border-color: #fff; outline: none; }
.search input:focus::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 11px; top: 11px; color: rgba(255,255,255,.8); pointer-events: none; display: flex; }
.search input:focus ~ .search-icon, .search:focus-within .search-icon { color: var(--muted); }
.search-key { position: absolute; right: 10px; top: 9px; font: 12px/1 var(--font); border: 1px solid rgba(255,255,255,.35); color: rgba(255,255,255,.8); border-radius: 4px; padding: 4px 7px; pointer-events: none; }
.search:focus-within .search-key { display: none; }
.results {
  position: absolute; left: 0; right: 0; top: 46px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-height: min(70vh, 520px); overflow: auto; padding: 6px;
}
.results a { display: block; padding: 10px 12px; border-radius: 6px; color: inherit; text-decoration: none; }
.results a:hover, .results a[aria-selected="true"] { background: var(--accent-soft); }
.res-title { font-weight: 600; }
.res-sec { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-left: 8px; font-weight: 500; }
.res-snip { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.results mark { background: #ffe58a; color: #1b2733; border-radius: 2px; padding: 0 1px; }
.res-empty { padding: 14px 12px; color: var(--muted); font-size: 15px; }

/* ---------- layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px; margin: 0 auto;
  min-height: calc(100vh - var(--header-h) - 80px);
}
.sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow: auto;
  padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--line);
  font-size: 15px;
}
.nav-home { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 600; margin-bottom: 8px; }
.nav-home:hover, .nav-home[aria-current] { background: var(--accent-soft); color: var(--accent); }
.nav-group { margin-bottom: 4px; }
.nav-group summary {
  cursor: pointer; list-style: none; padding: 8px 10px; border-radius: 6px;
  font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: ""; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; }
.nav-group[open] summary::after { transform: rotate(45deg); }
.nav-group summary:hover { background: var(--accent-soft); }
.nav-group ul { list-style: none; margin: 2px 0 10px; padding: 0 0 0 4px; }
.nav-group li a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--text); text-decoration: none; line-height: 1.4; }
.nav-group li a:hover { background: var(--accent-soft); }
.nav-group li a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { padding: 36px 48px 64px; min-width: 0; }
.toc { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; padding: 36px 20px 0 0; font-size: 14px; max-height: calc(100vh - var(--header-h)); overflow: auto; }
.toc-title { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--text); }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }

/* ---------- article ---------- */
.doc { max-width: 740px; }
.crumbs { display: flex; gap: 8px; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.doc h1, .home h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 10px; letter-spacing: -.01em; font-weight: 700; }
.lede { font-size: 1.12rem; color: var(--muted); margin: 0 0 26px; line-height: 1.55; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.4rem; line-height: 1.3; margin: 2.2em 0 .6em; padding-top: .2em; font-weight: 700; }
.prose h3 { font-size: 1.12rem; margin: 1.7em 0 .4em; font-weight: 650; }
.prose h2, .prose h3 { position: relative; }
.anchor { position: absolute; left: -1.1em; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li > ul, .prose li > ol { margin: .35em 0; }
.prose ol > li::marker { font-weight: 650; color: var(--accent); }
.prose code { background: var(--code-bg); padding: .12em .4em; border-radius: 4px; font-size: .9em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--line); color: var(--muted); }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--code-bg); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td:first-child { min-width: 120px; }

.callout { display: flex; gap: 12px; margin: 1.3em 0; padding: 12px 16px; border-radius: var(--radius); border: 1px solid transparent; }
.callout-label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; flex: none; padding-top: 2px; min-width: 56px; }
.callout-body { min-width: 0; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-tip { background: var(--tip-bg); border-color: color-mix(in srgb, var(--tip) 35%, transparent); }
.callout-tip .callout-label { color: var(--tip); }
.callout-note { background: var(--note-bg); border-color: color-mix(in srgb, var(--note) 35%, transparent); }
.callout-note .callout-label { color: var(--note); }
.callout-careful { background: var(--careful-bg); border-color: color-mix(in srgb, var(--careful) 40%, transparent); }
.callout-careful .callout-label { color: var(--careful); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; }
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; margin-bottom: 2px; }
.pager-next { text-align: right; grid-column: 2; }
.pager-prev { grid-column: 1; }

/* ---------- home ---------- */
.home { max-width: 1000px; }
.hero { padding: 8px 0 36px; }
.hero h1 { font-size: 2.5rem; max-width: 18ch; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 56ch; margin: 0 0 22px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-block; padding: 11px 18px; border-radius: 8px; background: var(--navy); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; border: 1px solid var(--navy); }
.btn:hover { background: var(--navy-2); }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--line); }
.btn-quiet:hover { background: var(--surface); border-color: var(--accent); }
.home h2 { font-size: 1.5rem; margin: 0 0 6px; }
.home section + section { margin-top: 44px; }
.section-intro { color: var(--muted); margin: 0 0 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card-num { font-size: 12.5px; font-weight: 700; color: var(--accent); letter-spacing: .06em; }
.card-title { font-weight: 650; font-size: 1.05rem; line-height: 1.3; }
.card-text { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 28px 32px; margin-top: 18px; }
.group h3 { margin: 0 0 4px; font-size: 1.05rem; }
.group p { margin: 0 0 8px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.group ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.group li { border-bottom: 1px solid var(--line); }
.group li a { display: block; padding: 7px 2px; text-decoration: none; font-size: 15px; }
.group li a:hover { text-decoration: underline; }

.footer { border-top: 1px solid var(--line); padding: 22px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.footer-small { font-size: 12.5px; margin-top: 4px; }

.scrim { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(8,16,26,.5); z-index: 29; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  :root { --header-h: 56px; }
  body { font-size: 16px; }
  .topbar { padding: 0 12px 0 16px; gap: 8px; }
  .menu-btn { display: inline-flex; }
  .brand-sub, .brand-name { display: none; }
  .brand-mark { margin-left: 2px; }
  .search { max-width: none; }
  .search-key { display: none; }
  .shell { display: block; }
  .sidebar {
    position: fixed; z-index: 30; top: var(--header-h); left: 0; bottom: 0; width: min(86vw, 320px); height: auto;
    background: var(--surface); transform: translateX(-102%); transition: transform .2s ease; border-right: 1px solid var(--line);
    padding: 16px 12px 40px 16px;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open { overflow: hidden; }
  .main { padding: 24px 16px 48px; }
  .doc h1, .home h1 { font-size: 1.65rem; }
  .hero h1 { font-size: 1.9rem; }
  .prose h2 { font-size: 1.25rem; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager-next, .pager-prev { grid-column: auto; text-align: left; }
  .callout { flex-direction: column; gap: 4px; }
  .results { position: fixed; left: 8px; right: 8px; top: calc(var(--header-h) + 4px); max-height: 75vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .topbar, .sidebar, .toc, .pager, .footer, .scrim { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
}
