/* Redesigned dead-space-free Collection sidebar with synchronized masthead glide. */
.owner-sidebar-anchor { display:contents; }

/* Compact inline View + Sort strip & pinned bottom utility footer (all viewports). */
#screen > .collection-screen .collection-sidebar .owner-rail-brand {
  display:block;
  max-height:0;
  opacity:0;
  margin:0;
  padding:0;
  overflow:hidden;
  pointer-events:none;
  font-family:Interface,Display,sans-serif;
  font-size:15px;
  font-weight:600;
  letter-spacing:.08em;
  line-height:1.15;
  text-transform:uppercase;
  text-decoration:none;
  color:#f4f1ea;
  border-bottom:1px solid transparent;
  transition:max-height 240ms cubic-bezier(.22,1,.36,1),opacity 200ms ease,margin 240ms cubic-bezier(.22,1,.36,1),padding 240ms cubic-bezier(.22,1,.36,1),color 160ms ease;
}
#screen > .collection-screen .collection-sidebar .owner-rail-brand:is(:hover,:focus-visible) {
  color:#eac36b;
  text-shadow:0 0 10px #ffc77755;
}
html[data-display-mode="day"] #screen > .collection-screen .collection-sidebar .owner-rail-brand {
  color:#241d14;
}
html[data-display-mode="day"] #screen > .collection-screen .collection-sidebar .owner-rail-brand:is(:hover,:focus-visible) {
  color:#8a5c14;
  text-shadow:none;
}

#screen > .collection-screen .collection-sidebar .sidebar-view-controls {
  display:grid !important;
  grid-template-columns:auto minmax(0,1fr) !important;
  align-items:center !important;
  gap:8px !important;
  margin:7px 0 0 !important;
  padding:0 !important;
  border:0 !important;
  border-image:none !important;
}
#screen > .collection-screen .collection-sidebar .sidebar-view-controls .segmented {
  display:grid;
  grid-template-columns:1fr 1fr;
  width:auto;
  min-width:118px;
}
#screen > .collection-screen .collection-sidebar .sidebar-view-controls .segmented button {
  min-height:30px !important;
  padding:4px 9px !important;
  font-size:11.5px !important;
  white-space:nowrap;
}
#screen > .collection-screen .collection-sidebar .sidebar-view-controls .sidebar-sort {
  margin:0 !important;
  min-width:0;
}
#screen > .collection-screen .collection-sidebar .sidebar-view-controls .combo-trigger {
  min-height:30px !important;
  padding:4px 9px !important;
  font-size:12.5px !important;
}

#screen > .collection-screen .collection-sidebar > .codex-sidebar-utility {
  flex:none;
  display:flex;
  align-items:center;
  gap:8px;
  margin:0 !important;
  padding:8px 10px !important;
  border-top:1px solid transparent !important;
  border-image-source:var(--codex-taper-line) !important;
  border-image-slice:1 0 0 0 !important;
  background:rgba(10,12,14,.28);
}
html[data-display-mode="day"] #screen > .collection-screen .collection-sidebar > .codex-sidebar-utility {
  background:rgba(241,234,220,.38);
}
#screen > .collection-screen .collection-sidebar > .codex-sidebar-utility .codex-concordance-shortcut {
  flex:1 1 auto;
  width:auto;
  min-width:0;
  margin:0;
  min-height:30px;
  padding:5px 9px !important;
  font-size:11px !important;
  text-align:center;
  border-radius:3px;
}
#screen > .collection-screen .collection-sidebar > .codex-sidebar-utility .codex-export-btn {
  flex:none;
  margin:0;
  min-height:30px;
  padding:5px 9px !important;
  font-family:Interface,CodexGeometric,sans-serif;
  font-size:11px !important;
  font-weight:600;
  letter-spacing:.05em;
  text-transform:uppercase;
  color:var(--muted,#b6c0c5);
  border:1px solid #ffffff26;
  border-radius:3px;
  background:#ffffff06;
  white-space:nowrap;
  cursor:pointer;
}
#screen > .collection-screen .collection-sidebar > .codex-sidebar-utility .codex-export-btn:is(:hover,:focus-visible) {
  color:#f4f1ea;
  border-color:#c9a66b88;
  background:#c9a66b1c;
}
html[data-display-mode="day"] #screen > .collection-screen .collection-sidebar > .codex-sidebar-utility .codex-export-btn {
  color:#4f4536;
  border-color:#74695455;
  background:#00000006;
}
html[data-display-mode="day"] #screen > .collection-screen .collection-sidebar > .codex-sidebar-utility .codex-export-btn:is(:hover,:focus-visible) {
  color:#241d14;
  border-color:#9e743088;
  background:#c9a66b22;
}

