:root {
  --bg: #FEFEFC;
  --ink: #1a1a1a;
  --ink-soft: #4a4a48;
  --ink-mute: #8a8a86;
  --rule: #e6e3dc;
  --accent: #2a8a86;
  --sidebar-w: 280px;
  --measure: 38rem;
  --serif-display: "Playfair Display", "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --serif-body: "Lora", "Iowan Old Style", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-mute);
  transition: text-decoration-color 200ms ease, color 200ms ease;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

::selection {
  background: #ece4cf;
  color: var(--ink);
}

/* ------------------------------------------------------------------
   Sidebar
------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 3.5rem 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
  background: var(--bg);
  z-index: 10;
}

.brand {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.25;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.005em;
  display: block;
  margin-bottom: 3rem;
}
.brand { text-decoration: none; transition: color 180ms ease; }
.brand:hover { color: var(--accent); }
.brand .cafe-word {
  letter-spacing: 0.02em;
}
.brand .accent {
  display: block;
  width: 28px;
  height: 1px;
  background: var(--ink-mute);
  margin-top: 0.9rem;
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--serif-body);
  font-size: 1.02rem;
  flex: 1;
}

.nav > li {
  margin: 0 0 0.55rem;
}

.nav a, .nav .nav-group-toggle {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  line-height: 1.6;
  text-align: left;
  transition: color 180ms ease;
}
.nav a:hover, .nav .nav-group-toggle:hover {
  color: var(--accent);
}

.nav li.is-current > a,
.nav li.is-current > .nav-group-toggle {
  color: var(--accent);
}

.nav-group-toggle .chev {
  display: inline-block;
  color: var(--ink-mute);
  font-size: 0.7rem;
  transition: transform 220ms ease, color 180ms ease;
  transform: translateY(-1px);
}
.nav .nav-group-toggle:hover .chev,
.nav li.is-current > .nav-group-toggle .chev {
  color: var(--accent);
}
.nav li.is-open > .nav-group-toggle .chev {
  transform: rotate(90deg) translateX(-1px);
}

.nav-sub {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.85rem;
  border-left: 1px solid transparent;
  font-size: 0.95rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 260ms ease, opacity 220ms ease, margin 220ms ease, border-color 220ms ease;
}
.nav li.is-open > .nav-sub {
  max-height: 400px;
  opacity: 1;
  margin: 0.45rem 0 0.25rem 0.85rem;
  border-left-color: var(--rule);
}
.nav-sub li {
  margin: 0.15rem 0;
}
.nav-sub a {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.6;
}
.nav-sub a:hover {
  color: var(--accent);
}
.nav-sub li.is-current > a {
  color: var(--accent);
}

.sidebar-footer {
  margin-top: 2rem;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}

.topbar {
  display: block;
}

/* ------------------------------------------------------------------
   Main content
------------------------------------------------------------------- */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 4rem 3.5rem 5rem;
  display: flex;
  flex-direction: column;
}

.content {
  max-width: var(--measure);
  width: 100%;
}

/* Home page — center the image in the right pane */
.main.home {
  padding: 2rem 2rem;
  align-items: center;
  justify-content: center;
}
.home-image {
  max-width: min(520px, 78vw);
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Typography on pages */
.page-title {
  font-family: var(--serif-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2rem, 4.2vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 2rem;
  letter-spacing: -0.005em;
}
/* On piece pages the divider sits between title and body — keep it close to the body */
.page-title + .divider {
  margin: 0 0 2rem;
}
.page-kicker {
  font-family: var(--serif-body);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 1.6rem;
}
.divider {
  width: 32px;
  height: 1px;
  background: var(--ink-mute);
  margin: 2rem 0;
  border: 0;
}

html, body {
  hyphens: manual;
  -webkit-hyphens: manual;
}

.prose p {
  margin: 0 0 1.15rem;
}
.prose p:first-of-type::first-letter {
  /* gentle drop cap on prose pages only when class added */
}
/* Editorial drop cap on Writings pieces.
   Aims for ~3-line visual height with safe right-side clearance so wide italic
   glyphs (T's horizontal bar, D's serif) don't overlap the wrapped body text. */
.prose.has-dropcap p:first-of-type::first-letter {
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  font-size: 3.1em;
  line-height: 1;
  float: left;
  margin: 0.05em 0.22em 0 0;
  color: var(--ink);
}

.poem {
  font-family: var(--serif-body);
  font-size: 1.05rem;
  line-height: 1.85;
  white-space: pre-line;
  margin: 0;
}

/* Index lists (writings / poetry) */
.index-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}
.index-list li {
  border-bottom: 1px solid var(--rule);
  padding: 1.1rem 0;
}
.index-list li:first-child {
  border-top: 1px solid var(--rule);
}
.index-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  text-decoration: none;
  color: var(--ink);
}
.index-list a {
  text-decoration: none;
}
.index-list a:hover .index-title,
.index-list a:hover .index-meta {
  color: var(--accent);
}
.index-title {
  font-family: var(--serif-display);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.25;
}
.index-meta {
  font-family: var(--serif-body);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* About page — photo stacked above text, same width */
.about-grid {
  display: block;
}
.about-photo {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 0 0 2rem;
  filter: saturate(0.95);
}
.about-text { max-width: 100%; }

/* Footer line for piece pages */
.piece-foot {
  margin-top: 3.5rem;
  font-family: var(--serif-body);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink-mute);
  display: flex;
  gap: 1.2rem;
}
.piece-foot a { color: var(--ink-soft); }

