/* Mary Kenworthy Art — archive stylesheet.
   Palette, metrics and layout follow the original site. The whole type system
   hangs off --font-serif; swap that one line to change the face everywhere. */

:root {
  --font-serif: "EB Garamond", "Hoefler Text", Garamond, "Times New Roman", serif;
  --ink: #012b55;
  --ink-soft: #546e87;
  --ink-faint: #91a1b4;
  --overlay: #0e2032;
  --bg: #fff;
  --rule: rgba(1, 43, 85, 0.12);
  --header-h: 65px;
  --gutter: 3%;
  --gap: 5px;
  /* one shared content column, so every block lines up down the page */
  --content-max: 1240px;
  --mat: #faf9f6;
  --cols: 2;
  /* chapbook (poetry) */
  --book-ink: #6b4428;
  --book-ink-soft: #8c6a4d;
  --book-paper: #fdfaf4;
  --book-rule: #b99b78;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink-soft); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: #fff; color: var(--ink); padding: 10px 16px;
}
.skip-link:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 3px; }

/* ----------------------------------------------------------- header */

.site-header {
  position: fixed; inset: 0 0 auto 0;
  display: flex; align-items: center;
  height: var(--header-h);
  padding: 0 var(--gutter);
  background: #fff;
  z-index: 30;
  transition: box-shadow .3s ease;
}
.site-header.on-scroll { box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.primary-nav { width: 30%; }
.primary-nav ul { display: flex; margin: 0; padding: 0; list-style: none; }
.primary-nav li { padding-right: 20px; }
.primary-nav li:last-child { padding-right: 0; }
.primary-nav a {
  font-size: 14px; line-height: 24px; font-weight: 400; color: var(--ink);
}
.primary-nav a.active { text-decoration: underline; text-underline-offset: 4px; }

.logo-wrap { flex: 1; text-align: center; }
.logo { font-size: 17px; line-height: 30px; font-weight: 600; color: var(--ink); }

.header-social { width: 30%; display: flex; justify-content: flex-end; }
.social { display: flex; margin: 0; padding: 0; list-style: none; }
.social svg { width: 21px; height: 21px; color: var(--ink); display: block; }
.social a { display: block; padding: 4px; }
.social a:hover svg { color: var(--ink-soft); }

.hamburger {
  display: none; width: 30px; height: 22px; padding: 0;
  background: none; border: 0; cursor: pointer;
  flex-direction: column; justify-content: space-between;
}
.hamburger i { display: block; height: 2px; background: var(--ink); border-radius: 2px; }

.responsive-nav {
  position: fixed; inset: 0; z-index: 40;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 50px 5%;
}
.responsive-nav[hidden] { display: none; }
.responsive-nav ul { list-style: none; margin: 0; padding: 0; text-align: center; }
.responsive-nav li { padding-bottom: 30px; }
.responsive-nav a { font-size: 22px; line-height: 32px; }
.nav-close {
  position: absolute; top: 14px; right: 5%;
  background: none; border: 0; font-size: 34px; line-height: 1;
  color: var(--ink); cursor: pointer;
}
.responsive-nav .social-wrap {
  position: fixed; left: 0; right: 0; bottom: 0;
  border-top: 1px solid rgba(0, 0, 0, .08);
  display: flex; justify-content: center; padding: 20px;
}

/* ----------------------------------------------------------- shell */

.site-container { width: 100%; max-width: 1500px; margin: 0 auto; position: relative; }
main { padding-top: var(--header-h); }
.home-page main { padding-top: 0; }
.content { padding: 0 var(--gutter); }

.page-header { padding-top: 70px; text-align: center; }
.page-header .title {
  font-size: 30px; line-height: 1.2; font-weight: 600; margin: 0 0 10px;
}
.gallery-page .page-header { padding-top: 60px; padding-bottom: 28px; }

.site-footer {
  width: 100%; padding: 60px var(--gutter);
  text-align: center; font-size: 10px; line-height: 20px; color: var(--ink-soft);
}
.site-footer .social { justify-content: center; margin-bottom: 18px; }
.site-footer .social svg { width: 22px; height: 22px; }

.back-to-top {
  position: fixed; right: 28px; bottom: 28px; z-index: 20;
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(1, 43, 85, .07); color: var(--ink-faint);
  font-size: 22px; opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: rgba(1, 43, 85, .14); color: var(--ink); }

/* ----------------------------------------------------------- masthead */

.masthead-placeholder { height: 51vh; }
.masthead {
  position: fixed; top: 0; left: 0; right: 0; height: 51vh; z-index: -1;
  display: flex; align-items: center; justify-content: center;
  background-image: url("/assets/img/masthead.jpg");
  background-size: cover; background-position: center; background-repeat: no-repeat;
  overflow: hidden;
}
.masthead::after {
  content: ""; position: absolute; inset: 0;
  background: #fff; opacity: .37;
}
.masthead-contents {
  position: relative; z-index: 1; max-width: 800px; width: 100%;
  padding: 0 var(--gutter); text-align: center;
}
.masthead p { margin: 0; font-size: 15px; line-height: 1.7; color: var(--ink); text-wrap: balance; }

/* ----------------------------------------------------------- covers */

.project-covers {
  display: flex; flex-wrap: wrap; gap: var(--gap);
  padding: 70px var(--gutter) 0;
  background: #fff;
}
.project-cover {
  display: block; position: relative;
  width: calc(50% - var(--gap) / 2);
}
.cover-content-container { position: relative; overflow: hidden; }
.cover-image { position: relative; padding-bottom: 75%; }
.cover-image::after {
  content: ""; position: absolute; inset: 0;
  background: var(--overlay); opacity: 0;
  transition: opacity .2s ease;
}
.cover {
  position: absolute; inset: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
/* The tile and every cover image are 4:3, so the painting fills it edge to
   edge: no mat showing, and contain still guarantees nothing is cut off. */
.cover__img {
  width: 100%; height: 100%;
  object-fit: contain;
}
.details-wrap {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s ease;
}
.details-inner { width: 100%; padding: 0 8%; text-align: center; }
.project-cover .title { color: #fff; font-size: 24px; line-height: 1.1; }
.project-cover:hover .cover-image::after,
.project-cover:focus-visible .cover-image::after { opacity: .95; }
.project-cover:hover .details-wrap,
.project-cover:focus-visible .details-wrap { opacity: 1; }

/* ----------------------------------------------------------- gallery */

/* Paintings flow down balanced columns rather than across fixed rows, so a
   tall canvas never drags its neighbour's row taller and leaves dead space.
   Each frame hugs the work it holds: nothing is cropped, nothing is padded
   out to a size it was never painted at. */
.grid--main {
  max-width: var(--content-max); margin: 0 auto;
  column-count: var(--cols); column-gap: 30px;
  padding-bottom: 20px;
}
.grid__item { break-inside: avoid; margin: 0 0 30px; }

/* With JavaScript the tiles are dealt into real columns, each painting going
   to whichever column is shortest, so both columns finish level. Without it
   the CSS columns above still do a decent job. */
.grid--main.is-masonry {
  column-count: auto; display: flex; align-items: flex-start; gap: 30px;
}
.grid--main.is-masonry .grid__col {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 30px;
}
.grid--main.is-masonry .grid__item { margin: 0; }
.grid__link {
  display: block; width: 100%; padding: 22px;
  background: var(--mat); border: 1px solid var(--rule);
  transition: transform .25s ease, box-shadow .25s ease;
}
.grid__link img {
  display: block; width: 100%; height: auto;
  box-shadow: 0 5px 18px rgba(1, 43, 85, .22);
  transition: opacity .2s ease;
}
.grid__link:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(1, 43, 85, .14);
}
.grid__link:hover img { opacity: .92; }
.empty-note { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* 'You may also like': every other gallery, three in view, arrows to scroll */
.other-projects { padding: 56px var(--gutter) 0; border-top: 1px solid var(--rule); margin-top: 60px; }
.other-projects-title {
  margin: 0 0 30px; text-align: center;
  font-size: 22px; font-weight: 600; color: var(--ink);
}
/* room either side so the arrows sit in the margin, never over a painting */
.related-scroller {
  position: relative; padding: 0 38px;
  max-width: calc(var(--content-max) + 76px); margin: 0 auto;
}
.related-track {
  display: flex; gap: var(--gap);
  overflow-x: auto; scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
}
.related-track::-webkit-scrollbar { display: none; }
.related-track .project-cover {
  flex: 0 0 calc((100% - var(--gap) * 2) / 3);
  scroll-snap-align: start;
}

.rel-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none;
  color: var(--ink-faint); font-size: 24px; line-height: 1; cursor: pointer;
  transition: color .18s ease;
}
.rel-arrow:hover { color: var(--ink); }
.rel-arrow[hidden] { display: none; }
.rel-prev { left: 2px; }
.rel-next { right: 2px; }
/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(255, 255, 255, .985);
  display: flex; align-items: center; justify-content: center;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 92vw; max-height: 88vh; width: auto; height: auto;
  object-fit: contain; box-shadow: 0 10px 50px rgba(0, 0, 0, .14);
}
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; background: none; border: 0; cursor: pointer;
  color: var(--ink); line-height: 1;
}
.lightbox-close { top: 18px; right: 24px; font-size: 38px; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); font-size: 54px; padding: 10px 18px; }
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
.lightbox-count {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--ink-soft);
}

