/* Gameficate — the design changes with every question. js/ui/QuestionLayout.js sets body[data-qmode] for each question
   and this file arranges the page for it:
     map      the question is played on a map: the question panel and the map, arranged by the layout preset
              (body[data-preset], from config.xml — Theme Configurator): split (Classic: panel left, map right; here),
              dock (Map first: css/layout-dock.css), stack (Question strip: css/layout-stack.css) or tray (Puzzle
              board: css/layout-tray.css)
     quiz     no map — a centred card: the question on one side, big answer tiles on the other
     picture  no map — the picture large, the question in a narrow column beside it
     reading  no map — the passage and question in a wide column, the answers beside them
     words    no map — the question on top, one wide row for the answer (unscramble, spot the error, blanks, order, sort)
     board    no map — the question in a narrow column, the word search or crossword filling the rest
   Whether a question has a map is the author's choice in Craft. Off the map, the map stays loaded but hidden, and the
   area behind the card is a quiet backdrop whose tint changes with the layout. Colours, fonts and roundness come from
   config.xml (Theme Configurator), not from this file. */

/* ---------- On the map, Classic (split) and Puzzle board (tray): the card's sections flow as one column ---------- */
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .card-col,
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .card-act,
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .card-btns {
  display: contents;
}
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .hintbar {
  order: 1;
}
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .pinbox {
  order: 2;
}
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel #checkBtn,
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel #revealBtn {
  order: 3;
}
body[data-layout='hybrid']:is([data-preset='split'], [data-preset='tray'])[data-qmode='map'] #qpanel .progress {
  order: 4;
}

/* ---------- Off the map: the backdrop ---------- */
body[data-layout='hybrid']:not([data-qmode='map']) #main {
  position: relative;
}
body[data-layout='hybrid']:not([data-qmode='map']) #mapPanel {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  --hy-tint: var(--orange);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--navy) 10%, transparent) 1.2px, transparent 0) 0 0 / 28px
      28px,
    linear-gradient(160deg, color-mix(in srgb, var(--hy-tint) 12%, var(--bg)), var(--bg) 55%);
  transition: background 0.3s;
}
body[data-layout='hybrid'][data-qmode='picture'] #mapPanel {
  --hy-tint: var(--teal);
}
body[data-layout='hybrid'][data-qmode='reading'] #mapPanel {
  --hy-tint: var(--violet);
}
body[data-layout='hybrid'][data-qmode='words'] #mapPanel,
body[data-layout='hybrid'][data-qmode='board'] #mapPanel {
  --hy-tint: var(--gold);
}
/* The map stays loaded (and keeps its size) but is out of sight. */
body[data-layout='hybrid']:not([data-qmode='map']) #map-host {
  visibility: hidden;
}
body[data-layout='hybrid']:not([data-qmode='map']) .side-toggle {
  display: none;
}

