/* Shared iOS shell for typo teaching site. Also hides 3D part-name callouts. */
:root {
  --ios-bg: #F2F2F7;
  --ios-card: #FFFFFF;
  --ios-ink: #000000;
  --ios-label: #1C1C1E;
  --ios-secondary: #6C6C70;
  --ios-tertiary: #8E8E93;
  --ios-sep: rgba(60, 60, 67, 0.18);
  --ios-hairline: rgba(60, 60, 67, 0.29);
  --ios-fill: #E5E5EA;
  --ios-fill-2: #F2F2F7;
  --ios-blue: #007AFF;
  --ios-blue-press: #0066D6;
  --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

/* ---- 3D part callouts: fully hide (including later JS-created tags) ---- */
#labels,
#labels .tag3d,
.tag3d {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* ---- Structure 1–6 switcher ---- */
.struct-nav {
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 10px 6px calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  background: rgba(242, 242, 247, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--ios-sep);
  font-family: var(--ios-font);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.struct-nav::-webkit-scrollbar { display: none; }
.struct-nav a,
.struct-nav .struct-home,
.struct-nav .struct-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 11px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ios-label);
  font-size: 15px;
  font-weight: 510;
  letter-spacing: -0.01em;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.struct-nav .struct-kicker {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 650;
  color: var(--ios-tertiary);
  padding: 0 4px 0 2px;
  letter-spacing: 0.02em;
}
.struct-nav .struct-home { color: var(--ios-blue); font-weight: 600; }
.struct-nav .struct-item[aria-current="page"],
.struct-nav .struct-item.is-active {
  background: var(--ios-blue);
  color: #fff;
  font-weight: 600;
}
.struct-nav .struct-num {
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
  font-weight: 650;
}
@media (hover: hover) and (pointer: fine) {
  .struct-nav a:hover { background: var(--ios-fill); }
  .struct-nav .struct-item[aria-current="page"]:hover,
  .struct-nav .struct-item.is-active:hover { background: var(--ios-blue); }
}

/* ---- 3D lesson chrome: light iOS ---- */
html.ios-3d, html:has(#app) {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--ios-bg);
}
body.ios-3d, body:has(#app) {
  font-family: var(--ios-font) !important;
  background: var(--ios-bg) !important;
  color: var(--ios-label) !important;
}
body.ios-3d, body:has(#app) {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}
body.ios-3d #app, body:has(#app) #app {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  max-height: none;
  background: var(--ios-bg) !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-top: 0 !important;
}
#sidebar {
  background: #F2F2F7 !important;
  color: var(--ios-label) !important;
  border-right: 0.5px solid var(--ios-sep) !important;
  border-bottom-color: var(--ios-sep) !important;
}
#sideTitle {
  color: var(--ios-label) !important;
  border-bottom: 0.5px solid var(--ios-sep) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
}
#sideTitle small { color: var(--ios-tertiary) !important; }
.home-link,
a.top-home {
  color: var(--ios-blue) !important;
}
.mech-btn,
.mode-btn,
#modeList button {
  background: transparent !important;
  color: var(--ios-label) !important;
  border: none !important;
  border-radius: 10px !important;
}
.mech-btn.active,
.mode-btn.active,
#modeList button.active {
  background: var(--ios-blue) !important;
  color: #fff !important;
  font-weight: 650 !important;
}
#sideTip,
#holdInfo {
  color: var(--ios-secondary) !important;
  border-top: 0.5px solid var(--ios-sep) !important;
}
#topbar {
  background: rgba(247, 247, 247, 0.94) !important;
  border-bottom: 0.5px solid var(--ios-sep) !important;
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
}
#mechTitle,
#modeTitle {
  color: var(--ios-label) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
}
.tb-btn,
.step-btn,
.view-btn,
#stepBar button,
#qualityBtn {
  background: var(--ios-fill) !important;
  border: none !important;
  border-radius: 10px !important;
  color: var(--ios-label) !important;
  font-family: var(--ios-font) !important;
}
.tb-btn.active,
.speed-preset.active,
.step-btn.active,
#btnPlay {
  /* play stays neutral gray unless active class says otherwise */
}
.speed-preset.active {
  background: var(--ios-blue) !important;
  color: #fff !important;
}
#viewport { background: #F2F2F7 !important; }
#info,
#legendBar,
#bottom,
#stepBar {
  background: #fff !important;
  border-top: 0.5px solid var(--ios-sep) !important;
  color: var(--ios-label) !important;
}
#infoName,
#infoPrinciple,
#infoHint { color: inherit; }
#infoPrinciple { color: var(--ios-secondary) !important; }
.tab-btn,
.info-tab {
  background: transparent !important;
  color: var(--ios-blue) !important;
  border: none !important;
}
.tab-btn.active,
.info-tab.active {
  font-weight: 650 !important;
}
#btnTrig {
  background: var(--ios-blue) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 12px !important;
  font-weight: 650 !important;
  min-height: 44px !important;
}
#sliders h3 { color: var(--ios-label) !important; }
#sliders, #timingBox, #demoBox { color: var(--ios-label) !important; }

/* 555 mobile dock */
.ios-555-dock {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-top: 0.5px solid var(--ios-sep);
}
.ios-param-toggle {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: var(--ios-fill);
  color: var(--ios-label);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--ios-font);
}
html.ios-params-open .ios-param-toggle {
  background: var(--ios-blue);
  color: #fff;
}

