/* ==========================================================================
   SunPathly — design system
   Single stylesheet, no build step, no external fonts.
   ========================================================================== */

:root {
  /* Dark is the default theme.

     Light is opt-in: the toggle sets data-theme="light" on <html>. Doing it
     this way round rather than via prefers-color-scheme means dark also applies
     with JavaScript disabled, and does not flip based on the visitor's OS. */
  --bg:          #0d1117;
  --bg-sunk:     #090c11;
  --surface:     #151b23;
  --surface-alt: #1b222c;
  --border:      #262d38;
  --border-strong:#39424f;
  --text:        #e6ebf2;
  --text-muted:  #9aa6b4;
  --text-faint:  #6e7a89;

  --sun:         #f0a020;
  --sun-strong:  #d97f06;
  --sun-soft:    #2a2014;
  --sky:         #6ea8fe;
  --sky-soft:    #131e33;
  --shade:       #4b5563;
  --good:        #16a34a;
  --warn:        #d97706;
  --bad:         #dc2626;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow-md:   0 4px 14px rgba(0,0,0,.45);

  --radius:      10px;
  --radius-lg:   14px;
  --maxw:        1180px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg:          #ffffff;
  --bg-sunk:     #f4f6f8;
  --surface:     #ffffff;
  --surface-alt: #f7f9fb;
  --border:      #e2e7ec;
  --border-strong:#cbd3dc;
  --text:        #10161d;
  --text-muted:  #5a6673;
  --text-faint:  #8b96a3;

  --sun-soft:    #fdf3e0;
  --sky:         #2563eb;
  --sky-soft:    #eaf1fe;

  --shadow-sm:   0 1px 2px rgba(16,22,29,.06), 0 1px 3px rgba(16,22,29,.04);
  --shadow-md:   0 4px 12px rgba(16,22,29,.08), 0 1px 3px rgba(16,22,29,.04);
}

/* --------------------------------------------------------------------- *
   Base
 * --------------------------------------------------------------------- */

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

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

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

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.75rem); }
h3 { font-size: 1.12rem; }
p  { margin: 0 0 1em; }

a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

code, kbd { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-alt); padding: .12em .35em; border-radius: 4px; }

img, canvas, svg { max-width: 100%; }

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 20px;
  height: 60px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1.06rem; color: var(--text);
  letter-spacing: -.02em; flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; flex: none;
  display: block;
}

.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a {
  padding: 7px 11px; border-radius: 7px; font-size: .92rem; font-weight: 500;
  color: var(--text-muted);
}
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-alt); }

.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none; margin-left: 4px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

.nav-toggle {
  display: none; width: 36px; height: 34px; margin-left: auto;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: grid; place-items: center; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 12px 14px; margin-left: 0;
    box-shadow: var(--shadow-md);
  }
  .nav:not(.open) { display: none; }
  .nav a { padding: 11px 12px; font-size: 1rem; }
  .theme-toggle { margin: 6px 0 0; width: 100%; height: 40px; }
}

/* --------------------------------------------------------------------- *
   Hero
 * --------------------------------------------------------------------- */

.hero {
  padding: 56px 0 40px;
  background:
    radial-gradient(900px 380px at 78% -12%, var(--sun-soft), transparent 62%),
    radial-gradient(700px 320px at 12% 0%, var(--sky-soft), transparent 58%);
  border-bottom: 1px solid var(--border);
}
.hero h1 { max-width: 20ch; margin-bottom: .4em; }
.hero .lede { font-size: 1.12rem; color: var(--text-muted); max-width: 60ch; margin-bottom: 1.6em; }

.eyebrow {
  display: inline-block; margin-bottom: 14px;
  font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--sun-strong);
  background: var(--sun-soft); border: 1px solid color-mix(in srgb, var(--sun) 30%, transparent);
  padding: 4px 10px; border-radius: 999px;
}

