/* NeuroScience Decoded — a WordPress-style magazine theme on top of Tailwind's Play CDN.
   Top bar, centred masthead, sticky glass primary menu with a Topics mega-menu, content + right
   sidebar widgets, footer widget area; long-form article typography with "make it simple"
   callouts; and motion primitives (neural background, reveals, parallax, reading progress,
   lightbox, marquee) driven by js/neuroscience.js. */

:root {
  --line: #e3e3f0;
  --ink: #1b1940;
  --cortex: #4f46e5;
  --cortex-deep: #3730a3;
  --spark: #db2777;
  --signal: #0d9488;
  --amber: #f59e0b;
  --mist: #f5f5ff;
  --shadow-soft: 0 18px 44px -24px rgba(49, 46, 129, .45);
  --shadow-glow: 0 0 0 1px rgba(99, 102, 241, .18), 0 22px 50px -26px rgba(79, 70, 229, .55);
  --ease-silk: cubic-bezier(.22, 1, .36, 1);
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; overflow-x: hidden; scroll-padding-top: 5rem; }
body {
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  max-width: 100vw;
  background-image:
    radial-gradient(48rem 28rem at 85% -10%, rgba(219, 39, 119, .10), transparent 70%),
    radial-gradient(44rem 26rem at -8% 6%, rgba(79, 70, 229, .13), transparent 70%),
    radial-gradient(40rem 30rem at 50% 110%, rgba(13, 148, 136, .08), transparent 70%);
  background-attachment: fixed;
  background-repeat: no-repeat;
}
h1:focus, h2:focus, [tabindex="-1"]:focus { outline: none; }
::selection { background: #fbcfe8; color: #1b1940; }

.font-display { font-family: "Space Grotesk", Inter, system-ui, sans-serif; letter-spacing: -.01em; }
.font-mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ------------------------------------------------------------------ masthead */
.masthead-title {
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1;
  word-break: break-word;
  background: linear-gradient(100deg, #312e81 0%, #4f46e5 38%, #db2777 72%, #0d9488 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: masthead-shift 14s ease-in-out infinite alternate;
}
@keyframes masthead-shift { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
.masthead-rule { height: 1px; background: linear-gradient(90deg, transparent, rgba(79, 70, 229, .55), rgba(219, 39, 119, .45), transparent); }
.kicker {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cortex);
}

/* ------------------------------------------------------------------ sticky primary menu */
.primary-nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .3s var(--ease-silk), background .3s ease;
}
.primary-nav.scrolled { box-shadow: 0 10px 30px -18px rgba(30, 27, 75, .45); background: rgba(255, 255, 255, .92); }
.menu-link {
  position: relative;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .9rem .25rem;
  font-size: .86rem; font-weight: 600;
  color: #2a2754;
  white-space: nowrap;
  transition: color .18s ease;
}
.menu-link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .55rem; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--cortex), var(--spark));
  transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease-silk);
}
.menu-link:hover, .menu-link.active { color: var(--cortex); }
.menu-link:hover::after, .menu-link.active::after { transform: scaleX(1); }

