/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
  --font: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-nav: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  --color-bg: #ffffff;
  --color-text: #111111;
  --color-muted: #777777;
  --color-border: #e8e8e8;
  --header-height: 72px;
  --mobile-bar-height: 52px;
}

/* =============================================
   RESET
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Gallery page: body holds fixed header, container is the scroller */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   MULTI-GALLERY snap-scroll container
   ============================================= */
.galleries-container {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;         /* Firefox */
  -ms-overflow-style: none;      /* IE / Edge */
}
.galleries-container::-webkit-scrollbar { display: none; }

/* Each gallery fills exactly the container */
.gallery-section {
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  padding: 2.5rem 0;
}

/* Loading spinner */
.gallery-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-loading span {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--color-border);
  border-top-color: var(--color-muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   PUBLIC HEADER (index + archive)
   ============================================= */
.header {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 3.5rem;
  background: var(--color-bg);
  z-index: 100;
  /* Smooth hide/show on scroll */
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.header.header-hidden {
  transform: translateY(-100%);
}

.footer {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 3.5rem;
  background: var(--color-bg);
  z-index: 100;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer.footer-hidden {
  transform: translateY(100%);
}

.logo { justify-self: start; }
.logo a {
  font-family: var(--font-nav);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--color-text);
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}
.nav-links a {
  font-family: var(--font-nav);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--color-text);
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--color-muted); }

.social-icons {
  justify-self: end;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.social-icons a {
  display: flex;
  align-items: center;
  color: var(--color-text);
  transition: color 0.2s ease;
}
.social-icons a:hover { color: var(--color-muted); }

/* =============================================
   GALLERY (index.html)
   ============================================= */
.slideshow-main {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  /* Top and bottom margin to match Simon's whitespace above/below image */
  height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 0; /* consistent white-space above and below image */
}

.slide-nav {
  flex-shrink: 0;
  width: 60px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  transition: color 0.2s ease;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}
.slide-nav:hover { color: var(--color-text); }

.slide-viewport {
  flex: 1;
  height: 90%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.slide.active {
  opacity: 1;
  visibility: visible;
  position: relative;
  width: 100%;
  height: 100%;
}

/* Object-fit: contain keeps full image visible at any aspect ratio */
.slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* =============================================
   ARCHIVE (archive.html)
   ============================================= */
body.archive-body {
  overflow: auto;
  height: auto;
}
html:has(body.archive-body) { height: auto; }

.archive-page {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 4rem) 1.5rem 6rem;
}

.archive-header { margin-bottom: 4rem; }
.archive-header h1 {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 500;
}

.archive-entry {
  margin-bottom: 5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 2rem;
}

.archive-entry-meta {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.archive-entry-title {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.9rem;
  line-height: 1.4;
}

.archive-entry-body {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--color-text);
  line-height: 1.85;
  white-space: pre-wrap;
}

.archive-entry-photos {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}
.archive-entry-photos img {
  width: 100%;
  height: auto;
  display: block;
}

/* =============================================
   ADMIN — general body
   ============================================= */
body.admin-body {
  overflow: hidden;
  height: 100vh;
  background: #fafafa;
}

/* =============================================
   ADMIN — Login
   ============================================= */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 2rem;
}
.login-card label {
  display: block;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.4rem;
}
.login-card input {
  display: block;
  width: 100%;
  padding: 0.7rem 0;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 300;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  outline: none;
  margin-bottom: 1.8rem;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  border-radius: 0;
}
.login-card input:focus { border-color: var(--color-text); }

.login-error {
  font-family: var(--font);
  font-size: 0.8rem;
  color: #c0392b;
  margin-bottom: 1rem;
  min-height: 1rem;
}

.btn-primary {
  width: 100%;
  padding: 0.8rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: var(--color-text);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-appearance: none;
  border-radius: 0;
}
.btn-primary:hover:not(:disabled) { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* =============================================
   ADMIN — Dashboard layout
   ============================================= */
.admin-dashboard {
  display: none;
  height: 100vh;
  overflow: hidden;
  position: relative;
}
.admin-dashboard.visible { display: flex; }

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 199;
}
.sidebar-overlay.visible { display: block; }

/* =============================================
   ADMIN — Sidebar
   ============================================= */