/* ----------------------------------------------------------- prose */

.prose { max-width: 780px; margin: 0 auto; padding-top: 10px; }
.prose h2 {
  font-size: 24px; font-weight: 600; margin: 44px 0 14px;
}
.prose h2:first-child { margin-top: 10px; }
.prose p { margin: 0 0 18px; font-size: 17px; line-height: 1.75; }
.prose blockquote {
  margin: 26px 0; padding-left: 20px; border-left: 2px solid var(--rule);
  font-style: italic; color: var(--ink-soft);
}
.prose ul { margin: 0 0 18px; padding-left: 20px; }
.prose li { margin-bottom: 10px; line-height: 1.7; }

/* Photographs inside the About copy */
.figure-row {
  display: grid; gap: 18px; margin: 34px 0 30px;
}
.figure-row.cols-2 { grid-template-columns: 1fr 1fr; align-items: start; }
.figure-row figure { margin: 0; }
.figure-row img {
  width: 100%; height: auto; border-radius: 2px;
  box-shadow: 0 8px 26px rgba(1, 43, 85, .10);
}

/* ----------------------------------------------------------- contact */

/* balance evens the line lengths instead of filling the first line and
   leaving a stub on the second; the narrower measure is the fallback where
   balance is not supported. */
.contact-intro {
  max-width: 560px; margin: 0 auto 26px; text-align: center; font-size: 17px;
  text-wrap: balance;
}
.form-note {
  max-width: 560px; margin: 0 auto 22px; text-align: center; text-wrap: balance;
  font-size: 13px; color: var(--ink-soft);
}
.form-note code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.contact-form { max-width: 620px; margin: 0 auto 40px; display: grid; gap: 18px; }
.contact-form label { display: grid; gap: 7px; font-size: 14px; color: var(--ink-soft); }
.field-label { display: block; }
.contact-form input, .contact-form textarea {
  font-family: inherit; font-size: 16px; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--rule); border-radius: 2px; background: #fff;
}
.contact-form input:focus, .contact-form textarea:focus {
  outline: none; border-color: var(--ink-soft);
}
.contact-form button {
  justify-self: start; font-family: inherit; font-size: 15px;
  padding: 11px 30px; border: 1px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: #fff; cursor: pointer;
}
.contact-form button:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.contact-form button:disabled { opacity: .6; cursor: default; }
.form-status:empty { display: none; }
.form-status { margin: 0; font-size: 14px; color: #8a3324; }

.form-thanks {
  max-width: 620px; margin: 0 auto 40px; padding: 38px 30px;
  text-align: center; border: 1px solid var(--rule); border-radius: 3px;
}
.form-thanks[hidden] { display: none; }
.thanks-mark { margin: 0 0 8px; font-size: 24px; font-weight: 600; color: var(--ink); }
.form-thanks p + p { margin: 0; font-size: 15px; color: var(--ink-soft); }

/* ----------------------------------------------------------- poetry */

.poetry-page { background: #fff; }
.poetry .page-header { padding-top: 76px; }
.poetry-eyebrow {
  margin: 0 0 10px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--book-ink-soft);
}
.book-title {
  font-size: 44px; line-height: 1.1; font-weight: 600;
  font-style: italic; color: var(--book-ink); margin-bottom: 18px;
}
.poetry-intro {
  max-width: 620px; margin: 0 auto; font-size: 16px; line-height: 1.75;
  color: var(--ink-soft);
}

.chapbook-frame {
  background: var(--book-paper);
  border: 1px solid var(--book-rule);
  border-radius: 10px;
  padding: 38px 34px;
  color: var(--book-ink);
}

.poem-intro { max-width: 620px; margin: 46px auto 0; }
.poem-eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--book-ink-soft); font-style: italic;
}
.poem-title {
  margin: 0 0 20px; font-size: 27px; font-weight: 600; color: var(--book-ink);
}
.poem-body .stanza {
  margin: 0 0 17px; font-size: 17px; line-height: 1.62;
}
.poem-body .stanza:last-child { margin-bottom: 0; }
.poem-body .indent { display: inline-block; padding-left: 2.1em; }

