/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f8f8f6;
  --bg-white:    #ffffff;
  --border:      #e8e8e4;
  --text:        #1a1a18;
  --text-muted:  #888880;
  --accent:      #2a2a28;
  --accent-hover:#000000;
  --error:       #c0392b;
  --success:     #27ae60;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --radius: 3px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Nav ───────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-white);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.nav-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-link:hover { color: var(--text); }
.nav-admin { font-weight: 500; color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-white);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--border); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }

/* ── Gallery Grid ──────────────────────────────────────────── */
.gallery-main { max-width: 1600px; margin: 0 auto; padding: 1.5rem 2rem 4rem; }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.filter-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.search-input {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  width: 280px;
  background: var(--bg-white);
  transition: border-color var(--transition);
}
.search-input:focus { outline: none; border-color: var(--text-muted); }

.filter-selects { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.filter-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  background: var(--bg-white);
  cursor: pointer;
}
.filter-select:focus { outline: none; }

.results-info { font-size: 0.85rem; color: var(--text-muted); }
.slideshow-link { color: var(--text); font-weight: 500; }
.slideshow-link:hover { text-decoration: underline; }

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

.grid-item { display: block; }

.thumb-wrap {
  position: relative;
  overflow: hidden;
  background: var(--border);
  aspect-ratio: 4/3;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.grid-item:hover .thumb-img { transform: scale(1.03); }

.thumb-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: #fff;
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.grid-item:hover .thumb-overlay { opacity: 1; }

.thumb-title { font-size: 0.875rem; font-weight: 500; }
.thumb-year  { font-size: 0.75rem; opacity: 0.85; }

.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 3rem;
  font-size: 0.875rem;
}

.page-link { color: var(--text); }
.page-link:hover { text-decoration: underline; }
.page-info { color: var(--text-muted); }

/* ── Single Image View ─────────────────────────────────────── */
.image-main {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 57px);
}

.image-viewer {
  position: relative;
  flex: 1;
  background: #f0f0ee;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 60vh;
}

