/* ============================================
   PHOTO ARCHIVE — Stylesheet v3
   Dark/Light theme + All Images mode
   ============================================ */

/* ---- DARK THEME (default) ---- */
:root,
[data-theme="dark"] {
  --bg:           #0a0a0a;
  --bg-2:         #111111;
  --bg-3:         #1a1a1a;
  --border:       #2a2a2a;
  --border-light: #333333;
  --text:         #d8d8d8;
  --text-dim:     #777777;
  --text-dimmer:  #444444;
  --accent:       #e8e8e8;
  --accent-2:     #c0c0c0;
  --header-bg:    #0a0a0a;
  --sidebar-bg:   #0d0d0d;
  --overlay-bg:   rgba(0,0,0,0.95);
  --font-mono: 'Courier New', 'Lucida Console', monospace;
  --font-sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* ---- LIGHT THEME ---- */
[data-theme="light"] {
  --bg:           #f5f4f0;
  --bg-2:         #eceae4;
  --bg-3:         #e2e0d8;
  --border:       #d0cdc4;
  --border-light: #b8b5ac;
  --text:         #1a1a1a;
  --text-dim:     #555555;
  --text-dimmer:  #999999;
  --accent:       #111111;
  --accent-2:     #333333;
  --header-bg:    #f5f4f0;
  --sidebar-bg:   #eceae4;
  --overlay-bg:   rgba(240,238,232,0.97);
}

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

html { font-size: 13px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 8px;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: normal;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-decoration: none;
}
.site-title:hover { opacity: 0.7; }

.header-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================
   BUTTONS — shared
   ============================================ */
.mode-btn, .sort-btn, .issue-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover, .sort-btn:hover, .issue-action-btn:hover {
  border-color: var(--border-light);
  color: var(--accent);
}
.mode-btn.active, .sort-btn.active {
  background: var(--bg-3);
  border-color: var(--border-light);
  color: var(--accent);
}

/* ============================================
   YEAR FILTER
   ============================================ */
.year-filter-wrap { display: flex; align-items: center; }

.year-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.year-select:hover, .year-select:focus {
  border-color: var(--border-light);
  color: var(--accent);
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--border-light); color: var(--accent); }

/* Show/hide the right label based on current theme */
[data-theme="dark"]  .theme-icon-light { display: inline; }
[data-theme="dark"]  .theme-icon-dark  { display: none; }
[data-theme="light"] .theme-icon-dark  { display: inline; }
[data-theme="light"] .theme-icon-light { display: none; }

/* ============================================
   MAIN
   ============================================ */
.main-content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================
   ARCHIVE META
   ============================================ */
.archive-meta {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.archive-meta .meta-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.archive-meta .meta-stats {
  font-size: 11px;
  color: var(--text-dimmer);
  letter-spacing: 0.05em;
}
.archive-meta .meta-stats span { color: var(--text-dim); }

/* ============================================
   VIEW CONTROLS
   ============================================ */
.view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.sort-controls { display: flex; align-items: center; gap: 4px; }
.sort-controls .label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dimmer);
  margin-right: 8px;
}
.view-info {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dimmer);
}

/* ============================================
   VIEW SECTIONS
   ============================================ */
.view-section { display: none; }
.view-section.active-view { display: block; }

/* ============================================
   GRID VIEW
   ============================================ */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--border);
}
.grid-item {
  background: var(--bg);
  position: relative;
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
}
.grid-item img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: opacity 0.2s;
  filter: grayscale(10%);
}
.grid-item:hover img { opacity: 0.75; filter: grayscale(0%); }
.grid-item-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 24px 12px 12px;
  opacity: 0; transition: opacity 0.2s;
}
.grid-item:hover .grid-item-overlay { opacity: 1; }
.grid-item .grid-label { font-size: 10px; letter-spacing: 0.1em; color: #fff; display: block; }
.grid-item .grid-date  { font-size: 9px; color: #ccc; letter-spacing: 0.05em; }
.grid-item-placeholder {
  background: var(--bg-2);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; transition: background 0.15s;
}
.grid-item-placeholder:hover { background: var(--bg-3); }
.grid-placeholder-icon {
  width: 40px; height: 40px;
  border: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
}
.grid-placeholder-icon span { font-size: 18px; color: var(--text-dimmer); }
.grid-item-placeholder .grid-label { font-size: 10px; letter-spacing: 0.1em; color: var(--text-dim); }
.grid-item-placeholder .grid-date  { font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.05em; }

/* ============================================
   LIST VIEW
   ============================================ */
.issues-table { width: 100%; border-collapse: collapse; font-size: 11px; letter-spacing: 0.05em; }
.issues-table th {
  text-align: left; padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-dimmer); font-weight: normal;
  letter-spacing: 0.12em; font-size: 10px;
}
.issues-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.issues-table tr:hover td { background: var(--bg-2); }
.issues-table .roll-link { color: var(--accent); text-decoration: none; letter-spacing: 0.08em; }
.issues-table .roll-link:hover { text-decoration: underline; }
.issues-table .frame-count { color: var(--text-dim); }
.list-actions { display: flex; gap: 8px; }
.action-link {
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-dimmer); text-decoration: none;
  border: 1px solid var(--border); padding: 3px 8px;
  transition: all 0.15s;
}
.action-link:hover { border-color: var(--border-light); color: var(--accent); }

