/* =========================================================
   ROOT VARIABLES
========================================================= */

:root {
  --neuro-stroke: #CAA7A7;
  --note: #E5D8CB;
  --note-hover: #E5D8CB;
}

:root[data-theme="dark"] {
  --neuro-stroke: #9FB7FF;    /* soft cortical blue highlight */
  --note: #1E293B;            /* slate navy panel (clean and modern) */
  --note-hover: #334155;      /* slightly lighter hover contrast */
}

/* =========================================================
   GLOBAL PAGE LAYOUT
========================================================= */

html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

main {
  flex: 1;
  background: linear-gradient(to bottom right, var(--panel-0), var(--panel-1));
}

/* Hide inactive brain layers */
.brain-svg-view { display: none; }
.brain-svg-view.active-view { display: block; }

/* =========================================================
   BRAIN DISPLAY CONTAINER
========================================================= */

.brain-container {
  background: linear-gradient(to bottom right, var(--panel-0), var(--panel-1));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 140px 0 20px;
  position: relative;
}

.brain-svg-wrapper { display: flex; justify-content: center; }

.svg-aligned-wrapper {
  position: relative;
  width: 700px;
  height: auto;
}

.svg-aligned-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
}

/* =========================================================
   BRAIN PATH BASE STYLE
========================================================= */

.animated-path {
  fill: var(--neuro-stroke);
  fill-opacity: 0;
  stroke: var(--neuro-stroke);
  stroke-width: 30;
  stroke-dasharray: 4000;
  stroke-dashoffset: 4000;
  opacity: 0;
  transform: scale(0.95);
  transform-origin: center;

  animation:
    drawAndFade 3s ease-in-out forwards,
    fillAfterStroke 1s ease-in 3.2s forwards;
}

@keyframes drawAndFade {
  to { stroke-dashoffset: 0; opacity: 1; transform: scale(1); }
}

@keyframes fillAfterStroke {
  to { fill-opacity: 1; }
}

/* =========================================================
   ORIENTATION: LATERAL
========================================================= */

.lateral-brain .animated-path {
  stroke-width: 8;
  transform: scale(0.98);

  animation:
    drawAndFadeLateral 3.5s ease-in-out forwards,
    fillAfterStrokeLateral 1s ease-in 3.6s forwards;
}