/* mega-menu (a <details> so it works without JS) */
.mega { position: relative; }
.mega > summary { list-style: none; cursor: pointer; }
.mega > summary::-webkit-details-marker { display: none; }
.mega[open] > summary svg { transform: rotate(180deg); }
.mega > summary svg { transition: transform .2s ease; }
.mega-panel {
  position: absolute; left: 50%; top: calc(100% + 1px); transform: translateX(-38%);
  width: min(56rem, 92vw);
  border: 1px solid var(--line); border-radius: 1.1rem; background: #fff;
  box-shadow: 0 30px 70px -30px rgba(30, 27, 75, .55);
  padding: 1rem; animation: mega-in .22s var(--ease-silk);
}
@keyframes mega-in { from { opacity: 0; transform: translate(-38%, -6px); } to { opacity: 1; transform: translate(-38%, 0); } }
.mega-item { display: flex; align-items: center; gap: .6rem; border-radius: .7rem; padding: .55rem .7rem; font-size: .86rem; color: #2a2754; transition: background .15s ease, color .15s ease; }
.mega-item:hover { background: var(--mist); color: var(--cortex); }
.mega-dot { height: .6rem; width: .6rem; flex-shrink: 0; border-radius: 999px; }

/* mobile drawer — CSS only: a hidden #nav-toggle checkbox, <label>s as the buttons, and
   `:checked ~` sibling rules. js/nav.js only adds Escape / link-tap closing and aria sync. */
.nav-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nav-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 18, 47, .45);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.nav-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(20rem, 88vw); overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-left: 1px solid var(--line); box-shadow: -30px 0 60px -30px rgba(30, 27, 75, .55);
  padding: 1rem 1.1rem 2rem;
  transform: translateX(100%); visibility: hidden;
  transition: transform .3s var(--ease-silk), visibility 0s linear .3s;
}
.nav-toggle:checked ~ .nav-backdrop { opacity: 1; pointer-events: auto; }
.nav-toggle:checked ~ .nav-drawer { transform: none; visibility: visible; transition: transform .3s var(--ease-silk); }
body:has(.nav-toggle:checked) { overflow: hidden; }
.hb-btn:focus-visible { outline: 2px solid var(--cortex); outline-offset: 2px; }
.mobile-link { display: block; padding: .7rem .25rem; font-weight: 600; color: #2a2754; border-bottom: 1px solid var(--line); }
@media (min-width: 1024px) { .mobile-menu, .nav-backdrop, .nav-drawer { display: none !important; } }

/* ------------------------------------------------------------------ search */
.search-input {
  width: 100%; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  padding: .5rem .9rem .5rem 2.2rem; font-size: .85rem; color: var(--ink); outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-input:focus { border-color: #a5b4fc; box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }

/* ------------------------------------------------------------------ cards */
.post-card {
  position: relative; overflow: hidden; border-radius: 1.1rem; border: 1px solid var(--line); background: #fff;
  transition: transform .45s var(--ease-silk), box-shadow .45s var(--ease-silk), border-color .45s var(--ease-silk);
}
.post-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-glow); border-color: #c7d2fe; }
.post-card .post-thumb { overflow: hidden; position: relative; }
.post-card .post-thumb img { transition: transform .7s var(--ease-silk); }
.post-card:hover .post-thumb img { transform: scale(1.07); }
.post-card .post-thumb::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(20, 18, 47, .35));
  opacity: 0; transition: opacity .4s ease;
}
.post-card:hover .post-thumb::after { opacity: 1; }
.cat-chip { display: inline-block; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .64rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--cortex); }

