/* =========================================================================
   styles.css — chrome is intentionally minimal; layout values come from
   config.js and are injected as CSS variables at runtime (see gallery.js).
   You normally won't need to edit this file — tune config.js instead.
   ========================================================================= */

:root {
  --bg: #9d9d9d;
  --fg: #111;
  --panel-bg: #fff;
  --gap: 16px;
  --outer: 24px;
  --cols: 6;
  --aspect: 3 / 4;
  --single-max: 900px;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* ---- Header / nav -------------------------------------------------------- */
header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: var(--outer);
  padding-bottom: 0;
}

.nav-label {
  display: inline-block;
  background: var(--panel-bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0.2px;
  cursor: default;
  user-select: none;
  white-space: nowrap;
}
button.nav-label {
  font-family: inherit;
  cursor: pointer;
}
button.nav-label:hover { background: #f0f0f0; }

.spacer { flex: 1; }

/* Preset switcher (top-right, understated) */
.preset-switch {
  display: flex;
  gap: 6px;
  align-items: center;
}
.preset-switch button {
  font-family: var(--mono);
  font-size: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: #333;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 2px;
  text-transform: lowercase;
}
.preset-switch button:hover { color: #000; }
.preset-switch button[aria-pressed="true"] {
  background: var(--panel-bg);
  border-color: var(--fg);
  color: #000;
}

/* ---- Gallery container --------------------------------------------------- */
main { padding: var(--outer); }

/* Masonry — images keep natural aspect ratio. gallery.js places photos
   across the columns in reading order (always into the shortest column). */
.gallery.masonry {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}
.masonry-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Tight symmetrical grid — cropped cells, all same shape */
.gallery.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
}
.gallery.grid .tile img {
  width: 100%;
  height: 100%;
  aspect-ratio: var(--aspect);
  object-fit: cover;
  display: block;
}

/* Full-bleed single column */
.gallery.single {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
}
.gallery.single .tile {
  width: 100%;
  max-width: var(--single-max);
}

/* Shared tile look */
.tile {
  cursor: zoom-in;
  position: relative;
}
.tile img {
  width: 100%;
  display: block;
  background: #8a8a8a; /* placeholder tone while loading */
}
.hoverfade .tile img { transition: opacity 0.25s ease; }
.hoverfade .tile:hover img { opacity: 0.82; }

.tile .caption {
  font-size: 12px;
  color: #2a2a2a;
  padding: 6px 2px 0;
  line-height: 1.3;
}
.captions-off .tile .caption { display: none; }

/* ---- Lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 86vh;
  object-fit: contain;
  user-select: none;
}
.lightbox .lb-caption {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ddd;
  font-size: 13px;
  font-family: var(--mono);
}
.lb-btn {
  position: absolute;
  top: 0; bottom: 0;
  width: 24%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.lb-btn:hover { opacity: 1; }
.lb-prev { left: 0; text-align: left; padding-left: 24px; }
.lb-next { right: 0; text-align: right; padding-right: 24px; }
.lb-close {
  position: absolute;
  top: 16px; right: 20px;
  width: auto;
  font-size: 22px;
  padding: 6px 10px;
}

/* ---- Info / contact panel ------------------------------------------------ */
.info-panel {
  position: fixed;
  inset: 0;
  background: rgba(157, 157, 157, 0.97);
  display: none;
  z-index: 90;
  padding: var(--outer);
}
.info-panel.open { display: block; }
.info-panel .info-inner {
  max-width: 480px;
  font-size: 15px;
  line-height: 1.7;
}
.info-panel a { color: #000; }
.info-panel .info-close {
  margin-bottom: 20px;
}

/* ---- Secret admin editor (only rendered after login) --------------------- */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 200;
  font-family: var(--mono);
}
.admin-box {
  background: var(--panel-bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow: auto;
  padding: 18px;
}
.admin-box-sm { max-width: 340px; }
.admin-hash { font-size: 11px; word-break: break-all; margin-top: 10px; resize: vertical; }
.admin-title { font-size: 14px; margin-bottom: 12px; }
.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.admin-row { display: flex; gap: 6px; flex-wrap: wrap; }

.admin-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px;
  border: 1px solid var(--fg);
  background: #fff;
  margin-bottom: 10px;
}
.admin-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 11px;
  border: 1px solid var(--fg);
  background: #fff;
  cursor: pointer;
}
.admin-btn:hover { background: #f0f0f0; }
.admin-btn.ghost { border-color: #999; color: #333; }
.admin-msg { font-size: 12px; color: #444; min-height: 16px; margin: 8px 0; }

.admin-drop {
  border: 1px dashed #666;
  padding: 26px 14px;
  text-align: center;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  background: #fafafa;
}
.admin-drop.over { background: #e8e8e8; border-color: #000; color: #000; }

.admin-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.admin-empty { font-size: 12px; color: #777; padding: 10px 0; }
.admin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #ddd;
  padding: 6px;
}
.admin-thumb { width: 48px; height: 48px; object-fit: cover; display: block; background: #ccc; }
.admin-cap {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px;
  border: 1px solid #ccc;
}
.admin-item-btns { display: flex; gap: 4px; }
.admin-mini {
  font-family: var(--mono);
  width: 26px; height: 26px;
  border: 1px solid #999;
  background: #fff;
  cursor: pointer;
  line-height: 1;
}
.admin-mini:hover { background: #eee; }
.admin-mini.danger:hover { background: #f3d6d6; border-color: #a33; }

/* ---- Design panel (side drawer; gallery stays visible beside it) --------- */
.design-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  background: var(--panel-bg);
  color: var(--fg);
  border-left: 1px solid var(--fg);
  padding: 18px;
  overflow-y: auto;
  z-index: 200;
  font-family: var(--mono);
}
body.design-open header,
body.design-open main { margin-right: 320px; }
.design-presets { margin: 8px 0 18px; }
.design-presets .admin-btn.active { background: var(--fg); color: #fff; border-color: var(--fg); }
.design-field { display: block; margin-bottom: 16px; }
.design-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #333;
  margin-bottom: 6px;
}
.design-val { color: #000; }
.design-field input[type="range"] { width: 100%; accent-color: #111; }
.design-select { margin: 0; font-size: 12px; }
.design-section { margin-top: 26px; padding-top: 16px; border-top: 1px solid #ddd; }
.design-field .admin-input { margin: 0; font-size: 13px; }
.design-textarea { resize: vertical; line-height: 1.5; }
.design-hint { font-size: 11px; color: #777; margin-top: 4px; }
.design-link {
  font-family: var(--mono); font-size: 11px;
  background: none; border: none; padding: 0;
  text-decoration: underline; cursor: pointer; color: #333;
}
/* Keep save/undo reachable while scrolling a long panel */
.design-actions {
  position: sticky;
  bottom: -18px;
  background: var(--panel-bg);
  padding: 12px 0;
  margin-top: 8px;
  border-top: 1px solid #ddd;
}

/* ---- Arrange mode (drag photos on the real page) ------------------------- */
body.arranging .tile { cursor: grab; }
body.arranging .tile img { outline: 1px dashed rgba(0, 0, 0, 0.35); outline-offset: -1px; }
body.arranging .tile.dragging { opacity: 0.35; }
body.arranging .tile.drop-target img { outline: 3px solid #111; outline-offset: -3px; }
body.arranging main { padding-bottom: 96px; }
.arrange-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 32px);
  background: var(--panel-bg);
  border: 1px solid var(--fg);
  padding: 10px 14px;
  z-index: 200;
  font-family: var(--mono);
  font-size: 12px;
}

@media (max-width: 640px) {
  .design-drawer {
    top: auto; left: 0; width: 100%; height: 55vh;
    border-left: none; border-top: 1px solid var(--fg);
  }
  body.design-open header,
  body.design-open main { margin-right: 0; }
  body.design-open main { padding-bottom: 56vh; }
}

/* ---- Responsive breakpoints (column counts come from JS vars) ------------ */
@media (max-width: 1100px) {
  .gallery.masonry, .gallery.grid { --cols: var(--cols-tablet); }
}
@media (max-width: 640px) {
  .gallery.masonry, .gallery.grid { --cols: var(--cols-mobile); }
  header { flex-wrap: wrap; }
  .lb-btn { width: 30%; }
}
