/* Mobile discovery controls. Desktop catalogue controls remain in place. */
body .site-header .mobile-sort-trigger { display: none; }
body .site-header .desktop-explore-trigger { display: none !important; }

/* Information is secondary to the category list in the shared explore panel. */
#categories-dialog.mobile-explore-dialog .flow-category-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
}
#categories-dialog.mobile-explore-dialog .flow-category-links > a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  text-decoration: none;
  overflow-wrap: anywhere;
}
#categories-dialog.mobile-explore-dialog .flow-category-links > a > .reel-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--muted);
}
#categories-dialog.mobile-explore-dialog .flow-category-links > a > .reel-icon:first-child { margin-left: 0; }
#categories-dialog.mobile-explore-dialog .flow-category-links > a > .reel-icon:not(:first-child) { width: 16px; height: 16px; flex-basis: 16px; margin-left: auto; }
#categories-dialog.mobile-explore-dialog .flow-category-links > a[aria-current="page"] {
  background: var(--control-soft, var(--bg));
  border-color: var(--line);
  font-weight: 600;
}
#categories-dialog.mobile-explore-dialog .mobile-information {
  margin-top: 21px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
#categories-dialog.mobile-explore-dialog .mobile-information:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
#categories-dialog.mobile-explore-dialog .mobile-information > h3 {
  margin: 0 0 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .04em;
}
#categories-dialog.mobile-explore-dialog .mobile-information-links {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  margin: 0;
  padding: 0;
}
#categories-dialog.mobile-explore-dialog .mobile-information-links > :is(a, button) {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 44px;
  margin: 0;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}
#categories-dialog.mobile-explore-dialog .mobile-information-links > :is(a, button) > .reel-icon { width: 16px; height: 16px; flex: 0 0 16px; margin-left: auto; color: var(--muted); opacity: .7; }
#categories-dialog.mobile-explore-dialog :is(.flow-category-links, .mobile-information-links) > :is(a, button):focus-visible {
  outline: 2px solid var(--control-focus, var(--action, var(--ink)));
  outline-offset: 1px;
}

/* Five immediate choices: no extra confirmation action. */
#sort-dialog.mobile-sort-dialog .mobile-sort-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#sort-dialog.mobile-sort-dialog .mobile-sort-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease;
}
#sort-dialog.mobile-sort-dialog .mobile-sort-label { min-width: 0; overflow-wrap: anywhere; }
#sort-dialog.mobile-sort-dialog .mobile-sort-check {
  display: block;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: var(--action, var(--ink));
  pointer-events: none;
}
#sort-dialog.mobile-sort-dialog .mobile-sort-option[aria-pressed="true"] {
  background: var(--control-soft, var(--bg));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
  font-weight: 600;
}
#sort-dialog.mobile-sort-dialog .mobile-sort-option:focus-visible {
  outline: 2px solid var(--control-focus, var(--action, var(--ink)));
  outline-offset: 1px;
}
#sort-dialog.mobile-sort-dialog .mobile-sort-option:disabled { cursor: not-allowed; opacity: .45; }

@media (max-width: 760px) {
  body.has-mobile-sort .site-header .mobile-sort-trigger:not([hidden]) {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
  }
  body.has-mobile-sort .site-header .mobile-sort-trigger > .reel-icon { width: 23px; height: 23px; }
  body.has-mobile-sort .site-header .mobile-sort-trigger[aria-expanded="true"] { background: var(--control-soft, var(--field, var(--surface))); }
  body.has-mobile-sort .catalog-toolbar > .sort-form { display: none !important; }
  body.has-mobile-sort .flow-toolbar { min-height: 0; margin: 0; padding: 0; gap: 0; }
  /* The remaining Flow toolbar children are its hidden heading and desktop-only column control. */
  body.has-mobile-sort .flow-toolbar:not(:has(> :not(.flow-toolbar-heading, .sort-form, .flow-view-control, [hidden]))) { display: none; }

  #sort-dialog.mobile-sort-dialog,
  #categories-dialog.mobile-explore-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 100vw;
    height: auto;
    max-height: calc(100dvh - 18px);
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 -10px 36px #00000026;
    overflow: hidden;
    overscroll-behavior: contain;
  }
  #sort-dialog.mobile-sort-dialog[open],
  #categories-dialog.mobile-explore-dialog[open] { display: flex; flex-direction: column; }
  #sort-dialog.mobile-sort-dialog > .drawer-header,
  #categories-dialog.mobile-explore-dialog > .drawer-header {
    position: relative;
    flex: 0 0 auto;
    padding: 17px 20px 13px;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  #sort-dialog.mobile-sort-dialog > .drawer-header h2,
  #categories-dialog.mobile-explore-dialog > .drawer-header h2 { margin: 0; font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -.3px; }
  #sort-dialog.mobile-sort-dialog > .drawer-header .icon-button,
  #categories-dialog.mobile-explore-dialog > .drawer-header .icon-button { flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 50%; }
  #sort-dialog.mobile-sort-dialog > .drawer-body,
  #categories-dialog.mobile-explore-dialog > .drawer-body {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
    padding: 12px 15px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    overscroll-behavior-y: contain;
    touch-action: pan-y pinch-zoom;
  }
  #categories-dialog.mobile-explore-dialog > .mobile-explore-body { padding-top: 10px; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}