/* ------------------------------------------------------------------
   Mobile
------------------------------------------------------------------- */

/* ------------------------------------------------------------------
   Mobile
------------------------------------------------------------------- */

@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }

  /* Top bar — brand on left, hamburger on right */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    background: var(--bg);
    z-index: 50;
    flex-direction: column;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.4rem;
    min-height: 62px;
  }

  .brand {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.2;
  }
  .brand .accent { display: none; }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    padding: 0.5rem;
    margin-right: -0.5rem;
    cursor: pointer;
    color: var(--ink);
    z-index: 60;
    -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle .bars {
    position: relative;
    display: inline-block;
    width: 26px;
    height: 16px;
  }
  .menu-toggle .bars::before,
  .menu-toggle .bars::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 1.5px;
    background: var(--ink);
    border-radius: 1px;
    transform-origin: 50% 50%;
    transition: transform 280ms cubic-bezier(.4,.0,.2,1), top 220ms ease 80ms, bottom 220ms ease 80ms;
  }
  .menu-toggle .bars::before { top: 3px; }
  .menu-toggle .bars::after  { bottom: 3px; }

  /* X state — both bars collapse to the vertical centre then rotate.
     Using margin-top + top:50% (instead of translateY) avoids the antialiasing
     mismatch between translateY(-50%) and translateY(50%) that can make the
     two arms appear unequal in weight. */
  .sidebar.is-open .menu-toggle .bars::before {
    top: 50%;
    margin-top: -0.75px;
    transform: rotate(45deg);
    transition: top 220ms ease, margin-top 220ms ease, transform 280ms cubic-bezier(.4,.0,.2,1) 120ms;
  }
  .sidebar.is-open .menu-toggle .bars::after {
    top: 50%;
    bottom: auto;
    margin-top: -0.75px;
    transform: rotate(-45deg);
    transition: top 220ms ease, bottom 220ms ease, margin-top 220ms ease, transform 280ms cubic-bezier(.4,.0,.2,1) 120ms;
  }

  /* Overlay nav panel */
  .nav {
    position: fixed;
    top: 62px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    padding: 2rem 1.6rem 2rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 1.5rem;
    font-family: var(--serif-display);
    overflow-y: auto;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 240ms ease, transform 280ms cubic-bezier(.4,.0,.2,1);
    z-index: 40;
  }
  .sidebar.is-open .nav {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav > li { margin: 0; }

  .nav a, .nav .nav-group-toggle {
    font-family: var(--serif-body);
    font-style: normal;
    font-weight: 400;
    font-size: 1.4rem;
    line-height: 2;
    padding: 0.35rem 0;
    gap: 0.4rem;
  }
  .nav .nav-group-toggle .chev {
    font-size: 0.85rem;
    transform: translateY(-3px);
  }

  /* Sub-menu within overlay */
  .nav-sub {
    margin: 0;
    padding: 0 0 0 1.2rem;
    border-left: 1px solid var(--rule);
    font-family: var(--serif-body);
    font-size: 1.05rem;
  }
  .nav li.is-open > .nav-sub {
    margin: 0.25rem 0 0.5rem 0.2rem;
  }
  .nav-sub a {
    font-size: 1.05rem;
    font-style: normal;
    line-height: 1.9;
    padding: 0.2rem 0;
  }

  /* Hide footer on mobile */
  .sidebar-footer { display: none; }

  /* Lock scroll when menu open */
  body.menu-open {
    overflow: hidden;
  }

  /* Main content sits below the fixed top bar */
  .main {
    margin-left: 0;
    padding: calc(62px + 3rem) 1.4rem 3rem;
  }
  .main.home {
    padding-top: calc(62px + 2rem);
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 1.4rem;
  }
  .about-photo {
    max-width: 100%;
    width: 100%;
  }
  .about-text {
    max-width: 100%;
  }
  .content {
    max-width: 100%;
  }

  .index-list a {
    flex-direction: column;
    gap: 0.2rem;
  }

  /* Mobile drop cap */
  .prose.has-dropcap p:first-of-type::first-letter {
    font-size: 2.8em;
    line-height: 1;
    margin: 0.05em 0.2em 0 0;
  }
}

/* Desktop: hide the hamburger button entirely */
@media (min-width: 821px) {
  .menu-toggle { display: none; }
}

/* Focus styles */
:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  border-radius: 1px;
}
