/* BitcoinDistilled — design system. Text is the interface. */

/* Dark is the default (Joe's call, 2026-07-29); the toggle forces light. */
:root {
  color-scheme: dark;
  --bg: #111114;
  --text: #e9e8e4;
  --text-muted: #a2a19a;
  --accent: #f7931a;
  --accent-text: #f7931a; /* orange used AS text — passes contrast on dark; light theme darkens it */
  --link: #f7a641;
  --border: #29292f;
  --wrap: 44rem;

  --s1: .25rem; --s2: .5rem; --s3: 1rem; --s4: 1.5rem; --s5: 2.5rem; --s6: 4rem;

  --step--1: clamp(.83rem, .80rem + .15vw, .90rem);
  --step-0:  clamp(1.00rem, .96rem + .20vw, 1.09rem);
  --step-1:  clamp(1.19rem, 1.13rem + .30vw, 1.33rem);
  --step-2:  clamp(1.42rem, 1.32rem + .50vw, 1.62rem);
  --step-3:  clamp(1.70rem, 1.53rem + .85vw, 2.05rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #faf9f7;
  --text: #1b1b1f;
  --text-muted: #6a6963;
  --accent-text: #ad5e00;
  --link: #ad5e00;
  --border: #e7e4de;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--s4);
}

/* ---------- header ---------- */

.site-header { border-bottom: 1px solid var(--border); }

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--s4);
  padding-bottom: var(--s2);
}

.wordmark {
  font-size: var(--step-1);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
}

.wordmark span { color: var(--accent-text); }

.theme-toggle {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: var(--step-1);
  line-height: 1;
  cursor: pointer;
  padding: var(--s1) var(--s2);
}

.theme-toggle:hover { color: var(--text); }

.tab-strip {
  display: flex;
  gap: var(--s3) var(--s4);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0;
}

.tab-strip::-webkit-scrollbar { display: none; }

@media (min-width: 46rem) {
  .tab-strip { flex-wrap: wrap; }
}

.tab {
  flex: none;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--s2) 0 calc(var(--s2) + 2px);
}

.tab:hover { color: var(--text); }

.tab--active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- left sidebar (desktop only; mobile keeps the tab strip) ---------- */

.sidenav { display: none; }

@media (min-width: 64rem) {
  .site-header .tab-strip { display: none; }

  .layout {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: var(--s5);
    max-width: 62rem;
    margin-inline: auto;
    padding-inline: var(--s4);
  }

  .layout > .wrap { margin-inline: 0; padding-inline: 0; }

  .sidenav {
    display: block;
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
    padding-block: var(--s5);
  }
}

.side-label {
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 0 0 var(--s2);
  padding-left: var(--s3);
}

.side-group + .side-group { margin-top: var(--s4); }

.side-link {
  display: block;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: .32rem var(--s3);
  border-left: 2px solid transparent;
}

a.side-link:hover { color: var(--text); border-left-color: var(--text-muted); }

.side-link--active {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--accent);
}

.side-pending { cursor: default; }

/* ---------- text & links ---------- */

main { display: block; min-height: 60vh; }

a {
  color: var(--link);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

h1 {
  font-size: var(--step-3);
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: var(--s5) 0 var(--s3);
}

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

.muted { color: var(--text-muted); }

/* ---------- topic page ---------- */

.crumb {
  margin: var(--s5) 0 0;
  font-size: var(--step--1);
}

.crumb a {
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}

.crumb a:hover { color: var(--text); }

.crumb + h1 { margin-top: var(--s2); }

.oneliner {
  font-size: var(--step-1);
  line-height: 1.45;
  margin: 0 0 var(--s4);
  padding-left: var(--s3);
  border-left: 3px solid var(--accent);
}

.topic section h2, .home h2 {
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: var(--s5) 0 var(--s2);
}

.topic p, .topic li { max-width: 65ch; }

.topic ul { padding-left: 1.2rem; margin: 0; }

.topic li { margin-bottom: var(--s2); }

.topic li::marker { color: var(--accent); }

.topic strong { font-weight: 700; }

.numbers strong { color: var(--accent-text); }

.pending {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
  cursor: default;
}

.updated {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* ---------- search (task 08) ---------- */

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 15rem;
  margin-inline: var(--s3);
}

.search input {
  width: 100%;
  font: inherit;
  font-size: var(--step--1);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  min-height: 2.25rem;
}

.search input::placeholder { color: var(--text-muted); }

.search input:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + var(--s1));
  left: auto;
  right: 0;
  width: min(26rem, 88vw);
  z-index: 10;
  list-style: none;
  margin: 0;
  padding: var(--s1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
  max-height: min(24rem, 70vh);
  overflow-y: auto;
}

.search-results a {
  display: block;
  padding: var(--s2) var(--s3);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: var(--step--1);
}

.search-results a:hover,
.search-results li[aria-selected="true"] a { background: var(--border); }

.sr-context {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-empty {
  padding: var(--s2) var(--s3);
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* ---------- related block (task 08) ---------- */

.related-block .topic-list li:last-child { border-bottom: none; }

/* ---------- category page ---------- */

.topic-list {
  list-style: none;
  padding: 0;
  margin: var(--s4) 0 0;
}

.topic-list li {
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}

.topic-list a {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.topic-list a:hover { color: var(--link); }

.topic-list p {
  margin: var(--s1) 0 0;
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* ---------- homepage ---------- */

.hero {
  text-align: center;
  margin-top: var(--s6);
}

.hero-wordmark {
  font-size: clamp(2.7rem, 1.9rem + 4.5vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  margin: 0;
}

.hero-wordmark span { color: var(--accent-text); }

.hero-tagline {
  font-size: var(--step-2);
  font-weight: 600;
  margin: var(--s3) 0 0;
}

.hero-sub {
  font-size: var(--step-0);
  color: var(--text-muted);
  max-width: 46ch;
  margin: var(--s2) auto 0;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: var(--s6);
  border-top: 1px solid var(--border);
  padding-top: var(--s4);
  padding-bottom: var(--s5);
  font-size: var(--step--1);
  color: var(--text-muted);
}

/* ---------- category grid (homepage) ---------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--s3);
  margin-top: var(--s4);
}

.cat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--s4);
}

.cat-card h2 {
  margin: 0 0 var(--s1);
  font-size: var(--step-0);
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.cat-card h2 a { color: var(--text); text-decoration: none; }

.cat-card h2 a:hover { color: var(--link); }

.cat-intro {
  margin: 0 0 var(--s2);
  font-size: var(--step--1);
  color: var(--text-muted);
}

.cat-card ul { list-style: none; padding: 0; margin: 0 0 var(--s2); }

.cat-card li { font-size: var(--step--1); margin-bottom: var(--s1); }

.cat-count { margin: 0; font-size: var(--step--1); color: var(--text-muted); }

/* ---------- mobile polish (task 08): tap targets ≥44px ---------- */

@media (max-width: 45.99rem) {
  .header-row { position: relative; }
  .search { position: static; max-width: none; }
  .search input { min-height: 44px; }
  .search-results { left: var(--s4); right: var(--s4); width: auto; }
  .theme-toggle { min-height: 44px; min-width: 44px; }
  .tab { padding-block: .8rem calc(.8rem + 2px); }
}

@media (prefers-reduced-motion: no-preference) {
  .tab, a, .theme-toggle, .side-link { transition: color .12s ease, border-color .12s ease; }
}
