/* https://site.invalid/assets/css/interactive-polish.css?v=tpl-fix-1 */
@scope (html[data-site-styles~="f0bfaf40af1c2a9f"]) {/* interactive-polish.css (tpl-fix-1): template-level fixes for the standalone interactive families
   (animations, games, simulations). Linked into every page by astro/scripts/postbuild-interactive-polish.mjs.
   FS-0002/0040 overflow + checkpoint mascot, FS-0006 page margins, FS-0008 boundaries note, FS-0007/0023 hero,
   FS-0005/0022 collapsible docs, FS-0021/0028 title first, LR-6007/6014 results + delta chip, back-link strip. */

/* ---- never scroll sideways (FS-0002, FS-0040) ------------------------------------------------------------ */
body[data-iotclass-interactive-family] :is(img, video, canvas, svg:not([width]), picture, figure):where(:scope, *) { max-width: 100%; }
body[data-iotclass-interactive-family] :is(img, video):where(:scope, *) { height: auto; }
body[data-iotclass-interactive-family] figure :is(img, svg):where(:scope, *) { max-width: 100%; height: auto; }
body[data-iotclass-interactive-family] #quarto-document-content:where(:scope, *) { min-width: 0; max-width: 100%; box-sizing: border-box; }
body[data-iotclass-interactive-family] #quarto-document-content :is(.cell-output-display, .quarto-figure, .table-responsive, figure):where(:scope, *) { max-width: 100%; overflow-x: auto; }
body[data-iotclass-interactive-family] #quarto-document-content :is(pre, table):where(:scope, *) { max-width: 100%; }
body[data-iotclass-interactive-family] #quarto-document-content > *:where(:scope, *) { min-width: 0; }
@media (max-width: 700px) {
  body[data-iotclass-interactive-family] #quarto-document-content :is(.page-columns, .column-page, .column-body, .column-screen):where(:scope, *) { min-width: 0; max-width: 100%; }
}

/* checkpoint tip pages: the character is a small badge, the caption stays on one line with it (FS-0002) */
body[data-iotclass-interactive-family] .callout-title-container :is(img.checkpoint-guide-icon, img[class*="guide-icon"]):where(:scope, *) {
  display: inline-block;
  float: none;
  width: 40px;
  height: 40px;
  max-width: 40px;
  margin: 0 .6rem 0 0;
  vertical-align: middle;
  object-fit: contain;
  border-radius: 50%;
}
body[data-iotclass-interactive-family] .callout-title-container:where(:scope, *) { min-width: 0; overflow-wrap: anywhere; }

/* ---- technical-boundaries note: full content width, never a margin column (FS-0008) -------------------- */
body[data-iotclass-interactive-family] :is(.iot-boundaries, .conform-boundaries, [aria-label="Technical boundaries"], [data-iotclass-former-aside].iot-boundaries):where(:scope, *) {
  display: block;
  float: none !important;
  grid-column: 1 / -1 !important;
  width: auto !important;
  max-width: none !important;
  margin: .75rem 0 !important;
  box-sizing: border-box;
  columns: auto !important;
  position: static !important;
}

/* ---- text and documentation sections keep the page margin (FS-0006) -------------------------------------- */
body[data-iotclass-interactive-family="games"] #quarto-document-content:where(:scope, *) {
  box-sizing: border-box;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}
body[data-iotclass-interactive-family="games"] #quarto-document-content > :is(section, .callout, p, ul, ol, h2, h3):not([id$="Game"]):where(:scope, *) {
  margin-inline: 0;
}

