/* ===== These are CSS definitions for the rows of icons on the bottom left and right ===== */
/* Control and Search Panels Styles */
#controlPanel,
#searchPanel {
  position: fixed;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
  z-index: 4000;
  background: rgba(30, 30, 30, 0.35);
  border-radius: 0.7em;
  padding: 0.4em 0.3em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#controlPanel {
  left: 20px;
}

#searchPanel {
  right: 20px;
}

#controlPanel button,
#searchPanel button {
  background: none;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8em;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  pointer-events: auto;
}

#controlPanel svg,
#searchPanel svg {
  width: 32px;
  height: 32px;
  display: block;
}

#controlPanel button:hover,
#searchPanel button:hover {
  opacity: 1;
}

#controlPanel button.back-nav-disabled,
#controlPanel button.back-nav-disabled:hover,
#controlPanel button.slideshow-disabled,
#controlPanel button.slideshow-disabled:hover {
  opacity: 0.25;
  cursor: default;
}

/* ===== Pulldown chevrons (Slideshow, Back) ===== */

/* An icon that owns a pulldown menu pairs with a chevron to its right; the two
   sit side by side above the one shared label, so the label centers under the
   pair rather than under the icon. */
.icon-with-chevron {
  display: flex;
  flex-direction: row;
  align-items: center;
}

/* Deliberately far narrower than the 40px panel buttons — the whole point of
   this panel work is to reclaim horizontal room, and the chevron is an
   affordance, not an icon in its own right. */
#controlPanel button.menu-chevron {
  width: 24px;
  min-width: 24px;
  border-radius: 4px;
  /* The icon beside it is a 32px glyph centred in a 40px button, so 4px of
     this comes free out of that slack. The remaining 2px is bought from the
     icon's hit area, leaving it 34px wide — still comfortable for touch, but
     this is as far as the tuck can go without making the icons awkward. */
  margin-left: -6px;
  /* Brighter than the 0.6 of the 32px icons beside it, not dimmer: a 16px
     glyph lays down far less ink, so matching their opacity leaves it barely
     separable from the translucent panel behind it. */
  opacity: 0.9;
}

/* Same specificity as #controlPanel button:hover (1,1,1) but later in the
   file, so the rule above would otherwise win and the chevron would never
   brighten on hover. */
#controlPanel button.menu-chevron:hover {
  opacity: 1;
}

#controlPanel button.menu-chevron svg {
  width: 22px;
  height: 22px;
  /* The panel is translucent, so the chevron can land on a bright photo with
     almost no contrast of its own. The icons survive that on sheer mass; this
     one needs the outline. */
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9));
}

#controlPanel button.menu-chevron:disabled,
#controlPanel button.menu-chevron:disabled:hover {
  opacity: 0.3;
  cursor: default;
}

#backNavFlyout {
  position: fixed;
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid #444;
  padding: 8px;
  border-radius: 6px;
  z-index: 10000;
  /* Fixed 4×3 grid sized to the FLYOUT_LIMIT of 12. back-button.js places
     each thumb with explicit grid-column / grid-row so the oldest sits at the
     bottom-right corner, newer entries fill upward then leftward, and partial
     fills leave empty cells at the top-left — mirroring the grid view's
     column-major ordering. */
  display: grid;
  grid-template-columns: repeat(4, 72px);
  grid-template-rows: repeat(3, 72px);
  gap: 6px;
}

#backNavFlyout .back-nav-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  background: #111;
}

#backNavFlyout .back-nav-thumb:hover {
  border-color: #fff;
}

/* Drag-over highlight for search panel */
#searchPanel.drag-over {
  border: 2px dashed #00ff99;
  box-shadow: 0 0 12px 2px #00ff9980;
  background: rgba(30, 30, 30, 0.45);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.control-panel-title,
.search-panel-title {
  color: #fff;
  font-size: 1em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 0;
  letter-spacing: 0.5px;
  width: 100%;
  display: block;
}

.control-icons-row,
.search-icons-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
}

.checkmark-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.control-icon-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hide-panel-text .control-panel-title,
.hide-panel-text .button-label,
.hide-panel-text .search-panel-title,
.hide-panel-text .search-icon-container .button-label {
  display: none !important;
}

@media (max-width: 600px) {
  #panelStackContainer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 4000;
    pointer-events: none;
  }

  #searchPanel,
  #controlPanel {
    position: static !important;
    width: 100vw;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    pointer-events: auto;
    /* Remove any max-width if present */
  }

  #searchPanel {
    order: 0;
    border-bottom: 1px solid #222;
  }

  #controlPanel {
    order: 1;
    border-top: 1px solid #222;
  }

  /* Keep icons in a horizontal row */
  .control-icons-row,
  .search-icons-row {
    flex-direction: row !important;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    width: 100%;
  }

  #controlPanel button,
  #searchPanel button {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 2em;
  }

  /* The rule above is less specific than #controlPanel button.menu-chevron, so
     the chevron keeps its 16px width here; only the height needs restating to
     stay flush with the 48px button it is attached to. */
  #controlPanel button.menu-chevron {
    height: 48px;
    min-height: 48px;
  }
}

/* The Search panel carries six icons since Clear became always-visible and
   About moved across. At the phone layout's 48px that needs 328px of row,
   which a 320px viewport cannot give — and html/body are overflow:hidden, so
   the excess is clipped off both ends rather than scrolled. Step the buttons
   back down on the narrowest screens: 6x40 + 5x4 = 260px fits with room over. */
@media (max-width: 380px) {
  #controlPanel button,
  #searchPanel button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.8em;
  }

  #controlPanel button.menu-chevron {
    height: 40px;
    min-height: 40px;
  }

  .control-icons-row,
  .search-icons-row {
    gap: 0.25em;
  }
}