/* difficulty badges */
.lvl { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .14rem .55rem; font-size: .66rem; font-weight: 700; letter-spacing: .04em; border: 1px solid transparent; white-space: nowrap; }
.lvl::before { content: ""; height: .42rem; width: .42rem; border-radius: 999px; background: currentColor; }
.lvl-beginner { color: #0f766e; background: #f0fdfa; border-color: #99f6e4; }
.lvl-intermediate { color: #4338ca; background: #eef2ff; border-color: #c7d2fe; }
.lvl-advanced { color: #be185d; background: #fdf2f8; border-color: #fbcfe8; }
.lvl-simple { color: #0f766e; background: #f0fdfa; border-color: #99f6e4; }
.lvl-in-depth { color: #4338ca; background: #eef2ff; border-color: #c7d2fe; }

/* ------------------------------------------------------------------ sidebar widgets */
.widget {
  border-radius: 1.1rem; border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f8f8ff);
  padding: 1.35rem; box-shadow: 0 12px 30px -26px rgba(30, 27, 75, .55);
}
.widget h2 { font-family: "Space Grotesk", Inter, sans-serif; letter-spacing: -.01em; }
.widget .widget-accent { width: 2.25rem; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--cortex), var(--spark)); }
.tag-pill {
  display: inline-block; border-radius: 999px; border: 1px solid #d6d8f5; background: #fff;
  padding: .28rem .7rem; font-size: .72rem; color: #3730a3;
  transition: background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease;
}
.tag-pill:hover { background: var(--cortex); color: #fff; transform: translateY(-2px); border-color: var(--cortex); }

/* ------------------------------------------------------------------ hero */
.hero-wrap { position: relative; overflow: hidden; border-radius: 1.6rem; isolation: isolate; }
.hero-art { position: absolute; inset: -14% 0; width: 100%; height: 128%; object-fit: cover; will-change: transform; }
.hero-veil { position: absolute; inset: 0; background: linear-gradient(to top, rgba(20, 18, 47, .94) 4%, rgba(20, 18, 47, .45) 50%, rgba(20, 18, 47, .1) 85%); }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .7; pointer-events: none; }
.hero-grain {
  position: absolute; inset: 0; opacity: .45; mix-blend-mode: overlay; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}
.btn-primary { display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; padding: .55rem 1.1rem; font-size: .8rem; font-weight: 700; color: #fff; background: linear-gradient(90deg, var(--cortex), var(--spark)); box-shadow: 0 10px 24px -12px rgba(219, 39, 119, .7); transition: transform .2s ease, box-shadow .2s ease; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(219, 39, 119, .75); }
.btn-ghost { display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; padding: .55rem 1.1rem; font-size: .8rem; font-weight: 600; color: #fff; background: rgba(255, 255, 255, .14); backdrop-filter: blur(6px); transition: background .2s ease; }
.btn-ghost:hover { background: rgba(255, 255, 255, .26); }

/* neural background canvas */
#neural-bg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; opacity: .55; }
@media (prefers-reduced-motion: reduce) { #neural-bg { display: none; } }

/* ------------------------------------------------------------------ scroll reveal */
[data-reveal] { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease-silk), transform .8s var(--ease-silk); transition-delay: var(--reveal-delay, 0ms); will-change: opacity, transform; }
[data-reveal="left"] { transform: translateX(-38px); }
[data-reveal="right"] { transform: translateX(38px); }
[data-reveal="zoom"] { transform: scale(.94); }
[data-reveal="float"] { transform: translateY(46px) rotate(-1.5deg); }
[data-reveal].in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-reveal] { opacity: 1 !important; transform: none !important; } }

/* ------------------------------------------------------------------ reading progress / to top / lightbox */
#readbar { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 90; background: linear-gradient(90deg, var(--cortex), var(--spark), var(--signal)); box-shadow: 0 0 14px rgba(219, 39, 119, .55); transition: width .12s linear; }
#totop {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 80; height: 2.9rem; width: 2.9rem; display: grid; place-items: center;
  border-radius: 999px; color: #fff; background: linear-gradient(135deg, var(--cortex), var(--spark)); box-shadow: var(--shadow-soft);
  opacity: 0; transform: translateY(14px) scale(.8); pointer-events: none; transition: opacity .3s var(--ease-silk), transform .3s var(--ease-silk);
}
#totop.show { opacity: 1; transform: none; pointer-events: auto; }
#totop:hover { transform: translateY(-3px); }
#lightbox { position: fixed; inset: 0; z-index: 120; display: none; align-items: center; justify-content: center; padding: 5vw; background: rgba(20, 18, 47, .88); backdrop-filter: blur(6px); }
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: 90vh; border-radius: 1rem; background: #fff; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7); transform: scale(.95); transition: transform .28s var(--ease-silk); }
#lightbox.open img { transform: scale(1); }

/* ------------------------------------------------------------------ marquee */
.marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.marquee__track { display: inline-flex; gap: 2.2rem; white-space: nowrap; font-family: "Space Grotesk", Inter, sans-serif; font-weight: 500; animation: marquee 48s linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee__track { animation: none; } }
.stat-num { font-variant-numeric: tabular-nums; font-family: "Space Grotesk", Inter, sans-serif; }

/* ------------------------------------------------------------------ long-form article body */
.article-body { font-size: 1.07rem; line-height: 1.82; color: #23214a; overflow-wrap: break-word; }
.article-body > * + * { margin-top: 1.15rem; }
.article-body h2 {
  font-family: "Space Grotesk", Inter, sans-serif; font-size: 1.55rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.25;
  margin-top: 2.6rem; margin-bottom: .3rem; color: var(--ink); padding-top: 1.3rem; border-top: 1px solid var(--line); clear: both;
}
.article-body h2::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 999px; margin-right: .6rem; vertical-align: middle; background: linear-gradient(135deg, var(--cortex), var(--spark)); box-shadow: 0 0 0 4px rgba(99, 102, 241, .12); }
.article-body strong { color: #1b1940; font-weight: 700; }
.article-body .lead { font-size: 1.28rem; line-height: 1.6; font-weight: 500; color: #312e81; }
.article-body figure { margin: 1.9rem 0; }
.article-body figure img { width: 100%; border-radius: 1rem; border: 1px solid var(--line); cursor: zoom-in; background: #fff; }
.article-body figcaption { font-size: .9rem; color: #5b5d85; margin-top: .55rem; }
.figure-diagram img { box-shadow: var(--shadow-soft); }
.drop-cap::first-letter { float: left; font-family: "Space Grotesk", Inter, sans-serif; font-size: 3.6rem; font-weight: 700; line-height: .8; padding: .4rem .55rem 0 0; color: var(--spark); }
.float-fig { margin: .4rem 0 1.4rem; }
@media (min-width: 900px) {
  .float-fig.right { float: right; width: 19rem; margin: .3rem 0 1.1rem 2rem; }
  .float-fig.left { float: left; width: 19rem; margin: .3rem 2rem 1.1rem 0; }
}

/* "make it simple" callouts */
.plain-box {
  position: relative; overflow: hidden; border-radius: 1.2rem; padding: 1.3rem 1.4rem 1.3rem 1.4rem;
  background: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 100%); border: 1px solid #dcdcfe;
}
.plain-box::after { content: ""; position: absolute; right: -2.5rem; top: -2.5rem; width: 8rem; height: 8rem; border-radius: 999px; background: radial-gradient(circle, rgba(219, 39, 119, .22), transparent 70%); }
.example-card { border-radius: 1.1rem; border: 1px solid var(--line); background: #fff; padding: 1.15rem 1.25rem; transition: transform .3s var(--ease-silk), box-shadow .3s var(--ease-silk); }
.example-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); }
.example-kind { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .64rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; border-radius: 999px; padding: .2rem .6rem; }
.kind-analogy { color: #4338ca; background: #eef2ff; }
.kind-try-it { color: #0f766e; background: #f0fdfa; }
.kind-real-world { color: #b45309; background: #fffbeb; }
.kind-picture-it { color: #be185d; background: #fdf2f8; }
.kind-by-the-numbers { color: #6d28d9; background: #f5f3ff; }
.takeaways { border-radius: 1.1rem; background: #14122f; color: #e9e8ff; padding: 1.3rem 1.4rem; }
.takeaways li { position: relative; padding-left: 1.7rem; }
.takeaways li + li { margin-top: .55rem; }
.takeaways li::before { content: "✓"; position: absolute; left: 0; top: 0; font-weight: 800; color: #5eead4; }
.concept-chip { display: inline-flex; align-items: center; gap: .45rem; border-radius: .8rem; border: 1px solid var(--line); background: #fff; padding: .45rem .75rem; font-size: .84rem; font-weight: 600; color: #2a2754; transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.concept-chip:hover { border-color: #a5b4fc; transform: translateY(-2px); box-shadow: 0 10px 20px -14px rgba(79, 70, 229, .6); color: var(--cortex); }
.video-box { border-radius: 1.2rem; border: 1px solid var(--line); background: linear-gradient(135deg, #fff 0%, #fff5f6 100%); padding: 1.3rem 1.4rem; }
.search-phrase { display: inline-flex; align-items: center; gap: .45rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; padding: .45rem .85rem; font-size: .86rem; font-weight: 600; color: #2a2754; cursor: copy; transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.search-phrase:hover { border-color: #fda4af; transform: translateY(-2px); box-shadow: 0 10px 20px -14px rgba(225, 29, 72, .6); }
.toc a { display: block; border-left: 2px solid var(--line); padding: .25rem 0 .25rem .8rem; font-size: .84rem; color: #4b4d75; transition: border-color .2s ease, color .2s ease; }
.toc a:hover, .toc a.current { border-color: var(--spark); color: var(--cortex); }

img.img-fallback { object-fit: cover; background: #e0e7ff; }