/* ---------- Off the map: the card ---------- */
body[data-layout='hybrid']:not([data-qmode='map']) #qpanel {
  position: absolute;
  z-index: 2;
  top: 26px;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1360px, calc(100% - 64px));
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 22px 30px;
  padding: 28px 32px 24px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: calc(28px * var(--rs, 1));
  box-shadow: 0 24px 70px rgba(10, 25, 40, 0.16);
  overflow: visible;
  animation: hy-in 0.35s cubic-bezier(0.2, 1.1, 0.4, 1);
}
@keyframes hy-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.98);
  }
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-q .qcard {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-q .qmedia:not(.loaded) {
  display: none;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-q .qmedia.loaded {
  height: 220px;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-q .qbody {
  padding: 22px 26px;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-q .qprompt {
  font-size: 28px;
  line-height: 1.35;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-a {
  justify-content: center;
}
/* The bottom row: hints · check / show answer · progress. */
body[data-layout='hybrid']:not([data-qmode='map']) .card-act {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding-top: 18px;
  border-top: 2px solid var(--line);
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-act .hintbar {
  margin: 0;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-btns {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-btns .btn-primary,
body[data-layout='hybrid']:not([data-qmode='map']) .card-btns .btn-secondary {
  margin: 0;
}
body[data-layout='hybrid']:not([data-qmode='map']) .card-act .progress {
  grid-column: 3;
  grid-row: 1;
  margin: 0;
}

/* quiz: big answer tiles */
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-head {
  font-size: 16px;
}
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-opts:not(.tf) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-opt {
  min-height: 92px;
  padding: 14px 20px;
  font-size: 23px;
  border-radius: calc(18px * var(--rs, 1));
}
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-opts.tf .qz-opt {
  min-height: 130px;
  font-size: 32px;
}
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-mark {
  width: 38px;
  height: 38px;
  font-size: 17px;
}
body[data-layout='hybrid'][data-qmode='quiz'] #quizBox .qz-input {
  height: 80px;
  font-size: 30px;
}

/* picture: the picture takes the stage */
body[data-layout='hybrid'][data-qmode='picture'] #qpanel {
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.6fr);
}
body[data-layout='hybrid'][data-qmode='picture'] .card-q .qprompt {
  font-size: 25px;
}
body[data-layout='hybrid'][data-qmode='picture'] #quizBox .hs-pic {
  max-height: calc(var(--main-h, 930px) - 230px);
}
body[data-layout='hybrid'][data-qmode='picture'] #quizBox .hs-pic img {
  max-height: calc(var(--main-h, 930px) - 230px);
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

/* reading: the passage gets the wide column */
body[data-layout='hybrid'][data-qmode='reading'] #qpanel {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}
body[data-layout='hybrid'][data-qmode='reading'] .card-q .qcard {
  justify-content: flex-start;
}
body[data-layout='hybrid'][data-qmode='reading'] .q-passage .qp-text {
  max-height: none;
  font-size: 19px;
  line-height: 1.6;
}
body[data-layout='hybrid'][data-qmode='reading'] .card-q .qprompt {
  font-size: 23px;
}
body[data-layout='hybrid'][data-qmode='reading'] #quizBox .qz-opt {
  min-height: 70px;
  font-size: 20px;
}

/* words: the question on top, one wide answer row */
body[data-layout='hybrid'][data-qmode='words'] #qpanel {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1180px, calc(100% - 64px));
}
body[data-layout='hybrid'][data-qmode='words'] .card-q {
  flex-direction: row;
  align-items: stretch;
  overflow: visible;
}
body[data-layout='hybrid'][data-qmode='words'] .card-q .cat-head {
  flex: 0 0 auto;
  align-self: center;
}
body[data-layout='hybrid'][data-qmode='words'] .card-q .qmedia.loaded {
  height: 120px;
  width: 180px;
  flex: 0 0 180px;
}
body[data-layout='hybrid'][data-qmode='words'] .card-q .qcard {
  flex-direction: row;
  align-items: center;
}
body[data-layout='hybrid'][data-qmode='words'] .card-q .qprompt {
  font-size: 26px;
}
body[data-layout='hybrid'][data-qmode='words'] .card-a {
  justify-content: center;
  padding: 0 4%;
}
body[data-layout='hybrid'][data-qmode='words'] #quizBox {
  font-size: 22px;
}

/* board: a word search or crossword fills the card */
body[data-layout='hybrid'][data-qmode='board'] #qpanel {
  grid-template-columns: minmax(340px, 0.55fr) minmax(0, 1.8fr);
}
/* The board itself grows to fill its side of the card. */
body[data-layout='hybrid'][data-qmode='board'] #quizBox .qt-ws {
  width: min(100%, calc(var(--n) * 64px), calc(var(--main-h, 930px) - 320px));
}
body[data-layout='hybrid'][data-qmode='board'] #quizBox .qt-ws-cell {
  font-size: 26px;
}
body[data-layout='hybrid'][data-qmode='board'] #quizBox .qt-cw {
  --sq: clamp(30px, calc(min(620px, calc(var(--main-h, 930px) - 330px)) / var(--cols)), 60px);
}
body[data-layout='hybrid'][data-qmode='board'] .card-q .qprompt {
  font-size: 22px;
}
body[data-layout='hybrid'][data-qmode='board'] .card-a {
  justify-content: center;
}

/* Feedback pops up near the top of the card, centred, clear of the answers' buttons. */
body[data-layout='hybrid']:not([data-qmode='map']) .fbpop {
  z-index: 6;
  top: 40px;
  bottom: auto;
  width: min(640px, calc(100% - 120px));
}
body[data-layout='hybrid']:not([data-qmode='map']) .toast {
  z-index: 7;
}
