:root {
  --ink: #1c1c1c;
  --gray: #757575;
  --hairline: #e6e6e6;
  --white: #ffffff;
  --sidebar-bg: #161616;
  --subbar-bg: #242424;
  --subbar-w: 190px;
  --sidebar-ink: #f2f2f2;
  --sidebar-gray: #9b9b9b;
  --serif: 'EB Garamond', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --sidebar-w: 260px;
}

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

html { background: var(--white); }

body {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ================= Sidebar (inner pages) ================= */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  padding: 56px 28px 40px 36px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  z-index: 10;
}

.site-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
  color: var(--sidebar-ink);
  text-decoration: none;
  display: block;
  margin-bottom: 56px;
}

.nav { list-style: none; }

.nav > li { margin-bottom: 14px; }

.nav a, .nav button {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--sidebar-gray);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 120ms ease;
}

.nav a:hover, .nav button:hover,
.nav a:focus-visible, .nav button:focus-visible { color: var(--sidebar-ink); }

.nav a.active, .nav button.active { color: var(--sidebar-ink); }

.nav a:focus-visible, .nav button:focus-visible {
  outline: 1px solid var(--sidebar-ink);
  outline-offset: 3px;
}

/* ================= Sub-sidebar (Photos panel) ================= */
/* Slides out from behind the primary sidebar; a shade lighter. */

.subbar {
  position: fixed;
  top: 0; bottom: 0;
  left: var(--sidebar-w);
  width: var(--subbar-w);
  padding: 132px 28px 40px 32px;
  background: var(--subbar-bg);
  transform: translateX(-100%);
  transition: transform 240ms ease;
  z-index: 5;
}

.subbar.open { transform: translateX(0); }

.subbar ul { list-style: none; }

.subbar li { margin-bottom: 13px; }

.subbar a {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--sidebar-gray);
  text-decoration: none;
  transition: color 120ms ease;
}

.subbar a:hover, .subbar a:focus-visible { color: var(--sidebar-ink); }
.subbar a.active { color: var(--sidebar-ink); }
.subbar a:focus-visible { outline: 1px solid var(--sidebar-ink); outline-offset: 3px; }

/* ================= Main (inner pages) ================= */

.main {
  margin-left: var(--sidebar-w);
  padding: 56px 64px 96px 48px;
  max-width: 1080px;
  transition: margin-left 240ms ease;
}

body.subbar-open .main {
  margin-left: calc(var(--sidebar-w) + var(--subbar-w));
}

/* Gallery pages: full remaining width, symmetric padding, and locked
   to exactly one viewport — no vertical scroll. The strip anchors to
   the bottom; the photo sizes itself to whatever height remains. */
.gallery { overflow: hidden; }

.gallery .main {
  max-width: none;
  height: 100vh;
  height: 100dvh;
  padding: 40px 56px 5px;
  display: flex;
  flex-direction: column;
}

.gallery .viewer { flex: 0 1 auto; }

.gallery .strip {
  margin-top: auto;
  padding-top: 24px;
}

.page-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.page-meta {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--gray);
  margin-bottom: 36px;
}

.page-body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.75;
  max-width: 58ch;
  color: var(--ink);
}

.page-body p + p { margin-top: 1.2em; }

/* ================= Gallery: viewer + strip ================= */

/* display:table shrink-wraps the figure to the image's width, so
   margin:auto centers the photo and the table-caption metadata below
   is exactly as wide as the photo — left-aligned with its left edge. */
.viewer {
  display: table;
  margin: 0 auto;
}

.viewer-frame { position: relative; }

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-size: 36px;
  line-height: 1;
  padding: 10px 12px;
  color: var(--gray);
  text-decoration: none;
  user-select: none;
  transition: color 120ms ease;
}

.arrow:hover, .arrow:focus-visible { color: var(--ink); }
.arrow:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.arrow-prev { left: -54px; }
.arrow-next { right: -54px; }

