/* opt-in ios-inspired controls and materials; activated only on the three supported pages */
html[data-ios-styling="true"] {
  --ios-glass-fill: color-mix(in srgb, var(--ui-surface) 54%, transparent);
  --ios-glass-fill-strong: color-mix(in srgb, var(--ui-surface) 78%, transparent);
  --ios-glass-edge: color-mix(in srgb, var(--ui-text-strong) 18%, transparent);
  --ios-glass-highlight: color-mix(in srgb, white 30%, transparent);
  --ios-glass-shadow: 0 8px 24px color-mix(in srgb, black 16%, transparent);
  --ios-radius-card: 22px;
  --ios-radius-control: 999px;
}

html[data-ios-styling="true"] body {
  background-image: radial-gradient(ellipse at 12% 0%, color-mix(in srgb, var(--ui-accent) 10%, transparent), transparent 38%);
}

html[data-ios-styling="true"] .shell { background-color: var(--bg); }
html[data-ios-styling="true"] .app,
html[data-ios-styling="true"] .app-inner { background-color: var(--ui-bg); }
html[data-ios-styling="true"] #page { background-color: var(--bg-color); }

/* functional layer: translucent, tactile controls with a clear press state */
html[data-ios-styling="true"] body :is(
  button,
  [role="button"],
  a[class*="-btn"],
  a.icon-btn,
  a.nav-btn,
  a.link-item,
  a.explore-tab,
  a.discover-chip,
  a.sort-btn
) {
  border-radius: var(--ios-radius-control) !important;
  border-color: var(--ios-glass-edge) !important;
  background-color: var(--ios-glass-fill) !important;
  background-image: linear-gradient(180deg, color-mix(in srgb, white 10%, transparent), transparent 78%) !important;
  color: var(--ui-text-strong) !important;
  box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 3px 10px color-mix(in srgb, black 9%, transparent) !important;
  -webkit-backdrop-filter: saturate(1.45) blur(16px);
  backdrop-filter: saturate(1.45) blur(16px);
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease !important;
}

html[data-ios-styling="true"] body :is(
  button,
  [role="button"],
  a[class*="-btn"],
  a.icon-btn,
  a.nav-btn,
  a.link-item,
  a.explore-tab,
  a.discover-chip,
  a.sort-btn
):not(:disabled):not([aria-disabled="true"]):hover {
  border-color: color-mix(in srgb, var(--ui-accent) 58%, var(--ios-glass-edge)) !important;
  background-color: color-mix(in srgb, var(--ui-accent) 12%, var(--ios-glass-fill-strong)) !important;
  box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 7px 18px color-mix(in srgb, black 13%, transparent) !important;
  transform: translateY(-1px);
}

html[data-ios-styling="true"] body :is(
  button,
  [role="button"],
  a[class*="-btn"],
  a.icon-btn,
  a.nav-btn,
  a.link-item,
  a.explore-tab,
  a.discover-chip,
  a.sort-btn
):not(:disabled):not([aria-disabled="true"]):active {
  transform: scale(0.98);
  box-shadow: inset 0 1px 3px color-mix(in srgb, black 13%, transparent) !important;
}

/* preserve large, text-heavy choices as rounded rectangles rather than tiny pills */
html[data-ios-styling="true"] body :is(
  .start-opt,
  .checklist-item,
  .saved-chat-open,
  .project-pick-item,
  .mention-option,
  .account-btn
) {
  border-radius: 18px !important;
}

/* prominent and destructive roles retain their meaning */
html[data-ios-styling="true"] body :is(
  .btn-primary,
  #discover-search-submit,
  #compose-send,
  .modal-btn.primary,
  .sm-btn.primary,
  .new-chat-btn
) {
  background-color: color-mix(in srgb, var(--ui-accent) 88%, white 12%) !important;
  border-color: color-mix(in srgb, var(--ui-accent) 72%, white 28%) !important;
  color: var(--ui-on-accent) !important;
}

html[data-ios-styling="true"] body :is(
  .danger,
  .danger-zone,
  .post-delete-btn,
  .logout-item
) {
  border-color: color-mix(in srgb, var(--ui-danger) 42%, var(--ios-glass-edge)) !important;
}