.poem-grid {
  display: grid; gap: 18px; margin: 56px auto 20px; max-width: 1180px;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
}
.poem-card {
  font-family: inherit; text-align: left; cursor: pointer; padding: 0;
  background: none; border: 0;
}
.poem-card-inner {
  display: flex; flex-direction: column; gap: 9px; height: 100%;
  background: var(--book-paper);
  border: 1px solid var(--book-rule); border-radius: 10px;
  padding: 26px 24px 22px;
  transition: transform .18s ease, box-shadow .18s ease;
}
.poem-card:hover .poem-card-inner,
.poem-card:focus-visible .poem-card-inner {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(107, 68, 40, .14);
}
.poem-card-title {
  font-size: 20px; font-weight: 600; color: var(--book-ink); line-height: 1.25;
}
.poem-card-first {
  font-size: 15px; line-height: 1.55; color: var(--book-ink-soft); font-style: italic;
}
.poem-page {
  margin-top: auto; padding-top: 10px;
  font-size: 11px; letter-spacing: .12em; color: var(--book-ink-soft);
}
.poem-page::before { content: "page "; }

.poem-reader {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(253, 250, 244, .97);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.poem-reader[hidden] { display: none; }
.reader-stage { width: 100%; max-width: 620px; max-height: 100%; overflow-y: auto; }
.reader-page { min-height: 300px; }
.reader-note {
  margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--book-rule);
  font-size: 12px; line-height: 1.6; color: var(--book-ink-soft); font-style: italic;
}
.reader-pagenum {
  margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--book-ink-soft);
}
.reader-close, .reader-prev, .reader-next {
  position: absolute; background: none; border: 0; cursor: pointer;
  color: var(--book-ink-soft); line-height: 1;
}
.reader-close { top: 18px; right: 24px; font-size: 38px; }
.reader-prev, .reader-next { top: 50%; transform: translateY(-50%); font-size: 50px; padding: 10px 18px; }
.reader-prev { left: 10px; }
.reader-next { right: 10px; }
.reader-close:hover, .reader-prev:hover, .reader-next:hover { color: var(--book-ink); }

