/* ————————————————————————————————————————————
   The Walsh Family Archive
   paper · ink · the red pen of K. M. Olsen
   ———————————————————————————————————————————— */

:root {
  --paper: #f4eddd;
  --paper-deep: #ece2cc;
  --ink: #221d15;
  --ink-soft: #5c5340;
  --red: #9c2f1d;
  --green: #32502e;
  --line: #c9bca0;
  --serif: "Newsreader", Georgia, serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* paper grain over everything */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--red); color: var(--paper); }

/* ——— hero ——— */

.hero {
  position: relative;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 50% -10%, #faf5e9 0%, var(--paper) 55%, var(--paper-deep) 100%);
  overflow: hidden;
}

.hero-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem) clamp(2rem, 4vw, 3.5rem);
  text-align: center;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: clamp(1.5rem, 3vw, 2.75rem);
  animation: rise .9s .05s cubic-bezier(.2,.7,.2,1) both;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) minmax(120px, 220px);
  gap: clamp(1.25rem, 3.5vw, 3.5rem);
  align-items: center;
}

.hero-portrait { animation: rise 1s .35s cubic-bezier(.2,.7,.2,1) both; }
.hero-portrait--right { animation-delay: .5s; }

.hero-portrait img {
  width: 100%;
  height: auto;
  display: block;
  filter: sepia(.28) contrast(1.02);
  border: 1px solid var(--line);
  outline: 6px solid #fffdf6;
  outline-offset: -7px;
  box-shadow: 0 14px 34px -16px rgba(34, 29, 21, .55);
}

.hero-portrait--left  { transform: rotate(-1.6deg); }
.hero-portrait--right { transform: rotate(1.4deg); }

.hero-portrait figcaption {
  margin-top: .9rem;
  font-family: var(--display);
  font-style: italic;
  font-size: .95rem;
  line-height: 1.35;
}
.hero-portrait figcaption span {
  font-family: var(--mono);
  font-style: normal;
  font-size: .62rem;
  letter-spacing: .12em;
  color: var(--ink-soft);
}

.hero-title { animation: rise 1s .15s cubic-bezier(.2,.7,.2,1) both; }

.hero-title h1 {
  font-family: var(--display);
  font-weight: 380;
  font-variation-settings: "opsz" 144;
  font-size: clamp(2.6rem, 7.2vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: -.015em;
}
.hero-title h1 em {
  font-style: italic;
  font-weight: 330;
  color: var(--ink-soft);
  font-size: .55em;
  display: block;
  letter-spacing: .02em;
}
.hero-title h1 .amp { font-style: italic; color: var(--red); }

.hero-rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.4rem auto 1.3rem;
  max-width: 420px;
  color: var(--red);
}
.hero-rule::before, .hero-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line));
}
.hero-rule::after { background: linear-gradient(90deg, var(--line), transparent); }

.hero-lede {
  max-width: 56ch;
  margin: 0 auto;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  line-height: 1.6;
  color: #3a342a;
}

.hero-credit {
  margin-top: 1.1rem;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

.hero-down {
  display: inline-block;
  margin-top: clamp(1.75rem, 3vw, 2.75rem);
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: .8rem 1.5rem;
  border-radius: 99px;
  text-decoration: none;
  transition: background .2s, transform .2s;
  animation: rise 1s .6s cubic-bezier(.2,.7,.2,1) both;
}
.hero-down:hover { background: var(--red); transform: translateY(-2px); }

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ——— voyage timeline ——— */

.voyage {
  background: var(--ink);
  color: var(--paper);
  overflow-x: auto;
  scrollbar-width: none;
}
.voyage::-webkit-scrollbar { display: none; }

.voyage ol {
  display: flex;
  list-style: none;
  min-width: max-content;
  margin: 0 auto;
  max-width: 1240px;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  gap: 2.6rem;
}

.voyage li {
  position: relative;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .06em;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  gap: .55rem;
}
.voyage li b {
  font-weight: 500;
  color: #e8b47e;
  font-size: .85rem;
}
.voyage li span { opacity: .75; }
.voyage li + li::before {
  content: "→";
  position: absolute;
  left: -1.85rem;
  color: var(--red);
}

/* ——— toolbar ——— */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.toolbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: .7rem clamp(1.25rem, 4vw, 3rem);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #fffdf6;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: .45rem .95rem;
  flex: 1 1 260px;
  max-width: 380px;
  color: var(--ink-soft);
}
.search:focus-within { border-color: var(--red); }
.search svg { width: 15px; height: 15px; flex: none; }
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: .95rem;
  width: 100%;
  color: var(--ink);
}
.search input::placeholder { color: #a89a7d; font-style: italic; }

.chapters {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.chapters a {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 99px;
  padding: .35rem .7rem;
  transition: color .15s, border-color .15s;
}
.chapters a:hover { color: var(--red); border-color: var(--line); }

.count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

/* ——— gallery ——— */

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 4rem;
}

.chapter { padding-top: clamp(2.5rem, 5vw, 4rem); }

.chapter-head {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: .9rem;
}
.chapter-head .roman {
  font-family: var(--display);
  font-style: italic;
  font-weight: 330;
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  color: var(--red);
  line-height: 1;
}
.chapter-head h2 {
  font-family: var(--display);
  font-weight: 430;
  font-variation-settings: "opsz" 100;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  letter-spacing: -.01em;
}
.chapter-head .rule {
  flex: 1;
  height: 1px;
  background: var(--line);
  position: relative;
  top: -.4em;
}

.chapter-sub {
  max-width: 72ch;
  color: #4a4233;
  font-size: 1.02rem;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.plate {
  cursor: zoom-in;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
  display: block;
}

.plate-frame {
  display: block;
  position: relative;
  background: #fffdf6;
  border: 1px solid var(--line);
  padding: 10px;
  box-shadow: 0 1px 2px rgba(34,29,21,.08), 0 10px 24px -18px rgba(34,29,21,.4);
  transition: transform .25s cubic-bezier(.2,.7,.2,1), box-shadow .25s;
}
.plate:hover .plate-frame,
.plate:focus-visible .plate-frame {
  transform: translateY(-4px) rotate(-.35deg);
  box-shadow: 0 2px 3px rgba(34,29,21,.08), 0 24px 40px -20px rgba(34,29,21,.5);
}
.plate:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }

.plate-frame img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--paper-deep);
  filter: sepia(.14);
  transition: filter .3s;
}
.plate:hover .plate-frame img { filter: none; }

