/* WPTK.org — Brand system (Palette B: Midnight Modern) + Manrope
   Dark is the default. Light is opt-in via <html data-theme="light">.
*/

/* ===== Design Tokens ===== */
:root{
  /* Core palette (Dark) */
  --bg-0:#0B1220;      /* Midnight */
  --bg-1:#121B2E;      /* Deep Navy */
  --text-0:#F4F6F8;    /* Off-White */
  --text-1:#AAB4C2;    /* Steel */
  --line:#2A3443;      /* Slate */

  --accent-0:#2D5BFF;  /* Cobalt */
  --accent-1:#B14DFF;  /* Orchid */
  --accent-2:#1AA7A1;  /* Teal */

  /* Derived surfaces (Dark) */
  --surface: rgba(18, 27, 46, 0.78);
  --surface-2: rgba(18, 27, 46, 0.55);
  --surface-3: rgba(11, 18, 32, 0.70);

  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;

  --shadow: 0 20px 70px rgba(0,0,0,.35);
  --shadow-soft: 0 12px 38px rgba(0,0,0,.24);

  --maxw: 1280px;
  --gutter: clamp(18px, 2.5vw, 34px);

  --font: "Manrope", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Light mode (derived) */
:root[data-theme="light"]{
  --bg-0:#F7F9FC;      /* Paper Cool */
  --bg-1:#E9EDF4;      /* Mist Blue */
  --text-0:#0E1422;    /* Near-Black Navy */
  --text-1:#4A5568;    /* Graphite */
  --line:#D5DBE5;      /* Soft Slate */

  --accent-0:#2D5BFF;  /* Cobalt */
  --accent-1:#9E3EDC;  /* Orchid (tuned) */
  --accent-2:#138F8A;  /* Teal (tuned) */

  --surface: rgba(255,255,255,0.75);
  --surface-2: rgba(255,255,255,0.60);
  --surface-3: rgba(233,237,244,0.80);

  --shadow: 0 20px 70px rgba(6, 10, 18, .12);
  --shadow-soft: 0 12px 38px rgba(6, 10, 18, .10);
}

/* Wider layouts on large displays */
@media (min-width: 1500px){
  :root{ --maxw: 1360px; }
}

/* ===== Base ===== */
*{ box-sizing:border-box; }
html, body{ height:100%; }

body.wptk{
  margin:0;
  font-family: var(--font);
  font-size: 19px; /* increased readability */
  line-height: 1.6;
  color: var(--text-0);
  background-color: var(--bg-0);
  background-image:
    radial-gradient(900px 520px at 16% 10%, rgba(177,77,255,0.18) 0%, rgba(177,77,255,0) 60%),
    radial-gradient(1100px 600px at 82% 18%, rgba(26,167,161,0.16) 0%, rgba(26,167,161,0) 62%),
    radial-gradient(950px 520px at 64% 92%, rgba(45,91,255,0.14) 0%, rgba(45,91,255,0) 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 62%, rgba(0,0,0,0.55) 120%);
  background-attachment: fixed;
}

:root[data-theme="light"] body.wptk{
  background-image:
    radial-gradient(900px 520px at 18% 12%, rgba(158,62,220,0.12) 0%, rgba(158,62,220,0) 62%),
    radial-gradient(1100px 600px at 84% 20%, rgba(19,143,138,0.10) 0%, rgba(19,143,138,0) 62%),
    radial-gradient(950px 520px at 64% 92%, rgba(45,91,255,0.10) 0%, rgba(45,91,255,0) 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 70%);
}

a{ color: var(--text-0); text-underline-offset: 3px; }
a:hover{ color: var(--accent-0); }
a:focus-visible{
  outline: 2px solid var(--accent-0);
  outline-offset: 3px;
  border-radius: 10px;
}

.wptk-container{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px var(--gutter) 62px;
}

/* ===== Nav ===== */
.wptk-nav{
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid rgba(42,52,67,0.6);
  background: rgba(11, 18, 32, 0.72);
  backdrop-filter: blur(12px);
}
:root[data-theme="light"] .wptk-nav{
  background: rgba(247, 249, 252, 0.78);
  border-bottom: 1px solid rgba(213,219,229,0.9);
}

.wptk-nav__inner{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  gap: 14px;
}

.wptk-nav__brand{
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.12em;
  font-size: 14px;
  padding: 10px 10px 10px 0;
  color: var(--text-0);
}

.wptk-nav__burger{
  display: none;
  background: transparent;
  border: 1px solid rgba(42,52,67,0.75);
  color: var(--text-0);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
}
:root[data-theme="light"] .wptk-nav__burger{
  border-color: rgba(213,219,229,1);
}
.wptk-nav__burger-lines{
  display: inline-block;
  width: 18px;
  height: 12px;
  position: relative;
}
.wptk-nav__burger-lines::before,
.wptk-nav__burger-lines::after{
  content:"";
  position: absolute;
  left:0;
  right:0;
  height:2px;
  border-radius: 2px;
  background: var(--text-0);
}
.wptk-nav__burger-lines::before{ top: 2px; }
.wptk-nav__burger-lines::after{ bottom: 2px; opacity: .9; }

.wptk-nav__menu{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.wptk-nav__menu a{
  text-decoration: none;
  color: var(--text-1);
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(42,52,67,0.45);
  background: rgba(18,27,46,0.35);
}
:root[data-theme="light"] .wptk-nav__menu a{
  color: var(--text-1);
  border-color: rgba(213,219,229,0.95);
  background: rgba(255,255,255,0.55);
}
.wptk-nav__menu a:hover{
  color: var(--text-0);
  border-color: rgba(45,91,255,0.75);
  background: rgba(45,91,255,0.10);
}
.wptk-nav__menu a[aria-current="page"]{
  color: var(--text-0);
  border-color: rgba(45,91,255,0.95);
  background: rgba(45,91,255,0.16);
}

/* Theme toggle (industry-standard: persistent + accessible) */
.wptk-theme-toggle{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(42,52,67,0.75);
  background: rgba(18,27,46,0.35);
  color: var(--text-0);
  cursor: pointer;
}
:root[data-theme="light"] .wptk-theme-toggle{
  border-color: rgba(213,219,229,1);
  background: rgba(255,255,255,0.55);
}
.wptk-theme-toggle__track{
  width: 44px;
  height: 24px;
  border-radius: 999px;
  position: relative;
  background: rgba(42,52,67,0.8);
  border: 1px solid rgba(42,52,67,0.7);
}
:root[data-theme="light"] .wptk-theme-toggle__track{
  background: rgba(213,219,229,1);
  border-color: rgba(213,219,229,1);
}
.wptk-theme-toggle__thumb{
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--text-0);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transition: transform .18s ease, left .18s ease;
}
:root[data-theme="light"] .wptk-theme-toggle__thumb{
  background: var(--text-0);
  box-shadow: 0 6px 18px rgba(6,10,18,.15);
}
:root[data-theme="light"] .wptk-theme-toggle__thumb{
  /* thumb color remains text-0 (dark ink) in light mode */
}
:root[data-theme="light"] .wptk-theme-toggle__text{
  color: var(--text-0);
}
:root[data-theme="light"] body.wptk .wptk-theme-toggle__thumb{
  background: var(--text-0);
}
:root[data-theme="light"] body.wptk .wptk-theme-toggle__track{
  background: rgba(213,219,229,1);
}

:root[data-theme="light"] .wptk-theme-toggle__thumb{
  left: 23px;
}

.wptk-theme-toggle__text{
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-1);
}

