:root {
  --bg: #f3f3f2;
  --text: #2a2a2a;
  --muted: #6f6f6e;
  --line: rgba(26,26,26,0.14);
  --hover-bg: rgba(26,26,26,0.04);
  --flash: rgba(26,26,26,0.18);
  --overlay: rgba(0,0,0,0.30);
}

[data-theme="dark"] {
  --bg: #0f0e0c;
  --text: #d8d5cc;
  --muted: #888278;
  --line: rgba(232,229,221,0.14);
  --hover-bg: rgba(232,229,221,0.04);
  --flash: rgba(232,229,221,0.22);
  --overlay: rgba(0,0,0,0.50);
}

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
  height: 100%;
  overflow: hidden;
}

::selection {
  background-color: var(--text);
  color: var(--bg);
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--text);
}

/* Layout */
.container {
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  padding: 3rem max(1rem, 2vw) 0 max(1rem, 2vw);
  height: 100vh;
  overflow: hidden;
  width: 100%;
  max-width: 1040px;
}

/* Sidebar */
.sidebar {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0 0.85rem 2.5rem 0;
  text-align: right;
  background-color: var(--bg);
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  font-family: 'EB Garamond', serif;
  font-size: 1.35rem;
  font-weight: 400;
  border-bottom: none;
  color: var(--text);
  display: block;
  margin-bottom: 2rem;
  transition: opacity 0.15s ease;
}

.sidebar-logo:hover {
  opacity: 0.7;
  border-bottom: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  margin-bottom: 1.5rem;
}

.sidebar-nav a {
  font-size: 0.92rem;
  color: var(--muted);
  border-bottom: none;
  transition: color 0.15s ease, transform 0.2s ease;
  display: inline-block;
}

.sidebar-nav a:hover {
  color: var(--text);
  border-bottom: none;
}

.sidebar-nav a.active {
  color: var(--text);
  transform: translateX(3px);
}

.sidebar-photos {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 4px;
  margin-bottom: 1.25rem;
}

.sidebar-photo {
  width: 32px;
  height: 32px;
  background-color: var(--border);
  background-size: cover;
  background-position: center;
  filter: grayscale(100%);
  cursor: pointer;
  transition: filter 0.4s ease;
  border-bottom: none;
  display: block;
}

.sidebar-photo:hover {
  filter: grayscale(0%);
  border-bottom: none;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  color: var(--muted);
  transition: color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* Divider */
.divider {
  width: 1px;
  background-color: var(--line);
  align-self: stretch;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
  position: relative;
  z-index: 100;
}

/* Main */
.main {
  flex: 0 0 540px;
  width: 540px;
  max-width: 540px;
  padding: 0 2rem 4rem 2rem;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  text-align: justify;
}

.main::-webkit-scrollbar {
  display: none;
}

section {
  margin-bottom: 5rem;
}

h1 {
  font-family: 'Inter', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: left;
}

h2 {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-style: normal;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.6rem;
  text-align: left;
  letter-spacing: 0;
}

p {
  font-size: 1rem;
  margin-bottom: 0.6rem;
  color: var(--text);
}

p:last-child {
  margin-bottom: 0;
}

/* Read more / see all link */
.read-more {
  display: inline-block;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: none;
  transition: color 0.15s ease;
  text-align: left;
}

.read-more:hover {
  color: var(--text);
  border-bottom: none;
}

/* Work blocks */
.work-block {
  margin-bottom: 1.5rem;
}

.work-block:last-child {
  margin-bottom: 0;
}

.work-title-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  text-align: left;
}

.work-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
}

.work-sep {
  color: var(--text);
  font-weight: 400;
}

.work-role {
  font-size: 0.82rem;
  color: var(--text);
}

/* Writing rows */
.writing-list {
  display: flex;
  flex-direction: column;
}

.writing-row {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.35rem 0.4rem;
  border-radius: 3px;
  transition: background-color 0.15s ease;
  cursor: pointer;
  margin: 0 -0.4rem;
  text-align: left;
}

.writing-row:hover {
  background-color: var(--hover-bg);
}

.writing-row a {
  border-bottom: none;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  width: 100%;
}

.writing-row a:hover {
  border-bottom: none;
}

.writing-date {
  flex-shrink: 0;
  width: 80px;
  font-size: 0.85rem;
  color: var(--muted);
}

.writing-title {
  font-size: 1rem;
  color: var(--text);
}

/* Now */
.muted {
  color: var(--muted);
}

.now-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.85rem;
}

.writing-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.now-block {
  margin-bottom: 1.2rem;
}

