/* Five-book shared theme: warm, cheerful and print-friendly. */
@import url('https://fonts.googleapis.com/css2?family=Kiwi+Maru:wght@400;500&family=Mochiy+Pop+One&display=swap');

:root {
  --cream: #fff9e9;
  --paper: #fffdf7;
  --ink-pop: #463d3a;
  --coral: #ef806f;
  --peach: #ffd1b8;
  --sage: #a9cbb7;
  --blue-pop: #91bddd;
  --yellow-pop: #f7d878;
  --soft-line: #eadfca;
  --theme: #ef806f;
  --theme-dark: #a9473d;
  --theme-soft: #fff0ea;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0 !important;
  background-color: var(--cream) !important;
  background-image:
    radial-gradient(circle at 12px 12px, #e9bd9b38 2px, transparent 2.5px),
    linear-gradient(135deg, #fffdf5 0%, #fff5dc 100%) !important;
  background-size: 28px 28px, 100% 100% !important;
  color: var(--ink-pop) !important;
  font-family: "Kiwi Maru", "Yu Gothic", sans-serif !important;
}

main {
  position: relative;
  overflow: hidden;
  width: min(960px, calc(100% - 28px)) !important;
  max-width: 960px !important;
  margin: 28px auto !important;
  padding: 0 58px 52px !important;
  border: 2px solid #f0dfc2 !important;
  border-top: 2px solid #f0dfc2 !important;
  border-radius: 30px !important;
  background: var(--paper) !important;
  box-shadow: 0 14px 0 #ead9ba, 0 22px 50px #7e64452b !important;
}

main.theme-trig { --theme:#ef806f; --theme-dark:#a84743; --theme-soft:#fff0ea; }
main.theme-seq { --theme:#65aa8c; --theme-dark:#35735f; --theme-soft:#ebf8f1; }
main.theme-geometric { --theme:#d49b4c; --theme-dark:#8a5a22; --theme-soft:#fff5e4; }
main.theme-set { --theme:#9a7cc1; --theme-dark:#674e8b; --theme-soft:#f3edfb; }
main.theme-circle { --theme:#62aab4; --theme-dark:#367681; --theme-soft:#eaf8f8; }
main.theme-log { --theme:#e9a751; --theme-dark:#9a6528; --theme-soft:#fff4df; }
main.theme-quadratic { --theme:#de7798; --theme-dark:#93435f; --theme-soft:#fff0f5; }
main.theme-complex { --theme:#6f88c6; --theme-dark:#425d9b; --theme-soft:#eef2ff; }

main::before,
main::after {
  position: absolute;
  z-index: 0;
  color: var(--theme);
  opacity: .17;
  font: 56px "Mochiy Pop One", sans-serif;
  pointer-events: none;
}
main::before { content: "＋ ＝ △"; top: 18px; left: 25px; transform: rotate(-8deg); }
main::after { content: "○ × √"; top: 155px; right: 18px; transform: rotate(9deg); }
main > * { position: relative; z-index: 1; }

.lesson-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 265px;
  align-items: center;
  min-height: 330px;
  margin: 0 -58px 38px;
  padding: 38px 48px 24px 58px;
  background:
    radial-gradient(circle at 76% 24%, #ffffff9c 0 9%, transparent 9.5%),
    linear-gradient(125deg, var(--theme-soft), #fffaf0 66%);
  border-bottom: 3px dashed color-mix(in srgb, var(--theme), white 40%);
}

.hero-copy { z-index: 2; min-width: 0; }
.kicker {
  display: inline-block;
  margin-bottom: 8px;
  padding: 5px 14px;
  color: var(--theme-dark);
  background: white;
  border: 2px solid var(--theme);
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .08em;
  box-shadow: 3px 3px 0 var(--theme);
}

h1 {
  margin: 4px 0 10px !important;
  color: var(--theme-dark) !important;
  font-family: "Mochiy Pop One", "Yu Gothic", sans-serif !important;
  letter-spacing: .04em;
  text-shadow: 3px 3px 0 #fff;
}

.lead { color: #655b57 !important; font-weight: 500; }

.teacher-talk {
  position: relative;
  margin-top: 18px;
  padding: 12px 16px;
  max-width: 510px;
  background: white;
  border: 2px solid var(--theme);
  border-radius: 18px;
  color: var(--theme-dark);
  font-weight: 700;
  box-shadow: 4px 5px 0 #ead9c3;
}
.teacher-talk::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 24px;
  width: 24px;
  height: 24px;
  background: white;
  border-top: 2px solid var(--theme);
  border-right: 2px solid var(--theme);
  transform: rotate(45deg);
}

.teacher-frame {
  position: relative;
  align-self: end;
  height: 285px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
.teacher-frame::before {
  content: "";
  position: absolute;
  width: 225px;
  height: 225px;
  bottom: 12px;
  border-radius: 48% 52% 44% 56% / 53% 42% 58% 47%;
  background: color-mix(in srgb, var(--theme), white 62%);
  box-shadow: inset 0 0 0 8px #ffffff7a;
  transform: rotate(-7deg);
}
.teacher-frame img {
  position: relative;
  z-index: 2;
  display: block;
  width: 225px;
  height: 310px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 7px 6px #59453533);
}
.spark { position:absolute; z-index:3; color:var(--yellow-pop); font-size:30px; text-shadow:1px 2px 0 #bd7f2b; }
.spark.one { top:24px; right:14px; }
.spark.two { top:76px; left:10px; font-size:20px; }

h2 {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 2.4em !important;
  padding: 10px 16px !important;
  border: 0 !important;
  border-radius: 14px 22px 14px 22px;
  color: var(--theme-dark) !important;
  background: var(--theme-soft);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--theme), white 55%);
  font-family: "Mochiy Pop One", "Yu Gothic", sans-serif;
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}
h2::before {
  content: "✎";
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  color: white;
  background: var(--theme);
  transform: rotate(-8deg);
}
h3 { color: var(--theme-dark) !important; }

.box, .example, .warning {
  position: relative;
  border-radius: 18px !important;
  box-shadow: 0 5px 0 #eadfcb;
}
.box {
  border: 2px solid color-mix(in srgb, var(--theme), white 28%) !important;
  border-left: 7px solid var(--theme) !important;
  background: var(--theme-soft) !important;
}
.example {
  border: 2px solid #a8cdbb !important;
  background: #f0faf4 !important;
}
.example::before {
  content: "できた！";
  position: absolute;
  top: -14px;
  right: 18px;
  padding: 2px 12px;
  border-radius: 999px;
  color: white;
  background: #65aa8c;
  font-weight: 700;
  transform: rotate(3deg);
}
.warning {
  border: 2px solid #f2b09f !important;
  border-left: 7px solid var(--coral) !important;
  background: #fff1eb !important;
}

.formula {
  margin: 12px auto !important;
  padding: 10px 16px;
  max-width: 680px;
  border-radius: 12px;
  color: var(--theme-dark);
  background: #ffffffc9;
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--theme), white 65%);
}

table {
  overflow: hidden;
  border: 2px solid var(--soft-line) !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  border-radius: 15px;
  background: white;
  box-shadow: 0 4px 0 #ede2cf;
}
th { color: var(--theme-dark); background: var(--theme-soft) !important; }
th, td { border: 0 !important; border-right: 1px solid var(--soft-line) !important; border-bottom: 1px solid var(--soft-line) !important; }
tr:last-child td { border-bottom: 0 !important; }
th:last-child, td:last-child { border-right: 0 !important; }

li { margin: .45em 0; }
li::marker { color: var(--theme); font-weight: 700; }
code { color: var(--theme-dark); background: var(--theme-soft) !important; }

details {
  border: 2px dashed var(--theme) !important;
  border-radius: 15px !important;
  background: #fffaf0 !important;
}
summary { color: var(--theme-dark) !important; }
summary::marker { color: var(--theme); }

footer {
  margin-top: 3.4em !important;
  padding: 18px 20px !important;
  border: 0 !important;
  border-radius: 16px;
  color: #71665f !important;
  background: #f8efdf;
  text-align: center;
}

/* Contextual mascot callouts used below the hero. */
.mascot-callout {
  position: relative;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  align-items: center;
  gap: 8px 18px;
  min-height: 132px;
  margin: 1.5em 0;
  padding: 15px 20px 15px 8px;
  border: 2px solid color-mix(in srgb, var(--theme), white 38%);
  border-radius: 22px;
  background: linear-gradient(135deg, #fff, var(--theme-soft));
  box-shadow: 0 5px 0 #eadfcb;
}
.mascot-callout.right {
  grid-template-columns: minmax(0, 1fr) 118px;
  padding: 15px 8px 15px 20px;
}
.mascot-callout.right .mascot-art { grid-column: 2; grid-row: 1; }
.mascot-callout.right .mascot-copy { grid-column: 1; grid-row: 1; }
.mascot-art {
  display: block;
  width: 112px;
  height: 125px;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 5px 3px #47392926);
}
.mascot-copy { min-width: 0; }
.mascot-label {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 11px;
  border-radius: 999px;
  color: white;
  background: var(--theme);
  font-size: .88rem;
  font-weight: 700;
}
.mascot-copy p { margin: .25em 0; }
.mascot-callout.caution {
  border-color: #efa895;
  background: linear-gradient(135deg, #fff, #fff0e9);
}
.mascot-callout.caution .mascot-label { background: var(--coral); }
.mascot-callout.question {
  border-style: dashed;
  background: linear-gradient(135deg, #fff, #f1f5fb);
}
.mascot-callout.praise {
  border-color: #9ac9af;
  background: linear-gradient(135deg, #fff, #ecf8f0);
}
.mascot-callout.praise .mascot-label { background: #599c79; }
.mini-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 1.2em 0;
}
.mini-flow > div {
  position: relative;
  padding: 15px 12px;
  border: 2px solid var(--soft-line);
  border-radius: 16px;
  background: white;
  text-align: center;
}
.mini-flow > div:not(:last-child)::after {
  content: "→";
  position: absolute;
  z-index: 2;
  top: 50%;
  right: -20px;
  width: 26px;
  color: var(--theme);
  font-weight: 900;
  transform: translateY(-50%);
}
.step-list { counter-reset: lesson-step; padding-left: 0; list-style: none; }
.step-list > li {
  position: relative;
  margin: .8em 0;
  padding: 10px 12px 10px 48px;
  border-radius: 13px;
  background: #fffaf0;
}
.step-list > li::before {
  counter-increment: lesson-step;
  content: counter(lesson-step);
  position: absolute;
  left: 10px;
  top: 10px;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--theme);
  font-weight: 700;
}
.math-line {
  overflow-x: auto;
  margin: .55em 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #ffffffc7;
  font-family: Cambria, "Times New Roman", serif;
  font-size: 1.1rem;
  text-align: center;
}
.lesson-nav { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin-top:1em; }
.lesson-nav a { padding:4px 10px; border-radius:999px; color:var(--theme-dark); background:white; text-decoration:none; }
.lesson-nav a:hover { background:var(--theme-soft); }

@media (max-width: 720px) {
  main { padding: 0 24px 34px !important; border-radius: 20px !important; }
  .lesson-hero { grid-template-columns: 1fr 130px; min-height: 290px; margin: 0 -24px 30px; padding: 28px 18px 20px 24px; }
  .teacher-frame { height: 220px; }
  .teacher-frame::before { width: 135px; height: 155px; }
  .teacher-frame img { width: 145px; height: 230px; }
  .teacher-talk { font-size: .9rem; }
  .teacher-talk::after { display:none; }
  h2 { font-size: 1.08rem !important; }
  .mascot-callout, .mascot-callout.right { grid-template-columns: 84px minmax(0,1fr); padding: 12px 13px 12px 5px; }
  .mascot-callout.right .mascot-art { grid-column: 1; }
  .mascot-callout.right .mascot-copy { grid-column: 2; }
  .mascot-art { width: 82px; height: 102px; }
  .mini-flow { grid-template-columns: 1fr; }
  .mini-flow > div:not(:last-child)::after { content:"↓"; top:auto; right:50%; bottom:-24px; transform:translateX(50%); }
}

@media (max-width: 470px) {
  .lesson-hero { display:block; padding-right:24px; }
  .teacher-frame { height:185px; margin-top:14px; }
  .teacher-frame img { height:205px; }
  .teacher-frame::before { width:155px; height:150px; }
}

@media print {
  @page { margin: 14mm; }
  body { background: white !important; }
  main { box-shadow: none !important; border: 0 !important; }
  .lesson-hero { break-inside: avoid; }
  h2, .box, .example, .warning, details { break-inside: avoid; }
}