/* Mobile nav */
@media (max-width: 900px){
  .wptk-nav__burger{ display: inline-flex; }
  .wptk-nav__menu{
    display: none;
    width: 100%;
    padding-top: 10px;
  }
  .wptk-nav.is-open .wptk-nav__menu{
    display: flex;
  }
  .wptk-nav__inner{
    flex-wrap: wrap;
  }
}

/* ===== Page structure ===== */
.page{
  margin-top: 18px;
}

.surface{
  background: var(--surface);
  border: 1px solid rgba(42,52,67,0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 22px;
}
:root[data-theme="light"] .surface{
  border-color: rgba(213,219,229,0.95);
}


h1, h2, h3{
  margin: 0 0 12px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h1{
  font-weight: 300;
  font-size: clamp(34px, 4vw, 50px);
  margin-bottom: 10px;
}
h2{
  font-weight: 500;
  font-size: 26px;
}
h3{
  font-weight: 500;
  font-size: 20px;
  color: var(--text-1);
}

p{ margin: 0 0 14px; color: var(--text-0); }
:root[data-theme="light"] p{ color: var(--text-0); }

hr{
  border: 0;
  border-top: 1px solid rgba(42,52,67,0.75);
  margin: 18px 0;
}
:root[data-theme="light"] hr{
  border-top-color: rgba(213,219,229,1);
}

/* ===== Index hub grid ===== */
.hub-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 18px 0 0;
}

.hub-card{
  text-decoration: none;
  display: block;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid rgba(42,52,67,0.65);
  box-shadow: 0 14px 36px rgba(0,0,0,.22);
  position: relative;
  overflow: hidden;
}
:root[data-theme="light"] .hub-card{
  border-color: rgba(213,219,229,1);
  box-shadow: 0 14px 36px rgba(6,10,18,.10);
}
.hub-card::before{
  content:"";
  position:absolute;
  inset: -1px;
  background: radial-gradient(520px 220px at 10% 20%, rgba(45,91,255,0.14), transparent 60%),
              radial-gradient(520px 220px at 92% 22%, rgba(177,77,255,0.12), transparent 60%);
  opacity: .9;
  pointer-events: none;
}
.hub-card:hover{
  border-color: rgba(45,91,255,0.95);
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: no-preference){
  .hub-card{ transition: transform .15s ease, border-color .15s ease; }
}

.hub-title{
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.01em;
  margin: 0 0 6px;
}
.hub-desc{
  margin: 0;
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Books / section cards ===== */
.wptk-section{
  background: var(--surface);
  border: 1px solid rgba(42,52,67,0.65);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow-soft);
  position: relative;
}
:root[data-theme="light"] .wptk-section{
  border-color: rgba(213,219,229,0.95);
}

.wptk-section::before{
  content:"";
  position:absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 999px;
  background: var(--accent-0);
}
.wptk-section[data-accent="1"]::before{ background: var(--accent-1); }
.wptk-section[data-accent="2"]::before{ background: var(--accent-2); }

.content .section{
  margin: 16px 0;
}

.wptk-section ul{
  margin: 10px 0 14px 22px;
  padding: 0;
}
.wptk-section li{
  margin: 8px 0;
}
.wptk-section ul ul{
  margin-top: 8px;
  margin-bottom: 10px;
  opacity: .98;
}
.wptk-section em a{
  font-weight: 600;
  color: var(--text-0);
}
.wptk-section em a:hover{
  color: var(--accent-0);
}

/* ===== Readable ordered lists (CFP + FBS) ===== */

/* CFP: treat each rule as a card with clear separation */
body.wptk-page--cfp ol.rules{
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  counter-reset: cfp;
}
body.wptk-page--cfp li.rule{
  counter-increment: cfp;
  background: var(--surface-2);
  border: 1px solid rgba(42,52,67,0.65);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  margin: 0 0 14px;
  box-shadow: 0 14px 36px rgba(0,0,0,.18);
  position: relative;
  overflow: hidden;
}
:root[data-theme="light"] body.wptk-page--cfp li.rule{
  border-color: rgba(213,219,229,1);
  box-shadow: 0 14px 36px rgba(6,10,18,.08);
}
body.wptk-page--cfp li.rule::before{
  content:"";
  position:absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 999px;
  background: var(--accent-0);
}
body.wptk-page--cfp li.rule:nth-child(3n+2)::before{ background: var(--accent-1); }
body.wptk-page--cfp li.rule:nth-child(3n)::before{ background: var(--accent-2); }

body.wptk-page--cfp li.rule::after{
  content: counter(cfp, decimal-leading-zero);
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-1);
  opacity: .75;
}
body.wptk-page--cfp li.rule h2{
  margin: 0 0 10px;
  font-size: 22px;
}
body.wptk-page--cfp li.rule p{
  margin: 0 0 12px;
  color: var(--text-0);
}
body.wptk-page--cfp li.rule p.note{
  color: var(--text-1);
  font-size: 14px;
  margin-top: 8px;
}

