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

/* ── TOKENS ── */
:root {
  --font: 'IBM Plex Mono', 'Courier New', monospace;
  --fs: 14px;
  --fs-site: 16px;
  --sidebar-w: 250px;
  --content-w: 900px;
  --gap: 25px;
  --tr: 0.2s ease;
  --sidebar-pt: 28px;
}

[data-theme="dark"] {
  --bg: #111;
  --fg: #c4c4c4;
  --fg-link: #959595;
  --fg-hover: #5f5f5f;
  --fg-subtle: rgba(196,196,196,0.18);
  --border: rgba(196,196,196,0.1);
  --thumb-bg: #1e1e1e;
}
[data-theme="light"] {
  --bg: #f4f4f2;
  --fg: #111111;
  --fg-link: #717171;
  --fg-hover: #5d5d5d;
  --fg-subtle: rgba(17,17,17,0.2);
  --border: rgba(17,17,17,0.1);
  --thumb-bg: #e2e2e0;
}

/* ── BASE ── */
html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  font-weight: 400;
  height: 100%;
  overflow: hidden;
  transition: background var(--tr), color var(--tr);
  text-transform: uppercase;
}

/* ── LAYOUT ── */
#app { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--sidebar-pt) 0 24px 28px;
  overflow: hidden;
}

/* ── SITE NAME ── */
#site-name {
  font-size: var(--fs-site);
  font-weight: 400;
  color: var(--fg);
  line-height: 1.4;
  margin-bottom: 32px;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  padding-right: 16px;
  flex-shrink: 0;
  text-decoration: none;
  display: block;
}

/* ── NAV ── */
#main-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: hidden; }
#desktop-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow: hidden; min-height: 0; }
.nav-item { display: flex; flex-direction: column; }

.nav-label {
  font-size: var(--fs);
  font-weight: 400;
  color: var(--fg-link);
  cursor: pointer;
  padding: 8px 16px 8px 0;
  user-select: none;
  transition: color var(--tr);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font);
  text-transform: uppercase;
  text-align: left;
  width: 100%;
  display: block;
}
.nav-label:hover { color: var(--fg-hover); }
.nav-label.active { color: var(--fg); }

.sub-nav { display: none; flex-direction: column; padding-left: 12px; margin-bottom: 4px; }
.sub-nav.open { display: flex; }

.sub-label {
  font-size: var(--fs);
  font-weight: 400;
  color: var(--fg-link);
  cursor: pointer;
  padding: 7px 16px 7px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--tr);
  user-select: none;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font);
  text-transform: uppercase;
  text-align: left;
  width: 100%;
  display: block;
}
.sub-label:hover { color: var(--fg-hover); }
.sub-label.active { color: var(--fg); }

/* ── THEME TOGGLE ── */
#theme-toggle, #theme-toggle-mobile {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--fg-link);
  transition: color var(--tr);
  padding: 8px 0;
  -webkit-tap-highlight-color: transparent;
}
#theme-toggle:hover, #theme-toggle-mobile:hover { color: var(--fg-hover); }

/* ── CONTENT ── */
#content { flex: 1; height: 100vh; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOOLBAR ── */
#toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 28px 28px 8px;
  padding-top: calc(var(--sidebar-pt) + var(--fs-site) * 1.4 * 3 + 32px - var(--fs));
  max-width: calc(var(--content-w) + 56px);
}

#toolbar-project {
  font-size: var(--fs);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: right;
}

.tool-btn {
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-link);
  transition: color var(--tr);
  flex-shrink: 0;
  padding: 0;
}
.tool-btn:hover { color: var(--fg-hover); }
.tool-btn.gone { display: none; }

#nav-controls { display: flex; align-items: center; gap: 4px; }
#nav-controls.gone { display: none; }

#photo-counter {
  font-size: var(--fs);
  color: var(--fg-link);
  min-width: 52px;
  text-align: center;
  letter-spacing: 0.02em;
}