/* --------------------------------------------------------------------- *
   Buttons & controls
 * --------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 17px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .94rem; font-weight: 550; cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; border-color: var(--text-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--sun-strong); border-color: var(--sun-strong); color: #fff;
}
.btn-primary:hover { background: #c07105; border-color: #c07105; }
.btn-sm { padding: 6px 11px; font-size: .85rem; }
.btn-icon { padding: 8px; width: 36px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label {
  display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 5px; letter-spacing: .01em;
}

input[type="text"], input[type="search"], input[type="number"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .94rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); outline-offset: -1px; border-color: var(--sky); }

input[type="range"] {
  width: 100%; margin: 6px 0; accent-color: var(--sun-strong);
  background: transparent;
}

.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: .92rem; }
.switch-row input { width: auto; margin: 0; accent-color: var(--sun-strong); }

.seg {
  display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px;
  overflow: hidden; background: var(--surface);
}
.seg button {
  padding: 7px 13px; border: 0; background: transparent; color: var(--text-muted);
  font: inherit; font-size: .87rem; font-weight: 550; cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--sun-strong); color: #fff; }
.seg button:hover:not([aria-pressed="true"]) { background: var(--surface-alt); color: var(--text); }

/* --------------------------------------------------------------------- *
   Cards, panels, sections
 * --------------------------------------------------------------------- */

.section { padding: 52px 0; }
.section-sunk { background: var(--bg-sunk); border-block: 1px solid var(--border); }
.section-head { max-width: 62ch; margin-bottom: 28px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-pad-lg { padding: 26px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

a.card-link { color: inherit; display: block; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card-link:hover {
  text-decoration: none; border-color: var(--border-strong);
  box-shadow: var(--shadow-md); transform: translateY(-2px);
}
a.card-link h3 { color: var(--text); }
a.card-link .go { color: var(--sky); font-weight: 550; font-size: .9rem; }

.tool-icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 14px;
  display: grid; place-items: center;
  background: var(--sun-soft); color: var(--sun-strong);
}

/* Stat tiles */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.stat .k {
  font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: 3px;
}
.stat .v { font-size: 1.35rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .8rem; color: var(--text-muted); }

/* --------------------------------------------------------------------- *
   Tool layout
 * --------------------------------------------------------------------- */

.tool-layout {
  display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 22px; align-items: start;
  padding: 26px 0 44px;
}
/* Grid tracks default to a min of auto, which lets a wide canvas or table
   push the whole column past the viewport. Pinning min-width to 0 lets the
   inner scroll containers do their job instead. */
.tool-layout > * { min-width: 0; }

@media (max-width: 940px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  /* Show the tool doing something before asking for input. */
  .tool-layout > .sticky-panel { order: 2; }
  .tool-layout > :not(.sticky-panel) { order: 1; }
}

/* Article pages: prose beside a sidebar rail, collapsing on narrow screens. */
.article-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: 34px; align-items: start;
  padding: 32px 0 48px;
}
.article-layout > * { min-width: 0; }
@media (max-width: 940px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-layout > aside { display: none; }
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 16px; }
.panel > h2, .panel > h3 {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); margin-bottom: 14px;
}
.sticky-panel { position: sticky; top: 76px; }
@media (max-width: 940px) { .sticky-panel { position: static; } }

.viz {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  box-shadow: var(--shadow-sm);
}
.viz + .viz { margin-top: 18px; }
.viz-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.viz-head h2 { font-size: 1.02rem; margin: 0; }
.viz canvas { display: block; width: 100%; }

/* Time scrubber */
.scrub { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.scrub input[type="range"] { flex: 1; }
.scrub .readout {
  font-family: var(--mono); font-size: .95rem; font-weight: 600;
  min-width: 6.2ch; text-align: right; font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------- *
   Location picker
 * --------------------------------------------------------------------- */

.locbox { position: relative; }
.locbox-results {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-height: 280px; overflow-y: auto; padding: 4px;
}
.locbox-results:empty { display: none; }
.locbox-results button {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.locbox-results button:hover, .locbox-results button.active { background: var(--surface-alt); }
.locbox-results .r-sub { display: block; font-size: .8rem; color: var(--text-muted); }

.loc-current {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 9px 11px; margin-bottom: 12px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem;
}
.loc-current strong { font-weight: 600; }
.loc-current .coords { font-family: var(--mono); font-size: .78rem; color: var(--text-muted); }

/* --------------------------------------------------------------------- *
   Legend / chips
 * --------------------------------------------------------------------- */

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: block; flex: none; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-muted);
}
.chip-good { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 34%, transparent); color: var(--good); }
.chip-warn { background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: color-mix(in srgb, var(--warn) 36%, transparent); color: var(--warn); }
.chip-bad  { background: color-mix(in srgb, var(--bad) 11%, transparent); border-color: color-mix(in srgb, var(--bad) 32%, transparent); color: var(--bad); }

