﻿@media(max-width:720px){body{overflow-x:hidden}.wrap{width:100%;padding:12px}.hero{display:grid;grid-template-columns:48px minmax(0,1fr) 72px;align-items:center;gap:10px;min-height:0;padding:14px;border-radius:18px}.mascot-badge{width:48px;height:48px;border-width:2px}.hero .titles{width:100%;min-width:0}.hero .eyebrow{max-width:100%;font-size:8px;line-height:1.35;letter-spacing:1px;overflow-wrap:normal;word-break:normal}.hero h1{max-width:100%;margin-top:3px;font-size:clamp(19px,5.6vw,23px);line-height:1.08;letter-spacing:-.02em;overflow-wrap:normal;word-break:normal;text-wrap:balance}.hero p{max-width:34ch;margin:5px 0 0;font-size:9.5px;line-height:1.42;overflow-wrap:normal;word-break:normal}.xp-badge{width:72px;min-width:0;padding:6px 4px;border-radius:12px}.xp-badge .xp-num{font-size:18px;line-height:1}.xp-badge .xp-lbl{font-size:6.5px;line-height:1.25;letter-spacing:.35px;text-align:center}.xp-badge .lvl-lbl{font-size:9px;padding:2px 7px}.util-bar{display:grid;grid-template-columns:1fr auto;gap:8px;margin-top:10px}.util-btn{min-width:0;min-height:44px;padding:8px 11px;justify-content:center;font-size:10px;white-space:nowrap}.util-btn .kbd{display:none}.tabs-wrap{margin:10px -12px 0;padding:8px 12px 7px}.tabs{display:flex;flex-wrap:nowrap;gap:7px;width:100%;overflow-x:auto;overscroll-behavior-inline:contain;scroll-snap-type:x proximity;scrollbar-width:none;-webkit-overflow-scrolling:touch}.tabs::-webkit-scrollbar{display:none}.tab-btn{flex:0 0 auto;min-height:44px;max-width:none;padding:7px 12px 7px 7px;gap:6px;font-size:11px;white-space:nowrap;scroll-snap-align:start}.tab-num{width:24px;height:24px;font-size:10px}.progress-track{height:4px;margin-top:7px}.progress-caption{font-size:8px}.panel>.card,.panel>.grid2>.card,.panel>.grid3>.card{padding:13px;border-radius:16px}.card-head h2{font-size:18px;line-height:1.2}}
@media(max-width:420px){.wrap{padding:10px}.hero{grid-template-columns:42px minmax(0,1fr) 64px;gap:8px;padding:12px;border-radius:16px}.mascot-badge{width:42px;height:42px}.hero .eyebrow{font-size:7px;letter-spacing:.7px}.hero h1{font-size:19px}.hero p{font-size:8.5px;line-height:1.35}.xp-badge{width:64px;padding:6px 3px}.xp-badge .xp-lbl{font-size:6px}.tabs-wrap{margin-left:-10px;margin-right:-10px;padding-left:10px;padding-right:10px}.tab-btn{font-size:10.5px}}