#counter-hint {
  font-size: 11px;
  color: var(--fg-subtle);
  white-space: nowrap;
  font-weight: 300;
  letter-spacing: 0.04em;
  margin-left: 10px;
  display: none;
}

/* ── VIEWER ── */
#viewer { flex: 1; display: flex; overflow: hidden; position: relative; min-height: 0; }

/* ── SLIDESHOW ── */
#slideshow { position: absolute; inset: 0; overflow: hidden; display: none; }

.slide-card {
  position: absolute;
  cursor: grab;
  user-select: none;
  opacity: 0;
  transition: opacity 0.9s ease;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.5));
}
.slide-card.visible { opacity: 1; }
.slide-card.dragging { cursor: grabbing; transition: none; }
.slide-card img { width: 100%; height: auto; display: block; pointer-events: none; }

/* ── SINGLE VIEW ── */
#single-view {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 0 28px 40px;
}
#single-view.active { display: flex; }

#main-photo {
  max-width: min(var(--content-w), 100%);
  max-height: calc(100vh - 180px);
  width: auto; height: auto;
  display: block; object-fit: contain;
  transition: opacity 0.25s ease;
  flex-shrink: 0;
}
#main-photo.fade { opacity: 0; }

#photo-desc {
  max-width: min(var(--content-w), 100%);
  font-size: var(--fs);
  font-weight: 300;
  color: var(--fg-link);
  line-height: 1.7;
  text-transform: none;
  letter-spacing: 0.01em;
  margin-top: 14px;
}

/* ── GRID VIEW ── */
#grid-view { display: none; width: 100%; height: 100%; overflow-y: scroll; scrollbar-gutter: stable; padding: 8px 28px 28px; }
#grid-view.active { display: block; }

#grid-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  max-width: var(--content-w);
}

.thumb { aspect-ratio: 3/2; overflow: hidden; background: var(--thumb-bg); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.2s ease; }
.thumb:hover img { opacity: 0.6; }

/* ── PANEL VIEW ── */
#panel-view { display: none; width: 100%; height: 100%; overflow-y: scroll; scrollbar-gutter: stable; padding: 8px 28px 28px; }
#panel-view.active { display: block; }

/* ── INFO ── */
.info-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 52px;
  max-width: var(--content-w);
  align-items: start;
}
.info-text {
  font-size: var(--fs);
  font-weight: 400;
  color: var(--fg);
  line-height: 1.8;
  text-transform: none;
  letter-spacing: 0.01em;
}
.info-text p { margin-bottom: 20px; }
.info-text a { color: var(--fg-link); text-decoration: none; border-bottom: 1px solid var(--border); transition: color var(--tr); }
.info-text a:hover { color: var(--fg-hover); }
.info-portrait { width: 100%; display: block; object-fit: cover; background: var(--thumb-bg); min-height: 400px; }

/* ── NEWSLETTER ── */
.nl-wrap { max-width: var(--content-w); width: 100%; }
.nl-section-title { font-size: var(--fs); font-weight: 400; color: var(--fg); letter-spacing: 0.06em; margin-bottom: 16px; }
.nl-embed-wrap { margin-bottom: 44px; width: 100%; }