/* --------------------------------------------------------------------- *
   Tables
 * --------------------------------------------------------------------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); background: var(--surface-alt);
}
table.data td { font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td:first-child { font-weight: 550; }

/* --------------------------------------------------------------------- *
   Prose (guides & location pages)
 * --------------------------------------------------------------------- */

.prose { max-width: 72ch; }
.prose h2 { margin-top: 2em; padding-top: .2em; }
.prose h3 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .45em; }
.prose blockquote {
  margin: 1.5em 0; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--sun); color: var(--text-muted);
}
.prose .callout {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-left: 3px solid var(--sky);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px; margin: 1.6em 0;
}
.prose .callout p:last-child { margin-bottom: 0; }
.prose .callout strong { color: var(--text); }

.toc {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 2em;
}
.toc p { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: .5em; }
.toc ol { margin: 0; padding-left: 1.2em; font-size: .93rem; }
.toc li { margin-bottom: .25em; }

.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span { margin: 0 6px; color: var(--text-faint); }

/* FAQ */
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 10px; background: var(--surface);
}
.faq summary { font-weight: 600; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--text-faint); font-weight: 400; }
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { margin-bottom: .7em; }
.faq details p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------- *
   Ads
 * --------------------------------------------------------------------- */

.ad {
  display: block; margin: 30px auto; text-align: center;
  max-width: 100%; overflow: hidden;
}
.ad::before {
  content: "Advertisement";
  display: block; font-size: .62rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 6px;
}
.ad-leaderboard { min-height: 100px; }
.ad-rect        { min-height: 260px; }
.ad-sidebar     { min-height: 620px; margin: 0; }
.ad-inarticle   { min-height: 260px; }

/* Placeholder shown until a real ad unit is configured. */
.ad-placeholder {
  display: grid; place-items: center;
  min-height: inherit; height: 100%;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, var(--surface-alt) 0 10px, var(--surface) 10px 20px);
  color: var(--text-faint); font-size: .8rem;
}
.ad-leaderboard .ad-placeholder { min-height: 90px; }
.ad-rect .ad-placeholder, .ad-inarticle .ad-placeholder { min-height: 250px; }
.ad-sidebar .ad-placeholder { min-height: 600px; }

@media (max-width: 940px) { .ad-sidebar { display: none; } }

/* --------------------------------------------------------------------- *
   Consent banner
 * --------------------------------------------------------------------- */

.consent {
  position: fixed; z-index: 200; left: 16px; right: 16px; bottom: 16px;
  max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 18px 20px;
}
.consent p { font-size: .88rem; margin-bottom: 14px; }
.consent .btn-row { justify-content: flex-end; }

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

.site-footer {
  border-top: 1px solid var(--border); background: var(--bg-sunk);
  padding: 42px 0 30px; margin-top: 60px; font-size: .9rem;
}
.footer-grid { display: grid; gap: 26px; grid-template-columns: 1.4fr repeat(3, 1fr); }
@media (max-width: 780px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-grid h4 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); margin-bottom: .8em;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: .45em; }
.footer-grid a { color: var(--text-muted); }
.footer-grid a:hover { color: var(--text); }
.footer-bottom {
  margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between;
  color: var(--text-faint); font-size: .84rem;
}

/* --------------------------------------------------------------------- *
   Utilities
 * --------------------------------------------------------------------- */

.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

.obstacle-list { list-style: none; margin: 0; padding: 0; }
.obstacle-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; margin-bottom: 6px; font-size: .87rem;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 7px;
}
.obstacle-list .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.obstacle-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obstacle-list .dm { font-family: var(--mono); font-size: .76rem; color: var(--text-muted); }
.obstacle-list button {
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 4px;
}
.obstacle-list button:hover { color: var(--bad); }

@media print {
  .site-header, .site-footer, .ad, .consent, .scrub { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
