/* =========================================================================
   Campus Questionnaire — scrollytelling
   OU crimson & cream theme
   ========================================================================= */
:root {
  --crimson: #841617;
  --crimson-d: #5e0f10;
  --crimson-l: #b34a3f;
  --cream: #fbf6e9;
  --cream-2: #f3ecd7;
  --paper: #fffdf6;
  --ink: #241f1d;
  --muted: #6f655c;
  --line: #e3d9c2;
  --gold: #c8a85a;

  /* 5-step diverging rating scale (negative -> positive) */
  --r1: #8c1d18; /* poor / strongly disagree   */
  --r2: #cf7b5c; /* below avg / somewhat dis.   */
  --r3: #e3d6bb; /* average / neutral           */
  --r4: #7fae93; /* good / somewhat agree       */
  --r5: #2f7d5b; /* excellent / strongly agree  */
  --na: #d8cfbf;

  --maxw: 1180px;
  --shadow: 0 10px 30px rgba(60, 30, 10, 0.10);

  /* fonts — change in one place */
  --font-head: "Arimo", Arial, sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; background: var(--cream); }

/* ---- campus linework background (opt-in via <body class="campus-bg-on">) ---- */
body.campus-bg-on { background: transparent; }   /* reveal the fixed layer below */
body.campus-bg-on #campus-bg { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; background: var(--cream); } /* base color beneath the linework — reads the (themeable) --cream */
body.campus-bg-on #campus-bg svg { position: absolute; top: 0; will-change: transform; } /* opacity set in js/background.js (OPACITY const) */
body.campus-bg-on #campus-bg :is(path, polygon, polyline, line, rect) {
  stroke: #8a7c63 !important; stroke-width: .8px !important;
  fill: none !important; vector-effect: non-scaling-stroke;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.1;
  color: var(--crimson-d);
}

a { color: var(--crimson); }

/* progress bar ---------------------------------------------------------- */
#progress {
  position: fixed; top: 0; left: 0; height: 4px; width: 0%;
  background: linear-gradient(90deg, var(--crimson), var(--gold));
  z-index: 200; transition: width .12s linear;
}

/* section nav ----------------------------------------------------------- */
#nav {
  position: fixed; top: 50%; right: 14px; transform: translateY(-50%);
  z-index: 150; display: flex; flex-direction: column; gap: 6px;
}
#nav a {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(132, 22, 23, .42); background: transparent;
  transition: all .18s; position: relative;
}
#nav a svg { width: 19px; height: 19px; }
#nav a:hover { color: var(--crimson); background: rgba(132, 22, 23, .09); }
#nav a.active { color: #fff; background: var(--crimson); box-shadow: var(--shadow); }
#nav a span {
  position: absolute; right: 42px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: 12px; color: var(--crimson-d);
  background: var(--paper); padding: 2px 8px; border-radius: 4px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s;
}
#nav a:hover span { opacity: 1; }

/* ===================== HERO ============================================ */
.hero {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
  padding: 6vh 24px; position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(132,22,23,.12), transparent 60%),
    var(--cream);
}
.hero__kicker {
  font-size: 15px; color: var(--crimson); font-weight: 700; margin-bottom: 22px;
}
.hero h1 { font-size: clamp(40px, 8vw, 92px); margin: 0 0 18px; max-width: 14ch; }
.hero__sub { font-size: clamp(18px, 2.4vw, 24px); color: var(--muted); max-width: 60ch; margin: 0 auto; }
.hero__stat { margin-top: 46px; }
.hero__num {
  font-family: var(--font-head); font-size: clamp(64px, 12vw, 150px);
  color: var(--crimson); line-height: 1; font-weight: 600;
}
.hero__num small { font-size: .26em; color: var(--muted); display: block; margin-top: 10px; font-family: var(--font-body); font-weight: 600; }
.scroll-cue { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 13px; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%,100%{transform:translate(-50%,0)} 50%{transform:translate(-50%,8px)} }