@keyframes drawAndFadeLateral {
  0% { stroke-dashoffset: 4000; opacity: 0; }
  50% { opacity: 0.8; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes fillAfterStrokeLateral {
  from { fill-opacity: 0; }
  to { fill-opacity: 0.5; }
}

/* =========================================================
   ORIENTATION: SAGITTAL
========================================================= */

.sagittal-brain .animated-path {
  stroke-width: 10;
  transform: scale(0.96);
  animation:
    drawAndFadeSagittal 4s ease-in-out forwards,
    fillAfterStrokeSagittal 1.2s ease-in 4.2s forwards;
}

@keyframes drawAndFadeSagittal {
  0% { stroke-dashoffset: 4000; opacity: 0; }
  40% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes fillAfterStrokeSagittal {
  from { fill-opacity: 0; }
  to { fill-opacity: 0.6; }
}

/* =========================================================
   ORIENTATION: CORONAL
========================================================= */

.coronal-brain .animated-path {
  stroke-width: 5;
  transform: scale(1);
  animation:
    drawAndFadeCoronal 5.5s ease-in-out forwards,
    fillAfterStrokeCoronal 1s ease-in 5.8s forwards;
}

@keyframes drawAndFadeCoronal {
  0% { stroke-dashoffset: 4000; opacity: 0; }
  40% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes fillAfterStrokeCoronal {
  from { fill-opacity: 0; }
  to { fill-opacity: 0.4; }
}

/* =========================================================
   ORIENTATION: DORSAL
========================================================= */

.dorsal-brain .animated-path {
  stroke-width: 10;
  fill-opacity: 0;
  animation:
    drawAndFadeDorsal 5s ease-in-out forwards,
    fillAfterStrokeDorsal 1.2s ease-in 5.3s forwards;
}

@keyframes drawAndFadeDorsal {
  0% { stroke-dashoffset: 4000; opacity: 0; }
  30% { opacity: 0.5; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes fillAfterStrokeDorsal {
  from { fill-opacity: 0; }
  to { fill-opacity: 0.3; }
}

/* =========================================================
   BRAIN REGION OVERLAY SHAPES
========================================================= */

.brain-overlay {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, filter 0.2s ease;
}

.brain-overlay:hover {
  filter: brightness(1.15);
}

.brain-overlay.sticky {
  opacity: 1 !important;
  filter: brightness(1.15);
  pointer-events: auto;
}

/* Individual Regions (unchanged) */

.vmPFC-area { top:33%; left:16%; width:13%; height:20%; background:rgba(181,194,202,.4); border-radius:50% 40% 60% 70% / 50% 60% 45% 65%; transform:rotate(-10deg) skewX(-4deg);}
.OFC-area   { top:51%; left:20%; width:14%; height:3%;  background:rgba(128,0,128,.4); border-radius:40% 25% 35% 50% / 50% 40% 60% 45%; }
.TPJ-area   { top:35%; left:70%; width:12%; height:14%; background:rgba(177,112,118,.4); }
.SMA-area   { top:30%; left:48%; width:12%; height:30%; background:rgba(218,165,32,.4); }
.VTA-area   { top:50%; left:52%; width:8%;  height:18%; background:rgba(0,128,128,.4); }
.NAcc-area  { top:40%; left:35%; width:8%;  height:7%;  background:rgba(255,140,0,.4); border-radius:45% 35% 50% 40%/55% 45% 35% 50%; }
.ACC-area   { top:30%; left:25%; width:15%; height:15%; background:rgba(139,99,159,.4); border-radius:50%; transform:rotate(-3deg); }
.PCC-area   { top:25%; left:60%; width:11%; height:15%; background:rgba(200,50,50,.4); border-radius:55% 60% 45% 50%/50% 55% 50% 60%; transform:rotate(-4deg) skewX(-2deg); }
.CN-area    { top:28%; left:57%; width:4%;  height:10%; background:rgba(255,165,0,.4); border-radius:60% 50% 50% 60%/55% 50% 45% 55%; transform:rotate(3deg) skewX(1deg); }
.Insula-area{ top:30%; left:70%; width:6%;  height:20%; background:rgba(128,0,32,.4); border-radius:60% 40% 70% 50%/50% 60% 40% 70%; }
.Amygdala-area { top:53%; left:34%; width:5%; height:5%; background:rgba(0,100,255,.4); }
.dlPFC-area { top:19%; left:22%; width:14%; height:16%; background:rgba(100,161,101,.4); border-radius:60% 50% 45% 65%/55% 60% 45% 55%; transform:rotate(-7deg) skewX(-4deg); }

/* =========================================================
   LABELS + ORIENTATION CONTROLLER
========================================================= */
.label {
  font-family: 'Georgia', serif;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  cursor: pointer;

  font-size: 14px;
  opacity: 0;
  transform: translateY(-20px);
  animation: slideDownElegant 0.8s ease-out forwards;
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .2s ease;
}

.label.active {
  background: rgba(16, 185, 129, 0.9) !important; 
  color: var(--text-4);
  border-color: var(--ink);
}

.label:hover {
  background: var(--ink);
  color: var(--text-4);
}

.label:active {
  transform: translateY(1px);
}


@keyframes slideDownElegant {
  0% { opacity: 0; transform: translateY(-40px); filter: blur(2px); }
  60% { opacity: 0.6; transform: translateY(10px); filter: blur(1px); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* label container */

.label-group {
  position: absolute;
  top: 20px;
  left: 20px;
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.label-group.active-labels {
  display: flex;
}

/* stagger labels */
.label-group .label:nth-child(1) { animation-delay: 0.2s; }
.label-group .label:nth-child(2) { animation-delay: 0.4s; }
.label-group .label:nth-child(3) { animation-delay: 0.6s; }
.label-group .label:nth-child(4) { animation-delay: 0.8s; }
.label-group .label:nth-child(5) { animation-delay: 1s; }

/* orientation buttons */

.brain-orientation-switcher {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 320px;
  z-index: 10;
}

@keyframes slideInElegant {
  0% { opacity: 0; transform: translateX(-80px); filter: blur(2px);}
  60% { opacity: 0.6; transform: translateX(10px); filter: blur(1px);}
  100%{ opacity: 1; transform: translateX(0); filter: blur(0);}
}
.orientation-btn {
  font-family: 'Georgia', serif;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: transparent;

  border: 1px solid var(--ink);
  border-radius: 6px;

  cursor: pointer;
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .2s ease;
  opacity: 0;
  transform: translateX(-80px);
  animation: slideInElegant 1s ease-out forwards;
}

.orientation-btn.active {
  background: rgba(16, 185, 129, 0.9) !important; 
  color: var(--text-4);
  border-color: var(--ink);
}

.orientation-btn:hover {
  background: var(--ink);
  color: var(--text-4);
}

.orientation-btn:active {
  transform: translateY(1px);
}


.orientation-btn:nth-child(1) { animation-delay: .2s; }
.orientation-btn:nth-child(2) { animation-delay: .4s; }
.orientation-btn:nth-child(3) { animation-delay: .6s; }
.orientation-btn:nth-child(4) { animation-delay: .8s; }



/* =========================================================
   REGION INFO PANEL
========================================================= */

.region-info {
  position: absolute;
  left: 0; top: 0; width: 100%; max-width: 600px;
  margin: 0 auto;
  padding: 0;
  opacity: 0;
  transform: translateY(10px);
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;

  background: var(--panel-gradient);
  border: 1.2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
  backdrop-filter: blur(10px);

  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    max-height 0.4s ease,
    padding 0.35s ease,
    margin 0.35s ease;
}

.region-info.visible {
  position: static;
  opacity: 1;
  transform: translateY(0);
  max-height: 500px;
  padding: 20px 24px;
  margin: 16px auto 40px;
  pointer-events: auto;
  overflow-y: auto;
}

.region-info h3 { font-size: 16px; margin-bottom: 12px; color: var(--ink); }

.region-description,
.region-papers li {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
}

.region-papers::before {
  content: "Relevant Papers:";
  display: block;
  
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-2, #555);
  
  /* Positioning */
  margin-bottom: 8px;
  margin-left: -20px; 
}

.region-papers { padding-left: 20px; margin-top: 10px; }

.paper-ref { font-weight: 500; margin-bottom: 10px; }
.paper-notes { font-size: 14px; line-height: 1.55; color: var(--ink-2,#555); margin: 12px 0 8px; }

.mini-label{
  display:block;
  font-size:12px;
  font-weight:600;
  letter-spacing:.02em;
  color: var(--ink-2, #555);
  margin:0 0 4px 0;
}

/* =========================================================
   NEUROECONOMICS SLIDE-IN PANEL
========================================================= */

#neuro-slide {
  z-index: 10;
  font-family: 'Georgia', serif;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: flex-end; 
  margin-right: 10px;
  margin-top: 10px;
}

#neuro-slide i { 

  color: var(--neuro-stroke);

}


#neuro-banner {
  position: relative; 
  background: var(--panel-0);
  border: 1px solid var(--neuro-stroke);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateX(100px);
  animation: slideInFromRight 1s ease forwards 1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: background .25s ease, color .25s ease, border-color .25s ease, transform .15s ease;
}

#neuro-banner:hover {
  background: var(--ink);
  color: var(--text-4);
  border-color: var(--neuro-stroke);
}

@keyframes slideInFromRight {
  to { opacity: 1; transform: translateX(0); }
}

#neuro-info {
  display: block;
  position: relative;
  background: var(--panel-0);
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;
  margin-left: 5px;
  font-size: 14px;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: unfurlSlide 0.4s ease forwards;
}

#neuro-info.is-collapsed { display: none; }

@keyframes unfurlSlide {
  from { opacity:0; transform: scaleY(.9) translateY(-10px);}
  to   { opacity:1; transform: scaleY(1) translateY(0);}
}

/* Close X button */
.neuro-close-x {
  position: absolute;
  top: 10px;
  right: 12px;

  background: none;
  border: none;

  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;

  color: var(--ink);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Hover effect */
.neuro-close-x:hover {
  opacity: 0.6;
  transform: scale(1.1);
}

/* =========================================================
   MOBILE RESPONSIVE
========================================================= */

@media (max-width: 600px) {

  .svg-aligned-wrapper { width: 90vw; max-width: 450px; }

  .label {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 8px;
  }

  .region-info {
    padding: 10px;
    margin: 20px auto;
    font-size: 12px;
    max-width: 60vw;
  }

  .orientation-btn {
    padding: 3px 7px;
    font-size: 10px;
  }

  .brain-orientation-switcher {
    top: 12px;
    left: 12px;
    gap: 6px;
    flex-wrap: wrap;
    top: 70px;           /* moves pills below icon bar */
    left: 12px;
    max-width: 100%;
    gap: 6px;
  }


  #neuro-banner {
    padding: 6px 10px;
    font-size: 12px;
    gap: 6px;
    border-radius: 8px;
  }

  #neuro-banner i { font-size: 14px; }
  #neuro-banner span { font-size: 12px; }

  #neuro-info {
    font-size: 12px;
    padding: 12px;
    max-height: 220px;
  }
  .neuro-close-x {
    top: 6px;
    right: 8px;
    font-size: 15px;
  }
}

  
.note-pop {
  position: absolute;
  z-index: 1000;
  max-width: 32ch;
  padding: .6rem .7rem;
  background: var(--panel-0);
  color: var(--text);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-m);
  border-radius: .5rem;
  font-size: .9rem;
  display: none;
}

.copy-cite {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  margin-left: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.12s ease;
}

.copy-cite:hover   { color: var(--accent-2); transform: scale(1.1); }
.copy-cite:active  { transform: scale(0.95); }
.copy-cite:focus-visible { outline: none; box-shadow: none; }
.copy-cite.copied { color: #2e7d32; }

.copy-cite i { pointer-events: none; }

/* Footnote formatting */
.footnotes li { display: list-item; }