@media (min-width:721px) {
  /* Synchronize masthead slide and sidebar glide on the exact same curve. */
  body.home-ui.gallery-locked .frame {
    transition:transform 260ms cubic-bezier(.22,1,.36,1),opacity 220ms ease !important;
  }

  body.home-ui.gallery-locked:not(.gallery-sidebar-collapsed) #screen > .collection-screen > .owner-sidebar-anchor {
    display:block; min-inline-size:0; block-size:0; align-self:start;
  }
  body.home-ui.gallery-locked #screen > .collection-screen:has(> .owner-sidebar-anchor [data-owner-sidebar-pinned]) {
    transform:none !important; will-change:auto !important;
  }

  body.home-ui.gallery-locked #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column:not(.sidebar-sliding) {
    --owner-rail-top:calc(var(--masthead-height) + 14px);
    --owner-rail-bottom:12px;
    min-block-size:0;
  }
  body.home-ui.gallery-locked.gallery-header-hidden #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column:not(.sidebar-sliding) {
    --owner-rail-top:12px;
  }

  body.home-ui.gallery-locked #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column[data-owner-sidebar-pinned]:not(.sidebar-sliding) {
    position:fixed;
    top:var(--owner-rail-top) !important;
    bottom:auto !important;
    left:var(--owner-rail-left);
    width:var(--owner-rail-width);
    display:flex;
    flex-direction:column;
    block-size:auto !important;
    max-block-size:max(0px,calc(100dvh - var(--owner-rail-top) - var(--owner-rail-bottom))) !important;
    max-height:max(0px,calc(100dvh - var(--owner-rail-top) - var(--owner-rail-bottom))) !important;
    z-index:7;
    transition:top 260ms cubic-bezier(.22,1,.36,1),max-block-size 260ms cubic-bezier(.22,1,.36,1),max-height 260ms cubic-bezier(.22,1,.36,1);
  }

  /* Reveal compact brand inside the rail once the masthead glides away; prevent duplicate brand at 721–1120px. */
  body.home-ui.gallery-locked.gallery-header-hidden #screen > .collection-screen .sidebar-column > .sidebar-brand {
    display:none !important;
  }
  body.home-ui.gallery-locked.gallery-header-hidden #screen > .collection-screen .collection-sidebar .owner-rail-brand {
    max-height:28px;
    opacity:1;
    margin:0 0 7px;
    padding:0 0 6px;
    pointer-events:auto;
    border-image-source:var(--codex-taper-line);
    border-image-slice:0 0 1 0;
  }

  body.home-ui.gallery-locked #screen > .collection-screen .sidebar-column > .collection-sidebar {
    flex:0 1 auto;
    min-block-size:0;
    block-size:auto;
    max-block-size:100% !important;
    max-height:100% !important;
    padding:0 !important;
    display:flex;
    flex-direction:column;
    overflow:hidden;
  }

  #screen > .collection-screen .collection-sidebar > .sidebar-search-area {
    padding:9px 10px 8px !important;
    flex:none;
  }
  #screen > .collection-screen .collection-sidebar .sidebar-search-area .collection-tools {
    min-height:34px !important;
    margin:0 !important;
  }
  #screen > .collection-screen .collection-sidebar .sidebar-result-line {
    margin:6px 0 0 !important;
    gap:8px;
    min-height:22px;
    align-items:center;
  }
  #screen > .collection-screen .collection-sidebar #objectCount {
    margin:0;
    min-inline-size:0;
    line-height:1.15;
  }
  #screen > .collection-screen .collection-sidebar #sidebarReset {
    flex:none;
    margin:0;
    padding:2px 6px !important;
    font-size:11px !important;
    line-height:1.25;
  }

  #screen > .collection-screen .collection-sidebar > .sidebar-body {
    flex:1 1 auto;
    min-height:0;
    padding:8px 10px 6px !important;
    overflow-y:auto;
    overscroll-behavior-y:contain;
    scrollbar-width:thin;
    scrollbar-color:#c9a66b44 transparent;
  }

  #screen > .collection-screen .collection-sidebar .settings-rows > .location-filter {
    margin:0 0 6px !important;
    padding:0 0 7px !important;
  }
  #screen > .collection-screen .collection-sidebar .location-filter > .sidebar-field-label {
    margin:0 0 3px !important;
    font-size:10.5px !important;
  }
  #screen > .collection-screen .collection-sidebar .location-filter > .themed-select {
    margin-top:0 !important;
  }
  #screen > .collection-screen .collection-sidebar .location-filter .combo-trigger {
    min-height:30px !important;
    padding:4px 9px !important;
    font-size:12.5px !important;
  }

  #screen > .collection-screen .collection-sidebar .settings-rows > details > summary {
    min-height:30px;
    padding:5px 20px 5px 1px !important;
    line-height:1.25;
    box-sizing:border-box;
  }
  #screen > .collection-screen .collection-sidebar .codex-category-list {
    gap:2px !important;
    padding:3px 0 7px !important;
  }
  #screen > .collection-screen .collection-sidebar .codex-cat-choice {
    padding:3.5px 7px !important;
    font-size:12px !important;
    line-height:1.25 !important;
    border-radius:2px;
  }
}

@media (min-width:1121px) {
  body.home-ui.gallery-locked #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column:not(.sidebar-sliding) {
    --owner-rail-top:calc(var(--masthead-height) + 10px);
  }
  body.home-ui.gallery-locked.gallery-header-hidden #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column:not(.sidebar-sliding) {
    --owner-rail-top:12px;
  }
}

@media (prefers-reduced-motion:reduce) {
  body.home-ui.gallery-locked .frame,
  body.home-ui.gallery-locked #screen > .collection-screen > .owner-sidebar-anchor > .sidebar-column[data-owner-sidebar-pinned]:not(.sidebar-sliding),
  #screen > .collection-screen .collection-sidebar .owner-rail-brand {
    transition:none !important;
  }
}

/* ── Zero-Jump GPU Masthead Glide on Gallery Scroll ── */
body.home-ui.gallery-locked #screen,
body.home-ui.gallery-locked.gallery-header-hidden #screen {
  margin-top: 0 !important;
}
body.home-ui.gallery-locked #screen > .collection-screen {
  padding-top: calc(var(--masthead-height, 150px) + 12px) !important;
}
body.home-ui.gallery-locked .frame {
  will-change: transform;
  transition: transform 300ms cubic-bezier(.22, 1, .36, 1) !important;
}
body.home-ui.gallery-locked.gallery-header-hidden .frame {
  transform: translate3d(0, -100%, 0) !important;
  pointer-events: none;
}
body.home-ui.gallery-locked:not(.gallery-header-hidden) .frame {
  transform: translate3d(0, 0, 0) !important;
}