.viewer-img {
  display: block;
  max-width: 100%;
  max-height: max(200px, calc(100dvh - 320px));
  height: auto;
  background: #d8d8d8;
}

.viewer-meta {
  display: table-caption;
  caption-side: bottom;
  padding-top: 16px;
  text-align: left;
  font-size: 12px;
  color: var(--gray);
  letter-spacing: 0.03em;
  line-height: 1.7;
}

.viewer-meta strong {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin-bottom: 2px;
}

.viewer-meta span { display: block; }

.strip {
  margin-top: 36px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--hairline) transparent;
}

.strip a {
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  display: block;
  scroll-snap-align: start;
  opacity: 0.75;
  transition: opacity 120ms ease;
}

.strip a:hover, .strip a:focus-visible { opacity: 1; }

.strip a.current { opacity: 1; outline: 2px solid var(--ink); outline-offset: -2px; }

.strip a:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

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

/* ================= Detail list (contact) ================= */

.detail-list {
  margin-top: 28px;
  font-size: 13px;
  line-height: 2.1;
  color: var(--gray);
  letter-spacing: 0.03em;
}

.detail-list a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hairline); }
.detail-list a:hover { border-bottom-color: var(--ink); }

/* ================= Homepage mosaic ================= */
/* Sidebar stays; the main area becomes a full-height, zero-gap
   3×2 grid of the six category tiles filling the rest of the screen. */

.home { overflow: hidden; }

.home .main {
  margin-left: var(--sidebar-w);
  padding: 0;
  max-width: none;
}

body.home.subbar-open .main {
  margin-left: calc(var(--sidebar-w) + var(--subbar-w));
}

.mosaic {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 100vh;   /* fallback */
  height: 100dvh;  /* mobile-safe viewport */
  width: 100%;
  gap: 0;
}

.cell {
  position: relative;
  display: block;
  overflow: hidden;
  text-decoration: none;
}

.cell img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms ease, filter 250ms ease;
}

.cell .cell-name {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--white);
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 250ms ease;
}

.cell:hover img,
.cell:focus-visible img { filter: brightness(0.75); transform: scale(1.03); }

.cell:hover .cell-name,
.cell:focus-visible .cell-name { opacity: 1; }

.cell:focus-visible { outline: 2px solid var(--white); outline-offset: -2px; }

/* ================= Responsive ================= */

@media (max-width: 980px) {
  .mosaic { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: 100%;
    padding: 40px 28px 8px;
  }
  .site-title { margin-bottom: 24px; }
  .main { margin-left: 0; padding: 24px 28px 72px; }
  .gallery { overflow: auto; }
  .gallery .main { height: auto; display: block; }
  .gallery .strip { margin-top: 28px; padding-top: 0; }
  .viewer-img { max-height: 55vh; }
  .strip a { width: 72px; height: 72px; }
  .arrow { color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
  .arrow:hover, .arrow:focus-visible { color: #fff; }
  .arrow-prev { left: 4px; }
  .arrow-next { right: 4px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
  .nav > li { margin-bottom: 8px; }

  .subbar {
    position: static;
    width: 100%;
    transform: none;
    display: none;
    padding: 12px 28px 20px;
    background: var(--subbar-bg);
  }
  .subbar.open { display: block; }
  body.subbar-open .main { margin-left: 0; }
  .subbar ul { display: flex; flex-wrap: wrap; gap: 6px 18px; }
  .subbar li { margin-bottom: 0; }

  /* Phones: sidebar stacks on top; mosaic becomes one scrolling column */
  .home { overflow: auto; }
  .home .main { margin-left: 0; padding: 0; }
  .mosaic { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: 34dvh; height: auto; }
  .cell .cell-name { opacity: 1; background: rgba(0, 0, 0, 0.30); font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav a, .nav button, .cell img, .cell .cell-name, .subbar, .subbar a, .main, .arrow { transition: none; }
  .cell:hover img, .cell:focus-visible img { transform: none; }
}
