/*
 * TobyCon — Gallery (gallery.php)
 * File browser, thumbnails, lightbox, root-listing home page.
 * ──────────────────────────────────────────────────────────
 */

/* ── Nav: sticky + secondary links ── */

nav {
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  font-size: 0.83rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sand-dark);
  text-decoration: none;
}

.nav-links a:hover { color: var(--white); }

/* ── Root tabs (multi-root selector) ── */

.root-bar {
  background: var(--ink-light);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 2rem;
  display: flex;
  overflow-x: auto;
}

.root-tab {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sand-dark);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.root-tab:hover { color: var(--white); }
.root-tab.active { color: var(--sage-light); border-color: var(--sage-light); }

/* ── Breadcrumb ── */

.breadcrumb-bar {
  background: var(--white);
  border-bottom: 1px solid var(--sand);
  padding: 0.6rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.breadcrumb-bar a,
.breadcrumb-bar span {
  font-size: 0.82rem;
  color: var(--earth);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb-bar a:hover { color: var(--sage-dark); }
.breadcrumb-bar .sep { color: var(--sand-dark); }
.breadcrumb-bar .current { color: var(--ink); font-weight: 600; }

/* ── Toolbar ── */

.toolbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-count {
  font-size: 0.82rem;
  color: var(--earth);
  font-weight: 500;
}

.view-toggle { display: flex; gap: 4px; }

.view-btn {
  background: none;
  border: 1.5px solid var(--sand-dark);
  padding: 0.3rem 0.55rem;
  border-radius: 3px;
  cursor: pointer;
  color: var(--ink-light);
  transition: all 0.15s;
  line-height: 1;
  font-size: 0.9rem;
}

.view-btn.active { background: var(--ink); border-color: var(--ink); color: var(--white); }

/* ── Content wrapper ── */

.gallery-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem 4rem;
}

/* ── Section label (reused from home, scoped here for gallery specifics) ── */

.section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 0.75rem;
}

/* ── Folder cards ── */

.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 2rem;
}

.folder-card {
  background: var(--white);
  border: 1.5px solid var(--sand);
  border-radius: 3px;
  padding: 1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.15s, background 0.15s;
}

.folder-card:hover { border-color: var(--sage-light); background: var(--sand-light); }
.folder-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }
.folder-name { font-size: 0.85rem; font-weight: 600; color: var(--ink); word-break: break-word; line-height: 1.3; }
.folder-count { font-size: 0.72rem; color: var(--earth); margin-top: 0.15rem; }

/* ── Media grid ── */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.media-grid.list-view {
  grid-template-columns: 1fr;
  gap: 4px;
}

/* ── Thumbnail card (grid mode) ── */

.media-card {
  background: var(--ink);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  aspect-ratio: 3 / 2;
  transition: transform 0.15s;
}

.media-card:hover { transform: scale(1.015); z-index: 2; }

.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}

.media-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 12, 8, 0.75) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.75rem;
}

.media-card:hover .media-card-overlay { opacity: 1; }

.media-card-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-meta {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.1rem;
}

/* ── Media type badges ── */

.media-type-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 2px;
}

.badge-video { background: rgba(74, 100, 72, 0.9); color: #fff; }
.badge-360   { background: rgba(78, 135, 168, 0.9); color: #fff; }
.badge-image { display: none; }

/* ── List view overrides ── */

.media-grid.list-view .media-card {
  aspect-ratio: unset;
  height: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--white);
  border: 1px solid var(--sand);
  transform: none;
}

.media-grid.list-view .media-card:hover { background: var(--sand-light); transform: none; }
.media-grid.list-view .media-card img { width: 64px; height: 44px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.media-grid.list-view .media-card-overlay { display: none; }
.media-grid.list-view .media-type-badge { position: static; }

.list-info { flex: 1; min-width: 0; }
.list-info .name { font-size: 0.88rem; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-info .meta { font-size: 0.75rem; color: var(--earth); margin-top: 0.1rem; }

/* ── Empty state ── */

.empty { text-align: center; padding: 4rem 2rem; color: var(--earth); }
.empty h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.5rem; font-weight: 700; text-transform: uppercase; color: var(--ink); margin-bottom: 0.5rem; }

/* ── Lightbox ── */

.lb {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 10, 6, 0.96);
  flex-direction: column;
}

.lb.open { display: flex; }

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.lb-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--sand-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100vw - 200px);
}

.lb-header-right { display: flex; gap: 0.75rem; align-items: center; flex-shrink: 0; }
.lb-counter { font-size: 0.78rem; color: rgba(255, 255, 255, 0.4); }

.lb-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.1rem;
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  font-family: inherit;
  line-height: 1;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.lb-btn:hover { color: var(--white); background: rgba(255, 255, 255, 0.1); }

.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.lb-video {
  max-width: 100%;
  max-height: 100%;
  outline: none;
}

.lb-insv-note {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(78, 135, 168, 0.85);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  pointer-events: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  color: var(--white);
  font-size: 1.5rem;
  padding: 1rem 0.75rem;
  border-radius: 3px;
  transition: background 0.15s;
  line-height: 1;
}

.lb-nav:hover { background: rgba(255, 255, 255, 0.15); }
.lb-prev { left: 0.75rem; }
.lb-next { right: 0.75rem; }

.lb-footer {
  padding: 0.5rem 1.25rem;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lb-filmstrip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.lb-filmstrip-item {
  width: 60px;
  height: 42px;
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.45;
  border-radius: 2px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: opacity 0.15s, border-color 0.15s;
}

.lb-filmstrip-item img { width: 100%; height: 100%; object-fit: cover; }
.lb-filmstrip-item.active { opacity: 1; border-color: var(--sage-light); }

/* ── Gallery home: root-listing page ── */

.roots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.root-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border: 1.5px solid var(--sand);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.root-card:hover {
  border-color: var(--sage-light);
  background: var(--sand-light);
  transform: translateY(-1px);
}

.root-card--offline { opacity: 0.5; pointer-events: none; }
.root-card-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.root-card-body { flex: 1; min-width: 0; }

.root-card-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink);
  line-height: 1.1;
}

.root-card-desc {
  font-size: 0.82rem;
  color: var(--earth);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.root-card-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sage-dark);
  margin-top: 0.35rem;
}

.root-offline { color: var(--earth); }

.root-card-arrow {
  font-size: 1.2rem;
  color: var(--sand-dark);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}

.root-card:hover .root-card-arrow { color: var(--sage-dark); transform: translateX(3px); }

/* ── Responsive ── */

@media (max-width: 700px) {
  nav { padding: 0 1rem; }
  .gallery-wrap { padding: 1rem 1rem 3rem; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .lb-footer { display: none; }
}
