:root {
  --purple: #3C1874;
  --navy: #283747;
  --header-h: 4.5rem;
  --footer-h: 2rem;
}

* { box-sizing: border-box; }

html { font-size: 16px; }
@media (max-width: 1000px) { html { font-size: 15px; } }
@media (max-width: 800px) { html { font-size: 14px; } }

body {
  margin: 0;
  padding: 0;
  background-color: #F3F3F3;
  font-family: 'Open Sans', sans-serif;
  color: #1d1d1d;
  top: 0 !important; /* google translate pushes the page down otherwise */
}

#google_translate_element,
.skiptranslate { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 4px;
  background-color: var(--purple);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
  transition: filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
.btn:disabled { background-color: #9b92ad; cursor: default; box-shadow: none; }
.btn-large { min-height: 3rem; padding: 0 1.5rem; line-height: 3rem; font-size: 1rem; }
.btn-small { min-height: 2rem; padding: 0 .75rem; line-height: 2rem; font-size: .8rem; }
.btn svg { vertical-align: middle; }

/* ---------- titles ---------- */
.bigTitle { font-family: 'Roboto Slab', serif; font-size: 2.25rem; color: #fff; padding: .5rem 0 .5rem 1rem; }
.medTitle { font-size: 1.75rem; color: #e7e7e7; padding: 1rem; font-weight: 700; }
.boldUnder { font-weight: 700; text-decoration: underline; color: rgb(118, 0, 170); }
.bottomPadder { margin-bottom: 15rem; }

/* ---------- welcome ---------- */
#modalWelcome {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #293c65, #283747);
  padding: 1rem 2rem 0;
  overflow: auto;
  z-index: 2000;
  text-align: center;
}
#modalWelcome .bigTitle { padding-left: 0; }
#welcomeButton { margin: 0 auto; width: min(30rem, 100%); }
#spanishButton { float: left; }
.welcomeMessage {
  font-weight: 300;
  color: #dfdfdf;
  font-size: 1.25rem;
  margin: 0 auto;
  max-width: 75rem;
  text-align: left;
}
.welcomeMessage a { color: #b9d4ff; }
#loadStatus { text-align: center; }
#loadStatus.loadError { color: #ffb4a8; font-weight: 700; }
#welcomeImage { float: right; height: 17rem; width: auto; margin: 5px; border: 2px solid #fff; }
@media (max-width: 800px) { #welcomeImage { float: none; display: block; height: auto; width: 100%; margin: 0 0 1rem; } }

/* ---------- header / footer ---------- */
#header {
  position: fixed;
  top: 0;
  width: 100%;
  min-height: var(--header-h);
  padding: .25rem 5rem .25rem .25rem;
  background-color: var(--navy);
  z-index: 1000;
}
#header .bigTitle { font-size: clamp(1.25rem, 4vw, 2.25rem); }
#helpButton { position: absolute; top: .75rem; right: 1rem; min-width: 3rem; padding: 0; }

#positionIndicator {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: var(--footer-h);
  line-height: var(--footer-h);
  font-size: 1rem;
  color: #f0f0f0;
  text-align: center;
  background-color: var(--navy);
  z-index: 1000;
}

/* ---------- dialog + toast ---------- */
dialog.modal {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(42rem, 92vw);
  max-height: 85vh;
  overflow: auto;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal-content { padding: 1.5rem; font-size: 1.1rem; line-height: 1.5; }
.modal-footer { padding: 0 1.5rem 1.25rem; text-align: right; }
.allFullDiv { display: block; width: 100%; margin: 5px 0; background-color: #412C77; line-height: 1.3; padding: .75rem; text-transform: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 3.5rem;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: .75rem 1.25rem;
  border-radius: 2rem;
  background: var(--purple);
  color: #fff;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 6000;
}
#toast.show { opacity: 1; }

/* ---------- survey questions ---------- */
#surveyHolder { position: absolute; width: 100%; top: 0; }
#questionHolder {
  display: none;
  width: auto;
  max-width: 60rem;
  margin: 0 auto;
  padding: calc(var(--header-h) + 1.5rem) 1rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: left;
}
body.view-survey #questionHolder { display: block; }
@media (min-width: 801px) {
  /* keeps the side arrows clear of the text */
  #questionHolder { max-width: 70rem; padding-left: 5rem; padding-right: 5rem; }
}
body.view-qsort #backButton,
body.view-qsort #finalButton { display: none; }

#forwardButton, #backButton {
  position: fixed;
  bottom: 50%;
  z-index: 100;
  min-width: 3.5rem;
  padding: 0;
}
#forwardButton { right: 1rem; }
#backButton { left: 1rem; }
@media (max-width: 800px) {
  #forwardButton, #backButton { bottom: 3rem; min-width: 3rem; min-height: 2.5rem; line-height: 2.5rem; }
}
#finalButton { display: block; margin: 5rem auto 0; width: min(20rem, 90%); }

label { font-size: 1rem; color: #464646; }
input[type=radio], input[type=checkbox] { accent-color: var(--purple); width: 1.1rem; height: 1.1rem; margin-right: .6rem; vertical-align: middle; }
input[type=text], input[type=number], textarea {
  font: inherit;
  font-weight: 400;
  color: #000;
  width: 100%;
  max-width: 40rem;
  padding: .5rem .6rem;
  border: 1px solid #8a8a8a;
  border-radius: 4px;
  background: #fff;
}
textarea { min-height: 7rem; }
::placeholder { color: #7d7d7d; opacity: 1; }
.otherSelectInput { display: inline-block; min-width: min(18rem, 100%); }
.multipleChoiceHolder, .singleChoiceHolder { margin-left: 1rem; font-weight: 400; }
.multipleChoiceHolder p, .singleChoiceHolder p { margin: .6rem 0; }
.nameInput, .whatsSpecialInput, .whatActionsInput { margin: .25rem 0 1rem; }

/* drivers of change */
.driversGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 6px; margin-bottom: 1.5rem; }
.driverBox {
  min-height: 8rem;
  padding: 8px;
  border: 3px solid #fff;
  background-color: #d0d9e0;
  color: #000;
  font: 700 1rem/1.2 'Open Sans', sans-serif;
  cursor: pointer;
  user-select: none;
}
.driverBox:focus-visible { outline: 3px solid #ffbf47; }
.driverBox.toggledBox { background-color: var(--purple); color: #fff; }

/* map */
.mapWrap { position: relative; margin: .5rem 0; }
.mapsObject { width: 100%; height: 30rem; }
#basemapButton { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 10; }

/* matrix */
.tableScroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-weight: 400; font-size: 1rem; }
th, td { padding: .5rem; border-bottom: 1px solid #ddd; }
th { text-align: center; font-size: .9rem; }
.valueNameCell { text-align: left; min-width: 14rem; }
.tableCell label { display: block; text-align: center; cursor: pointer; padding: .25rem; }
.tableCell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.matrixMark::before { content: '○'; font-size: 1.5rem; color: #555; }
.tableCell input:checked + .matrixMark::before { content: '✔'; color: var(--purple); }
.tableCell input:focus-visible + .matrixMark { outline: 3px solid #ffbf47; }

/* ---------- q-sort ---------- */
#qQuiz, #qQuizMobile { display: none; }
body.view-qsort:not(.is-mobile) #qQuiz { display: flex; }
body.view-qsort.is-mobile #qQuizMobile { display: block; }

#qQuiz {
  /* the cell shrinks to fit the screen width (columns) and height (tallest column) */
  --cell: min(var(--cell-max, 7rem), calc((100vw - 5rem) / var(--cols, 9)), calc((100dvh - 19rem) / var(--rows, 3)));
  position: fixed;
  top: var(--header-h);
  bottom: var(--footer-h);
  left: 0;
  right: 0;
  flex-direction: column;
  padding: .5rem 1rem;
  user-select: none;
}
#qAxis { display: flex; justify-content: space-between; align-items: center; padding: 0 1rem; font-weight: 300; font-size: 1.25rem; }
#qAxis .qProgress { font-size: 1rem; color: #555; }

/* every column is exactly as tall as the tallest one, so rows line up across columns even when the grid scrolls */
#qGrid { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: safe center; gap: var(--gap, 4px); overflow: auto; }
.qColumn { display: flex; flex-direction: column; width: var(--cell); flex: none; }
.qColLabel { text-align: center; font-weight: 700; color: #555; padding-bottom: 4px; }
.qCells {
  flex: none;
  height: calc(var(--rows, 3) * var(--cell) + (var(--rows, 3) - 1) * var(--gap, 4px));
  display: flex;
  flex-direction: column;
  justify-content: var(--align, flex-end);
  gap: var(--gap, 4px);
}

.qCell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--cell-bg, #85a2c2);
  cursor: pointer;
}
.qCell:hover { filter: brightness(1.1); }
.qCell.over { outline: 3px solid var(--purple); outline-offset: -1px; }
.valueBg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * .35);
  font-weight: 300;
  color: #fff;
  opacity: .35;
  pointer-events: none;
}

.qCard {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: min(var(--cell), var(--cell-max, 7rem));
  height: min(var(--cell), var(--cell-max, 7rem));
  padding: 4px;
  border: 0;
  border-radius: .5rem;
  background: #fff;
  color: #424242;
  font: 400 clamp(.6rem, calc(var(--cell) * .115), .85rem) / 1.15 'Open Sans', sans-serif;
  text-align: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  hyphens: auto;
  cursor: grab;
  user-select: none;
  touch-action: pan-x;
}
.qCard.placed {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 4px;
  background: transparent;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  touch-action: none;
}
.qCard:focus-visible, .qCell:focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }
.qCard.selected { outline: 3px solid #993A00; outline-offset: 1px; }
.qCard.dragging { opacity: .3; }
.qCard.qGhost {
  position: fixed;
  inset: auto;
  left: 0;
  top: 0;
  z-index: 5000;
  pointer-events: none;
  opacity: .92;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .4);
  color: #fff;
  text-shadow: 0 0 3px #000;
}
.qGhost:not(.placed) { color: #424242; text-shadow: none; }

#valuesHolder {
  display: flex;
  gap: .75rem;
  padding: .75rem;
  min-height: calc(min(var(--cell), var(--cell-max, 7rem)) + 1.5rem);
  overflow-x: auto;
  background: #e6e6e6;
  border-radius: 6px;
  align-items: center;
  justify-content: safe center;
}
#valuesHolder.awaitingDrop { outline: 3px dashed var(--purple); outline-offset: -3px; }
.ribbonDone { color: #666; font-style: italic; }

/* ---------- q-sort: mobile ---------- */
#qQuizMobile { padding-top: calc(var(--header-h) + 1rem); padding-bottom: 3rem; text-align: center; }
#titleText { font-size: 1.25rem; font-weight: 700; padding: 0 1rem; }
#currentMobileValue { min-height: 9rem; padding: 1rem; }
.mobileValueHolder { font-size: 1.25rem; font-weight: 700; text-decoration: underline; }
.mobileCounter, .mobileStatus { color: #555; }
.mobileNav { display: flex; justify-content: space-between; align-items: center; padding: 0 .5rem; }
.qProgress { color: #555; font-size: .9rem; }
.mobScores { display: flex; gap: 4px; padding: 1rem .5rem 0; justify-content: center; }
.mobQbox {
  flex: 1;
  max-width: 4.5rem;
  min-height: 4.5rem;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: var(--cell-bg, #85A2C2);
  color: #fff;
  font: 700 1rem 'Open Sans', sans-serif;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.mobFree { font-size: .7rem; font-weight: 400; }
.mobQbox.fullMobQbox { filter: grayscale(.7) brightness(.7); }
.mobQbox.currentMobQbox { filter: none; background: #993A00; outline: 3px solid #1d1d1d; }
#finishQSortButton { margin-top: 1.5rem; }