/* ===================== SECTION INTROS ================================= */
.section-intro {
  max-width: 760px; margin: 0 auto; padding: 22vh 24px 8vh; text-align: center;
}
.section-intro .eyebrow {
  font-size: 15px; color: var(--crimson); font-weight: 700; margin-bottom: 14px;
}
.section-intro h2 { font-size: clamp(32px, 5vw, 54px); margin: 0 0 18px; }
.section-intro p { font-size: 20px; color: #4a423a; } /* darker than --muted for contrast over the linework bg */

/* ===================== SCROLLY ======================================== */
.scrolly {
  position: relative; max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: 42% 58%; gap: 24px;
}
.scrolly[data-side="left"] { grid-template-columns: 58% 42%; }
.scrolly[data-side="left"] .scrolly__graphic { order: -1; }

.scrolly__steps { position: relative; z-index: 2; }
.step {
  min-height: 70vh; display: flex; align-items: center;
  margin: 0 0 8vh;
}
.step:first-child { padding-top: 12vh; }
.step:last-child { margin-bottom: 28vh; }
.step__card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px 28px; box-shadow: var(--shadow);
  transition: opacity .35s, transform .35s; opacity: .35; transform: translateY(8px);
}
.step.is-active .step__card { opacity: 1; transform: none; border-color: rgba(132,22,23,.25); }
.step__card h3 { font-size: 24px; margin: 0 0 10px; }
.step__card p { margin: 0 0 12px; }
.step__card p:last-child { margin-bottom: 0; }
.step__card .big { font-size: 40px; font-family: var(--font-head); color: var(--crimson); font-weight: 600; line-height: 1; }
.step__card .tag { display: inline-block; font-size: 13px; text-transform: capitalize; color: var(--crimson); font-weight: 700; margin-bottom: 10px; }
mark { background: rgba(200, 169, 90, 0); color: inherit; padding: 0 3px; border-radius: 3px; }

.scrolly__graphic { position: relative; }
.scrolly__graphic-inner {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  justify-content: center; align-items: stretch;
}
.viz {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 24px; width: 100%;
  max-height: 86vh; overflow: hidden; display: flex; flex-direction: column;
}
/* story graphics fill the sticky pane so flex children (incl. the map) get real height */
.scrolly__graphic-inner .viz { height: 86vh; }
.viz__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.viz__head-main { min-width: 0; }
.viz__aff { flex: 0 0 auto; text-align: right; }
.viz__aff:empty { display: none; }
.viz__aff label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-family: var(--font-body); font-weight: 600; }
.viz__aff select {
  font-family: var(--font-body); font-size: 13px; color: var(--ink); cursor: pointer;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--cream); max-width: 170px;
}
.viz__aff select:focus { outline: 2px solid var(--crimson-l); }
.viz__title { font-family: var(--font-head); font-size: 20px; color: var(--crimson-d); margin: 0 0 2px; }
.viz__sub { font-size: 13px; color: var(--muted); margin: 0 0 14px; min-height: 18px; }
.viz__note { font-size: 13px; color: var(--crimson-d); background: rgba(200,168,90,.16); padding: 8px 12px; border-radius: 6px; margin-top: 12px; min-height: 0; opacity: 0; transition: opacity .3s; }
.viz__note.show { opacity: 1; }
.viz__body { flex: 1; min-height: 0; position: relative; }
.viz__colhead { position: absolute; right: 0; width: 60px; text-align: center;
  font-size: 10px; line-height: 1.1; font-weight: 700; color: #2f7d5b; pointer-events: none;
  opacity: 0; transition: opacity .3s ease; }

/* chart bits */
.bar-row { font-size: 14px; }
.bar-label { fill: var(--ink); font-size: 13px; }
.bar-val { fill: var(--muted); font-size: 12px; }
svg text { font-family: var(--font-body); }
.axis line, .axis path { stroke: var(--line); }
.axis text { fill: var(--muted); font-size: 11px; }
.zero-line { stroke: var(--muted); stroke-dasharray: 2 3; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ===================== MAP ============================================ */
#map { width: 100%; height: 86vh; border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.map-legend { background: var(--paper); padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; }
.map-legend b { display:block; margin-bottom:4px; color: var(--crimson-d); font-family: var(--font-head); }
.map-legend .dot { display:inline-block; width:11px; height:11px; border-radius:50%; margin-right:6px; vertical-align:middle; }
.leaflet-popup-content { font-family: var(--font-body); font-size: 14px; }
.leaflet-popup-content .aff { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
/* card header: title (left) + affiliation filter (right) */
.map-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 18px 10px; }  /* no wrap: the title/subtitle text wraps, the filter stays on the right */
.map-head .viz__title, .map-head .viz__sub { padding: 0; }
.map-head__main { flex: 1 1 auto; min-width: 0; }   /* let the title/subtitle text wrap, keep the filter on the right */
.map-filter { flex: 0 0 auto; text-align: right; margin-top: 3px; }
.map-filter label { display: block; margin-bottom: 3px; color: var(--muted);
  font-size: 11px; font-family: var(--font-body); font-weight: 600; }
.map-filter select {
  font-family: var(--font-body); font-size: 14px; color: var(--ink); cursor: pointer;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--cream);
  max-width: 190px;
}
.map-filter select:focus { outline: 2px solid var(--crimson-l); }