/* 2026 responsive UX refresh */
html{scroll-padding-top:92px}body{overflow-wrap:break-word}img,svg,canvas,video,iframe{max-width:100%}button,a,summary,select,input{touch-action:manipulation}
@media(min-width:721px) and (max-width:1024px){.wrap{width:min(100% - 32px,920px);padding:16px 0}.hero{padding:15px 18px}.grid3{grid-template-columns:repeat(2,minmax(0,1fr))}.card{padding:16px}.tabs{gap:8px}.tab-btn{min-height:44px}.tt,.ptable{display:block;width:100%;overflow-x:auto;overscroll-behavior-inline:contain;-webkit-overflow-scrolling:touch}.tt tbody,.ptable tbody{min-width:680px}.chem-miner-toolbar,.disp-controls{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:720px){html{font-size:16px;scroll-padding-top:82px}body{background-attachment:scroll;padding-bottom:max(24px,env(safe-area-inset-bottom));overflow-x:hidden}.cc-mobile-header{padding-top:max(9px,env(safe-area-inset-top))}.wrap{width:100%;max-width:none;margin:0;padding:10px}.panel{min-width:0}.panel>.card,.panel>.grid2>.card,.panel>.grid3>.card,.card{min-width:0;margin-bottom:10px;padding:14px;border-radius:16px;box-shadow:0 4px 14px rgba(11,47,91,.09)}.card:hover{transform:none}.card-head{min-width:0;align-items:flex-start;gap:8px;margin-bottom:10px;padding-bottom:9px}.card-head h2{min-width:0;font-size:clamp(18px,5vw,22px);line-height:1.22;text-wrap:balance}.grid2,.grid3{grid-template-columns:minmax(0,1fr);gap:10px}p,.note,.lesson-intro{font-size:14px;line-height:1.65}h3{font-size:clamp(17px,4.8vw,21px);line-height:1.3}button,.btn,.util-btn,.tab-btn,select,input,.acc-head,.opt,summary{min-height:44px}select,input[type=number],input[type=text]{font-size:16px}.formula-box,.pthh-math,.mass-law-equation,.worked-example,.valency-rule{max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain}.katex-display{max-width:100%;margin:.55em 0!important;overflow-x:auto;overflow-y:hidden;padding:2px 0;-webkit-overflow-scrolling:touch}.katex-display>.katex{font-size:clamp(.82em,3.9vw,1em);white-space:nowrap}.tt,.ptable{display:block;width:100%;max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;scrollbar-width:thin;-webkit-overflow-scrolling:touch}.tt tbody,.ptable tbody{min-width:620px}.tt th,.tt td{padding:9px 10px;font-size:12px}.series-row,.legend,.filter-row,.chip-row,.segmented,.model-tabs{max-width:100%;overflow-x:auto;flex-wrap:nowrap!important;overscroll-behavior-inline:contain;scrollbar-width:none;-webkit-overflow-scrolling:touch}.series-row::-webkit-scrollbar,.legend::-webkit-scrollbar,.filter-row::-webkit-scrollbar,.chip-row::-webkit-scrollbar{display:none}.series-row>*,.legend>*,.filter-row>*,.chip-row>*{flex:0 0 auto}.palette-overlay{padding:calc(max(12px,env(safe-area-inset-top)) + 72px) 10px 10px}.palette-box{max-height:calc(100dvh - 94px)}.palette-results{max-height:55dvh}}
@media(max-width:480px){.wrap{padding:8px}.cc-mobile-header{height:68px;padding-inline:9px}.cc-mobile-brand img{width:44px;height:44px}.cc-mobile-brand span{font-size:17px}.cc-menu-toggle{width:46px;height:46px}.hero{grid-template-columns:40px minmax(0,1fr) 60px;padding:11px;gap:8px}.hero h1{font-size:clamp(18px,5.2vw,21px)}.hero p{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:10px}.util-bar{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.util-btn{width:100%;padding:7px 8px;font-size:11px}.panel>.card,.panel>.grid2>.card,.panel>.grid3>.card,.card{padding:12px}.card-head h2{font-size:18px}.chem-miner-shell,.disp-lab,.virtual-lab{margin-inline:-4px;padding:7px}.chem-miner-toolbar,.disp-controls,.lab-controls{grid-template-columns:minmax(0,1fr)!important}.chem-miner-start{grid-column:auto}.chem-miner-stage canvas,#chemMinerCanvas{min-height:230px;aspect-ratio:4/3}.chem-miner-frame-shell iframe{height:min(600px,145vw);min-height:500px}}
@media(max-width:360px){.cc-mobile-brand small{display:none}.hero .eyebrow{font-size:6.5px;letter-spacing:.55px}.hero h1{font-size:17px}.xp-badge{width:58px}.tab-btn{font-size:10px}.cluster-lesson-header p{display:none}}
@media(max-height:520px) and (orientation:landscape){.cc-mobile-header{height:58px}.cc-mobile-brand img{width:38px;height:38px}.chem-miner-frame-shell iframe{height:calc(100dvh - 86px);min-height:390px}}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}.card,.tab-btn,.util-btn{transition:none!important}}

/* Compact mining iframe on narrow phones */
@media(max-width:480px){.chem-miner-frame-shell iframe{height:min(520px,130vw);min-height:440px}}


/* =========================================================================
   2026-08 UX pass — lesson pages
   Loads last, so these intentionally override the per-module stylesheets.
   ========================================================================= */

/* --- 1. Stop gratuitous mid-word breaks -------------------------------- */
/* body{overflow-wrap:break-word} above is needed for long formulas, but it
   was also chopping ordinary words in narrow boxes ("Zirconi|um").
   Names, headings and short labels must never break inside a word.        */
h1,h2,h3,h4,
.card-head h2,.cluster-lesson-header h1,.cluster-kicker,.cluster-home-link,
.em-name,.element-identity,.periodic-modal-category,
.element-section-title b,.element-facts span,
.pel .m,.tab-btn,.periodic-filter,.atomic-lab-head b,
.disp-3d-badge,.cc-vlab-badge,.atomic-lab-modal-sheet>header h2{
  overflow-wrap:normal;word-break:normal;hyphens:none
}
/* values (electron config etc.) may wrap, but only when truly necessary */
.element-facts b{overflow-wrap:break-word}

/* --- 2. Lesson header card: stronger, more legible text (mobile) ------- */
@media(max-width:680px){
  .cluster-lesson-header{padding:14px}
  .cluster-home-link{color:#dcefff;font-size:12px}
  .cluster-kicker{margin-top:3px;color:#ffdc86;font-size:10.5px;letter-spacing:.1em}
  .cluster-lesson-header h1{margin:6px 0 4px;font-size:clamp(22px,5.8vw,27px);line-height:1.16;text-wrap:balance}
  .cluster-lesson-header p{color:#eaf6ff;font-size:11.5px;line-height:1.5}
}

/* --- 3. Periodic table on phones -------------------------------------- */
/* 18 columns can never be legible at 375px, so instead of shrinking text
   into illegibility we: drop the 5.5px element name (tapping a cell opens
   the full detail card anyway), enlarge the symbol, shrink the cell so
   there is ~17% less horizontal scrolling, and add real scroll affordance. */
@media(max-width:560px){
  .ptable.periodic-grid{--cell:36px;min-width:700px;gap:3px}
  .periodic-grid .pel{padding:2px;border-radius:6px}
  .periodic-grid .pel .m{display:none}
  .periodic-grid .pel .s{font-size:14px}
  .periodic-grid .pel .z{top:2px;left:3px;font-size:6.5px}
  .periodic-shell{
    touch-action:pan-x pan-y pinch-zoom;
    background:
      linear-gradient(90deg,#fff 32%,rgba(255,255,255,0)) left/22px 100% no-repeat local,
      linear-gradient(90deg,rgba(255,255,255,0),#fff 68%) right/22px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%,rgba(11,47,91,.17),transparent) left/11px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%,rgba(11,47,91,.17),transparent) right/11px 100% no-repeat scroll
  }
  .periodic-hint{
    display:flex;align-items:center;gap:6px;margin-bottom:8px;padding:7px 10px;
    border:1px solid #cfe3f2;border-radius:10px;background:#f2f9ff;
    color:#2b648f;font-size:10.5px
  }
  .periodic-hint::before{content:"↔";font-size:13px;font-weight:900}
}

/* --- 4. Element detail card: fit more above the fold ------------------- */
@media(max-width:560px){
  /* ID-scoped to beat `#elModalOverlay .el-modal-head` in lay-goc-hoa.css,
     otherwise the tightening below is dead CSS. Right padding must stay
     clear of .wiki-element-media (right:36px + 54px wide = 90px).        */
  #elModalOverlay .el-modal-head{min-height:0;padding:14px 96px 13px 15px}
  .el-modal-head .em-eyebrow{margin-bottom:7px}
  .element-identity .nuclear-element{font-size:42px}
  .el-modal-head .em-name{font-size:16px}
  .wiki-element-media{width:54px;height:54px;right:36px}
  .el-modal-body{padding:12px 13px 14px}
  .element-facts{gap:6px;margin-bottom:10px}
  .element-facts>div{padding:8px 9px}
  .element-facts b{font-size:12px}
  .atomic-model-2d.element-bohr-card{padding:10px}
  .element-bohr-card .periodic-shell-diagram svg{width:min(100%,152px)}
  .element-bohr-card>p{font-size:8.5px}
  .open-atomic-3d{min-height:52px;margin-top:8px}
}

/* --- 5. 3D simulation panels: keep overlays off the model -------------- */
@media(max-width:560px){
  .disp-3d-hint{bottom:6px;padding:5px 8px;font-size:7.5px;max-width:calc(100% - 16px)}
  .disp-3d-badge{padding:5px 8px}
  .atomic-lab-tip{left:6px;bottom:6px;padding:4px 6px}
}

/* --- 6. Element facts: keep 2x2 on the narrowest phones ---------------- */
/* atomic-lab.css collapses this to a single column under 370px, which
   turned four compact tiles into four full-width rows and pushed the
   "open 3D" button below the fold. Two columns still fit at 320px.      */
@media(max-width:560px){
  .element-facts{grid-template-columns:1fr 1fr}
  .element-facts>div{padding:8px 9px}
  .element-facts span{font-size:7.5px}
  .element-facts b{font-size:11.5px;line-height:1.35}
}

/* --- 7. Desktop: stop wasting half the screen -------------------------- */
/* Lesson pages were locked to .wrap{max-width:980px}, so on a 1440-1920px
   display roughly half the viewport was empty while the periodic table,
   the 3D labs and the virtual lab were all cramped. 1180px matches the
   marketing site's container (--container-max-width in DESIGN_SYSTEM.md),
   so the two halves of the product finally line up.
   Body copy keeps a readable measure via max-width on text blocks.      */
@media(min-width:1100px){
  .wrap{max-width:1180px}
  .cluster-lesson-header,.cluster-lesson-nav,.cluster-breadcrumb{width:min(100%,1180px)}
  /* keep prose at a comfortable measure even though the shell is wider */
  .card>p,.card>.note,.lesson-intro,.card-head+p{max-width:78ch}
  /* wide interactive modules get the extra room they actually need */
  .atomic-models-row{grid-template-columns:minmax(190px,.62fr) minmax(0,1.38fr)}
  .atomic-lab-stage,#atomicLabCanvas{height:300px;min-height:300px}
}
@media(min-width:1400px){
  .wrap{max-width:1280px}
}

/* --- 8. Virtual lab: declutter the simulation stage -------------------- */
/* The stage is only ~360x370 on a phone and was holding the drag hint,
   the temperature box, the thermometer, the beaker, the metal chip AND a
   canvas-drawn "H2O" label pinned at (19,34) - the hint sat right on top
   of that label. The stage background is a brown "ground" band across the
   bottom 25% that carried no information, so the hint moves there and the
   temperature box shrinks, clearing the whole upper-left corner.        */
@media(max-width:560px){
  .cc-vlab-hint{
    top:auto;bottom:8px;left:8px;right:8px;
    padding:6px 9px;border-radius:9px;background:#ffffffef;
    font-size:9px;line-height:1.3;text-align:center
  }
  .cc-vlab-tempbox{top:8px;right:8px;width:62px;padding:6px;border-radius:10px}
}

/* --- 9. Activity series: stop clipping the start of the row ----------- */
/* .series-row is `justify-content:center` and the mobile rules turn it
   into an overflow-x:auto strip. A centred flex line that overflows
   spills equally BOTH ways, and the left overflow is unreachable - the
   row silently lost K, Na, Ba, Ca, Mg off the front. `safe center`
   keeps the centring while it fits and falls back to flex-start the
   moment it overflows, so nothing is ever cut off.                     */
.series-row,.legend,.filter-row,.chip-row,.segmented,.model-tabs{
  justify-content:safe center
}
@supports not (justify-content:safe center){
  .series-row,.legend,.filter-row,.chip-row,.segmented,.model-tabs{justify-content:flex-start}
}
.series-row{scroll-padding-inline:8px}

/* --- 10. Data tables: scroll the wrapper, never the <table> ----------- */
/* Pairs with the wrapper injected by lay-goc-hoa-init.js. Setting
   display:block on a <table> (the previous approach) breaks column
   alignment and leaves the ugly seam that was reported.                */
.table-scroll{
  max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;border-radius:12px
}
.table-scroll:focus-visible{outline:3px solid var(--yellow-500,#f6b73c);outline-offset:2px}
.table-scroll>.tt{display:table;width:100%;min-width:520px;margin:0}
@media(max-width:720px){
  /* undo the old table-breaking rules now that a wrapper handles overflow */
  .tt{display:table!important;width:100%}
  .tt tbody{min-width:0!important}
}

/* --- 11. Lesson tab labels: readable on the navy pill ----------------- */
.tab-btn.active,.tab-btn[aria-selected=true]{color:#fff}
.tab-btn.active .tab-num,.tab-btn[aria-selected=true] .tab-num{
  background:#ffd166;color:#0b365e
}

/* --- 12. Periodic table must stay swipeable on touch ------------------ */
/* `manipulation` (inherited pattern from the button rule) was winning on
   .periodic-shell. Be explicit: horizontal panning + pinch zoom.        */
/* `pan-x pan-y pinch-zoom` was being dropped by the parser (computed
   stayed `manipulation`), so use plain `auto` - it permits horizontal
   panning and pinch zoom, which is exactly what this strip needs. */
.periodic-shell{touch-action:auto !important;-webkit-overflow-scrolling:touch}

/* --- 13. Data tables: stack on phones, no horizontal scrolling -------- */
/* Requested: show every column without scrolling. Below 620px each row
   becomes its own card and each cell prints "Column: value" using the
   data-label attribute injected by lay-goc-hoa-init.js. Above that the
   normal table (inside .table-scroll) is used unchanged.                */
@media(max-width:620px){
  .table-scroll{overflow-x:visible;border-radius:0}
  /* !important needed: rule 10 above sets .tt{display:table!important} to
     undo the old table-breaking CSS, and that would otherwise win here. */
  .table-scroll>.tt.tt--stackable{min-width:0;display:block!important;border-collapse:separate}
  .tt--stackable thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .tt--stackable tbody,.tt--stackable tr,.tt--stackable td{display:block;width:100%}
  .tt--stackable tr{
    margin:0 0 10px;padding:10px 12px;
    border:1px solid #d9e6f0;border-radius:12px;background:#fff;
    box-shadow:0 2px 8px rgba(11,47,91,.06)
  }
  .tt--stackable tr:first-child:has(th){display:none}
  .tt--stackable td{
    padding:6px 0;border:0;border-bottom:1px solid #eef4f9;
    font-size:13px;line-height:1.5;text-align:left
  }
  .tt--stackable td:last-child{border-bottom:0;padding-bottom:0}
  .tt--stackable td::before{
    content:attr(data-label);
    display:block;margin-bottom:2px;
    color:#5b7c93;font-size:10px;font-weight:900;
    letter-spacing:.06em;text-transform:uppercase
  }
  .tt--stackable td:not([data-label])::before{content:none}
}
