/* Rotation.Golf — clean, readable default. Light + dark, system fonts. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #24211c;
  --muted: #6b6455;
  --border: #e5e0d6;
  --accent: #2f6f4e;         /* fairway green */
  --accent-soft: #eaf2ec;
  --link: #295f43;
  --sidebar-w: 19rem;
  --measure: 42rem;          /* reading column */
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #16150f;
  --surface: #1e1d16;
  --text: #e7e3d8;
  --muted: #a49d8b;
  --border: #322f26;
  --accent: #6bbf90;
  --accent-soft: #1f2a22;
  --link: #83c7a2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16150f;
    --surface: #1e1d16;
    --text: #e7e3d8;
    --muted: #a49d8b;
    --border: #322f26;
    --accent: #6bbf90;
    --accent-soft: #1f2a22;
    --link: #83c7a2;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
a:hover { text-decoration-color: var(--link); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100;
}
.skip:focus { left: 0; }

/* --- Header --- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
}
.brand {
  font-weight: 700; letter-spacing: -.01em; font-size: 1.1rem;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.nav-toggle, .theme-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: .5rem; width: 2.2rem; height: 2.2rem; font-size: 1rem;
  cursor: pointer; flex: none;
}
.nav-toggle { display: none; }
.theme-toggle { margin-left: auto; }

.search { position: relative; flex: 1 1 auto; max-width: 30rem; margin: 0 .5rem; }
#search-input {
  width: 100%; padding: .5rem .8rem; border: 1px solid var(--border);
  border-radius: .6rem; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: .95rem;
}
#search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-results {
  position: absolute; top: calc(100% + .35rem); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: .6rem; box-shadow: 0 12px 30px rgba(0,0,0,.16);
  max-height: 70vh; overflow-y: auto; padding: .3rem;
}
.search-results a {
  display: block; padding: .5rem .6rem; border-radius: .45rem;
  color: var(--text); text-decoration: none;
}
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); }
.search-results .r-title { font-weight: 600; }
.search-results .r-part { display: block; font-size: .78rem; color: var(--muted); font-family: var(--sans); }
.search-results .r-none { padding: .6rem; color: var(--muted); }

/* --- Layout --- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: 3.4rem; align-self: flex-start;
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - 3.4rem); overflow-y: auto;
  padding: 1.2rem 1rem 3rem; border-right: 1px solid var(--border);
  font-family: var(--sans); font-size: .9rem;
}
.nav-home { display: block; font-weight: 600; margin-bottom: .6rem; text-decoration: none; }
.nav-part { margin: .9rem 0; }
.nav-part-title {
  display: block; font-weight: 700; color: var(--text);
  text-decoration: none; font-size: .82rem; letter-spacing: .01em;
  text-transform: uppercase; opacity: .75; margin-bottom: .3rem;
}
.nav-part ul { list-style: none; margin: 0; padding: 0; }
.nav-part li a {
  display: block; padding: .22rem .5rem; border-radius: .4rem;
  color: var(--text); text-decoration: none; line-height: 1.35;
}
.nav-part li a:hover { background: var(--accent-soft); }
.sidebar a.active {
  color: var(--accent); background: var(--accent-soft); font-weight: 600;
}

/* Collapsible section subnav */
.nav-sec-row { display: flex; align-items: stretch; }
.nav-sec-row > a { flex: 1 1 auto; min-width: 0; }
.nav-sub-toggle {
  flex: none; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: .62rem; line-height: 1;
  padding: 0 .55rem; border-radius: .4rem;
  transition: transform .15s ease;
}
.nav-sub-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.nav-sec.open > .nav-sec-row .nav-sub-toggle { transform: rotate(90deg); }
.nav-subs { list-style: none; margin: .05rem 0 .25rem; padding: 0 0 0 .85rem; display: none; }
.nav-sec.open > .nav-subs { display: block; }
.nav-subs li a {
  display: block; padding: .2rem .5rem; border-radius: .4rem;
  color: var(--muted); text-decoration: none; font-size: .84rem; line-height: 1.3;
}
.nav-subs li a:hover { background: var(--accent-soft); color: var(--text); }

.content { flex: 1 1 auto; min-width: 0; padding: 2.2rem clamp(1rem, 5vw, 3.5rem) 5rem; }

