/* ICE Tables page: additions on top of suite.css (Toy Box) and eq-intro.css.
   The worked-step, ICE-table and unit-analysis rules follow the Solubility Guide (solubility/assets/sol.css),
   so a calculation looks the same in both units. */

:root{
  --ice-right:#1f8a5b; --ice-right-soft:#e3f6ec;
  --ice-wrong:#c8233f; --ice-wrong-soft:#fde7eb;
}

/* ---------- layout: text on the left, a wider stage on the right ---------- */
/* Stage: the problem on top, then the ICE table with any picture under it, then the working.
   The stage is one fixed height and its content scrolls, so the footer (step buttons, bottom right) never moves. */
.ice-guide .guide-layout{grid-template-columns:minmax(0,0.85fr) minmax(0,1.15fr);}
.ice-guide .guide-beat p{max-width:36rem;}
.ice-stage{height:calc(100vh - 2rem);display:flex;flex-direction:column;overflow:hidden;}
.ice-stage .guide-stage-head{align-items:center;flex:none;}
.ice-modes{display:flex;gap:0.4rem;}
.ice-head-end{display:flex;align-items:center;flex-wrap:wrap;gap:0.5rem 0.7rem;margin-left:auto;}
.ice-modes[hidden]{display:none;}
/* the full-explanation checkbox: small, at the bottom left of the footer */
.ice-full{display:inline-flex;align-items:center;gap:0.35rem;font-size:0.8rem;color:var(--dim);cursor:pointer;user-select:none;white-space:nowrap;}
.ice-full input{width:0.95rem;height:0.95rem;margin:0;accent-color:var(--accent);cursor:pointer;}
.ice-full[hidden]{display:none;}
/* Full explanation: notes, captions and how-to lines (.ws-full) show only when the switch is on;
   the brief versions (.ws-brief) show when it is off, the default */
.ice-stage:not(.show-full) .ws-full{display:none !important;}
.ice-stage.show-full .ws-brief{display:none !important;}
.ice-modes .btn{padding:0.3rem 0.8rem;font-size:0.9rem;min-height:0;}
.ice-grid{flex:1;min-height:0;overflow:auto;overflow-anchor:none;display:grid;grid-template-columns:minmax(0,1fr);align-content:start;gap:0.9rem;padding-right:0.2rem;}
.ice-top,.ice-left,.ice-right{display:flex;flex-direction:column;gap:0.8rem;min-width:0;}
.ice-top{gap:0.5rem;}
.ice-top:empty,.ice-left:empty,.ice-right:empty{display:none;}
.ice-foot{flex:none;display:flex;align-items:center;gap:0.6rem;min-height:2.6rem;margin-top:0.7rem;padding-top:0.6rem;border-top:2px solid var(--line);}
.ice-foot-l,.ice-foot-r{display:flex;align-items:center;gap:0.5rem;flex-wrap:wrap;}
.ice-foot-r{margin-left:auto;justify-content:flex-end;}
.ice-foot .ws-bar{margin-top:0;justify-content:flex-end;}
.ice-foot .ice-bar{justify-content:flex-start;}