/* FBS: make lists easier to scan without turning the page into a wall of bullets */

/* ===== FBS list readability (indent + rhythm) ===== */
body.wptk-page--fbs main.panel ul,
body.wptk-page--fbs main.panel ol{
  margin: 14px 0 20px;
  padding: 0;
  list-style: none;
}

body.wptk-page--fbs main.panel ol{ counter-reset: wptk-ol; }

body.wptk-page--fbs main.panel ul li,
body.wptk-page--fbs main.panel ol li{
  position: relative;
  margin: 10px 0;
  padding: 12px 14px 12px 56px;
  border-radius: 14px;
  background: rgba(18,27,46,0.28);
  border: 1px solid rgba(42,52,67,0.45);
}

:root[data-theme="light"] body.wptk-page--fbs main.panel ul li,
:root[data-theme="light"] body.wptk-page--fbs main.panel ol li{
  background: rgba(255,255,255,0.60);
  border-color: rgba(213,219,229,1);
}

body.wptk-page--fbs main.panel ol li::before{
  counter-increment: wptk-ol;
  content: counter(wptk-ol) ".";
  position: absolute;
  left: 14px;
  top: 12px;
  width: 34px;
  text-align: right;
  color: var(--accent-0);
  font-weight: 700;
}

body.wptk-page--fbs main.panel ul li::before{
  content: "•";
  position: absolute;
  left: 22px;
  top: 10px;
  font-size: 22px;
  line-height: 1;
  color: var(--accent-2);
}