@media (hover: hover) {
  #sort-dialog.mobile-sort-dialog .mobile-sort-option:not(:disabled):hover { background: var(--control-soft, var(--bg)); border-color: var(--line); }
  #sort-dialog.mobile-sort-dialog .mobile-sort-option[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
  #categories-dialog.mobile-explore-dialog :is(.flow-category-links, .mobile-information-links) > :is(a, button):hover { background: var(--control-soft, var(--bg)); color: var(--ink); text-decoration: none; }
}
@media (prefers-reduced-motion: reduce) { #sort-dialog.mobile-sort-dialog .mobile-sort-option { transition: none; } }
@media (forced-colors: active) {
  #sort-dialog.mobile-sort-dialog .mobile-sort-option[aria-pressed="true"] { border-color: Highlight; }
  #sort-dialog.mobile-sort-dialog .mobile-sort-check { color: Highlight; }
}

/* The legacy themes switch their navigation at600px; keep access continuous to760px. */
@media (min-width: 601px) and (max-width: 760px) {
  body:not(.theme-flow):not(.admin-page):not(.auth-page):not(.install-page):not(.embedded-checkout) { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body:not(.theme-flow) .mobile-nav {
    display: flex;
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    align-items: center;
    justify-content: space-around;
    height: calc(64px + env(safe-area-inset-bottom));
    min-height: 64px;
    padding: 7px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
  }
  body:not(.theme-flow) .mobile-nav > :is(a, button) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 62px;
    min-height: 44px;
    padding: 1px 7px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
    text-decoration: none;
  }
  body:not(.theme-flow) .mobile-nav > :is(a, button)[aria-current="page"] { color: var(--ink); }
  body:not(.theme-flow) .mobile-nav > :is(a, button) > span { display: block; position: relative; height: 24px; color: inherit; font-size: 0; line-height: 1; }
  body:not(.theme-flow) .mobile-nav .reel-icon { width: 23px; height: 23px; }
  body:not(.theme-flow) .mobile-nav b { position: absolute; top: -4px; right: -10px; display: grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 10px; background: var(--action, var(--ink)); color: white; font-size: 9px; line-height: 1; }
}

/* An explore button replaces the former hamburger only while the desktop rail is absent. */
@media (min-width: 761px) and (max-width: 900px) {
  body.theme-flow .site-header .desktop-explore-trigger:not([hidden]) {
    display: inline-grid !important;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
  }
}
@media (min-width: 761px) and (max-width: 1050px) {
  body:not(.theme-flow) .site-header .desktop-explore-trigger:not([hidden]) {
    display: inline-grid !important;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
  }
}
body .site-header .desktop-explore-trigger > .reel-icon { width: 22px; height: 22px; }
body .site-header .desktop-explore-trigger[aria-expanded="true"] { background: var(--control-soft, var(--surface)); }
@media (hover: hover) { body .site-header .desktop-explore-trigger:hover { background: var(--control-soft, var(--surface)); border-color: var(--line); } }

/* Highlight the active mobile discovery destination. */
@media(max-width:760px){
 body.theme-flow .mobile-nav>:is(.mobile-for-you,.mobile-new)[aria-current="page"]{color:var(--accent);background:var(--soft);border-radius:9px;font-weight:600}
 body.theme-flow[data-color=light] .mobile-nav>:is(.mobile-for-you,.mobile-new)[aria-current="page"]{color:var(--action)}
}

/* The shared category links keep children directly beneath their visible parent. */
.category-nav-link > .category-nav-name { min-width:0; overflow-wrap:anywhere; }
.category-nav-link > .category-nav-branch { display:inline-flex; align-items:center; justify-content:center; flex:0 0 14px; width:14px; color:var(--muted); font-size:18px; line-height:1; }
.flow-categories > .category-nav-link > .category-nav-branch { margin-inline-start:calc(var(--category-nav-depth,0) * 10px); }
#categories-dialog.mobile-explore-dialog .category-nav-link > .category-nav-branch { flex-basis:20px; width:20px; margin-inline-start:calc(var(--category-nav-depth,0) * 16px); }