/* ---------- problem card ---------- */
.ice-card{border:2px solid var(--line-strong);border-radius:var(--radius);padding:0.8rem 0.95rem;background:var(--tray);line-height:1.5;}
.ice-problem{background:#f6f7fd;border-left-width:6px;border-left-color:var(--accent);}
.ice-problem.is-you{border-left-color:var(--eq-a,#e07a2e);background:#fff8f1;}
.ice-hint{margin:0;font-weight:700;color:var(--ink);}
.ice-howto{margin:0;font-size:0.9rem;color:var(--dim);}
.ice-cap{margin:-0.3rem 0 0;font-family:var(--font-mono);font-size:0.72rem;color:var(--dim);}

/* ---------- worked steps (as the Solubility Guide) ---------- */
.ws-lines{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:max-content max-content minmax(0,1fr);
  column-gap:0.5rem;row-gap:0.2rem;font-size:1.08rem;}
.ws-line{display:grid;grid-template-columns:subgrid;grid-column:1 / -1;align-items:center;padding:0.4rem 0.7rem;border-radius:10px;}
.ws-line[hidden]{display:none;}
.ws-lhs{text-align:right;font-weight:700;white-space:nowrap;}
.ws-eq{color:var(--dim);font-weight:700;}
.ws-rhs{font-weight:700;font-variant-numeric:tabular-nums;}
.ws-line.whole .ws-lhs{grid-column:1 / -1;text-align:left;white-space:normal;font-weight:400;line-height:1.45;}
.ws-line.tbl .ws-tag{grid-column:1;justify-self:end;display:inline-grid;place-items:center;min-width:1.7rem;height:1.7rem;padding:0 0.3rem;
  border:2px solid var(--line-strong);border-radius:7px;background:var(--accent-soft);font-weight:700;font-size:0.95rem;}
.ws-line.tbl .ws-note{grid-column:2 / -1;margin:0;color:var(--ink-soft);font-size:1rem;}
.ws-note{grid-column:3;font-size:0.92rem;color:var(--dim);margin-top:0.15rem;line-height:1.4;}
.ws-line.whole .ws-note{grid-column:1 / -1;}
.ws-line.tbl .ws-note.ws-brief{color:var(--ink);font-weight:700;font-variant-numeric:tabular-nums;}
.ws-line.is-current{background:var(--accent-soft);box-shadow:inset 4px 0 0 var(--accent);}
.ws-line.is-current .ws-note{color:var(--ink-soft);}
.ws-bar{display:flex;align-items:center;gap:0.6rem;margin-top:0.7rem;flex-wrap:wrap;}
.ws-bar .btn.ws-next{padding:0.3rem 0.9rem;font-size:0.85rem;min-height:0;box-shadow:0 2px 0 var(--ink);}
.ws-bar .btn.ws-next:active{transform:translateY(2px);box-shadow:0 0 0 var(--ink);}
.ws-bar .btn-sm{padding:0.25rem 0.65rem;font-size:0.82rem;min-height:0;}
.ws-count{font-family:var(--font-mono);font-size:0.85rem;color:var(--dim);}
.ws-lines.is-empty::before{content:"Each step appears here as we go.";grid-column:1 / -1;color:var(--dim);font-size:0.95rem;padding:0.4rem 0.7rem;}

/* unit analysis: stacked fractions, cancelled units struck through (SolUI.ua) */
.ua-frac{display:inline-flex;flex-direction:column;align-items:center;vertical-align:middle;margin:0.15em 0.1em;line-height:1.25;font-size:0.9em;}
.ua-num{padding:0 0.3em 0.12em;border-bottom:2px solid currentColor;white-space:nowrap;}
.ua-den{padding:0.12em 0.3em 0;white-space:nowrap;}
.ua-op{margin:0 0.1em;}
.ua-step{white-space:nowrap;}
.ua-x{text-decoration:line-through;text-decoration-color:var(--accent);text-decoration-thickness:2px;}

/* ---------- ICE table ---------- */
.ice-wrap{max-width:100%;overflow-x:auto;}
.ice{border-collapse:collapse;font-weight:700;font-variant-numeric:tabular-nums;font-size:1.35rem;margin:0 auto;}
.ice th,.ice td{padding:0.4rem 0.7rem;text-align:center;border-bottom:1.5px solid var(--line);white-space:nowrap;}
.ice thead th{border-bottom:2px solid var(--ink);}
.ice th.ice-unit{font-family:var(--font-mono);font-size:0.75rem;font-weight:400;color:var(--dim);text-align:left;padding-left:0.4rem;}
.ice .ice-key{text-align:left;padding-left:0.6rem;color:var(--ink);}
.ice .ice-alt{display:none;margin-left:0.5rem;font-family:var(--font-mono);font-size:0.72em;color:var(--accent);}
.ice-wrap.show-alt .ice-alt{display:inline;}
.ice .ice-op{padding:0.4rem 0.1rem;color:var(--dim);}
.ice td.is-blank .ice-val{visibility:hidden;}
.ice td.is-new{background:#fff1c7;}
.ice tr.is-current>*{background:var(--accent-soft);}
.ice tr.is-current>:first-child{box-shadow:inset 4px 0 0 var(--accent);}
.ice .is-col{background:var(--accent-soft);}
@media (prefers-reduced-motion:no-preference){ .ice td.is-new .ice-val{animation:ice-pop 0.35s ease-out;} }
@keyframes ice-pop{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}

/* Your turn: each cell is a text box until it is checked, shown, or filled by the answer */
.ice-input td.ice-cell{padding:0.25rem 0.3rem;position:relative;}
.ice-n4 .ice-in{width:5.6rem;}
.ice-input td.ice-cell .ice-val{display:none;}
.ice-input td.ice-cell.is-revealed .ice-val{display:inline;}
.ice-in{width:6.6rem;max-width:100%;font:inherit;font-size:1rem;font-weight:700;text-align:center;padding:0.35rem 0.3rem;
  border:2px solid var(--line-strong);border-radius:8px;background:#ffffff;color:var(--ink);}
.ice-in:focus{outline:3px solid var(--accent);outline-offset:1px;}
.ice-input td.is-right .ice-in{border-color:var(--ice-right);background:var(--ice-right-soft);}
.ice-input td.is-wrong .ice-in{border-color:var(--ice-wrong);background:var(--ice-wrong-soft);}
.ice-input td.is-revealed{color:var(--ink);}
.ice-input td.is-revealed.is-right{color:var(--ice-right);}
.ice-input td.is-given{color:var(--dim);}
.ice-show{display:block;margin:0.2rem auto 0;padding:0.05rem 0.5rem;font:inherit;font-size:0.72rem;font-weight:700;color:var(--ice-wrong);
  background:none;border:1.5px solid var(--ice-wrong);border-radius:999px;cursor:pointer;}
.ice-show:hover{background:var(--ice-wrong-soft);}

/* answer boxes under the table */
.ice-work{display:flex;flex-direction:column;gap:0.8rem;}
.ice-boxes{display:flex;flex-wrap:wrap;gap:0.5rem 1.2rem;justify-content:center;}
.ice-box{display:inline-flex;align-items:center;gap:0.4rem;font-weight:700;padding:0.2rem 0.4rem;border-radius:10px;}
.ice-box-eq{color:var(--dim);}
.ice-box-unit{font-family:var(--font-mono);font-size:0.8rem;font-weight:400;color:var(--dim);}
.ice-box-ans{color:var(--ice-right);margin-left:0.3rem;}
.ice-box.is-right .ice-in{border-color:var(--ice-right);background:var(--ice-right-soft);}
.ice-box.is-wrong .ice-in{border-color:var(--ice-wrong);background:var(--ice-wrong-soft);}
.ice-bar{display:flex;flex-wrap:wrap;gap:0.55rem;align-items:center;justify-content:center;}
.ice-bar .btn{padding:0.35rem 0.9rem;font-size:0.92rem;min-height:0;}
.ice-bar .btn-sm{font-size:0.82rem;}
.ice-feedback{margin:0;min-height:1.4em;text-align:center;font-weight:700;color:var(--ink-soft);}
.ice-feedback.is-good{color:var(--ice-right);}
.ice-feedback.is-bad{color:var(--ice-wrong);}
.ice-answer{border-top:2px dashed var(--line);padding-top:0.7rem;}
.ice-answer[hidden]{display:none;}
.ice-answer-head{margin:0 0 0.3rem;font-weight:700;}

/* Example D's Your turn: a Q box and a shift choice per mixture */
.ice-parts{display:flex;flex-direction:column;gap:0.7rem;}
.ice-part{border:1.5px solid var(--line);border-radius:var(--radius);padding:0.55rem 0.7rem;}
.ice-part-lab{margin:0 0 0.35rem;}
.ice-part .ice-box{margin-right:0.6rem;}
.ice-shift{display:inline-flex;flex-wrap:wrap;gap:0.35rem;margin-top:0.3rem;}
.ice-shift .btn{padding:0.25rem 0.6rem;font-size:0.82rem;min-height:0;}
.ice-shift .btn.is-right{background:var(--ice-right);border-color:var(--ice-right);color:#fff;}
.ice-shift .btn.is-wrong{background:var(--ice-wrong);border-color:var(--ice-wrong);color:#fff;}
.ice-shift .btn.is-answer{outline:3px solid var(--ice-right);outline-offset:2px;}

/* ---------- bulb ---------- */
.ice-bulb{display:flex;flex-direction:column;gap:0.35rem;min-height:0;}
.ice-bulb-box{position:relative;width:100%;aspect-ratio:16 / 5;min-height:120px;max-height:180px;}
.ice-bulb-box canvas{position:absolute;inset:0;display:block;}
.ice-legend{display:flex;flex-wrap:wrap;gap:0.3rem 1rem;font-weight:700;font-size:0.95rem;}
.ice-leg{display:inline-flex;align-items:center;gap:0.35rem;}
.ice-leg i{width:0.8rem;height:0.8rem;border-radius:50%;border:1.5px solid var(--ink);display:inline-block;}
.ice-leg b{font-family:var(--font-mono);font-variant-numeric:tabular-nums;}
.ice-leg sub,.ice-tally sub{font-size:0.72em;line-height:0;}
.ice-tally{margin:0;min-height:1.4em;font-size:0.92rem;color:var(--ink-soft);}

/* ---------- Q vs K gauge ---------- */
.ice-gauge{padding:0.2rem 0.4rem 0;}
.ig-cap{margin:0 0 2.6rem;font-family:var(--font-mono);font-size:0.72rem;color:var(--dim);}
.ig-track{position:relative;height:6px;margin:0 1.6rem 3.6rem;border-radius:3px;background:linear-gradient(90deg,#e3f1fb,#fdeccf);border:1.5px solid var(--line-strong);}
.ig-tick{position:absolute;top:-4px;width:2px;height:12px;margin-left:-1px;background:var(--line-strong);}
.ig-tick span{position:absolute;top:15px;left:50%;transform:translateX(-50%);font-family:var(--font-mono);font-size:0.68rem;color:var(--dim);}
/* K: a fixed post through the line, named underneath. Q: a pointer above the line that slides to K */
.ig-k{position:absolute;top:-12px;width:3px;height:28px;margin-left:-1.5px;background:var(--ink);border-radius:2px;}
.ig-k span{position:absolute;top:44px;left:50%;transform:translateX(-50%);white-space:nowrap;font-weight:700;font-size:0.92rem;}
.ig-q{position:absolute;bottom:12px;width:0;height:0;margin-left:-8px;border-left:8px solid transparent;border-right:8px solid transparent;border-top:12px solid var(--accent);}
.ig-q span{position:absolute;bottom:14px;left:0;transform:translateX(-50%);white-space:nowrap;font-weight:700;font-size:0.92rem;color:var(--accent);}
.ig-q[hidden]{display:none;}
@media (prefers-reduced-motion:no-preference){ .ig-q{transition:left 1.6s ease-in-out;} }
.ig-status{margin:0;font-weight:700;text-align:center;min-height:1.4em;}

/* ---------- Before we begin and the summary ---------- */
.ice-static h2{font-size:clamp(1.4rem,2.4vw,2rem);margin:0 0 0.6rem;}
.ice-brief-pic{position:relative;height:190px;}
.ice-brief-pic svg.hub-anim{position:absolute;inset:0;width:100%;height:100%;}
.ice-brief-text{display:none;}
.ice-brief-text ul{margin:0;padding-left:1.2rem;line-height:1.6;}
.ice-summary ol{margin:0;padding-left:1.4rem;display:flex;flex-direction:column;gap:0.45rem;line-height:1.45;}

/* ---------- presentation view: text hidden, the stage fills the screen ----------
   The problem across the top; below it, the ICE table (and its picture) on the left, the working on the right.
   Each column scrolls by itself (newest line kept in view); the footer stays at the bottom right. */
body.learn-mode .ice-stage{height:auto;bottom:0.75rem;}
body.learn-mode .ice-stage .guide-stage-head{display:flex;margin-bottom:0.5rem;}
body.learn-mode .ice-stage .force-badge{font-size:1.05rem;}
body.learn-mode .ice-grid{overflow:hidden;padding-right:0;align-content:stretch;gap:1rem 1.8rem;
  grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);grid-template-areas:"top top" "left right";}
body.learn-mode .ice-grid.no-top{grid-template-rows:minmax(0,1fr);grid-template-areas:"left right";}
body.learn-mode .ice-grid.no-left{grid-template-areas:"top top" "right right";}
body.learn-mode .ice-grid.no-top.no-left{grid-template-rows:minmax(0,1fr);grid-template-areas:"right right";}
body.learn-mode .ice-grid.one-col{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);grid-template-areas:"left";}
body.learn-mode .ice-top{grid-area:top;}
body.learn-mode .ice-left{grid-area:left;}
body.learn-mode .ice-right{grid-area:right;}
body.learn-mode .ice-left,body.learn-mode .ice-right{overflow:auto;overflow-anchor:none;min-height:0;padding-right:0.3rem;}
body.learn-mode .ice-grid.no-left .ice-right{max-width:62rem;width:100%;justify-self:center;}
body.learn-mode .ice-foot{margin-top:0.6rem;}
body.learn-mode .ice-foot .btn{font-size:1rem;padding:0.4rem 1rem;}
body.learn-mode .ws-count{font-size:0.95rem;}
body.learn-mode .ice-problem{font-size:clamp(1.05rem,1.4vw,1.4rem);}
body.learn-mode .ice-hint{font-size:clamp(1rem,1.25vw,1.25rem);}
body.learn-mode .ice-left .ice-wrap{flex:none;}
body.learn-mode .ice-left>*,body.learn-mode .ice-right>*{flex-shrink:0;} /* the column scrolls; nothing in it gets squashed */
/* the table is the star: large, the full width of its column; the bulb is a small strip under it */
body.learn-mode .ice-bulb{flex:none;}
body.learn-mode .ice-bulb-box{aspect-ratio:auto;flex:none;height:clamp(120px,20vh,190px);min-height:0;max-height:none;}
body.learn-mode .ice-left .ice{width:100%;}
body.learn-mode .ice{font-size:clamp(1.3rem,2vw,2.2rem);}
body.learn-mode .ice th,body.learn-mode .ice td{padding-top:0.55rem;padding-bottom:0.55rem;}
body.learn-mode .ice.ice-n4{font-size:clamp(1.15rem,1.6vw,1.8rem);}
body.learn-mode .ice.ice-n4 th,body.learn-mode .ice.ice-n4 td{padding-left:0.4rem;padding-right:0.4rem;}
body.learn-mode .ice th.ice-unit{font-size:0.6em;}
body.learn-mode .ws-lines{font-size:clamp(1.1rem,1.45vw,1.45rem);}
body.learn-mode .ws-note,body.learn-mode .ws-line.tbl .ws-note{font-size:clamp(0.95rem,1.15vw,1.2rem);}
body.learn-mode .ws-line.tbl .ws-note.ws-brief{font-size:inherit;}
body.learn-mode .ice-in{font-size:clamp(1.1rem,1.5vw,1.6rem);width:8rem;}
body.learn-mode .ice-n4 .ice-in{width:6.6rem;}
body.learn-mode .ice-static{height:100%;display:grid;align-content:center;}
body.learn-mode .ice-static:not(.ice-summary){grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);gap:2rem;align-items:center;}
body.learn-mode .ice-brief-pic{height:min(50vh,420px);}
body.learn-mode .ice-brief-text{display:block;font-size:clamp(1.05rem,1.5vw,1.45rem);}
body.learn-mode .ice-summary{max-width:58rem;margin:0 auto;font-size:clamp(1.1rem,1.7vw,1.6rem);}
/* tablet portrait: one column that scrolls as a whole (table, picture, then the working) */
@media (max-width:1000px){
  body.learn-mode .ice-grid:not(.one-col){overflow:auto;grid-template-columns:minmax(0,1fr);grid-template-rows:none;grid-template-areas:none;align-content:start;}
  body.learn-mode .ice-grid:not(.one-col)>*{grid-area:auto;overflow:visible;min-height:auto;}
  body.learn-mode .ice-grid:not(.one-col) .ice-bulb-box{flex:none;height:min(20vh,200px);}
}

/* ---------- narrow screens: the stage sits above the text ---------- */
@media (max-width:860px){
  .ice-guide .guide-layout{grid-template-columns:minmax(0,1fr);}
  body:not(.learn-mode) .ice-stage{height:auto;overflow:visible;}
  body:not(.learn-mode) .ice-grid{overflow:visible;}
  .ws-lines{font-size:1rem;column-gap:0.4rem;}
  .ws-line{padding:0.35rem 0.5rem;}
  .ws-rhs{overflow-wrap:anywhere;}
  .ice{font-size:1.05rem;}
  .ice th,.ice td{padding:0.35rem 0.4rem;}
  .ice-in{width:5.4rem;font-size:0.95rem;}
}