/* search fields and text entry use a quieter standard material */
html[data-ios-styling="true"] body :is(
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select,
  .input,
  .textarea,
  #discover-search,
  #compose-input,
  #generic-modal-textarea
) {
  border-radius: 16px !important;
  border-color: var(--ios-glass-edge) !important;
  background-color: var(--ios-glass-fill-strong) !important;
  box-shadow: inset 0 1px 0 color-mix(in srgb, white 12%, transparent) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* navigation floats above content; content cards stay legible and mostly opaque */
html[data-ios-styling="true"] body :is(
  .topnav,
  .sidebar,
  .mobile-bar,
  .account-dropup,
  .saved-chat-menu,
  .mention-popup,
  .modal-overlay,
  .modal,
  .modal-box,
  .wiki-sources-dialog
) {
  background-color: var(--ios-glass-fill) !important;
  border-color: var(--ios-glass-edge) !important;
  box-shadow: var(--ios-glass-shadow), inset 0 1px 0 color-mix(in srgb, white 16%, transparent) !important;
  -webkit-backdrop-filter: saturate(1.45) blur(22px);
  backdrop-filter: saturate(1.45) blur(22px);
}

html[data-ios-styling="true"] .topnav {
  top: 8px;
  left: 12px;
  right: 12px;
  height: 54px;
  border: 1px solid var(--ios-glass-edge) !important;
  border-radius: 28px !important;
}

html[data-ios-styling="true"] .shell { margin-top: 68px; }

html[data-ios-styling="true"] .sidebar,
html[data-ios-styling="true"] .mobile-bar,
html[data-ios-styling="true"] #compose-bar {
  border-radius: 26px !important;
  border: 1px solid var(--ios-glass-edge) !important;
}

html[data-ios-styling="true"] body :is(
  .panel,
  .points-card,
  .project-card,
  .checklist,
  .feed-item,
  .discover-card,
  .post-card,
  .proposal-card,
  .wiki-source-card,
  .project-pick-item,
  .dropzone
) {
  border-radius: var(--ios-radius-card) !important;
  border-color: color-mix(in srgb, var(--ui-border-strong) 72%, transparent) !important;
  box-shadow: 0 8px 22px color-mix(in srgb, black 10%, transparent), inset 0 1px 0 color-mix(in srgb, white 9%, transparent) !important;
}

html[data-ios-styling="true"] .points-card {
  transform: none;
  border-style: solid !important;
}

html[data-ios-styling="true"] #explore-tabs {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--ios-glass-edge) !important;
  border-radius: var(--ios-radius-control);
  background: var(--ios-glass-fill);
  box-shadow: inset 0 1px 0 var(--ios-glass-highlight);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
}

html[data-ios-styling="true"] .explore-tab {
  border: 0 !important;
  border-radius: var(--ios-radius-control) !important;
  background: transparent !important;
}

html[data-ios-styling="true"] .explore-tab.active,
html[data-ios-styling="true"] .explore-tab[aria-selected="true"] {
  background: color-mix(in srgb, var(--ui-accent) 18%, var(--ios-glass-fill-strong)) !important;
  border: 1px solid color-mix(in srgb, var(--ui-accent) 38%, transparent) !important;
  color: var(--ui-accent) !important;
  box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 3px 12px color-mix(in srgb, var(--ui-accent) 13%, transparent) !important;
}

html[data-ios-styling="true"] .tab.active,
html[data-ios-styling="true"] .sort-btn.active {
  background-color: color-mix(in srgb, var(--ui-accent) 18%, var(--ios-glass-fill-strong)) !important;
  border-color: color-mix(in srgb, var(--ui-accent) 42%, var(--ios-glass-edge)) !important;
  color: var(--ui-accent) !important;
}

html[data-ios-styling="true"] :is(.tabs, #sort-bar) {
  gap: 8px;
}

html[data-ios-styling="true"] :is(.tab, .sort-btn, .discover-chip) {
  min-height: 38px;
}

html[data-ios-styling="true"] :focus-visible {
  outline: 2px solid var(--ui-info) !important;
  outline-offset: 3px !important;
}

html[data-ios-styling="true"] :disabled,
html[data-ios-styling="true"] [aria-disabled="true"] {
  cursor: not-allowed;
  filter: saturate(0.65);
}

@media (prefers-reduced-motion: reduce) {
  html[data-ios-styling="true"] body :is(button, [role="button"], a[class*="-btn"], a.icon-btn, a.nav-btn, a.link-item, a.explore-tab, a.discover-chip, a.sort-btn) {
    transition: none !important;
  }
}