/* ----------------------------------------------------------- responsive */

@media (max-width: 932px) {
  :root { --gutter: 5%; }
  .primary-nav, .header-social { display: none; }
  .hamburger { display: flex; }
  .logo-wrap { text-align: left; }
  .site-header { justify-content: space-between; }
  .page-header .title { font-size: 26px; }
  .book-title { font-size: 36px; }
  .project-cover .title { font-size: 15px; }
  :root { --cols: 1; }
  .grid--main { column-gap: 20px; }
  .grid__item { margin-bottom: 20px; }
  .related-track .project-cover { flex-basis: calc((100% - var(--gap)) / 2); }
}

@media (max-width: 540px) {
  .masthead-placeholder, .masthead { height: 44vh; }
  .masthead p { font-size: 14px; }
  .project-covers { padding-top: 40px; }
  .project-cover { width: 100%; }
  .page-header { padding-top: 46px; }
  .book-title { font-size: 30px; }
  .chapbook-frame { padding: 26px 20px; }
  .poem-grid { grid-template-columns: 1fr; gap: 14px; margin-top: 36px; }
  .grid__item { margin-bottom: 16px; }
  .figure-row.cols-2 { grid-template-columns: 1fr; }
  .other-projects { margin-top: 40px; padding-top: 36px; }
  .related-scroller { padding: 0 26px; }
  .related-track .project-cover { flex-basis: 78%; }
  .rel-arrow { width: 24px; height: 24px; font-size: 20px; }
  .reader-prev, .reader-next { font-size: 38px; padding: 6px 10px; }
  .back-to-top { right: 16px; bottom: 16px; width: 44px; height: 44px; }
}

/* On a phone there is no room beside the artwork, so the arrows sit under it
   in a row with the counter instead of floating on top of the painting.
   This block comes last so it wins over the widths above. */
@media (max-width: 700px) {
  /* dvh, not vh: on iOS Safari 100vh is the height WITHOUT the browser bars,
     so a vh-sized overlay runs underneath them. env(safe-area-inset-*) keeps
     the controls clear of the home indicator and the notch. */
  .lightbox, .poem-reader { height: 100dvh; }

  .lightbox img { max-width: 88vw; max-height: 60dvh; }
  .lightbox-prev, .lightbox-next {
    top: auto; bottom: calc(22px + env(safe-area-inset-bottom));
    transform: none; font-size: 40px; padding: 10px 22px;
  }
  .lightbox-prev { left: 22%; }
  .lightbox-next { right: 22%; }
  .lightbox-count { bottom: calc(38px + env(safe-area-inset-bottom)); }
  .lightbox-close {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(14px + env(safe-area-inset-right));
  }

  .poem-reader {
    padding: calc(56px + env(safe-area-inset-top)) 26px
             calc(100px + env(safe-area-inset-bottom));
  }
  .reader-stage {
    max-height: calc(100dvh - 190px - env(safe-area-inset-top)
                             - env(safe-area-inset-bottom));
  }
  .reader-prev, .reader-next {
    top: auto; bottom: calc(24px + env(safe-area-inset-bottom));
    transform: none; font-size: 40px; padding: 10px 22px;
  }
  .reader-prev { left: 22%; }
  .reader-next { right: 22%; }
  .reader-close {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(14px + env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .responsive-nav, .back-to-top, .poem-reader, .lightbox { display: none !important; }
  body { color: #000; }
}
