/* Use the familiar book spread to bring a discovery and its next action together. */
body.student #expedition.space-active:has(.storybook-outcome) {
 grid-template-rows: auto minmax(0,1fr);
}
body.student #expedition.space-active:has(.storybook-outcome) > :is(.activity-heading,.footer) {
 display: none;
}
body.student #expedition.space-active .workspace:has(> .storybook-outcome) {
 grid-template-columns: minmax(0,1fr);
 grid-template-rows: minmax(0,1fr);
 padding: clamp(12px,2.1vw,30px);
}
.storybook-outcome {
 --paper: #fffaf0;
 --book-rule: #dec79b;
 --book-ink: #251d49;
 --book-action: #303c91;
 align-self: center;
 justify-self: center;
 display: grid;
 grid-template-columns: minmax(0,1.04fr) minmax(0,1fr);
 width: min(100%, 1380px);
 height: min(100%, 760px);
 min-height: 0;
 border: 2px solid var(--book-rule);
 border-radius: 24px;
 overflow: hidden;
 background: var(--paper);
 color: var(--book-ink);
 box-shadow: 0 14px 28px #303c9136;
}
.outcome-illustration {
 display: grid;
 place-items: center;
 position: relative;
 isolation: isolate;
 min-width: 0;
 min-height: 0;
 margin: 0;
 padding: 5%;
 background: #f4e6c4;
}
.outcome-illustration::after {
 content: '';
 position: absolute;
 inset: 0;
 background: url('assets/storybook/book-frame.webp') center/100% 100% no-repeat;
 pointer-events: none;
}
.outcome-illustration > img {
 width: 100%;
 height: 100%;
 max-height: none;
 min-height: 0;
 object-fit: cover;
}
.outcome-illustration > :is(.decision-source,.card-art) {
 width: 100%;
 max-height: 100%;
 overflow: auto;
}
.outcome-illustration .decision-source {
 position: relative;
 z-index: 1;
 background: var(--paper);
 padding: 18px;
}
.outcome-illustration .storybook-illustration-note {
 position: absolute;
 z-index: 2;
 left: 8%;
 bottom: 8%;
 padding: 5px 8px;
 border-radius: 6px;
 background: #282344e8;
 color: #fff;
 font-size: 15px;
}
.outcome-page {
 min-width: 0;
 min-height: 0;
 display: flex;
 flex-direction: column;
 justify-content: safe center;
 gap: clamp(12px,2vh,22px);
 padding: clamp(20px,3.2vw,52px);
 overflow-y: auto;
 word-break: keep-all;
 overflow-wrap: anywhere;
}
.outcome-page h2 {
 margin: 0;
 font-size: clamp(32px,3.3vw,50px);
 line-height: 1.18;
 letter-spacing: -.025em;
 text-wrap: balance;
}
.outcome-findings {
 padding: 0;
 margin: 0;
 list-style: none;
 border-block: 1px solid var(--book-rule);
}
.outcome-findings li {
 padding: .38em 0;
 font-size: clamp(28px,2.2vw,30px);
 line-height: 1.35;
}
.outcome-findings li + li {
 border-top: 1px solid var(--book-rule);
}
.outcome-findings span {
 display: block;
 color: #55476d;
 font-size: .78em;
}
.outcome-explanation {
 margin: 0;
 font-size: clamp(28px,2.4vw,34px);
 font-weight: 650;
 line-height: 1.45;
 white-space: pre-line;
}
body.student #expedition.space-active .outcome-page #continue {
 align-self: start;
 min-height: 52px;
 padding: 9px 20px;
 background: var(--book-action);
 color: #fff;
 font-size: clamp(22px,2vw,26px);
 box-shadow: none;
 border: 2px solid var(--book-action);
 border-radius: 12px;
}
body.student #expedition.space-active .outcome-page #continue:hover { background: #222d76; }
.outcome-page :focus-visible {
 outline: 3px solid #a96b12;
 outline-offset: 3px;
}
@media (min-width:701px) {
 body.student #expedition.space-active .decision-flow .foundation-situation figcaption > p,
 body.student #expedition.space-active .decision-flow .foundation-response > p {
  font-size: 28px;
  line-height: 1.4;
 }
}
@media (max-width:700px) {
 body.student #expedition.space-active:has(.storybook-outcome) {
  height: auto;
  min-height: 100dvh;
 }
 body.student #expedition.space-active .workspace:has(> .storybook-outcome) {
  grid-template-rows: auto;
 }
 .storybook-outcome {
  grid-template-columns: 1fr;
  height: auto;
  border-radius: 18px;
 }
 .outcome-illustration { height: clamp(170px,52vw,270px); }
 .outcome-page { padding: 22px 18px; overflow: visible; }
 .outcome-page h2 { font-size: clamp(28px,7vw,35px); }
 .outcome-findings li { font-size: 22px; }
 .outcome-explanation { font-size: 23px; }
}