/* ===================== QUOTES ========================================= */
.quotes { max-width: var(--maxw); margin: 0 auto; padding: 6vh 24px 10vh; }
.quotes h2 { text-align: center; font-size: clamp(30px, 5vw, 48px); margin-bottom: 8px; }
.quotes__sub { text-align: center; color: var(--muted); margin-bottom: 24px; max-width: 70ch; margin-left: auto; margin-right: auto; }

/* "one big change" topic bars (clickable to browse responses) */
.change-filter { max-width: 760px; margin: 0 auto 12px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.change-filter label { font-size: 13px; color: var(--muted); }
.change-filter select {
  font-family: var(--font-body); font-size: 14px; color: var(--ink); cursor: pointer;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper);
}
.change-filter select:focus { outline: 2px solid var(--crimson-l); }
.topics { max-width: 760px; margin: 0 auto; display: grid; gap: 4px; }
.topic { display: grid; grid-template-columns: minmax(110px, 230px) 1fr 42px; align-items: center; gap: 12px;
  width: 100%; background: none; border: none; padding: 5px 8px; border-radius: 8px;
  cursor: pointer; font-family: inherit; text-align: left; transition: background .15s; }
.topic:hover { background: rgba(132, 22, 23, .06); }
.topic.active { background: rgba(132, 22, 23, .10); }
.topic__name { font-size: 14px; line-height: 1.2; color: var(--ink); text-align: right; }
.topic__track { height: 20px; background: var(--cream-2); border-radius: 5px; overflow: hidden; }
.topic__bar { display: block; height: 100%; background: #b34a3f; border-radius: 5px; transition: background .15s; }
.topic:hover .topic__bar, .topic.active .topic__bar { background: var(--crimson); }
.topic__n { font-size: 13px; color: var(--muted); font-weight: 700; }
.quotes__head { text-align: center; color: var(--muted); margin: 22px 0 26px; min-height: 20px; }
.quotes__head.stuck {
  position: sticky; top: 0; z-index: 10; margin: 22px 0 20px; padding: 12px 8px;
  background: var(--cream); border-bottom: 1px solid var(--line); box-shadow: 0 6px 14px -10px rgba(60,30,10,.3);
}
.quotes__head .dim { opacity: .75; }
.link-btn { background: none; border: none; color: var(--crimson); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.link-btn:hover { color: var(--crimson-d); }

.quote-grid { columns: 3 280px; column-gap: 20px; transition: opacity .24s ease; }
.quote-more { display: flex; justify-content: center; gap: 14px; margin-top: 6px; }
.page-btn {
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--crimson);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; cursor: pointer; transition: all .15s;
}
.page-btn:hover { border-color: var(--crimson-l); background: rgba(132, 22, 23, .05); }
.quote {
  break-inside: avoid; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; margin: 0 0 20px; box-shadow: var(--shadow);
  font-size: 16px;
}
.quote::before { content: "\201C"; font-family: var(--font-head); color: var(--crimson-l); font-size: 40px; line-height: 0; vertical-align: -14px; margin-right: 4px; }
.quote .who { display:block; margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--crimson); font-weight: 700; }

