/* Goodgallery 2.0 default stylesheet — dark, dense, mobile-first.
   Place a `goodgallery.css` in the gallery root to override (TODO: wire up). */

:root {
  --bg: #0a0a0a;
  --fg: #cfcfcf;
  --muted: #888;
  --accent: #fff;
  --border: #2a2a2a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  height: 100vh; overflow: hidden;
}

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--accent); }

img { border: 0; max-width: 100%; height: auto; vertical-align: middle; }

button {
  background: #000;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  min-width: 64px;
  min-height: 36px;
}
button:hover { background: var(--fg); color: #000; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10,10,10,0.96);
  backdrop-filter: blur(6px);
  z-index: 10;
}
#breadcrumb {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;        /* no scrollbar gutter, no white sliver next to gear */
  min-width: 0;            /* let flex item actually shrink */
}
#breadcrumb a { padding: 2px 4px; }
#breadcrumb a:not(:last-child)::after { content: ' / '; padding: 0 6px; color: var(--muted); }
#adminlink { font-size: 18px; padding: 4px 8px; opacity: 0.6; }
#adminlink:hover { opacity: 1; }

#adminnotify {
  padding: 8px 14px;
  background: #1a1a1a;
  border-bottom: 1px solid var(--border);
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
#adminnotify.on { display: flex; }

#foldersWrap {
  margin: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #141414;
}
#foldersWrap > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 14px;
  color: #ccc;
  user-select: none;
}
#foldersWrap > summary::-webkit-details-marker { display: none; }
#foldersWrap > summary::before {
  content: '\25B6';
  display: inline-block;
  width: 1em;
  margin-right: 6px;
  font-size: 10px;
  transition: transform .12s ease;
}
#foldersWrap[open] > summary::before { transform: rotate(90deg); }
#foldersWrap > summary:hover { color: var(--accent); }
#folders {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
#folders .folder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #1c1c1c;
  word-break: break-word;
  transition: background .12s;
}
#folders .folder:last-child { border-bottom: 0; }
#folders .folder:hover { background: #1c1c1c; color: var(--accent); }
#folders .folder-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
#folders .folder-name { font-size: 13px; }

#prevnext {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 10px;
}
#prevnext a {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px;
}
#prevnext a:hover { color: var(--accent); }

#counter { text-align: center; padding: 4px; font-size: 12px; color: var(--muted); }
#realtime {
  text-align: center;
  padding: 8px 12px;
  color: var(--accent);
  font-size: 13px;
}
#realtime:empty { padding: 0; }

#thumbs {
  /* Was a flex grid back when each thumb was a DOM <img>. The renderer is now a
     single canvas + spacer, so we just need the box to size+scroll cleanly. */
  position: relative;
  overflow: hidden;  /* JS toggles overflowX/Y per mode; default is no scrollbars */
}



#bottomlink {
  text-align: center;
  padding: 18px 8px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
}
#bottomlink a { color: var(--muted); }
#bottomlink a:hover { color: var(--accent); }

/* mobile */
@media (max-width: 700px) {
  #foldersWrap { margin: 6px 8px; }
  #folders { max-height: 240px; }
  #prevnext button { min-width: 88px; }
}

/* Single-canvas thumb rendering — see gallery.js renderGallery(). */



/* prevent horizontal scroll due to row gap rounding */
html, body { overflow-x: hidden; }

/* Discrete zoom-level control: [−] Label [+] in grid mode, [← back] in focus. */
.zoom-control { display: flex; align-items: center; gap: 4px; user-select: none; }
.zoom-control button {
  background: transparent; color: var(--fg); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 12px; min-width: 36px;
  font: inherit; line-height: 1.2; cursor: pointer;
  /* Block iOS double-tap-to-zoom on the buttons themselves so rapid
     tapping the +/- doesn't accidentally zoom the page. Keeps pinch
     and scroll fully functional. */
  touch-action: manipulation;
}
.zoom-control button:disabled { opacity: 0.35; cursor: default; }
.zoom-control button:hover:not(:disabled) { background: var(--border); }
.zoom-control .zoom-label { min-width: 80px; text-align: center; color: var(--fg); }
.zoom-control .zoom-back { padding: 4px 14px; }

/* Hidden folders (admin view only — see server.js sethidden endpoint). The
   little (hidden) tag and dimmed cell make them obvious without changing the
   click target's position. */
#folders .folder.folder-hidden { opacity: 0.55; }
#folders .folder-hidden-tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  font-style: italic;
  white-space: nowrap;
}


/* ===========================================================================
   Auto-hiding top controls. The #topcontrols wrapper slides out of view by
   default; body.controls-revealed brings it back. #thumbs flows to the very
   top of the viewport so the image / grid uses every pixel.
   - Desktop: pointer near the top 80px reveals (JS).
   - Touch: tap on #topreveal pill reveals (JS).
   =========================================================================== */
#topcontrols {
  position: fixed;
  top: 0;
  left: 0;
  right: var(--scrollbar-w, 0px);
  z-index: 30;
  transform: translateY(-100%);
  transition: transform 220ms ease;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(6px);
  padding-top: env(safe-area-inset-top);
}
body.controls-revealed #topcontrols { transform: translateY(0); }

/* Existing top elements were styled with position:sticky / margins assuming
   they lived in the document flow. Inside the fixed wrapper they should be
   plain block-level. */
#topcontrols #topbar { position: static; background: transparent; backdrop-filter: none; border-bottom: 1px solid var(--border); }

/* Affordance pill. Shown on all devices, with platform-specific reveal:
   - Touch (hover: none): always visible.
   - Desktop: visible when cursor is within 150px of pill center (body.pill-near,
     set by JS) OR when drawer is open (body.controls-revealed).
   - Empty galleries (body.gallery-empty): hidden; drawer is locked open. */
#topreveal {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 44px;
  background: rgba(20,20,20,0.7);
  border: 1px solid rgba(255,255,255,0.18);
  border-top: none;
  border-radius: 0 0 16px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 31;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
#topreveal::before {
  content: '';
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.6);
}
body.pill-near #topreveal,
body.controls-revealed #topreveal {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: none) {
  #topreveal { opacity: 1; pointer-events: auto; }
}
body.gallery-empty #topreveal { display: none; }