/* Native subscribe form — replaces iframe */
.nl-form { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 10px; max-width: 480px; }
.nl-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--fg-subtle);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  font-weight: 400;
  padding: 8px 0;
  outline: none;
  text-transform: none;
  letter-spacing: 0.01em;
  transition: border-color var(--tr);
}
.nl-input::placeholder { color: var(--fg-subtle); }
.nl-input:focus { border-bottom-color: var(--fg-link); }
.nl-submit {
  background: none;
  border: none;
  color: var(--fg-link);
  font-family: var(--font);
  font-size: var(--fs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 0;
  white-space: nowrap;
  transition: color var(--tr);
  flex-shrink: 0;
}
.nl-submit:hover { color: var(--fg); }
.nl-note { font-size: 11px; color: var(--fg-subtle); letter-spacing: 0.04em; margin-bottom: 44px; text-transform: uppercase; }
.nl-success { font-size: var(--fs); color: var(--fg-link); letter-spacing: 0.02em; margin-bottom: 44px; text-transform: none; }
.nl-archive-title { font-size: var(--fs); font-weight: 400; color: var(--fg); letter-spacing: 0.06em; margin-bottom: 12px; }
.nl-list { list-style: none; display: flex; flex-direction: column; }
.nl-list li { font-size: var(--fs); font-weight: 400; color: var(--fg-link); padding: 8px 0; text-transform: none; letter-spacing: 0.01em; line-height: 1.4; }
.nl-list li a { color: var(--fg-link); text-decoration: none; transition: color var(--tr); }
.nl-list li a:hover { color: var(--fg-hover); }
.nl-date { color: var(--fg-subtle); margin-right: 6px; font-variant-numeric: tabular-nums; }
.nl-loading { font-size: var(--fs); color: var(--fg-subtle); padding: 12px 0; letter-spacing: 0.06em; }

/* ── MOBILE HEADER ── */
#mobile-header { display: none; }

/* ── SKIP LINK (accessibility) ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--bg);
  color: var(--fg);
  padding: 8px 16px;
  font-size: var(--fs);
  z-index: 1000;
  text-decoration: none;
  text-transform: uppercase;
}
.skip-link:focus { top: 0; }

/* ── FOCUS STYLES ── */
:focus-visible { outline: 2px solid var(--fg-link); outline-offset: 2px; }

/* ── MOBILE ── */
@media (max-width: 700px) {
  html, body { overflow: hidden; }
  #app { flex-direction: column; height: 100dvh; }

  #sidebar {
    width: 100%; height: auto; flex-direction: column;
    padding: 16px 20px 0; overflow: visible; flex-shrink: 0;
  }
  #mobile-header { display: flex; align-items: center; justify-content: space-between; width: 100%; }
  #site-name { display: none; }
  #theme-toggle { display: none; }
  #mobile-nav-wrap { display: block; padding: 8px 0 12px; width: 100%; }

  /* content area: fills remaining height, scrolls as one column */
  #content { flex: 1; height: 0; min-height: 0; overflow-y: auto; }
  #viewer { display: block; height: auto; min-height: 0; position: static; }

  #toolbar { padding: 12px 20px; align-items: center; flex-shrink: 0; max-width: 100%; }
  #btn-grid, #nav-controls { display: none !important; }
  #toolbar-project { margin-left: 0; max-width: 100%; }

  /* mobile project: images stacked, 20px gap, full natural height scroll */
  #single-view {
    display: none; flex-direction: column; align-items: stretch;
    padding: 0; height: auto; overflow: visible;
  }
  #single-view.active { display: flex; }
  #main-photo { display: none; }
  #photo-desc { display: none; }
  #mobile-scroll { display: flex; flex-direction: column; width: 100%; gap: 20px; padding: 16px 16px 60px; }
  #mobile-scroll img { width: 100%; height: auto; display: block; }

  #grid-view { display: none !important; }
  #panel-view { display: none; width: 100%; height: auto; overflow: visible; padding: 16px 20px 60px; }
  #panel-view.active { display: block; }
  .info-layout { grid-template-columns: 1fr; gap: 24px; }
  .info-portrait { min-height: 260px; }

  /* home slideshow: 60% smaller than desktop sizes */
  .slide-card { max-width: 40%; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fg-subtle); border-radius: 2px; }

/* ── MOBILE SITE NAME LINK ── */
#site-name-mobile {
  font-size: var(--fs);
  font-weight: 400;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--fg);
  line-height: 1.4;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── THEME TOGGLE PUSH TO BOTTOM ── */
#theme-toggle { margin-top: auto; }