/* The notebook tabs name the discovery a student can revisit. */
body.student #expedition.is-notebook .notebook .record-tabs {
 display: flex;
 justify-content: center;
 flex-wrap: wrap;
 gap: 8px;
}
body.student #expedition.is-notebook .notebook .record-tabs button {
 min-height: 48px;
 padding: 8px 12px;
 font-size: clamp(16px, 2.05vw, 22px);
 line-height: 1.3;
 white-space: normal;
 word-break: keep-all;
}
body.student #expedition.is-notebook .notebook .record-tabs button[aria-pressed="true"] {
 color: #fff;
 background: #303c91;
 border-color: #303c91;
}
body.student #expedition.is-notebook .notebook-record strong {
 color: #251d49;
 font-size: clamp(27px, 3.2vw, 42px);
}
body.student #expedition.is-notebook .notebook-record p {
 font-size: clamp(28px, 2.5vw, 33px);
 line-height: 1.5;
}
@media (max-width:700px) {
 body.student #expedition.is-notebook .notebook-record p { font-size: 23px; }
}

body.student #expedition.space-active .outcome-illustration > .decision-context-image {
 object-fit: cover;
 max-height: none;
}
body.student #expedition.space-active .outcome-illustration > .archival-image {
 object-fit: contain;
}
.outcome-illustration .decision-source {
 align-self: center;
 height: auto;
}
.outcome-illustration .decision-source .storybook-illustration-note {
 position: static;
 align-self: start;
}
.outcome-illustration .decision-source .decision-context-image {
 display: block;
 max-height: 170px;
 object-fit: contain;
}
.outcome-illustration .decision-source blockquote {
 font-size: clamp(23px,2.45vw,29px);
}
@media (max-width:700px) {
 .outcome-illustration:has(.decision-source) {
  height: auto;
  padding: 14px;
 }
}

/* Put the record control below the jar comparison instead of sharing a narrow cell. */
body.student #expedition[data-occasion="farm-kimchi"] .farm-model-story .jar-card {
 grid-template-columns: minmax(0,1fr);
 grid-template-rows: auto auto auto auto;
}
body.student #expedition[data-occasion="farm-kimchi"] .farm-model-story .jar-card > *,
body.student #expedition[data-occasion="farm-kimchi"] .farm-model-story .jar-card .visual-card-copy > * {
 grid-area: auto;
 width: 100%;
}
body.student #expedition[data-occasion="farm-kimchi"] .farm-model-story .jar-card button {
 white-space: normal;
 overflow-wrap: anywhere;
}

/* Portrait tablets have enough width for full Korean sentences when the
   choices use the page width and artwork does not set the card's height. */
@media (min-width:701px) and (max-width:900px) and (orientation:portrait) {
 body.student #expedition.space-active .decision-flow:has(.storybook-visual):has(.foundation-choice):has(.foundation-response p:not(:empty)):not(:has(.foundation-choice:nth-child(3))) {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
 }

 body.student #expedition.space-active .decision-flow .foundation-options:has(> .foundation-choice:nth-child(2)):not(:has(> .foundation-choice:nth-child(3))) {
  grid-template-columns: repeat(2,minmax(0,278px));
  justify-content: center;
 }
 body.student #expedition.space-active .decision-flow .foundation-options > .foundation-choice {
  justify-content: center;
  min-height: 48px !important;
  gap: 8px;
  padding: 8px;
 }
 body.student #expedition.space-active .decision-flow .foundation-options > .foundation-choice > span:last-child {
  line-height: 1.2 !important;
  padding-inline: 5px;
 }
 body.student #expedition.space-active .decision-flow .foundation-options > .foundation-choice > .card-art {
  width: min(100%,230px);
  height: auto;
  max-width: 230px;
  max-height: none;
 }
}

@media (min-width: 701px) {
 body.student #expedition.space-active .workspace :is(.farm-model-story, .model-story)
  :is(.controls, .tray, .jar-card, .water-lab, .water-use-grid, .hangul-controls) button,
 body.student dialog button {
  min-width: 48px;
  min-height: 48px;
 }
 body.student #expedition.space-active .air-grade-choice {
  min-height: 48px;
  font-size: 28px;
 }
}
@media (min-width: 701px) and (max-width: 1439px) {
 body.student #expedition.space-active > header .space-actions > button,
 body.student #expedition.space-active > header .storybook-previous,
 body.student #expedition.space-active > header #continue {
  min-width: 48px;
  min-height: 48px;
 }
}

/* Place retry guidance below the illustrated page on short tablets, leaving
   the answers at their full height beside the question. */