.now-block-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.now-list {
  list-style: disc outside;
  margin: 0.6rem 0 0 0;
  padding-left: 1.4rem;
  text-align: left;
}

.now-list li {
  font-size: 1rem;
  margin-bottom: 0.3rem;
  color: var(--text);
  display: list-item;
}

.now-list li::marker {
  color: var(--text);
}

.micro-label {
  color: var(--muted);
  margin-right: 0.5em;
}

[data-local-time] {
  color: var(--muted);
}

.now-location {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  text-align: left;
  font-size: 0.82rem;
}

.now-location-label {
  font-weight: 600;
  color: var(--text);
}

.now-location-time {
  font-weight: 400;
  color: var(--muted);
}

.work-role-inline {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
}

/* Memories */
.memories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.memory-photo {
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  filter: grayscale(100%);
  transition: filter 0.4s ease;
  border-bottom: none;
  display: block;
}

.memory-photo:hover {
  filter: grayscale(0%);
  border-bottom: none;
}

/* Memories archive (full grid w/ inline captions) */
.memories-archive {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.memory-card {
  display: flex;
  flex-direction: column;
}

.memory-card .memory-photo {
  margin-bottom: 0.5rem;
  cursor: default;
}

.memory-card .info-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
  text-align: left;
}

.memory-card .memory-caption {
  font-size: 0.92rem;
  color: var(--text);
  text-align: left;
  line-height: 1.55;
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  margin-top: 2rem;
  transition: border-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-email {
  font-size: 0.92rem;
  color: var(--muted);
  border-bottom: none;
  transition: color 0.15s ease;
}

.footer-email:hover {
  color: var(--text);
  border-bottom: none;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  list-style: none;
  justify-content: flex-end;
}

.footer-links li a {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  border-bottom: none;
  transition: color 0.15s ease;
}

.footer-links li a:hover {
  color: var(--text);
  border-bottom: none;
}

.footer-links li a svg {
  width: 18px;
  height: 18px;
  display: block;
}

@media (max-width: 720px) {
  footer {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 0.9rem;
  }
  .footer-links {
    justify-content: flex-start;
    gap: 0 0.85rem;
  }
}

.mobile-theme-toggle {
  display: none;
}

/* Curtain stage (home page only) */
.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  align-self: stretch;
  height: 100%;
}

.stage-home {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 604px;
  padding: 0 2rem 4rem 2rem;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  text-align: justify;
  z-index: 1;
  transition: transform 0.5s ease-in-out;
  background-color: var(--bg);
}

.stage-home::-webkit-scrollbar {
  display: none;
}

.divider-right {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 604px;
  width: 1px;
  background-color: var(--line);
  transition: transform 0.5s ease-in-out, background-color 0.3s ease;
  z-index: 3;
}

.stage-detail {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 9px;
  width: 604px;
  padding: 0 2rem 4rem 2rem;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  text-align: justify;
  background-color: var(--bg);
  z-index: 2;
  transform: translateX(100vw);
  transition: transform 0.5s ease-in-out;
}

.stage-detail::-webkit-scrollbar {
  display: none;
}

.container.panel-open .stage-home {
  transform: translateX(-596px);
}

.container.panel-open .divider-right {
  transform: translateX(-596px);
}

.container.panel-open .stage-detail {
  transform: translateX(0);
}

.panel-back {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: none;
  margin-bottom: 1.5rem;
  text-align: left;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: color 0.15s ease;
}

.panel-back:hover {
  color: var(--text);
  border-bottom: none;
}

/* Photo modal */
.photo-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.photo-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.photo-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 50vw;
  max-height: 100%;
}

.photo-modal-img {
  max-width: 50vw;
  max-height: 60vh;
  display: block;
  object-fit: contain;
}

.photo-modal-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 1.25rem;
  text-align: center;
}

.photo-modal-caption {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.6;
  margin-top: 0.5rem;
  max-width: 540px;
  text-align: center;
}

.photo-modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  font-family: inherit;
  transition: color 0.15s ease;
}

.photo-modal-close:hover {
  color: #fff;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .photo-modal {
    padding: 4rem 1.25rem;
  }
  .photo-modal-content,
  .photo-modal-img {
    max-width: 85vw;
  }
  .photo-modal-img {
    max-height: 55vh;
  }
}

/* Sidebar back link (mobile-only, on detail pages) */
.sidebar-back {
  display: none;
}