.image-full {
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.image-nav {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  padding: 0 1rem;
}

.nav-arrow {
  pointer-events: all;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  border-radius: 50%;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.nav-arrow:hover { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.image-info {
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem 2rem;
}

.info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.info-title {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.3;
}

.info-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.3rem 2rem;
  margin-bottom: 1.25rem;
}

.info-grid dt { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.6rem; }
.info-grid dd { font-size: 0.95rem; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.8rem;
}
.tag:hover { border-color: var(--text-muted); }

.info-background h3 { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }
.info-background p  { font-size: 0.9rem; line-height: 1.7; color: var(--text); }

/* ── Slideshow ─────────────────────────────────────────────── */
.slideshow-page {
  position: fixed;
  inset: 0;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.slide-img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  transition: opacity 0.4s ease;
}

.slide-caption {
  position: fixed;
  bottom: 4rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.slide-controls {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.slideshow-page:hover .slide-controls { opacity: 1; }

.ctrl-btn {
  width: 2.5rem;
  height: 2.5rem;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  text-decoration: none;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.3); }

.slide-counter {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  color: rgba(255,255,255,0.5);
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity var(--transition);
}
.slideshow-page:hover .slide-counter { opacity: 1; }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-box {
  background: var(--bg-white);
  padding: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.auth-title    { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.auth-tagline  { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.auth-form { display: flex; flex-direction: column; gap: 0.75rem; text-align: left; }

.auth-form label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.auth-form input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
}
.auth-form input:focus { outline: none; border-color: var(--text-muted); }

.auth-form .btn { width: 100%; justify-content: center; margin-top: 0.25rem; }

.back-link { display: block; margin-top: 1.25rem; font-size: 0.85rem; color: var(--text-muted); }
.back-link:hover { color: var(--text); }

/* ── Admin ─────────────────────────────────────────────────── */
.admin-main { max-width: 960px; margin: 0 auto; padding: 2rem; }

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.admin-header h1 { font-size: 1.5rem; }

.stat-grid { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 140px;
}

.stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 0.8rem; color: var(--text-muted); }

.admin-nav-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }

.admin-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.admin-card:hover { border-color: var(--text-muted); box-shadow: var(--shadow); }

.card-icon  { font-size: 1.5rem; }
.card-label { font-size: 0.85rem; font-weight: 500; }

.admin-section { margin-top: 2.5rem; }
.admin-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.recent-grid  { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.recent-item  { display: flex; flex-direction: column; gap: 0.3rem; width: 100px; }
.recent-thumb { width: 100px; height: 75px; object-fit: cover; border-radius: var(--radius); }
.recent-title { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.admin-form { display: flex; flex-direction: column; gap: 0; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-white); padding: 1.5rem; margin-bottom: 1rem; }
.form-section h2 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.form-group input { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font); font-size: 0.9rem; }
.form-group input:focus { outline: none; border-color: var(--text-muted); }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ── Messages ───────────────────────────────────────────────── */
.error-message   { color: var(--error); font-size: 0.875rem; margin-bottom: 1rem; padding: 0.6rem 0.85rem; background: #fdf2f2; border-radius: var(--radius); }
.success-message { color: var(--success); font-size: 0.875rem; margin-bottom: 1rem; padding: 0.6rem 0.85rem; background: #f2fdf5; border-radius: var(--radius); }

/* ── Error page ─────────────────────────────────────────────── */
.error-page { max-width: 560px; margin: 8rem auto; padding: 0 2rem; text-align: center; }
.error-page h1 { font-size: 2rem; margin-bottom: 0.75rem; }
.error-page p  { color: var(--text-muted); margin-bottom: 1.5rem; }
.error-stack   { text-align: left; background: #f5f5f3; padding: 1rem; border-radius: var(--radius); font-size: 0.75rem; overflow-x: auto; margin-bottom: 1.5rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer { padding: 2rem; text-align: center; font-size: 0.8rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .site-nav { padding: 0.875rem 1rem; }

  .gallery-main { padding: 1rem 1rem 3rem; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-form { flex-direction: column; }
  .search-input { width: 100%; }

  .image-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px; }

  .image-viewer { padding: 1rem; min-height: 50vh; }
  .image-full   { max-height: 55vh; }
  .image-info   { padding: 1rem; }
  .info-header  { flex-direction: column; align-items: flex-start; }
  .info-grid    { grid-template-columns: 1fr 1fr; }

  .admin-main { padding: 1rem; }
}

/* ── Upload ─────────────────────────────────────────────────── */
.upload-form { display: flex; flex-direction: column; gap: 1rem; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--text-muted);
  background: var(--bg);
}
.drop-icon  { font-size: 2rem; display: block; margin-bottom: .75rem; }
.drop-text  { font-weight: 500; margin-bottom: .25rem; }
.drop-hint  { font-size: .8rem; color: var(--text-muted); }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-preview { display: flex; flex-wrap: wrap; gap: .5rem; }
.preview-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  font-size: .8rem;
}
.preview-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 2px; }
.preview-name  { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-size  { color: var(--text-muted); }

.btn-upload { margin-top: .5rem; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.form-hint-inline { font-size: .75rem; font-weight: 400; color: var(--text-muted); }
.form-group--checkbox { justify-content: flex-end; padding-top: 1.5rem; }
.form-group--checkbox label { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .9rem; }

textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--text-muted); }

/* ── Admin image grid ───────────────────────────────────────── */
.admin-main--wide { max-width: 1400px; }
.admin-filter { margin-bottom: 1.5rem; }
.count-badge {
  font-size: .85rem;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .1rem .6rem;
  margin-left: .4rem;
}

.admin-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin-bottom: 2rem;
}

.admin-image-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-thumb-link { display: block; }
.admin-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.admin-image-info { padding: .5rem .6rem .25rem; flex: 1; }
.admin-image-title {
  font-size: .85rem;
  font-weight: 500;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .2rem;
}
.admin-image-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  font-size: .7rem;
  color: var(--text-muted);
}
.admin-image-meta span::after { content: '·'; margin-left: .25rem; }
.admin-image-meta span:last-child::after { content: ''; }

.admin-image-actions {
  padding: .4rem .6rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .4rem;
}

.btn-xs { padding: .2rem .5rem; font-size: .75rem; }
.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: transparent;
}
.btn-danger:hover { background: #fdf2f2; border-color: var(--error); }

/* ── Edit layout ────────────────────────────────────────────── */
.edit-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}

.edit-preview {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.edit-thumb {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.edit-filename { font-size: .75rem; color: var(--text-muted); word-break: break-all; }

.edit-form { display: flex; flex-direction: column; gap: .75rem; }

@media (max-width: 768px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-preview { position: static; }
}