@media (min-width: 901px) and (orientation: landscape) and (max-height: 700px) {
 body.student #expedition.space-active .decision-flow:has(.foundation-choice):has(.foundation-response :is(p:not(:empty), .decision-page)):not(:has(.foundation-choice:nth-child(3))) {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
 }
 body.student #expedition.space-active .decision-flow:has(.foundation-choice):has(.foundation-response :is(p:not(:empty), .decision-page)):not(:has(.foundation-choice:nth-child(3))) .foundation-decision {
  display: contents;
 }
 body.student #expedition.space-active .decision-flow:has(.foundation-choice):has(.foundation-response :is(p:not(:empty), .decision-page)):not(:has(.foundation-choice:nth-child(3))) .foundation-options {
  grid-column: 2;
  grid-row: 3 / 5;
 }
 body.student #expedition.space-active .decision-flow:has(.foundation-choice):has(.foundation-response :is(p:not(:empty), .decision-page)):not(:has(.foundation-choice:nth-child(3))) .foundation-response {
  grid-column: 1;
  grid-row: 4;
 }
}

/* The long findings and the next action fit on the same page. */
@media (min-width:701px) {
 .outcome-findings span { font-size: 28px; }
 .storybook-outcome:has(.outcome-findings li:nth-child(3)):not(:has(.decision-source)) {
  grid-template-columns: minmax(0,1fr) minmax(0,2.2fr);
 }
 .outcome-findings:has(li:nth-child(3)) {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 0 16px;
 }
 .outcome-findings:has(li:nth-child(3)) li:nth-child(2) {
  border-top: 0;
 }
}
@media (min-width:701px) and (orientation:portrait) {
 .storybook-outcome {
  grid-template-columns: minmax(0,1fr) minmax(0,1.35fr);
 }
 .storybook-outcome:has(.outcome-findings li:nth-child(3)):not(:has(.decision-source)) {
  grid-template-columns: minmax(0,1fr);
  grid-template-rows: minmax(150px,1fr) auto;
 }
 .storybook-outcome:has(.outcome-findings li:nth-child(3)) .outcome-illustration {
  padding: 12px 24px;
 }
 body.student #expedition.is-notebook .notebook .record-list > .notebook-record {
  grid-template-rows: minmax(0,1fr) auto;
  gap: 12px;
 }
}
@media (min-width:701px) and (max-width:900px) and (min-height:1000px) and (orientation:portrait) {
 body.student #expedition.space-active:not([data-occasion="wise-consumer"])
 .decision-flow:has(.storybook-visual):has(.foundation-options > .foundation-choice:nth-child(2)):not(:has(.foundation-choice:nth-child(3))) {
  grid-template-rows: auto minmax(0,1fr) auto auto;
 }
 body.student #expedition.space-active .decision-flow .foundation-decision:has(.foundation-choice):not(:has(.foundation-choice:nth-child(3))) {
  grid-template-rows: auto auto;
 }
 body.student #expedition.space-active .decision-flow .foundation-options:has(.foundation-choice):not(:has(.foundation-choice:nth-child(3))) {
  container-type: normal;
 }
 body.student #expedition.space-active .decision-flow .foundation-options:not(:has(.foundation-choice:nth-child(3))) > .foundation-choice:has(> .card-art) {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  align-content: center;
 }
 body.student #expedition.space-active .decision-flow .foundation-options:not(:has(.foundation-choice:nth-child(3))) > .foundation-choice:has(> .card-art) > span:last-child {
  grid-row: 1;
 }
 body.student #expedition.space-active .decision-flow .foundation-options:not(:has(.foundation-choice:nth-child(3))) > .foundation-choice:has(> .card-art) > .card-art {
  width: min(100%,var(--choice-art-size,240px));
  height: var(--choice-art-size,240px);
  max-width: 240px;
  max-height: none;
 }
 body.student #expedition[data-occasion="fire-safety"].space-active .decision-flow .foundation-options > [data-action="report"] {
  --choice-art-size: 228px;
 }
}
@media (min-width:901px) and (max-height:700px) {
 .storybook-outcome:not(:has(.decision-source)) {
  grid-template-columns: minmax(0,1fr) minmax(0,1.8fr);
 }
 .outcome-page {
  padding: 14px 24px;
  gap: 10px;
 }
 .outcome-findings li {
  padding: 6px 0;
  line-height: 1.25;
 }
 .outcome-explanation {
  line-height: 1.35;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .calendar-story-controls {
  justify-content: start;
  gap: 3px;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .foundation-situation figcaption {
  min-height: 0;
  padding: 6px 15px;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .foundation-situation figcaption > p {
  margin: 0;
  line-height: 1.25;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .calendar-top {
  padding: 3px;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .year-calendar {
  gap: 2px 4px;
  grid-template-rows: 26px;
 }
 body.student #expedition[data-occasion="new-year"] .calendar-story .tray > button {
  min-height: 48px;
  padding: 4px 14px;
 }
}

@media (min-width:901px) and (max-width:1100px) {
 body.student #expedition.is-notebook .notebook .record-list > .notebook-record {
  grid-template-columns: minmax(0,1fr) minmax(0,2.65fr);
  gap: 16px;
  padding: 12px 16px;
 }
 body.student #expedition.is-notebook .notebook-record p {
  margin-block-start: 8px;
  line-height: 1.35;
  word-break: keep-all;
 }
}