/* ============================================
   ALL IMAGES VIEW
   ============================================ */
.all-year-heading {
  font-size: 22px;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 32px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.all-roll-heading {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.all-roll-heading a {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-decoration: none;
}
.all-roll-heading a:hover { text-decoration: underline; }
.all-roll-meta {
  font-size: 10px;
  color: var(--text-dimmer);
  letter-spacing: 0.06em;
}
.all-img-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 32px;
}
.all-img-cell {
  position: relative;
  width: 160px;
  height: 107px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-2);
  flex-shrink: 0;
}
.all-img-cell img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: opacity 0.2s, filter 0.2s;
  filter: grayscale(10%);
}
.all-img-cell:hover img { opacity: 0.8; filter: grayscale(0%); }
.all-frame-num {
  position: absolute; bottom: 4px; left: 6px;
  font-size: 9px; color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  letter-spacing: 0.05em;
}
[data-theme="light"] .all-frame-num { color: rgba(0,0,0,0.55); text-shadow: none; }
.all-img-error {
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--text-dimmer); letter-spacing: 0.05em;
}

/* ============================================
   ISSUE PAGE
   ============================================ */
.issue-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.issue-title {
  font-size: 20px; font-weight: normal;
  letter-spacing: 0.1em; color: var(--accent); margin-bottom: 8px;
}
.issue-subtitle { font-size: 11px; color: var(--text-dim); letter-spacing: 0.06em; }

.section-label {
  font-size: 10px; font-weight: normal;
  letter-spacing: 0.15em; color: var(--text-dimmer);
  margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Contact sheet */
.contact-sheet-section { margin-bottom: 48px; }
.contact-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1px; background: var(--border);
}
.contact-frame { background: var(--bg-2); position: relative; cursor: pointer; overflow: hidden; }
.contact-frame img {
  width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block;
  filter: grayscale(15%); transition: filter 0.2s, opacity 0.2s;
}
.contact-frame:hover img { filter: grayscale(0%); opacity: 0.85; }
.contact-frame .frame-num {
  position: absolute; top: 4px; left: 6px;
  font-size: 9px; color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.contact-frame-placeholder {
  background: var(--bg-3); aspect-ratio: 3/2;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dimmer); font-size: 9px; letter-spacing: 0.05em;
}

/* Sequence */
.sequence-section { margin-bottom: 48px; }
.sequence-grid { display: flex; flex-direction: column; gap: 0; }
.sequence-item { display: flex; border-bottom: 1px solid var(--border); align-items: flex-start; }
.sequence-num { min-width: 48px; padding: 16px 0; font-size: 10px; color: var(--text-dimmer); letter-spacing: 0.1em; flex-shrink: 0; }
.sequence-img-wrap { flex: 0 0 auto; width: 280px; cursor: pointer; overflow: hidden; margin: 12px 0; }
.sequence-img-wrap img { width: 100%; display: block; filter: grayscale(15%); transition: filter 0.2s, opacity 0.2s; }
.sequence-img-wrap:hover img { filter: grayscale(0%); opacity: 0.88; }
.sequence-img-placeholder { width: 280px; height: 188px; background: var(--bg-3); display: flex; align-items: center; justify-content: center; margin: 12px 0; font-size: 9px; color: var(--text-dimmer); }
.sequence-meta { padding: 16px 20px; font-size: 10px; color: var(--text-dim); letter-spacing: 0.06em; }
.sequence-filename { color: var(--text-dimmer); margin-top: 4px; font-size: 9px; word-break: break-all; }

