/* Coding Classroom v0.8.3 — Round 3: responsive lab, mobile UX, first-use guidance, save state */

/* Keep real devices from inheriting accidental preview widths. */
html,body{max-width:100%;overflow-x:clip}
main{width:min(1480px,calc(100% - clamp(20px,3vw,48px)));margin-inline:auto}
img,svg,canvas{max-width:100%}
.page-view,.workspace-shell,.lesson-panel,.program-panel,.stage-panel{min-width:0}

/* First-use onboarding when no learner is active. */
.getting-started{
  display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:18px;
  margin:0 0 22px;padding:20px 22px;border:1px solid #bddcf4;border-radius:18px;
  background:linear-gradient(135deg,#f7fbff 0%,#edf7ff 60%,#f4fbff 100%);
  box-shadow:0 10px 28px rgba(20,77,132,.07)
}
.getting-started-icon{display:grid;place-items:center;width:54px;height:54px;border-radius:15px;background:#1558b8;color:#fff;font:800 1.4rem/1 ui-monospace,monospace;box-shadow:0 5px 0 #0e438f}
.getting-started h2{margin:2px 0 5px;font-size:1.18rem;color:#103965}
.getting-started p:not(.eyebrow){margin:0;color:#496985;line-height:1.65}
.getting-started small{display:block;margin-top:4px;color:#6d8297}
.getting-started .primary-cta{white-space:nowrap}

/* Editor mode + local save state share one compact toolbar. */
.editor-toolbar-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}
.editor-toolbar-row .editor-modes{margin:0;min-width:0}
.lab-save-state{display:inline-flex;align-items:center;gap:7px;min-height:34px;padding:5px 10px;border:1px solid #cfe0ee;border-radius:999px;background:#f7fbff;color:#55718d;font-size:.76rem;font-weight:700;white-space:nowrap}
.save-dot{width:8px;height:8px;border-radius:50%;background:#2a9b74;box-shadow:0 0 0 3px rgba(42,155,116,.10)}
.lab-save-state.is-saving .save-dot{background:#d49424;box-shadow:0 0 0 3px rgba(212,148,36,.12);animation:savePulse .85s ease-in-out infinite alternate}
.lab-save-state.is-error{color:#9e4337;border-color:#edc7c1;background:#fff6f4}.lab-save-state.is-error .save-dot{background:#d75b50;box-shadow:0 0 0 3px rgba(215,91,80,.11)}
@keyframes savePulse{to{transform:scale(1.22);opacity:.58}}

.technical-error{margin:8px 0 0;border:1px solid #efcec8;border-radius:10px;background:#fff8f6;overflow:hidden}
.technical-error summary{cursor:pointer;padding:9px 11px;color:#93453b;font-size:.82rem;font-weight:750}
.technical-error pre{margin:0;padding:10px 11px;border-top:1px solid #f2d9d4;background:#fff;color:#6f3933;white-space:pre-wrap;overflow-wrap:anywhere;font:12.5px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}

/* Desktop: Stage stays primary, while the editor keeps a safe readable minimum. */
@media(min-width:1281px){
  #view-lab .workspace-shell{grid-template-columns:minmax(210px,.70fr) minmax(390px,1.28fr) minmax(430px,1.48fr);gap:14px}
}
@media(min-width:1025px) and (max-width:1280px){
  #view-lab .workspace-shell{display:grid;grid-template-columns:minmax(185px,.62fr) minmax(340px,1.18fr) minmax(370px,1.28fr);gap:10px}
  #view-lab .lesson-panel,#view-lab .program-panel,#view-lab .stage-panel{padding:13px}
  #view-lab .lesson-head h2{font-size:1.16rem}
  #view-lab .goal-card{margin:10px 0;padding:10px}
  #view-lab .tips{margin-top:10px;padding:10px}
}

/* Short school notebooks: keep all three columns visible without forcing a huge vertical editor. */
@media(min-width:1025px) and (max-height:820px){
  #view-lab{padding-top:14px}
  #view-lab .lab-heading{margin-bottom:9px}
  #view-lab .mission-strip{margin-bottom:10px;padding:10px 14px}
  #view-lab .mission-tabs{padding-top:5px}
  #view-lab .mission-tab{min-height:36px;padding:6px 10px}
  #view-lab .lesson-panel,#view-lab .program-panel,#view-lab .stage-panel{padding-top:12px;padding-bottom:12px}
  #view-lab .python-ide,#view-lab .python-code-surface{min-height:315px}
  #view-lab .dropzone{min-height:245px;max-height:430px}
  #view-lab .stage-wrap{padding:7px;margin-top:7px}
  #view-lab .stage-legend{margin-top:6px}
  #view-lab .stage-run-actions{margin-top:8px}
  #view-lab .feedback{margin-top:9px;padding:9px 10px}
  #view-lab .stage-coordinates{margin:7px 0}
  #view-lab .lesson-prep{margin-top:10px}
  #view-lab .hint-panel{margin-top:10px}
}

/* Tablet and smaller: app-style tabs replace squeezed columns. */
@media(max-width:1024px){
  .mobile-lab-tabs{
    display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));position:sticky;
    top:calc(var(--site-header-height,120px) + 6px);z-index:45;margin:0 0 12px;padding:5px;
    background:rgba(241,247,253,.96);backdrop-filter:blur(12px);border:1px solid #cfe0ee;border-radius:13px;
    box-shadow:0 8px 20px rgba(24,67,112,.09)
  }
  .mobile-lab-tabs button{min-height:44px;border:0;border-radius:9px;background:transparent;color:#4f6881;font-weight:750}
  .mobile-lab-tabs button[aria-pressed=true]{background:linear-gradient(180deg,#1f66c5,#1957ab);color:#fff;box-shadow:0 3px 8px rgba(25,87,171,.20)}
  #view-lab .workspace-shell{display:block!important}
  #view-lab .workspace-shell>.lesson-panel,#view-lab .workspace-shell>.program-panel,#view-lab .workspace-shell>.stage-panel{width:100%;min-height:0;margin:0}
  .in-lab #labWorkspace[data-mobile-panel=mission] .program-panel,.in-lab #labWorkspace[data-mobile-panel=mission] .stage-panel{display:none!important}
  .in-lab #labWorkspace[data-mobile-panel=code] .lesson-panel,.in-lab #labWorkspace[data-mobile-panel=code] .stage-panel{display:none!important}
  .in-lab #labWorkspace[data-mobile-panel=result] .lesson-panel,.in-lab #labWorkspace[data-mobile-panel=result] .program-panel{display:none!important}
  #view-lab .stage{width:min(100%,760px);max-width:none;aspect-ratio:4/3}
  #view-lab .stage-wrap{width:100%;margin-inline:auto}
  #view-lab .program-panel{position:static}
  #view-lab .python-ide,#view-lab .python-code-surface{min-height:clamp(340px,55vh,590px)}
  #view-lab .dropzone{max-height:none;min-height:360px}
  .getting-started{grid-template-columns:auto minmax(0,1fr)}
  .getting-started .primary-cta{grid-column:2;justify-self:start}
}

/* Phones: maximize working area, avoid page-wide horizontal scrolling. */
@media(max-width:700px){
  main{width:min(100% - 20px,1480px)}
  .lab-heading{display:grid;grid-template-columns:1fr auto;gap:5px 10px;align-items:start}
  .lab-heading>span{grid-column:2;text-align:right;max-width:160px}
  .lab-heading>a:last-child{grid-column:1/-1;justify-self:start}
  .mission-strip{margin-bottom:10px}
  .mobile-lab-tabs{top:calc(var(--site-header-height,150px) + 5px);margin-inline:-1px}
  .mobile-lab-tabs button{font-size:.9rem;min-height:46px}
  #view-lab .lesson-panel,#view-lab .program-panel,#view-lab .stage-panel{padding:14px;border-radius:15px}
  #view-lab .stage{width:100%;max-width:none}
  #view-lab .stage-wrap{padding:6px;border-radius:12px}
  #view-lab .stage-run-actions{position:sticky;bottom:8px;z-index:14;grid-template-columns:minmax(0,1fr) auto auto;margin:10px -4px 0;padding:8px;background:rgba(255,255,255,.96);backdrop-filter:blur(10px);border:1px solid #d6e3ee;border-radius:12px;box-shadow:0 8px 22px rgba(25,59,97,.12)}
  #view-lab .stage-run-actions .run-btn{min-width:0}
  #view-lab .python-ide{grid-template-columns:40px minmax(0,1fr)}
  #view-lab .python-ide,#view-lab .python-code-surface{min-height:58vh;max-height:72vh}
  #view-lab .python-highlight,#view-lab #pythonEditor{padding:13px 10px;font-size:13px!important;overflow:auto}
  #view-lab .python-gutter pre{padding:13px 7px 13px 2px;font-size:13px}
  .editor-toolbar-row{align-items:stretch;flex-direction:column;gap:7px}
  .lab-save-state{align-self:flex-start;min-height:30px;font-size:.72rem}
  .getting-started{grid-template-columns:1fr;padding:17px;gap:12px}
  .getting-started-icon{width:46px;height:46px}
  .getting-started .primary-cta{grid-column:auto;width:100%}
  .learner-bar{min-width:0}.learner-bar>div{min-width:0}.learner-bar-actions{flex-wrap:wrap}
  .site-footer-v062 .footer-version{width:100%}
}

@media(max-width:430px){
  #view-lab .stage-run-actions{grid-template-columns:1fr 46px 52px;gap:6px}
  #view-lab .stage-run-actions button{padding-inline:7px;font-size:.78rem}
  #view-lab .stage-legend{gap:7px;font-size:.7rem}
  #view-lab .python-ide{grid-template-columns:36px minmax(0,1fr)}
  .mobile-lab-tabs{padding:4px}
}

@media(orientation:landscape) and (max-width:900px) and (max-height:520px){
  .mobile-lab-tabs{position:sticky;top:4px}
  #view-lab .python-ide,#view-lab .python-code-surface{min-height:300px;height:calc(100vh - 150px)}
  #view-lab .stage{width:min(72vh,100%)}
}

@media(prefers-reduced-motion:reduce){.lab-save-state.is-saving .save-dot{animation:none}}
