/* CSE One: phone layout shared by every page.
   Loaded after each page's own styles. Three jobs:
   1. nothing may run past the screen edge,
   2. everything tappable is big enough for a thumb,
   3. a bottom bar (added by nav.js) keeps the main sections one tap away. */

html{overflow-x:clip}
.tabbar,.tabsheet{display:none}

@media (max-width:760px){
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
  body{overflow-wrap:break-word}
  h1,h2,h3{text-wrap:balance}
  img,svg,video,canvas{max-width:100%}

  /* The soft backdrop used to reach past both edges and widen the page. */
  .glow{left:0!important;right:0!important}

  /* iOS zooms the whole page into any field set under 16px. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important}
  input[type=checkbox],input[type=radio]{width:20px!important;height:20px!important;flex:none}

  /* Footers: links wrap instead of running off screen, and each is a full-height target. */
  footer nav,.site-foot nav{display:flex;flex-wrap:wrap;gap:0 18px!important}
  footer nav a,.site-foot nav a{display:inline-flex;align-items:center;min-height:40px}
  footer .wrap{gap:4px 24px!important}

  /* Headers: the bar below carries the sections, so the header keeps the logo and one action. */
  header .brand span,header .brand,.site-head .brand span{white-space:nowrap}
  .has-tabbar .mnav{display:none!important}
  .has-tabbar .head-link{display:none!important}
  .has-tabbar header .nav a:not(.btn){display:none!important}
  .has-tabbar header .nav .btn{display:inline-flex!important;white-space:nowrap}
  .has-tabbar header nav[aria-label="Site"]{display:none!important}
  .site-head .brand,header .brand{min-height:44px;display:inline-flex;align-items:center}
  .site-head nav{gap:2px 14px!important}
  .site-head nav a{display:inline-flex;align-items:center;min-height:40px}

  /* Thumb-sized controls. */
  .chip,.dh-filter button,nav.tabs a,.mode button,.need,.card-btn,.dl a,.flag-btn{min-height:40px}
  nav.tabs a,.mode button,.dl a{display:inline-flex;align-items:center}
  .dh-topics a,.dh-foot a.t,a.t{min-height:32px;display:inline-flex;align-items:center}
  .dh-foot a.more,a.more{min-height:40px;display:inline-flex;align-items:center}

  /* Small print stays readable. */
  .tag,.card .tag,.status,.doors .door .status,.example-tag,.lbl,.st,.need small,.dh-angles b,.name{font-size:12px}

  /* Wide tables scroll inside their own box, never the page. */
  .tbl-wrap,.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .prose table{display:block;overflow-x:auto;max-width:100%}

  /* >>> bottom bar (Learn carries a copy of this block; keep the two in step) */
  /* Room for the bar, and anchors that don't land underneath sticky strips. */
  .has-tabbar body{padding-bottom:calc(64px + env(safe-area-inset-bottom,0px))}
  .has-tabbar{scroll-padding-bottom:80px}

  /* ---- Bottom bar ---- */
  .tabbar{position:fixed;left:0;right:0;bottom:0;z-index:60;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));
    padding:6px max(6px,env(safe-area-inset-right,0px)) calc(6px + env(safe-area-inset-bottom,0px)) max(6px,env(safe-area-inset-left,0px));
    background:color-mix(in srgb,var(--surface,#fff) 90%,transparent);
    -webkit-backdrop-filter:saturate(1.5) blur(16px);backdrop-filter:saturate(1.5) blur(16px);
    border-top:1px solid var(--line,#ede6d5);box-shadow:0 -8px 24px -18px rgba(40,28,4,.35);
    transition:transform .28s cubic-bezier(.2,.7,.2,1)}
  .tabbar.away{transform:translateY(120%)}
  .tabbar a,.tabbar button{appearance:none;border:0;background:none;margin:0;padding:4px 0 2px;min-height:52px;cursor:pointer;
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    font-family:inherit;font-size:11px;font-weight:650;line-height:1.1;letter-spacing:.01em;color:var(--muted,#6c6457);text-decoration:none;
    -webkit-tap-highlight-color:transparent;border-radius:14px}
  .tabbar .ti{display:grid;place-items:center;width:52px;height:28px;border-radius:999px;transition:background .25s,transform .25s}
  .tabbar svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
  .tabbar .on{color:var(--ink,#1f1c16)}
  .tabbar .on .ti{background:color-mix(in srgb,#ecb22e 34%,transparent)}
  .tabbar a:active .ti,.tabbar button:active .ti{transform:scale(.92)}
  .tabbar a:focus-visible,.tabbar button:focus-visible{outline:2px solid var(--accent,#ecb22e);outline-offset:-2px}

  /* ---- "More" sheet ---- */
  dialog.tabsheet{display:none}
  dialog.tabsheet[open]{display:block;position:fixed;inset:auto 0 0 0;margin:0;width:100%;max-width:none;max-height:86vh;overflow:auto;
    border:0;border-radius:22px 22px 0 0;padding:8px 14px calc(16px + env(safe-area-inset-bottom,0px));
    background:var(--surface,#fff);color:var(--ink,#1f1c16);box-shadow:0 -20px 60px -20px rgba(0,0,0,.35);
    animation:tabsheet-up .32s cubic-bezier(.2,.8,.2,1)}
  dialog.tabsheet::backdrop{background:rgba(24,18,6,.46);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}
  @keyframes tabsheet-up{from{transform:translateY(40%);opacity:0}to{transform:none;opacity:1}}
  .tabsheet .grab{width:40px;height:4px;border-radius:4px;background:var(--line,#ede6d5);margin:4px auto 10px}
  .tabsheet h2{font-size:13px!important;line-height:1.2!important;letter-spacing:.08em!important;text-transform:uppercase;font-weight:700!important;color:var(--muted,#6c6457);margin:0 6px 6px!important;font-family:inherit!important}
  .tabsheet ul{list-style:none;margin:0;padding:0}
  .tabsheet li{margin:0}
  .tabsheet a{display:grid;grid-template-columns:44px minmax(0,1fr) 16px;gap:12px;align-items:center;min-height:60px;padding:8px 6px;border-radius:14px;color:inherit;text-decoration:none;-webkit-tap-highlight-color:transparent}
  .tabsheet a:active{background:color-mix(in srgb,var(--accent,#ecb22e) 14%,transparent)}
  .tabsheet a[aria-current=page] .si{background:color-mix(in srgb,var(--accent,#ecb22e) 34%,transparent)}
  .tabsheet .si{width:44px;height:44px;border-radius:13px;display:grid;place-items:center;background:color-mix(in srgb,var(--accent,#ecb22e) 14%,transparent);color:var(--accent-ink,var(--ink,#1f1c16))}
  .tabsheet .si svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
  .tabsheet b{display:block;font-size:16px;font-weight:700;line-height:1.25}
  .tabsheet small{display:block;font-size:13px;line-height:1.35;color:var(--muted,#6c6457)}
  .tabsheet .go{width:16px;height:16px;fill:none;stroke:var(--muted,#6c6457);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
  .tabsheet .rule{height:1px;background:var(--line,#ede6d5);margin:6px}
  .tabsheet .minor{display:flex;flex-wrap:wrap;gap:0 18px;padding:0 6px}
  .tabsheet .minor a{display:inline-flex;min-height:44px;padding:0;font-size:14px;font-weight:600;color:var(--muted,#6c6457);grid-template-columns:none}
  .tabsheet .x{display:block;width:100%;margin-top:8px;min-height:48px;border-radius:14px;border:1px solid var(--line,#ede6d5);background:none;color:inherit;font-family:inherit;font-size:15px;font-weight:650;line-height:1;cursor:pointer}
  /* <<< bottom bar */
}

@media (max-width:760px) and (prefers-reduced-motion:reduce){
  .tabbar,.tabbar .ti{transition:none}
  dialog.tabsheet[open]{animation:none}
}
@media print{.tabbar,.tabsheet{display:none!important}}