.admin-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 200;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 1.25rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-header span {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.btn-new-entry {
  font-family: var(--font);
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color 0.2s;
}
.btn-new-entry:hover { color: var(--color-muted); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.4rem 0;
}
.sidebar-item {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s;
}
.sidebar-item:active { background: #eee; }
.sidebar-item:hover { background: #f5f5f5; }
.sidebar-item.active {
  background: #f0f0f0;
  border-left-color: var(--color-text);
}
.sidebar-item-title {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.sidebar-item-date {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--color-muted);
}
.sidebar-item-deleted { opacity: 0.4; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border);
}
.btn-signout {
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--color-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.btn-signout:hover { color: var(--color-text); }

/* =============================================
   ADMIN — Editor
   ============================================= */
.admin-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* Mobile top bar (hidden on desktop) */
.editor-mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--mobile-bar-height);
  border-bottom: 1px solid var(--color-border);
  background: #fff;
  flex-shrink: 0;
}
.btn-mobile-menu {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: 0.4rem;
  -webkit-tap-highlight-color: transparent;
}
.editor-mobile-title {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  gap: 0.75rem;
  background: #fff;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.toolbar-left {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Date input in toolbar */
.toolbar-date-input {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  background: transparent;
  padding: 0.3rem 0.5rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  border-radius: 0;
}
.toolbar-date-input:focus { border-color: var(--color-text); }

.toolbar-btn {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-muted);
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.toolbar-btn:hover, .toolbar-btn:active { color: var(--color-text); border-color: var(--color-text); }
.toolbar-btn.danger:hover { color: #c0392b; border-color: #c0392b; }

.save-status {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--color-muted);
  white-space: nowrap;
}

/* Locked badge */
.locked-badge {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #b8860b;
  background: #fffbe6;
  border: 1px solid #f0d060;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
}

/* Scrollable editor area */
.editor-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2.5rem 3rem;
  background: #fff;
}
.editor-scroll.editor-locked {
  background: #fafafa;
}

.editor-title-input {
  width: 100%;
  font-family: var(--font);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--color-text);
  border: none;
  outline: none;
  background: transparent;
  margin-bottom: 1.5rem;
  padding: 0;
  -webkit-appearance: none;
  border-radius: 0;
}
.editor-title-input::placeholder { color: #ccc; }
.editor-title-input:read-only { color: var(--color-muted); }

.editor-content {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--color-text);
  line-height: 1.9;
  min-height: 300px;
  outline: none;
  white-space: pre-wrap;
}
.editor-content:empty::before {
  content: 'Start writing, or paste / drag photos here...';
  color: #ccc;
  pointer-events: none;
}
.editor-content[contenteditable="false"] { color: var(--color-muted); }
.editor-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem 0;
}

/* =============================================
   ADMIN — Revision panel
   ============================================= */
.revision-panel {
  width: 230px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border);
  background: #fafafa;
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.revision-panel.visible { display: flex; }

.revision-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.revision-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.4rem 0;
}
.revision-item {
  padding: 0.8rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
}
.revision-item:hover { background: #efefef; }
.revision-item-date {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}
.revision-item-preview {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =============================================
   RESPONSIVE — Public pages (≤ 640px)
   ============================================= */
@media (max-width: 640px) {
  :root { --header-height: 56px; }

  .header {
    padding: 0 1.25rem;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
  }
  .nav-links { gap: 1.1rem; }
  .nav-links a { font-size: 0.8rem; }
  .logo a { font-size: 0.95rem; }

  .slide-nav { width: 36px; }
  .slide-nav svg { width: 20px; height: 20px; }

  .archive-page {
    padding: calc(var(--header-height) + 2.5rem) 1.25rem 4rem;
  }
  .archive-entry-photos {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   RESPONSIVE — Admin (≤ 768px)
   ============================================= */
@media (max-width: 768px) {
  /* Sidebar slides in as overlay on mobile */
  .admin-sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.08);
  }
  .admin-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Show mobile top bar */
  .editor-mobile-bar { display: flex; }

  /* Hide desktop save button on mobile */
  #btn-save { display: none; }

  /* Editor takes full width */
  .admin-editor {
    height: 100vh;
  }

  /* Toolbar scrolls horizontally */
  .editor-toolbar {
    padding: 0.6rem 1rem;
    gap: 0.5rem;
  }
  .toolbar-right { display: none; } /* save status & btn hidden; mobile bar has its own Save */

  .editor-scroll {
    padding: 1.5rem 1.25rem;
  }

  /* Hide revision panel on mobile — too cramped */
  .revision-panel { display: none !important; }

  /* Login card full width */
  .login-card { padding: 2.5rem 1.5rem; }
}

/* =============================================
   ADMIN — Sidebar tabs
   ============================================= */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 0.85rem 0.5rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px; /* overlap the border-bottom of parent */
}
.sidebar-tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
}
.sidebar-tab:hover:not(.active) { color: var(--color-text); }

/* =============================================
   GALLERY ADMIN — photo grid + drop zone
   ============================================= */
.gallery-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gallery-photo-card {
  position: relative;
  background: #f5f5f5;
  aspect-ratio: 4/3;
  overflow: hidden;
}

.gallery-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-photo-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(255,255,255,0.92);
  padding: 0.25rem;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.gallery-photo-card:hover .gallery-photo-controls { opacity: 1; }

.photo-ctrl-btn {
  flex: 1;
  font-family: var(--font);
  font-size: 0.75rem;
  background: none;
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 0.15rem 0;
  color: var(--color-text);
  transition: all 0.15s;
}
.photo-ctrl-btn:hover:not(:disabled) { background: var(--color-text); color: #fff; border-color: var(--color-text); }
.photo-ctrl-btn:disabled { opacity: 0.3; cursor: default; }
.photo-ctrl-delete { color: #c0392b; border-color: #e0b0a8; }
.photo-ctrl-delete:hover:not(:disabled) { background: #c0392b; border-color: #c0392b; }

.gallery-drop-zone {
  border: 1px dashed var(--color-border);
  padding: 2.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--color-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 300;
  transition: border-color 0.2s, color 0.2s;
  cursor: default;
}
.gallery-drop-zone:hover,
.gallery-drop-zone.drag-over {
  border-color: var(--color-text);
  color: var(--color-text);
}