.plate-no {
  position: absolute;
  top: -9px;
  left: 14px;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .14em;
  background: var(--ink);
  color: var(--paper);
  padding: .2rem .55rem;
  border-radius: 3px;
}

.plate h3 {
  font-family: var(--display);
  font-weight: 480;
  font-size: 1.18rem;
  line-height: 1.25;
  margin: .9rem 0 .3rem;
  letter-spacing: -.005em;
}
.plate:hover h3 { color: var(--red); }

.plate p {
  font-size: .88rem;
  line-height: 1.5;
  color: #564d3c;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.no-results {
  padding: 4rem 0;
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
}
.no-results b { font-style: normal; }

mark {
  background: color-mix(in srgb, #e8b47e 55%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 .1em;
}

/* ——— coda ——— */

.coda {
  border-top: 1px solid var(--line);
  background: var(--paper-deep);
  text-align: center;
  padding: clamp(3rem, 6vw, 4.5rem) 1.5rem;
}
.coda img {
  width: 130px;
  height: auto;
  margin-bottom: 1.25rem;
  filter: drop-shadow(0 8px 16px rgba(34,29,21,.25));
}
.coda-line {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.15rem;
  margin-bottom: .9rem;
}
.coda p { max-width: 58ch; margin-left: auto; margin-right: auto; color: #4a4233; }
.coda p + p { margin-top: .6rem; }
.coda-fine {
  margin-top: 1.5rem !important;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .12em;
  color: var(--ink-soft);
}

/* ——— viewer ——— */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #161310;
  color: #efe7d4;
}
.viewer[hidden] { display: none; }

.viewer-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.viewer-stage.dragging { cursor: grabbing; }

.viewer-stage img {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  max-width: none;
  will-change: transform;
}

.viewer-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.25rem;
  background: linear-gradient(rgba(15,13,10,.85), transparent);
  pointer-events: none;
}
.viewer-top > * { pointer-events: auto; }

.viewer-plate {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #c8bda2;
}

.viewer-actions { display: flex; gap: .6rem; align-items: center; }

.viewer-actions a {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .1em;
  color: #efe7d4;
  text-decoration: none;
  border: 1px solid rgba(239,231,212,.35);
  border-radius: 99px;
  padding: .42rem .85rem;
  transition: border-color .15s, color .15s;
}
.viewer-actions a:hover { border-color: #e8b47e; color: #e8b47e; }

#vClose {
  background: none;
  border: 1px solid rgba(239,231,212,.35);
  color: #efe7d4;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: .85rem;
  transition: border-color .15s, color .15s;
}
#vClose:hover { border-color: #e8b47e; color: #e8b47e; }

.viewer-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem 1.1rem;
  background: linear-gradient(transparent, rgba(15,13,10,.92));
  pointer-events: none;
}
.viewer-bottom > * { pointer-events: auto; }

.viewer-caption { flex: 1; text-align: center; min-width: 0; }
.viewer-caption h2 {
  font-family: var(--display);
  font-weight: 420;
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
  letter-spacing: -.005em;
}
.viewer-caption p {
  font-size: .85rem;
  color: #c8bda2;
  max-width: 78ch;
  margin: .25rem auto 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vnav {
  flex: none;
  background: none;
  border: 1px solid rgba(239,231,212,.35);
  color: #efe7d4;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.vnav:hover { border-color: #e8b47e; color: #e8b47e; transform: scale(1.06); }

.viewer-hint {
  position: absolute;
  top: 3.4rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .12em;
  color: rgba(239,231,212,.65);
  background: rgba(15,13,10,.6);
  padding: .4rem .9rem;
  border-radius: 99px;
  transition: opacity .6s;
  pointer-events: none;
  white-space: nowrap;
}
.viewer-hint.gone { opacity: 0; }

/* ——— responsive ——— */

@media (max-width: 760px) {
  .hero-row {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
  .hero-title {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .voyage li span { display: none; }
  .voyage ol { gap: 1.8rem; }
  .voyage li + li::before { left: -1.3rem; }
  .count { display: none; }
  .viewer-caption p { display: none; }
  .viewer-hint { display: none; }
}

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