/* Archive record */
.archive-record-section { margin-bottom: 48px; }
.record-table { border-collapse: collapse; font-size: 11px; min-width: 360px; }
.record-table td { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.record-table td:first-child { color: var(--text-dimmer); letter-spacing: 0.1em; font-size: 10px; min-width: 140px; }
.record-table td:last-child { color: var(--text); }

/* Frame index */
.frame-index-section { margin-bottom: 48px; }
.frame-index-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.frame-index-table th { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border-light); color: var(--text-dimmer); font-weight: normal; font-size: 10px; letter-spacing: 0.12em; }
.frame-index-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.frame-index-table td:first-child { color: var(--text-dimmer); width: 50px; }
.frame-index-table a { color: var(--text-dim); text-decoration: none; word-break: break-all; }
.frame-index-table a:hover { color: var(--accent); text-decoration: underline; }

/* Issue nav */
.issue-nav { display: flex; justify-content: space-between; padding: 20px 0; border-top: 1px solid var(--border); margin-top: 20px; }
.issue-nav a { font-size: 11px; letter-spacing: 0.08em; color: var(--text-dim); text-decoration: none; padding: 6px 14px; border: 1px solid var(--border); transition: all 0.15s; }
.issue-nav a:hover { color: var(--accent); border-color: var(--border-light); }
.issue-nav .nav-disabled { font-size: 11px; letter-spacing: 0.08em; color: var(--text-dimmer); padding: 6px 14px; border: 1px solid transparent; }

/* ============================================
   LIGHTBOX — sidebar layout
   ============================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: stretch; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-overlay { position: absolute; inset: 0; background: var(--overlay-bg); cursor: pointer; }
.lightbox-inner { position: relative; z-index: 1; display: flex; width: 100%; height: 100%; max-height: 100vh; }
.lightbox-img-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; overflow: hidden; }
.lightbox-img { max-width: 100%; max-height: 100vh; object-fit: contain; display: block; }
.lightbox-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 20px 24px;
  overflow-y: auto; gap: 20px;
}
.lightbox-close {
  align-self: flex-start; background: none;
  border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.1em; padding: 5px 12px; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.lightbox-close:hover { color: var(--accent); border-color: var(--border-light); }
.lb-counter { font-size: 18px; color: var(--accent); letter-spacing: 0.06em; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.lb-meta { display: flex; flex-direction: column; gap: 0; flex: 1; }
.lb-meta-group { display: flex; flex-direction: column; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lb-meta-label { font-size: 9px; letter-spacing: 0.15em; color: var(--text-dimmer); margin-bottom: 4px; }
.lb-meta-value { font-size: 11px; color: var(--text); letter-spacing: 0.04em; line-height: 1.5; }
.lb-filename { font-size: 10px; color: var(--text-dim); word-break: break-all; }
.lb-nav-btns { display: flex; gap: 8px; margin-top: auto; padding-top: 16px; }
.lb-btn { flex: 1; background: none; border: 1px solid var(--border); color: var(--text-dim); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; padding: 8px 4px; cursor: pointer; transition: all 0.15s; }
.lb-btn:hover { color: var(--accent); border-color: var(--border-light); }

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  font-size: 10px; letter-spacing: 0.1em; color: var(--text-dimmer);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  html { font-size: 12px; }
  .main-content { padding: 20px 16px; }
  .site-header { padding: 10px 16px; }
  .grid-container { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .contact-sheet-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .sequence-img-wrap, .sequence-img-placeholder { width: 160px; }
  .sequence-img-placeholder { height: 108px; }
  .all-img-cell { width: 120px; height: 80px; }
  .lightbox-inner { flex-direction: column; }
  .lightbox-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-left: none; border-top: 1px solid var(--border); max-height: 200px; }
  .lightbox-img-panel { padding: 16px; flex: 1; min-height: 0; }
  .lb-meta { flex-direction: row; flex-wrap: wrap; gap: 0; }
  .lb-meta-group { min-width: 120px; padding: 6px 12px 6px 0; border-bottom: none; }
  .lb-counter { width: 100%; padding-bottom: 8px; font-size: 14px; }
  .lb-nav-btns { width: 100%; }
  .lightbox-close { width: 100%; text-align: center; }
  .issues-table th:nth-child(4), .issues-table td:nth-child(4) { display: none; }
}

@media (max-width: 480px) {
  .grid-container { grid-template-columns: repeat(2, 1fr); }
  .all-img-cell { width: 100px; height: 67px; }
  .header-nav { gap: 3px; }
  .mode-btn, .sort-btn, .theme-toggle { padding: 4px 8px; font-size: 9px; }
}
