/* =========================================================
   Cannabis & the Brain — interactive 3D atlas
   Light "studio" theme · floating cards · custom cursor
   ========================================================= */
:root {
  /* palette shared with the About page: cream / navy / azure / sky / apricot */
  --bg: #aebfcf; /* muted sky studio */
  --bg-2: #9fb2c4;
  --card: #f7f2e4; /* cream, opaque: no backdrop blur needed */
  --card-solid: #faf6ea;
  --ink: #1c2a3a; /* navy ink */
  --ink-2: #2f4257;
  --muted: #64798f;
  --line: rgba(28, 42, 58, 0.12);
  --teal: #2d6ea3; /* azure — the primary accent */
  --thc: #c9603a; /* THC accent, terracotta */
  --cbd: #2b7d8c; /* CBD accent, deep teal */
  --accent: #2d6ea3;
  --navy: #1f4568;
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 18px 40px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.22);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}
* {
  box-sizing: border-box;
  margin: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.06;
  color: var(--ink);
}
button {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}

/* fixed 3D background */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}

/* film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}


/* ===== Loader ===== */
#loader {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  /* matches the About page's transition overlay so the screen carries over */
  background: #1f4568;
  transition:
    opacity 0.6s var(--ease),
    visibility 0.6s;
}
body.ready #loader {
  opacity: 0;
  visibility: hidden;
}
.loader-ring {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
  border: 2px solid rgba(250, 246, 234, 0.25);
  border-top-color: #faf6ea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loader-core p {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(250, 246, 234, 0.72);
  text-align: center;
}

/* shared floating card */
.card-float {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(0.9rem, 2vw, 1.4rem) clamp(1rem, 3vw, 2rem);
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: none;
}
.brand-text .t1 {
  font-weight: 800;
  font-size: 1.12rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.brand-text .t2 {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 600;
  transition:
    transform 0.2s var(--ease),
    color 0.2s var(--ease);
}
.btn-reset:hover {
  transform: translateY(-1px);
  color: var(--teal);
}
.btn-reset svg {
  width: 15px;
  height: 15px;
}

/* back to the About page — same pill treatment as Reset view */
.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.2s var(--ease),
    color 0.2s var(--ease);
}
.btn-back:hover {
  transform: translateY(-1px);
  color: var(--teal);
}
.btn-back svg {
  width: 15px;
  height: 15px;
}

/* ===== Scroll content ===== */
.scroll {
  position: relative;
  z-index: 3;
  pointer-events: none;
}
.scroll .card-float,
.scroll button,
.scroll a,
.scroll input {
  pointer-events: auto;
}

.section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(5rem, 10vh, 8rem) clamp(1.2rem, 4vw, 3.5rem);
}
.section.tight {
  min-height: auto;
}