/* Mobile */
@media (max-width: 720px) {
  body {
    font-size: 13px;
    height: auto;
    overflow: auto;
  }

  .container {
    flex-direction: column;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
    height: auto;
    overflow: visible;
    width: 100%;
    max-width: 100%;
  }

  .sidebar {
    width: auto;
    height: auto;
    align-items: stretch;
    text-align: left;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--bg);
    border-bottom: 1px solid var(--line);
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding: 1.25rem 1.5rem 0 1.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
  }

  .sidebar-back {
    display: inline-block;
    align-self: flex-start;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--muted);
    border-bottom: none;
    padding: 0.9rem 0 1rem 0;
    transition: color 0.15s ease;
  }

  .sidebar-back:hover {
    color: var(--text);
    border-bottom: none;
  }

  .sidebar:has(.sidebar-back) .sidebar-nav {
    display: none;
  }

  .sidebar:has(.sidebar-back) .sidebar-top-row {
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.9rem;
    margin-bottom: 0;
    transition: border-color 0.3s ease;
  }

  section[id] {
    scroll-margin-top: 140px;
  }

  .main {
    padding-top: 1.5rem;
  }

  .sidebar-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.9rem;
  }

  .sidebar-logo {
    margin-bottom: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem 1.25rem;
    border-top: 1px solid var(--line);
    padding-top: 0.9rem;
    padding-bottom: 1rem;
    margin-bottom: 0;
    transition: border-color 0.3s ease;
  }

  .sidebar-nav a.active {
    transform: none;
  }

  .sidebar-photos {
    display: none;
  }

  .sidebar-bottom {
    display: none;
  }

  .divider {
    display: none;
  }

  .main {
    padding: 2rem 0 3rem;
    max-width: 100%;
    width: 100%;
    overflow-y: visible;
    height: auto;
  }

  .stage {
    position: static;
    overflow: visible;
    height: auto;
    align-self: auto;
    width: 100%;
    flex: none;
  }

  .stage-home {
    position: static;
    width: 100%;
    padding: 2rem 0 3rem;
    overflow-y: visible;
    height: auto;
    transform: none !important;
    background-color: transparent;
  }

  .divider-right,
  .stage-detail {
    display: none;
  }

  .memories-archive {
    grid-template-columns: repeat(2, 1fr);
  }

  #memoriesGrid {
    grid-template-columns: repeat(2, 1fr);
  }

  #memoriesGrid .memory-photo:nth-child(n+7) {
    display: none;
  }

  .mobile-theme-toggle {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--muted);
    transition: color 0.15s ease;
  }

  .mobile-theme-toggle:hover {
    color: var(--text);
  }

  .mobile-theme-toggle svg {
    width: 17px;
    height: 17px;
    display: block;
  }
}

/* Detail-page chrome (about / work / writing / now) — mimic the open panel state on direct visit */
.detail-gap {
  width: 9px;
  flex-shrink: 0;
}

body.with-chrome .main {
  flex: 0 0 604px;
  width: 604px;
  max-width: 604px;
}

body.with-chrome .panel-back {
  display: inline-block;
  margin-bottom: 1.5rem;
}

@media (max-width: 720px) {
  .detail-gap {
    display: none;
  }
  body.with-chrome .main {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }
  body.with-chrome .panel-back {
    display: none;
  }
}

/* Memories archive — full color (overrides the b&w treatment used on home + sidebar) */
.memories-archive .memory-photo {
  filter: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.memories-archive .memory-photo:hover {
  filter: brightness(1.05);
  opacity: 0.85;
}

/* Placeholder photos — flat gray, no image */
.memory-photo.is-placeholder,
.sidebar-photo.is-placeholder {
  background-image: none !important;
  background-color: var(--placeholder, #d8d8d6);
  filter: none;
}

.memory-photo.is-placeholder:hover,
.sidebar-photo.is-placeholder:hover {
  filter: none;
  opacity: 0.85;
}

[data-theme="dark"] .memory-photo.is-placeholder,
[data-theme="dark"] .sidebar-photo.is-placeholder {
  background-color: #2a2a2a;
}

/* Initial load fade-in — sidebar lands first, then content slot */
@keyframes ndoz-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ndoz-fade-up-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

html.initial-load .sidebar {
  animation: ndoz-fade-in 0.3s ease both;
}

/* Animate opacity on slide containers (transform is reserved for panel-open) */
html.initial-load .stage-home,
html.initial-load .main {
  animation: ndoz-fade-in 0.3s ease 0.08s both;
}

/* TranslateY lives on the inner content so it doesn't fight the slide transform */
html.initial-load .stage-home > *,
html.initial-load .main > * {
  animation: ndoz-fade-up-in 0.3s ease 0.08s both;
}