.site-footer {
  max-width: var(--measure);
  margin: 2.5rem auto 0;
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}
/* --- Affiliate product card --- */
.buy-card {
  margin: 1.8rem 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: .6rem;
  background: var(--surface);
  padding: 1rem 1.1rem;
  font-family: var(--sans);
}
.buy-card-label {
  margin: 0 0 .5rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.buy-card-items { list-style: none; margin: 0; padding: 0; }
.buy-card-items li {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem;
  padding: .7rem 0; border-top: 1px solid var(--border);
}
.buy-card-items li:first-child { border-top: 0; padding-top: 0; }
.buy-card-name { font-weight: 700; font-size: 1.02rem; }
.buy-card-blurb { color: var(--muted); font-size: .88rem; flex: 1 1 12rem; }
.buy-card-btn {
  margin-left: auto; white-space: nowrap;
  background: var(--accent); color: #fff; text-decoration: none;
  padding: .5rem .85rem; border-radius: .5rem; font-size: .85rem; font-weight: 600;
}
.buy-card-btn:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .buy-card-btn { color: #10231a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .buy-card-btn { color: #10231a; }
}

.footer-links { margin-bottom: .4rem; }
.footer-links a { color: var(--muted); text-decoration: none; margin: 0 .5rem; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }

/* --- Document --- */
.doc { max-width: var(--measure); margin: 0 auto; }
.doc.home { max-width: 52rem; }

.crumb {
  font-family: var(--sans); font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin: 0 0 .4rem;
}
.doc h1 {
  font-family: var(--sans); font-weight: 800; letter-spacing: -.02em;
  font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.15; margin: 0 0 1rem;
}
.doc h2 {
  font-family: var(--sans); font-weight: 700; letter-spacing: -.01em;
  font-size: 1.45rem; margin: 2.4rem 0 .7rem; padding-top: .3rem;
  border-top: 1px solid var(--border);
}
.doc h3 { font-family: var(--sans); font-weight: 700; font-size: 1.15rem; margin: 1.8rem 0 .5rem; }
.doc h4 { font-family: var(--sans); font-weight: 700; font-size: 1rem; margin: 1.4rem 0 .4rem; color: var(--muted); }
.doc p { margin: 0 0 1.05rem; }
.doc ul, .doc ol { margin: 0 0 1.05rem; padding-left: 1.4rem; }
.doc li { margin: .3rem 0; }
.doc strong { font-weight: 700; }
.doc em { font-style: italic; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.doc blockquote {
  margin: 1.2rem 0; padding: .3rem 0 .3rem 1.1rem;
  border-left: 3px solid var(--accent); color: var(--muted); font-style: italic;
}

.doc table {
  width: 100%; border-collapse: collapse; margin: 1.2rem 0;
  font-family: var(--sans); font-size: .9rem; display: block; overflow-x: auto;
}
.doc th, .doc td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; vertical-align: top; }
.doc th { background: var(--accent-soft); font-weight: 700; }

.doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em; background: var(--accent-soft); padding: .1em .35em; border-radius: .3rem;
}
.doc pre { background: var(--surface); border: 1px solid var(--border); border-radius: .6rem; padding: 1rem; overflow-x: auto; }
.doc pre code { background: none; padding: 0; }

/* heading anchor links from toc extension */
.doc .headerlink { text-decoration: none; opacity: 0; margin-left: .35rem; color: var(--muted); }
.doc h2:hover .headerlink, .doc h3:hover .headerlink, .doc h4:hover .headerlink { opacity: 1; }

/* --- On this page --- */
.onthispage {
  font-family: var(--sans); font-size: .88rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: .6rem; padding: .5rem 1rem;
  margin: 0 0 2rem;
}
.onthispage summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.onthispage .toc > ul { margin: .6rem 0 .2rem; }
.onthispage ul { list-style: none; padding-left: 1rem; margin: .2rem 0; }
.onthispage a { text-decoration: none; }

/* --- Home extras --- */
.hero { margin-bottom: 2rem; }
.hero .subtitle { font-size: 1.2rem; color: var(--muted); font-style: italic; margin: 0; }
.frontmatter { margin-bottom: 1rem; }
.contents { margin-top: 2.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.contents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.4rem; }
.contents-part h3 { font-family: var(--sans); font-size: .95rem; margin: 0 0 .4rem; }
.contents-part ul { list-style: none; margin: 0; padding: 0; font-family: var(--sans); font-size: .9rem; }
.contents-part li { margin: .2rem 0; }
.contents-part a { text-decoration: none; }

.section-list { list-style: none; padding: 0; margin: 1.5rem 0; font-family: var(--sans); }
.section-list li { margin: 0; }
.section-list a {
  display: block; padding: .7rem .9rem; border: 1px solid var(--border);
  border-radius: .6rem; margin-bottom: .5rem; text-decoration: none; color: var(--text); font-weight: 600;
}
.section-list a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* --- Prev / next --- */
.prevnext {
  display: flex; gap: 1rem; justify-content: space-between; margin-top: 3rem;
  padding-top: 1.5rem; border-top: 1px solid var(--border); font-family: var(--sans);
}
.prevnext a {
  flex: 1 1 0; max-width: 48%; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: .6rem; padding: .7rem .9rem; font-weight: 600;
}
.prevnext a:hover { border-color: var(--accent); background: var(--accent-soft); }
.prevnext .next { text-align: right; margin-left: auto; }
.prevnext span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; }

/* --- Responsive --- */
@media (max-width: 60rem) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 3.4rem; left: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    background: var(--surface); width: min(85vw, var(--sidebar-w));
    box-shadow: 0 10px 40px rgba(0,0,0,.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .search { max-width: none; }
}
