/* UX and accessibility fixes (audit 2026-11-08): deep-link offset, header menus, phone header sheet, lesson player on
   phones, touch targets, small text, one primary button style, resume card and empty states. Loaded last. */

/* ---------- deep links and in-page jumps land below the sticky header ---------- */
html{scroll-padding-top:84px}
main:focus{outline:none}
#tk-detail,.tk-result,.ai-report,.ai-now,[id^="tkq-"]{scroll-margin-top:84px}
@media (max-width:640px){html{scroll-padding-top:76px}#tk-detail,.tk-result,.ai-report,.ai-now,[id^="tkq-"]{scroll-margin-top:76px}}

/* ---------- skip link ---------- */
.skip-link{position:absolute;left:16px;top:-60px;z-index:200;padding:10px 16px;border-radius:10px;background:var(--panel);color:var(--ink);
  border:2px solid var(--accent);font:600 14px var(--body);text-decoration:none;transition:top .12s}
.skip-link:focus{top:12px}

/* ---------- header menus (disclosure panels next to their buttons) ---------- */
.navdd-menu{white-space:normal;background:var(--panel)!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
/* while a panel is open the header must not clip it (its full-width background trick uses clip-path) */
header.top.dd-open{clip-path:none;box-shadow:none}
#menubtn,header.top .nav .sheet-only,.sheet-topics{display:none}

/* ---------- phones: one compact row (logo, language, Sign in, theme, ☰) and a full-height menu sheet ---------- */
@media (max-width:640px){
  header.top{position:sticky;top:0;flex-wrap:nowrap;gap:6px;padding-block:10px;min-height:58px}
  header.top>.brand{margin-right:auto;min-width:0}
  header.top>.brand img{width:30px;height:30px}
  header.top>*{flex-shrink:0}
  header.top .nav,header.top #navbtn,header.top #plus-link,header.top .gm-chip,header.top .prog-meter{display:none!important}
  header.top .lang-btn,header.top #account-trigger,header.top #theme,#menubtn{height:40px;min-width:40px}
  header.top #account-trigger{padding:0 12px}
  #menubtn{display:inline-grid;place-items:center;padding:0;border-radius:10px}
  /* the language picker lives in the ☰ sheet on phones; the study search icon stays in the row */
  header.top .langpick{display:none!important}
  header.top #st-search{height:40px;width:40px;min-width:40px;padding:0;display:inline-grid;place-items:center}
  .stripe{display:none}
  /* the sheet */
  .sheet-open,.sheet-open body{overflow:hidden}
  .sheet-open header.top{backdrop-filter:none;-webkit-backdrop-filter:none;clip-path:none;box-shadow:none;background:var(--bg)}
  .sheet-open header.top .nav{display:flex!important;flex-direction:column;align-items:stretch;gap:2px;position:fixed;left:0;right:0;top:var(--hdr,60px);bottom:0;z-index:90;
    margin:0;padding:12px 16px calc(32px + env(safe-area-inset-bottom));overflow-y:auto;overscroll-behavior:contain;white-space:normal;
    background:var(--bg);border-top:1px solid var(--line)}
  .sheet-open header.top .nav>.navlk{justify-content:space-between;width:100%;height:auto;min-height:48px;padding:0 12px;font-size:16px;font-weight:600;color:var(--ink);border-radius:12px}
  .sheet-open header.top .nav>.navlk+.navlk{border-top:1px solid var(--line);border-radius:0}
  .sheet-open header.top .nav-new{margin-left:8px}
  .sheet-open header.top .navdd-caret{width:14px;height:14px;margin-left:auto}
  .sheet-open .navdd-menu{position:static;width:auto!important;padding:0 0 10px;border:0;border-radius:0;box-shadow:none;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;animation:none!important}
  .sheet-open .navdd-menu.dd-wide{max-height:none;overflow:visible}
  .sheet-open .dd-cols{grid-template-columns:1fr}
  .sheet-open .dd-item small{display:none}
  .sheet-open .dd-item{align-items:center;min-height:44px}
  .sheet-open header.top .nav .sheet-only{display:flex}
  .sheet-open .sheet-topics:not([hidden]){display:block;margin-top:10px;padding-top:12px;border-top:1px solid var(--line)}
  .sheet-topics .dd-head{margin:0 4px 8px}
  .sheet-open .sheet-lang{flex-direction:column;gap:8px;margin-top:10px;padding-top:12px;border-top:1px solid var(--line)}
  .sheet-lang .dd-head{margin:0 4px}
  .sheet-lang-row{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
  .sheet-lang-row button{min-height:44px;border:1px solid var(--line);border-radius:10px;background:none;color:var(--ink);font:600 15px/1 inherit;cursor:pointer}
  .sheet-lang-row button[aria-pressed="true"]{border-color:var(--acc,currentColor);background:color-mix(in srgb,var(--acc,#f60) 14%,transparent)}
  .sheet-topics aside{display:flex;position:static;max-height:none;overflow:visible;padding:0}
  .sheet-topics aside .lk,.sheet-topics aside .cat{min-height:40px}
}
@media (max-width:420px){header.top{gap:4px}header.top>.brand{font-size:15px;gap:5px}header.top>.brand img{width:26px;height:26px}}

/* ---------- lesson player on phones ---------- */
#stage{max-width:100%;overflow-x:auto;scrollbar-width:thin}
@media (max-width:420px){
  #stage .cells{gap:3px}
  #stage .cell b{min-width:clamp(24px,6.9vw,34px);padding-inline:1px;font-size:12px}
  #stage .rl{width:16px;font-size:12px}
}
/* the floating Help button would sit on the animation: on lesson pages on phones it goes to the end of the page instead */
@media (max-width:640px){
  body:has(#lesson:not([hidden])) .help:not(.open){position:static;justify-items:end;margin:8px 0 0}
}

/* ---------- touch targets (WCAG 2.5.8: at least 24px; 32–36px where the layout allows) ---------- */
.btn.sm,a.btn.sm{min-height:32px}
.back,.side-home,a.back,a.side-home{display:inline-flex;align-items:center;min-height:32px;padding-block:6px}
#cat{display:inline-flex;align-items:center;min-height:28px}
#demo-motion,#demo-open{min-height:32px;display:inline-flex;align-items:center}
#scrub{height:28px}
.foot .navlk,.foot-legal .navlk{display:inline-flex;align-items:center;min-height:32px}
header.top #theme{min-width:36px}
@media (pointer:coarse){.btn.sm,a.btn.sm,.back,.side-home,.foot .navlk{min-height:40px}}

/* ---------- headings that changed level ---------- */
.code-card .code-h{display:flex;align-items:center;gap:8px;margin:0 0 8px}
.code-card .code-h h2{margin:0}
.band .band-h{font:700 24px var(--display);margin:0 0 6px}
@media (max-width:820px){.band .band-h{font-size:23px}}
.tk-detail>h1.tk-ch-title{font:800 clamp(24px,3vw,32px)/1.15 var(--display);margin:10px 0 8px;letter-spacing:-.01em}

/* ---------- one primary button style ---------- */
.btn.pri,a.btn.pri{background:var(--btn-pri-bg);border-color:transparent;color:var(--btn-pri-ink);box-shadow:0 0 20px -6px var(--btn-pri-solid)}
.btn.pri:hover:not(:disabled){box-shadow:0 5px 24px -5px var(--btn-pri-solid)}
.seg button.on{background:var(--btn-pri-solid);color:var(--btn-pri-ink)}

/* ---------- light theme contrast ---------- */
:root[data-theme="light"] .eyebrow:not(.hero-explore){background:color-mix(in srgb,var(--cat) 12%,var(--panel));color:color-mix(in srgb,var(--cat) 62%,#000)}
:root[data-theme="light"] .hero-copy>.hero-explore,:root[data-theme="light"] .hero-copy>.hero-explore:hover{color:var(--eyebrow-ink)}
:root[data-theme="light"] .pg-lvl-easy{color:color-mix(in srgb,var(--ok) 75%,#000)}
:root[data-theme="light"] .pg-lvl-medium{color:#8a5a00}
:root[data-theme="light"] .sd-requirements b,:root[data-theme="light"] .sd-interview>b{color:color-mix(in srgb,var(--cat) 70%,#000)}

/* ---------- smallest text on phones: 12px floor ---------- */
@media (max-width:640px){
  .pg-cat,.pg-lvl,.gm-heat-days,.gm-heat-months,.gm-legend,.gm-tier,#lesson kbd,#lesson small,aside .cat em,.dd-tag,.dd-head,.eyebrow,.tk-crumb,.solve-note,
  .foot-group h2,.diff,.case-row small,.case-row code,.solve-save-status,.solve-hint kbd,kbd,.pg-progress small,.chip small,.tk-side-head p,.tk-side b,.tk-q-n,
  .solve-example small,.solve-example small code,.seg button small,.tk-remember b,.tk-dg-title span,.c-table thead th,.sd-module>b,.sd-module small,.sd-stepper span,.stepno,#log li b,.stage-h b,.c-time,.c-item>b{font-size:12px!important}
}

/* ---------- home: continue where you left off ---------- */
.resume{display:grid;gap:10px;margin:8px 0 4px}
.resume-main{display:grid;gap:6px}
.resume-k{margin:0;font:600 13px var(--body);color:var(--muted)}
.resume-go{display:grid;grid-template-columns:auto 1fr auto;grid-template-areas:"kind title arrow" "kind sub arrow";align-items:center;gap:2px 14px;
  padding:14px 18px;border:1px solid color-mix(in srgb,var(--cat) 45%,var(--line));border-left:4px solid var(--cat);border-radius:14px;
  background:color-mix(in srgb,var(--cat) 7%,var(--panel));color:var(--ink);text-decoration:none}
.resume-go:hover{background:color-mix(in srgb,var(--cat) 13%,var(--panel))}
.resume-go .resume-kind{grid-area:kind}
.resume-go strong{grid-area:title;font:700 18px/1.25 var(--display)}
.resume-go small{grid-area:sub;color:var(--muted);font-size:13px}
.resume-arrow{grid-area:arrow;font-size:22px;color:var(--cat)}
.resume-kind{font:700 12px var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.resume-more{display:flex;flex-wrap:wrap;gap:8px;margin:0;padding:0;list-style:none}
.resume-more a{display:inline-flex;align-items:center;gap:8px;min-height:36px;padding:6px 12px;border:1px solid var(--line);border-radius:10px;background:var(--panel);color:var(--ink);text-decoration:none;font-size:14px}
.resume-more a:hover{border-color:var(--cat)}

/* ---------- Solve: after an accepted submit ---------- */
.solve-next{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 0}

/* ---------- Progress: first-step card ---------- */
.gm-empty{display:flex;gap:16px;align-items:flex-start;margin:0 0 18px;padding:20px 22px;border:1px solid color-mix(in srgb,var(--b1) 40%,var(--line));border-radius:14px;background:color-mix(in srgb,var(--b1) 7%,var(--panel))}
.gm-empty-ico{font-size:30px;line-height:1}
.gm-empty h2{margin:0 0 4px;font:700 20px var(--display)}
.gm-empty p{margin:0 0 12px;color:var(--muted)}
.gm-empty .cta{display:flex;flex-wrap:wrap;gap:8px}

/* system design module label: was blue text on the orange eyebrow background (about 1:1 in dark mode) */
.sd-detail-head .eyebrow{background:color-mix(in srgb,var(--c9) 14%,var(--panel));color:var(--c9);font-size:12px}
:root[data-theme="light"] .sd-detail-head .eyebrow{background:color-mix(in srgb,var(--c9) 10%,var(--panel));color:color-mix(in srgb,var(--c9) 62%,#000)}
details>summary{min-height:32px}

/* signed-out visitors: no personal header items (progress, streak, code language, search icon) or personal home cards */
html.guest header.top .prog-meter,html.guest header.top .gm-chip,html.guest header.top #langsw,html.guest header.top #st-search,html.guest .sheet-lang,html.guest #resume,html.guest #st-home{display:none!important}
/* the Compiler menu item is a plain link (separate page): line it up with the menu buttons */
header.top .nav>a.navlk[href="/compiler/"]{display:inline-flex;align-items:center}