/* ===================== APPENDIX ======================================= */
.appendix { background: var(--cream-2); border-top: 1px solid var(--line); padding: 8vh 24px; }
.appendix__inner { max-width: var(--maxw); margin: 0 auto; }
.appendix h2 { font-size: clamp(28px, 4vw, 42px); }
.appendix__lead { color: var(--muted); max-width: 60ch; margin-bottom: 24px; }
.filterbar { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 18px 0 30px; position: sticky; top: 8px; z-index: 20; background: rgba(228, 226, 217, 0.92); padding: 12px; border-radius: 12px; backdrop-filter: blur(4px); border: 1px solid var(--line); }
.flt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.flt-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.filterbar label { font-size: 13px; color: var(--muted); margin-right: 4px; }
.filterbar select {
  font-family: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
}
.filterbar select:hover { border-color: var(--crimson-l); }
.filterbar select:focus { outline: 2px solid var(--crimson-l); }
.shelf-chip { display: inline-flex; align-items: center; background: var(--crimson); color: #fff;
  border-radius: 999px; padding: 4px 4px 4px 12px; font-size: 13px; }
.shelf-chip button { background: none; border: none; color: #fff; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 6px; border-radius: 50%; }
.shelf-chip button:hover { background: rgba(255, 255, 255, .25); }
.chip {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.chip:hover { border-color: var(--crimson-l); }
.chip.active { background: var(--crimson); color: #fff; border-color: var(--crimson); }
.appendix__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 22px; }
.app-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.app-card h4 { margin: 0 0 4px; font-size: 16px; color: var(--ink); font-family: var(--font-body); font-weight: 700; }
.app-card .viz__title { display: none; } /* the card's <h4> is the title; hide the chart's built-in one */
.app-card .cap { font-size: 12px; color: var(--muted); margin: 0 0 12px; }

footer { text-align: center; padding: 6vh 24px; color: var(--muted); font-size: 14px; background: var(--cream-2); }
footer strong { color: var(--crimson-d); }

/* ===================== RESPONSIVE ===================================== */
@media (max-width: 820px) {
  body { font-size: 16px; }
  #nav { display: none; }
  .quote-grid { columns: 1; }

  /* Mobile scrolly: chart pins to the TOP, narrative scrolls underneath it.
     flex + order forces the graphic first regardless of its DOM position. */
  .scrolly, .scrolly[data-side="left"] {
    display: flex; flex-direction: column; gap: 0; padding: 0 16px; max-width: 640px;
  }
  .scrolly__graphic, .scrolly[data-side="left"] .scrolly__graphic {
    order: -1; position: sticky; top: 0; z-index: 6;
    background: var(--cream); padding-top: 8px;
  }
  /* fade so cards disappear cleanly as they scroll up behind the chart */
  .scrolly__graphic::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -22px; height: 22px;
    background: linear-gradient(var(--cream), transparent); pointer-events: none;
  }
  .scrolly__graphic-inner { position: static; height: auto; display: block; }
  .scrolly__graphic-inner .viz {
    height: 47vh; max-height: 47vh; padding: 14px 14px 10px; border-radius: 14px;
  }
  .viz__title { font-size: 17px; }
  .viz__sub { font-size: 12px; margin-bottom: 8px; }
  .legend { font-size: 11px; gap: 4px 10px; margin-top: 8px; }
  .bar-label, .bar-val { font-size: 11px; }

  /* steps MUST sit below the sticky chart (graphic z-index:6) so cards scroll
     behind it. Equal z-index falls back to DOM order, which alternates between
     default and data-side="left" sections -> words appear above on some. */
  .scrolly__steps { position: relative; z-index: 1; }
  .step {
    min-height: 60vh; align-items: flex-end; padding: 0 0 5vh; margin: 0;
  }
  .step:first-child { padding-top: 2vh; }
  .step:last-child { margin-bottom: 8vh; }
  .step__card { width: 100%; padding: 18px 20px; }
  .step__card h3 { font-size: 21px; }
  .step__card .big { font-size: 32px; }

  /* intros + appendix */
  .section-intro { padding: 16vh 18px 6vh; }
  .appendix { padding: 7vh 16px; }
  .appendix__grid { grid-template-columns: 1fr; gap: 18px; }
  .filterbar { top: 4px; }
  .quotes { padding: 5vh 16px 8vh; }
  /* on narrow screens let the affiliation filter drop below the title again */
  .map-head { flex-wrap: wrap; }
  .map-head__main { flex-basis: 100%; }
}
.hidden { display: none !important; }