/* hero */
.hero {
  align-items: flex-start;
}
.hero-card {
  max-width: 520px;
  padding: clamp(1.8rem, 3.5vw, 2.8rem);
}
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
}
.hero-card h1 {
  font-size: clamp(2.3rem, 5vw, 3.4rem);
  margin: 0.8rem 0 1rem;
}
.hero-card .sub {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--ink-2);
}
.search {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1.6rem;
  padding: 0.85rem 1.2rem;
  border-radius: 100px;
  background: var(--card-solid);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.search svg {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex: none;
}
.search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}
.search input::placeholder {
  color: var(--muted);
}
.scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.6rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
}
.scroll-cue .a {
  transition: transform 0.25s var(--ease);
}
.scroll-cue:hover .a {
  transform: translateY(3px);
}
.hero-legend {
  display: flex;
  gap: 1.4rem;
  margin-top: 1.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.hero-legend .lg {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}
.hero-legend .sw {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.hero-legend .sw.thc {
  background: var(--thc);
}
.hero-legend .sw.cbd {
  background: var(--cbd);
}

/* regions section */
.sec-head {
  max-width: 520px;
  margin-bottom: 1.6rem;
  padding: clamp(1.4rem, 3vw, 2rem);
}
.sec-head h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}
.sec-head p {
  margin-top: 0.7rem;
  color: var(--ink-2);
  font-size: 1.05rem;
  line-height: 1.55;
}
.region-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  max-width: 560px;
}
.rcard {
  text-align: left;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  transition:
    transform 0.28s var(--ease),
    box-shadow 0.28s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rcard:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.rcard.hide {
  display: none;
}
.rcard-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.rcard-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent);
  background: var(--c);
}
.rcard h3 {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.rcard .fn {
  font-size: 0.8rem;
  color: var(--muted);
}
.rcard .go {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* note section */
.note-card {
  max-width: 560px;
  padding: clamp(1.8rem, 3.5vw, 2.6rem);
}
.note-card h2 {
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
}
.note-card p {
  margin-top: 1rem;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--ink-2);
}
.note-legend {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1.6rem;
}
.note-legend .row {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}
.note-legend .tag {
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 7px;
  font-size: 0.78rem;
  flex: none;
}
.note-legend .tag.thc {
  background: color-mix(in srgb, var(--thc) 18%, transparent);
  color: var(--thc);
}
.note-legend .tag.cbd {
  background: color-mix(in srgb, var(--cbd) 18%, transparent);
  color: var(--cbd);
}
.note-legend .row span {
  font-size: 0.94rem;
  color: var(--ink-2);
}

/* footer */
.foot {
  margin: 0 clamp(1.2rem, 4vw, 3.5rem) 1.5rem;
  padding: 1.4rem 1.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  align-items: center;
}
.foot span {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ===== Tooltip ===== */
#tooltip {
  position: fixed;
  z-index: 45;
  transform: translate(-50%, -160%);
  padding: 0.35rem 0.75rem;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#tooltip.show {
  opacity: 1;
}

/* ===== Floating info panel (right) ===== */
.panel {
  position: fixed;
  z-index: 50;
  top: clamp(76px, 9vh, 96px);
  right: clamp(0.8rem, 2vw, 1.6rem);
  width: min(400px, 92vw);
  max-height: calc(100vh - clamp(76px, 9vh, 96px) - 1.4rem);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.5rem, 2.5vw, 2rem);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  opacity: 0;
  transform: translateX(24px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.4s var(--ease),
    transform 0.4s var(--ease);
}
.panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.panel::-webkit-scrollbar {
  width: 8px;
}
.panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}
.panel-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: 0.2s var(--ease);
}
.panel-close:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.panel-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}
.panel-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent);
}
.panel-head h2 {
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  margin: 0.55rem 0 1.1rem;
}

/* CB1 meter */
.cb1 {
  margin-bottom: 1.3rem;
}
.cb1-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
}
.cb1-label {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.cb1-val {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--accent);
}
.cb1-track {
  height: 7px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.cb1-fill {
  height: 100%;
  width: 0%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.8s var(--ease);
}

/* tabs */
.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--line);
}
.tab {
  flex: 1;
  padding: 0.58rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  transition: 0.22s var(--ease);
}
.tab:hover {
  color: var(--ink);
}
.tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.tab-thc.is-active {
  background: var(--thc);
  color: #fff;
}
.tab-cbd.is-active {
  background: var(--cbd);
  color: #fff;
}
.tab-body {
  margin-top: 1.2rem;
}
.tab-body p {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink-2);
  animation: fade 0.35s var(--ease);
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.panel-foot {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.foot-note {
  font-size: 0.76rem;
  color: var(--muted);
}

/* ===== Responsive ===== */
@media (max-width: 880px) {
  .region-grid {
    grid-template-columns: 1fr;
    max-width: 420px;
  }
  .panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 72vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(24px);
  }
  .panel.open {
    transform: none;
  }
  .topbar .legend {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.12ms !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* per-organ sources, so every claim in the panel is checkable */
.panel-sources {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.panel-sources a {
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(28, 42, 58, 0.25);
}
.panel-sources a:hover {
  color: var(--azure);
  text-decoration-color: currentColor;
}
