/* iOS Add-to-Home-Screen (A2HS) guidance:
   - Compact floating banner above the mobile capsule tab bar
   - Tactile 3-step iOS bottom sheet (<dialog>) matching Apple-craft tokens
   - Quiet permanent entry inside #mobile-me-hub ("我的")
   All rules respect dark (obsidian-gold) & light (washi-forest) focus palette. */

/* 1. Compact Floating Prompt Banner */
.ios-a2hs-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--mobile-nav-height, 76px) + 6px);
  z-index: 27;
  max-width: 440px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--apple-hairline-strong, var(--line));
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--apple-shadow-float, 0 12px 32px rgba(0, 0, 0, 0.24)), var(--apple-specular, inset 0 1px 0 rgba(255, 255, 255, 0.06));
  animation: ios-a2hs-banner-in 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ios-a2hs-banner[hidden] {
  display: none !important;
}

@media (min-width: 901px) {
  .ios-a2hs-banner {
    bottom: 24px;
    left: auto;
    right: 24px;
    width: min(400px, calc(100vw - 48px));
  }
}

.ios-a2hs-banner-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--apple-hairline, var(--line));
  background: var(--surface-muted);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.ios-a2hs-banner-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ios-a2hs-banner-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ios-a2hs-banner-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ios-a2hs-banner-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ios-a2hs-banner-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ios-a2hs-banner-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--journey-primary);
  color: var(--journey-on-primary);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--apple-shadow-btn-primary, 0 1px 4px rgba(0, 0, 0, 0.16));
  transition: background-color 150ms ease, transform 140ms ease;
}

.ios-a2hs-banner-cta:hover {
  background: var(--craft-primary-hover, var(--journey-primary));
}

.ios-a2hs-banner-cta:active {
  transform: scale(0.96);
}

.ios-a2hs-banner-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.ios-a2hs-banner-close:hover {
  background: var(--apple-pill-hover, var(--surface-muted));
  color: var(--ink);
}

/* 2. Quiet Permanent Entry in Mobile "我的" Hub (#mobile-me-hub) */
.ios-a2hs-hub-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: 0;
  border-radius: 16px;
  border: 1px solid var(--apple-hairline, var(--line));
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--apple-specular, none);
  transition: background-color 150ms ease, transform 140ms ease;
}

.ios-a2hs-hub-card[hidden] {
  display: none !important;
}

.ios-a2hs-hub-card:active {
  transform: scale(0.985);
}

.ios-a2hs-hub-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--apple-hairline, var(--line));
  background: var(--surface-muted);
}

.ios-a2hs-hub-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ios-a2hs-hub-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ios-a2hs-hub-copy strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.ios-a2hs-hub-copy span {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.ios-a2hs-hub-chevron {
  flex: none;
  color: var(--muted);
}

/* 3. Native Bottom Sheet Dialog (<dialog id="ios-a2hs-sheet">) */
dialog.ios-a2hs-sheet {
  width: min(440px, 100vw);
  max-width: 100vw;
  max-height: min(88dvh, 660px);
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--apple-hairline-strong, var(--line));
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--apple-shadow-float, 0 -8px 40px rgba(0, 0, 0, 0.28)), var(--apple-specular, inset 0 1px 0 rgba(255, 255, 255, 0.06));
  overflow: hidden;
  font-family: var(--font-ui, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif);
}

dialog.ios-a2hs-sheet::backdrop {
  background: var(--modal-scrim, rgba(8, 8, 10, 0.6));
  animation: ios-a2hs-backdrop-in 180ms ease-out both;
}

dialog.ios-a2hs-sheet[open] {
  display: flex;
  flex-direction: column;
  animation: ios-a2hs-sheet-up 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@media (min-width: 701px) {
  dialog.ios-a2hs-sheet {
    margin: auto;
    border-bottom: 1px solid var(--apple-hairline-strong, var(--line));
    border-radius: 24px;
  }
}

.ios-a2hs-sheet-grip {
  width: 36px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 42%, transparent);
  flex: none;
  touch-action: none;
}

.ios-a2hs-sheet-head {
  touch-action: none;
}

dialog.ios-a2hs-sheet.is-dragging {
  animation: none !important;
  transition: none !important;
}

dialog.ios-a2hs-sheet.is-settling {
  animation: none !important;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease;
}

@media (min-width: 701px) {
  .ios-a2hs-sheet-grip {
    display: none;
  }
}

.ios-a2hs-sheet-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 701px) {
  .ios-a2hs-sheet-scroll {
    padding: 22px 24px 24px;
  }
}

.ios-a2hs-sheet-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.ios-a2hs-app-badge {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid var(--apple-hairline-strong, var(--line));
  background: var(--surface-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.ios-a2hs-app-badge img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ios-a2hs-head-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.ios-a2hs-head-copy h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.ios-a2hs-head-copy p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.ios-a2hs-sheet-close {
  flex: none;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.ios-a2hs-sheet-close:hover {
  background: var(--apple-pill-hover, var(--line));
  color: var(--ink);
}

/* Conditional In-App Browser Notice */
.ios-a2hs-inapp-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin: 0 0 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--warning, var(--accent)) 36%, transparent);
  background: color-mix(in srgb, var(--warning, var(--accent)) 11%, var(--surface-muted));
  color: var(--ink);
}

.ios-a2hs-inapp-note[hidden] {
  display: none !important;
}

.ios-a2hs-inapp-icon {
  flex: none;
  color: var(--warning, var(--accent));
  margin-top: 2px;
}

.ios-a2hs-inapp-note strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.ios-a2hs-inapp-note p {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* 3 Visual Steps */
.ios-a2hs-steps {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ios-a2hs-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 15px;
  border: 1px solid var(--apple-hairline, var(--line));
  background: var(--surface-muted);
}

.ios-a2hs-step-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--journey-primary);
  color: var(--journey-on-primary);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ios-a2hs-step-body {
  flex: 1 1 auto;
  min-width: 0;
}

.ios-a2hs-step-body strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.ios-a2hs-step-body span {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.ios-a2hs-step-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 11px;
  border: 1px solid var(--apple-hairline-strong, var(--line));
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ios-a2hs-sheet-tip {
  margin: 14px 2px 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.ios-a2hs-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.ios-a2hs-primary-btn {
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 13px;
  background: var(--journey-primary);
  color: var(--journey-on-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--apple-shadow-btn-primary, 0 2px 8px rgba(0, 0, 0, 0.14));
  transition: background-color 150ms ease, transform 140ms ease;
}

.ios-a2hs-primary-btn:hover {
  background: var(--craft-primary-hover, var(--journey-primary));
}

.ios-a2hs-primary-btn:active {
  transform: scale(0.98);
}

.ios-a2hs-secondary-btn {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.ios-a2hs-secondary-btn[hidden] {
  display: none !important;
}

.ios-a2hs-secondary-btn:hover {
  background: var(--apple-pill-hover, var(--surface-muted));
  color: var(--ink);
}

@keyframes ios-a2hs-banner-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ios-a2hs-sheet-up {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ios-a2hs-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ios-a2hs-banner,
  dialog.ios-a2hs-sheet[open],
  dialog.ios-a2hs-sheet::backdrop {
    animation: none;
  }
}