body.wptk-page--fbs main.panel ul li > *:first-child,
body.wptk-page--fbs main.panel ol li > *:first-child{
  margin-top: 0;
}
body.wptk-page--fbs main.panel ul li > *:last-child,
body.wptk-page--fbs main.panel ol li > *:last-child{
  margin-bottom: 0;
}


/* ===== Inline mono helper (used on Nuclear Semiotics page) ===== */
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  padding: 0.15em 0.35em;
  border-radius: 8px;
  background: rgba(18,27,46,0.35);
  border: 1px solid rgba(42,52,67,0.55);
  color: var(--text-0);
}
:root[data-theme="light"] .mono{
  background: rgba(233,237,244,0.7);
  border-color: rgba(213,219,229,1);
}


/* ===== Nuclear Semiotics page ===== */
body.wptk-page--nooclear .quick-links{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 16px 0 22px;
}
body.wptk-page--nooclear .quick-links a{
  display: block;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-0);
  background: rgba(18,27,46,0.28);
  border: 1px solid rgba(42,52,67,0.45);
}
body.wptk-page--nooclear .quick-links a:hover{
  border-color: rgba(45,91,255,0.75);
  transform: translateY(-1px);
}
body.wptk-page--nooclear article{
  padding: 14px 14px 16px;
  border-radius: 16px;
  background: rgba(18,27,46,0.22);
  border: 1px solid rgba(42,52,67,0.42);
  margin: 14px 0;
}
body.wptk-page--nooclear article h3{
  margin-top: 0;
}
:root[data-theme="light"] body.wptk-page--nooclear .quick-links a,
:root[data-theme="light"] body.wptk-page--nooclear article{
  background: rgba(255,255,255,0.60);
  border-color: rgba(213,219,229,1);
}


/* ===== Skip link ===== */
.skip-link{
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus{
  left: 16px;
  top: 16px;
  width: auto;
  height: auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-1);
  border: 1px solid rgba(42,52,67,0.6);
  color: var(--text-0);
  z-index: 9999;
}
:root[data-theme="light"] .skip-link:focus{
  border-color: rgba(213,219,229,1);
}

/* ===== Footer ===== */
footer{
  margin-top: 24px;
  color: var(--text-1);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ===== Misc legacy helpers ===== */
.marquee, .ticker{ display:none !important; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior: auto !important; }
  .hub-card{ transition: none !important; }
}


/* ===== Targeted Fixes (v6-clean) ===== */

/* FBS: restore real indentation and rhythm */
.wptk-page--fbs ul,
.wptk-page--fbs ol {
  padding-left: 2.5rem;
  margin-left: 0;
}

.wptk-page--fbs li {
  margin-bottom: 0.75rem;
}

.wptk-page--fbs .columns {
  column-gap: 3rem;
}

/* NOOCLEAR: quick links grid */
.wptk-page--nooclear .quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  justify-content: center;
  margin-bottom: 2rem;
}

.wptk-page--nooclear .quick-links a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  padding: 12px 14px;
  min-height: 48px;
}

/* NOOCLEAR: stronger heading color usage */
.wptk-page--nooclear h2 {
  color: var(--accent-0);
}

.wptk-page--nooclear h3 {
  color: var(--accent-1);
}



/* ===== Targeted Fixes (350-math) ===== */
.eq{
  padding: 14px 16px;
  margin: 10px 0 18px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid rgba(42,52,67,0.65);
  overflow-x: auto;
}
:root[data-theme="light"] .eq{
  border-color: rgba(213,219,229,1);
}
.eq .math{
  font-size: 0.98em;
}
.eq .mjx-container{
  margin: 0 !important;
}