/* ---- hero legibility (FS-0007): chips and headline always contrast with their band ----------------------- */
body[data-iotclass-interactive-family] :is(.hero, [class*="-hero"], [class$="hero"]) :is(h1, h2):where(:scope, *) { text-shadow: none; -webkit-text-stroke: 0; }
body[data-iotclass-interactive-family] :is(.hero, [class*="-hero"]) :is(.chip, .tag, [class*="chip"], [class*="tag"], .quarto-category):where(:scope, *) { color: #172033; background: #fff; border-color: #94a3b8; }
body[data-iotclass-interactive-family] :is(.hero, [class*="-hero"])[data-hero-tone="dark"] :is(h1, h2):where(:scope, *) { color: #fff; }

/* tag-chip row never touches the headline (FS-0023) */
body[data-iotclass-interactive-family] :is(.hero, [class*="-hero"]) :is([class*="chips"], [class*="tags"], .quarto-categories):where(:scope, *) {
  border: 0; box-shadow: none; margin-bottom: .75rem; padding-bottom: 0; position: static;
}

/* ---- collapsible documentation / details (FS-0005, FS-0022) ------------------------------------------------ */
details.iot-doc-panel:where(:scope, *) { margin: 1rem 0; border: 1px solid #cbd5e1; border-radius: .5rem; background: #f8fafc; }
details.iot-doc-panel > summary:where(:scope, *) { cursor: pointer; padding: .7rem 1rem; font-weight: 700; color: #172033; }
details.iot-doc-panel > .iot-doc-panel__body:where(:scope, *) { padding: 0 1rem 1rem; }
details.iot-doc-panel > .iot-doc-panel__body > section:where(:scope, *) { margin-top: 1rem; }

/* ---- title first: no blank band, no controls above the page heading (FS-0021, FS-0028) --------------------- */
body[data-iotclass-interactive-family] [data-iot-dup-heading]:where(:scope, *) { display: none !important; }
body[data-iotclass-interactive-family] header#title-block-header .title:where(:scope, *) { margin-top: 0; }

/* ---- calculators: results beside / under the inputs, previous result chip (LR-6007, LR-6014) ------------------ */
@media (min-width: 1000px) {
  [data-iot-calc-split]:where(:scope, *) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem 2rem; align-items: start; }
  [data-iot-calc-split] > *:where(:scope, *) { grid-column: 1 / -1; min-width: 0; }
  [data-iot-calc-split] > [data-iot-calc="inputs"]:where(:scope, *) { grid-column: 1; grid-row: span 3; }
  [data-iot-calc-grid]:where(:scope, *) { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .25rem 2rem; align-items: start; }
  [data-iot-calc-grid] > *:where(:scope, *) { grid-column: 1 / -1; min-width: 0; }
  [data-iot-calc-grid] > [data-iot-calc="inputs"]:where(:scope, *) { grid-column: 1; }
  [data-iot-calc-grid] > [data-iot-calc="results"]:where(:scope, *) { grid-column: 2; grid-row: 1 / span var(--iot-calc-rows, 4); position: sticky; top: 1rem; }
  [data-iot-calc-grid] > [data-iot-calc="results"] ~ [data-iot-calc="results"]:where(:scope, *) { grid-row: auto; position: static; }
  [data-iot-calc-split] > [data-iot-calc="results"]:where(:scope, *) { grid-column: 2; grid-row: span 3; position: sticky; top: 1rem; align-self: start; }
}
.iot-delta-chip:where(:scope, *) { display: inline-block; margin-left: .5rem; padding: .1rem .5rem; border-radius: 999px; background: #eef2ff; color: #1e3a8a; font: 600 .78rem/1.4 system-ui, sans-serif; white-space: nowrap; }
.iot-delta-chip[data-dir="up"]:where(:scope, *) { background: #ecfdf5; color: #065f46; }
.iot-delta-chip[data-dir="down"]:where(:scope, *) { background: #fef2f2; color: #991b1b; }

/* ---- text-only recap pages (FS-0004) ---------------------------------------------------------------------------- */
.iot-reveal:where(:scope, *) { margin: .5rem 0 1rem; padding: .75rem 1rem; border: 1px solid #cbd5e1; border-left: 4px solid #2563eb; border-radius: .4rem; background: #f8fafc; }
.iot-reveal textarea:where(:scope, *) { display: block; box-sizing: border-box; width: 100%; min-height: 4.5rem; margin: .5rem 0; padding: .5rem; font: inherit; }
.iot-reveal button:where(:scope, *) { padding: .45rem 1rem; border: 1px solid #1d4ed8; border-radius: .35rem; background: #1d4ed8; color: #fff; font: 700 .95rem/1.3 system-ui, sans-serif; cursor: pointer; }
.iot-reveal [data-iot-answer]:where(:scope, *) { margin-top: .6rem; }
.iot-read-badge:where(:scope, *) { display: inline-block; margin: 0 0 .75rem; padding: .15rem .6rem; border-radius: 999px; background: #e2e8f0; color: #1e293b; font: 700 .8rem/1.5 system-ui, sans-serif; }

/* ---- back-link strip ---------------------------------------------------------------------------------------------- */
.iotclass-return-chrome:where(:scope, *) { flex-wrap: wrap; }
.iotclass-return-chrome [data-iotclass-chapter-back]:where(:scope, *) { color: #174ea6; font-weight: 600; }
.iotclass-used-in:where(:scope, *) { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; }
.iotclass-used-in__label:where(:scope, *) { color: #334155; font-weight: 700; }
.iotclass-used-in a:where(:scope, *) { color: #174ea6; text-decoration: none; }
.iotclass-used-in a + a:where(:scope, *)::before { content: "·"; margin-right: .75rem; color: #94a3b8; }
@media (max-width: 700px) { .iotclass-return-chrome:where(:scope, *) { padding-block: .4rem; gap: .35rem .6rem; } }

/* ---- pill rows are plain chips, not a bordered box that touches the headline (FS-0023) ---- */
body[data-iotclass-interactive-family] :is([class$="-pill-row"], [class*="-pill-row "], [class$="-kicker"], [class*="-kicker "]):where(:scope, *) {
  background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 0 .85rem !important;
}
body[data-iotclass-interactive-family] :is([class$="-pill-row"], [class$="-kicker"]) + :is(h1, h2):where(:scope, *) { margin-top: 0; padding-top: 0; }

/* ---- page margin on every standalone page (FS-0006) ---- */
body[data-iotclass-interactive-family] #quarto-document-content:where(:scope, *) { padding-inline: clamp(12px, 3vw, 24px); box-sizing: border-box; }

/* the Quarto page grid must not grow past the viewport because one child is wide (FS-0002, FS-0040) */
body[data-iotclass-interactive-family] #quarto-content.page-columns:where(:scope, *) { display: block; }
body[data-iotclass-interactive-family] #quarto-document-content:where(:scope, *) { width: auto; box-sizing: border-box; }
body[data-iotclass-interactive-family] #quarto-document-content table:where(:scope, *) { max-width: 100%; }
body[data-iotclass-interactive-family] #quarto-document-content .table-responsive:where(:scope, *) { display: block; overflow-x: auto; }
body[data-iotclass-interactive-family] #quarto-document-content :not(pre) > code:where(:scope, *) { white-space: pre-wrap; overflow-wrap: anywhere; }
body[data-iotclass-interactive-family] select.icq-blank-select:where(:scope, *) { max-width: min(100%, 14rem); }
body[data-iotclass-interactive-family] .icq-line-content:where(:scope, *) { flex-wrap: wrap; min-width: 0; max-width: 100%; }
@media (max-width: 700px) {
  body[data-iotclass-interactive-family] #quarto-document-content table:not(.table-responsive table):where(:scope, *) { display: block; max-width: 100%; overflow-x: auto; }
}
body[data-iotclass-interactive-family] .katex-display:where(:scope, *) { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
@media (max-width: 700px) {
  body[data-iotclass-interactive-family] #quarto-document-content :is(p, li, td, th, .callout-body):has(.katex:not(.katex-display .katex)):where(:scope, *) { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
}

/* a chapter stylesheet reserves a 50/61 px band for its fixed top bar; standalone tool pages have none (FS-0028) */
body[data-iotclass-interactive-family]:where(:scope, *)::before { content: none !important; display: none !important; height: 0 !important; }

/* ---- tpl-fix-3 ---- */
/* FS-0069: the Try/Observe/Explain ramp and the colour key keep their card styling on pages that lack the inline rules */
body[data-iotclass-interactive-family] section[class^="style-census-"][class$="-ramp"]:where(:scope, *) { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 12px 0; }
body[data-iotclass-interactive-family] section[class^="style-census-"][class$="-ramp"] > div:where(:scope, *) { padding: 12px; background: #fff; border: 1px solid #D8E3E8; border-radius: 8px; }
body[data-iotclass-interactive-family] section[class^="style-census-"][class$="-ramp"] strong:where(:scope, *) { display: block; margin-bottom: 5px; color: #20313a; font-size: .78rem; text-transform: uppercase; }
body[data-iotclass-interactive-family] section[class^="style-census-"][class$="-ramp"] span:where(:scope, *) { display: block; color: #5f727d; font-size: .84rem; line-height: 1.35; }
body[data-iotclass-interactive-family] div[class^="style-census-"][class$="-legend"]:where(:scope, *) { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .65rem 0 1rem; padding: .65rem .8rem; background: #fff; border: 1px solid #D8E3E8; border-radius: 8px; font-size: .78rem; }
body[data-iotclass-interactive-family] div[class^="style-census-"][class$="-legend"] span:where(:scope, *) { display: inline-flex; align-items: center; gap: .35rem; }
body[data-iotclass-interactive-family] div[class^="style-census-"][class$="-legend"] i:where(:scope, *) { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; }

/* FS-0066: tickable checklists */
ul.iot-checklist:where(:scope, *) { list-style: none; margin: .5rem 0 1rem; padding: 0; }
ul.iot-checklist > li:where(:scope, *) { margin: .35rem 0; }
ul.iot-checklist label:where(:scope, *) { display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; line-height: 1.45; }
ul.iot-checklist input[type="checkbox"]:where(:scope, *) { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin-top: .2rem; }
ul.iot-checklist input:checked + span:where(:scope, *) { color: #475569; text-decoration: line-through; text-decoration-color: #94a3b8; }
.iot-checklist-count:where(:scope, *) { margin: 0 0 1rem; font: 600 .85rem/1.4 system-ui, sans-serif; color: #334155; }

/* FS-0067: a record template becomes a small form */
form.iot-record-form:where(:scope, *) { margin: .75rem 0 1rem; display: grid; gap: .6rem; max-width: 46rem; }
form.iot-record-form label:where(:scope, *) { display: grid; gap: .2rem; font-weight: 700; color: #172033; }
form.iot-record-form textarea:where(:scope, *) { box-sizing: border-box; width: 100%; min-height: 2.6rem; padding: .45rem .55rem; font: 400 .95rem/1.4 system-ui, sans-serif; border: 1px solid #94a3b8; border-radius: .35rem; }
form.iot-record-form .iot-record-actions:where(:scope, *) { display: flex; gap: .6rem; align-items: center; }
form.iot-record-form button:where(:scope, *) { padding: .45rem 1rem; border: 1px solid #1d4ed8; border-radius: .35rem; background: #1d4ed8; color: #fff; font: 700 .9rem/1.3 system-ui, sans-serif; cursor: pointer; }
form.iot-record-form button[type="reset"]:where(:scope, *) { background: #fff; color: #1d4ed8; }
form.iot-record-form [role="status"]:where(:scope, *) { font-size: .85rem; color: #065f46; }

/* FS-0073: calculators that update live carry a Reset beside the inputs and no Calculate button */
[data-iot-live-calc] .iot-conformance-controls:where(:scope, *) { margin: .5rem 0; }
[data-iot-live-calc] [data-iot-verb="primary"][data-iot-removed]:where(:scope, *) { display: none !important; }

/* FS-0100: long code-quiz lines wrap instead of scrolling the page sideways on phones */
body[data-iotclass-interactive-family] .icq-line:where(:scope, *) { flex-wrap: wrap; overflow-x: visible; }
body[data-iotclass-interactive-family] .icq-line-content:where(:scope, *), body[data-iotclass-interactive-family] .icq-line-content *:where(:scope, *) { white-space: pre-wrap; overflow-wrap: anywhere; }
body[data-iotclass-interactive-family] .icq-code-block:where(:scope, *), body[data-iotclass-interactive-family] .icq-code-container:where(:scope, *) { max-width: 100%; }
}