input[type="range"] { accent-color: var(--ios-blue); }
#speedVal, #mechNo { color: var(--ios-label) !important; }
#stepIndicator {
  background: var(--ios-fill) !important;
  color: var(--ios-label) !important;
  border: none !important;
}

@media (max-width: 900px) {
  /* Keep iPad (768) in the same stacked layout as phones */
  #app {
    flex-direction: column !important;
    width: 100% !important;
  }
  #main {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
  }
  /* Compact lesson picker as a horizontal chip strip */
  #sidebar {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
    flex-direction: row !important;
    align-items: center !important;
    overflow: visible !important;
    border-right: none !important;
    border-bottom: 0.5px solid var(--ios-sep) !important;
  }
  body.ios-3d #sideTitle, body:has(#app) #sideTitle,
  body.ios-3d #sideTip, body:has(#app) #sideTip { display: none !important; }
  #mechList,
  #modeList {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 6px 8px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #mechList::-webkit-scrollbar,
  #modeList::-webkit-scrollbar { display: none; }
  .mech-btn,
  .mode-btn,
  #modeList button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    white-space: nowrap !important;
    font-size: 14px !important;
  }
  #topbar {
    height: auto !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 6px 8px !important;
    overflow-x: auto !important;
    max-width: 100% !important;
  }
  #topbar .tb-group,
  #topbar .view-btns {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-left: 0 !important;
  }
  .tb-btn, .view-btn, .step-btn {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  #main { min-width: 0 !important; }
  #viewport { min-height: 220px !important; }
  #info { max-height: 22vh !important; overflow-y: auto !important; }
  a.top-home { display: none !important; } /* 结构栏已有「全部」 */

  /* 555: after JS moves sliders under the dock, hide leftover sidebar block if empty-ish */
  .ios-555-dock { display: flex; }
  #sliders.ios-555-sliders {
    display: none;
    max-height: 36vh !important;
    overflow-y: auto !important;
    background: #fff;
    padding: 8px 12px 12px !important;
    border-top: 0.5px solid var(--ios-sep);
  }
  html.ios-params-open #sliders.ios-555-sliders { display: block; }
}

@media (pointer: coarse), (any-pointer: coarse) {
  .struct-nav a, .mech-btn, .tb-btn, .mode-btn, .view-btn, .step-btn, #btnTrig, .ios-param-toggle, input[type=range] {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .struct-nav a, a.row, .tb-btn { transition: none !important; }
}

/* ---- Homepage / catalog iOS lists (used with body.ios-home) ---- */
body.ios-home {
  margin: 0;
  font-family: var(--ios-font);
  background: var(--ios-bg);
  color: var(--ios-label);
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  line-height: 1.4;
}
body.ios-home .wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px calc(40px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}
body.ios-home .large-title {
  margin: 8px 4px 4px;
  font-size: clamp(1.75rem, 6vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
body.ios-home .subhead {
  margin: 0 4px 18px;
  color: var(--ios-secondary);
  font-size: 15px;
}
body.ios-home .group-label {
  margin: 20px 16px 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ios-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
body.ios-home .group {
  background: var(--ios-card);
  border-radius: 12px;
  overflow: hidden;
  margin: 0 0 8px;
}
body.ios-home a.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  min-height: 44px;
  color: inherit;
  text-decoration: none;
  border-bottom: 0.5px solid var(--ios-sep);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.ios-home .group a.row:last-child { border-bottom: none; }
body.ios-home a.row:active { background: var(--ios-fill-2); }
body.ios-home .row-num {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 8px;
  background: var(--ios-fill);
  color: var(--ios-label);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
body.ios-home .row-body { flex: 1 1 auto; min-width: 0; }
body.ios-home .row-body h2,
body.ios-home .row-body h3 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 590;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
body.ios-home .row-body p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ios-secondary);
}
body.ios-home .chev {
  flex: 0 0 auto;
  align-self: center;
  color: #C7C7CC;
  font-size: 17px;
  font-weight: 600;
}
body.ios-home details.glb {
  margin: 22px 4px 0;
  color: var(--ios-secondary);
  font-size: 14px;
}
body.ios-home details.glb summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--ios-blue);
  font-weight: 510;
  list-style: none;
}
body.ios-home details.glb summary::-webkit-details-marker { display: none; }
body.ios-home .glb-list { margin: 0; padding-left: 18px; }
body.ios-home .glb-list a { color: var(--ios-label); }
body.ios-home .skip {
  position: absolute;
  left: 12px; top: 8px; z-index: 90;
  padding: 8px 14px;
  background: #000; color: #fff;
  border-radius: 10px;
  text-decoration: none;
  transform: translateY(-160%);
}
body.ios-home .skip:focus { transform: none; }
body.ios-home a.row:focus-visible,
body.ios-home .struct-nav a:focus-visible {
  outline: 2px solid var(--ios-blue);
  outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
  body.ios-home a.row { transition: background .15s ease; }
  body.ios-home a.row:hover { background: #F2F2F7; }
}
@media (min-width: 700px) {
  body.ios-home .wrap { padding-top: 16px; }
}

.struct-short { margin-left: 4px; }
@media (max-width: 480px) {
  .struct-kicker { display: none; }
  .struct-nav { gap: 2px; padding-left: calc(6px + env(safe-area-inset-left, 0px)); padding-right: calc(6px + env(safe-area-inset-right, 0px)); }
  .struct-nav .struct-home { padding: 0 10px; }
  .struct-nav .struct-item { min-width: 44px; padding: 0 6px; }
  .struct-nav .struct-short { display: none; }
  .struct-nav .struct-num { margin-right: 0; }
}
