/* Theme ------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  font-size: 106.25%;
  --page: #f3f0e8;
  --surface: #e8e4db;
  --text: #1b1b1b;
  --muted: #68645c;
  --line: rgba(27, 27, 27, 0.2);
  --content-width: 1120px;
  --header-height: 4.8rem;
  --sidebar-top: calc(var(--header-height) + 2rem);
  --page-padding: clamp(2rem, 4vw, 3rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f3f0e8;
  --surface: #e8e4db;
  --text: #1b1b1b;
  --muted: #68645c;
  --line: rgba(27, 27, 27, 0.2);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #242424;
  --surface: #303030;
  --text: #ece9e2;
  --muted: #aaa69e;
  --line: rgba(236, 233, 226, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding-top: var(--header-height);
  background: var(--page);
  color: var(--text);
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.65;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  padding: 0.65rem 0.85rem;
  background: var(--text);
  color: var(--page);
  font-size: 0.8rem;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Fixed header bar ----------------------------------------------------- */
.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 5;
  height: var(--header-height);
  background: var(--page);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  width: min(100%, calc(var(--content-width) + (var(--page-padding) * 2)));
  margin-inline: auto;
  height: 100%;
  padding-inline: var(--page-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-mark,
.theme-toggle {
  width: 2rem;
  height: 2rem;
}

.home-mark {
  display: grid;
  place-items: center;
  opacity: 0.78;
  transition: opacity 150ms ease;
}

.home-mark:hover,
.home-mark:focus-visible {
  opacity: 1;
}

.home-mark img {
  display: block;
  width: 1.45rem;
  height: 1.45rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease;
}

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

.theme-toggle__icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.theme-toggle__icon--moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__icon--moon {
  display: block;
}

/* Book cover and contents ------------------------------------------------ */
.landing-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.landing-page .landing {
  flex: 1 0 auto;
}

.landing-page .site-footer {
  flex-shrink: 0;
}

.landing {
  width: min(100%, calc(var(--content-width) + (var(--page-padding) * 2)));
  margin-inline: auto;
  padding: calc(clamp(6rem, calc(7vh + 2rem), 7rem) - var(--header-height)) var(--page-padding) clamp(1.5rem, 3vh, 2.5rem);
  display: grid;
  grid-template-columns: minmax(220px, 0.32fr) minmax(0, 0.68fr);
  gap: clamp(2.5rem, 5vw, 5rem);
  align-items: center;
}

.cover-frontmatter {
  min-width: 0;
}

.landing .identity h1 {
  font-size: clamp(2.4rem, 3.5vw, 3.15rem);
  line-height: 1.05;
  font-weight: 450;
  text-transform: none;
}

.landing .roles {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.7;
}

.dates {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.contents {
  margin-top: clamp(1.75rem, 3vw, 2.5rem);
}

.contents h2 {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.contents ol {
  margin: 0;
  padding-left: 1.9rem;
  list-style: decimal-leading-zero;
}

.contents li {
  padding-left: 0.75rem;
}

.contents li + li {
  margin-top: 1.1rem;
}

.contents li::marker {
  color: var(--muted);
  font-size: 0.7rem;
}

.contents a {
  display: inline-block;
  padding-block: 0.35rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.06rem, 1.4vw, 1.18rem);
  font-weight: 600;
  line-height: 1.55;
  text-decoration-color: transparent;
  text-underline-offset: 0.25em;
}

.contents a:hover,
.contents a:focus-visible {
  text-decoration-color: currentColor;
}

.cover-portrait {
  min-width: 0;
  margin: 0;
}

.cover-portrait img {
  display: block;
  width: 96%;
  height: auto;
  margin-inline: auto;
}

/* Shared title defaults --------------------------------------------------- */
h1 {
  margin: 0;
  font-size: clamp(2.35rem, 4.2vw, 3.7rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.95;
  text-transform: uppercase;
}

/* Shared hero dividers --------------------------------------------------- */
.hero-divider {
  display: block;
  width: 3.75rem;
  height: 1px;
  margin: clamp(2.25rem, 5vw, 3.25rem) auto 0;
  background: currentColor;
  opacity: 0.42;
}

.hero-divider + .hero-portrait {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

/* Footer ------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line);
}

.site-footer__inner {
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 0.75rem 1.75rem;
  color: var(--muted);
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(0, 1120px) minmax(80px, 1fr);
  gap: 1.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.65;
}

.site-footer__contact {
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
  text-align: center;
  text-wrap: balance;
}

.site-footer__utility {
  justify-self: end;
}

.site-footer__inner a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 0.35em;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.site-footer__inner a:hover,
.site-footer__inner a:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

@media (min-width: 781px) {
  .site-footer__studio {
    position: relative;
    inset-inline-start: var(--page-padding);
  }

  .site-footer__utility {
    position: relative;
    inset-inline-end: var(--page-padding);
  }
}

@media (max-width: 780px) {
  .site-footer__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem 1rem;
  }

  .site-footer__contact {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-inline: calc(var(--page-padding) - 0.75rem);
  }

  .site-footer__studio {
    grid-column: 1;
    grid-row: 2;
  }

  .site-footer__utility {
    grid-column: 2;
    grid-row: 2;
  }
}

.page-source-link {
  margin: 2.5rem 0 0;
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 550;
  letter-spacing: 0.035em;
}

.page-source-link a {
  color: var(--muted);
  text-decoration-color: var(--line);
  text-underline-offset: 0.35em;
}

.page-source-link a:hover,
.page-source-link a:focus-visible {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* Responsive layout ------------------------------------------------------- */
@media (min-width: 781px) and (max-width: 900px) {
  .landing .roles {
    font-size: clamp(0.752rem, 1.6vw, 0.82rem);
  }
}

@media (max-width: 780px) {
  .landing {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 3rem;
    padding-top: calc(6.5rem - var(--header-height));
    padding-bottom: 1.5rem;
  }

  .contents {
    margin-top: 1.75rem;
  }

  .contents a {
    min-height: 44px;
  }

  h1 {
    font-size: clamp(2.4rem, 10vw, 4rem);
  }

}

@media (max-width: 480px) {
  :root {
    --page-padding: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Existing intro space includes the header; avoid reserving it twice. */
body > main .essay-hero {
  padding-top: calc(clamp(8rem, 14vh, 10rem) - var(--header-height));
}

body > main .bibliography-hero,
body > .contact-main {
  padding-top: calc(clamp(9rem, 17vh, 12rem) - var(--header-height));
}

@media (max-width: 780px) {
  body > main .essay-hero {
    padding-top: calc(7.5rem - var(--header-height));
  }
}

@media (max-width: 760px) {
  body > main .bibliography-hero {
    padding-top: calc(8rem - var(--header-height));
  }
}

@media (max-width: 700px) {
  body > .contact-main {
    padding-top: calc(8rem - var(--header-height));
  }
}
