/* ==========================================================================
   Kissa Koskinen — illustrator, author, visual storyteller
   Palette, type and layout are drawn from the artwork itself:
   parchment and ink, forest green, sea teal, watercolour clay.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
  color-scheme: light;

  --paper:      #f6f0e6;
  --paper-2:    #efe5d5;
  --paper-3:    #e7dac6;
  --ink:        #211c17;
  --ink-soft:   #443a31;
  --muted:      #6f6252;
  --rule:       #d9cab4;
  --rule-soft:  #e5d9c6;

  --sea:        #23707a;
  --forest:     #4a5b30;
  --clay:       #ab5335;
  --deep:       #1d4a5a;
  --accent:     var(--sea);

  --card:       #fbf7ef;
  --card-edge:  #e3d6c0;
  --scrim:      rgba(20, 16, 12, .55);
  --shadow:     0 1px 2px rgba(45, 33, 20, .05), 0 12px 34px -18px rgba(45, 33, 20, .32);
  --shadow-lg:  0 2px 6px rgba(45, 33, 20, .06), 0 34px 70px -34px rgba(45, 33, 20, .45);

  --display: "Playfair Display", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --body: "Merriweather", Georgia, "Times New Roman", serif;

  --header-h: 4.4rem;
  --maxw: 1220px;
  --readw: 64ch;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
  --section-y: clamp(4.5rem, 11vw, 9.5rem);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:     #14120e;
    --paper-2:   #1b1813;
    --paper-3:   #241f18;
    --ink:       #efe5d3;
    --ink-soft:  #d3c6b1;
    --muted:     #9d8f7a;
    --rule:      #362f25;
    --rule-soft: #2a251d;
    --sea:       #6fc0c4;
    --forest:    #9fb37a;
    --clay:      #d98a68;
    --deep:      #7fb0c2;
    --card:      #1c1913;
    --card-edge: #322b21;
    --scrim:     rgba(8, 7, 5, .58);
    --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 12px 34px -18px rgba(0, 0, 0, .7);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 34px 70px -34px rgba(0, 0, 0, .8);
  }
  :root:not([data-theme="light"]) .vignette {
    filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .5));
  }
  :root:not([data-theme="light"]) .lightbox { background: #0d0b08; }
  :root:not([data-theme="light"]) .piece-frame::after { box-shadow: inset 0 0 0 1px rgba(240, 230, 210, .10); }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:     #14120e;
  --paper-2:   #1b1813;
  --paper-3:   #241f18;
  --ink:       #efe5d3;
  --ink-soft:  #d3c6b1;
  --muted:     #9d8f7a;
  --rule:      #362f25;
  --rule-soft: #2a251d;
  --sea:       #6fc0c4;
  --forest:    #9fb37a;
  --clay:      #d98a68;
  --deep:      #7fb0c2;
  --card:      #1c1913;
  --card-edge: #322b21;
  --scrim:     rgba(8, 7, 5, .58);
  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 12px 34px -18px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 34px 70px -34px rgba(0, 0, 0, .8);
}

/* ---------- 2. Base ------------------------------------------------------ */

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

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 clamp(0.94rem, 0.9rem + 0.16vw, 1.02rem)/1.85 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
figure { margin: 0; }   /* the browser default is 40px inline, which nudges every figure off its column */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1.15em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.wrap { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }
.read { max-width: var(--readw); }

/* Visible to screen readers only — keeps the language button's accessible
   name ("Language: FI") aligned with the code shown in it. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 200;
  background: var(--ink); color: var(--paper);
  padding: 0.7rem 1.1rem; border-radius: 3px; font-size: 0.85rem;
  transition: top 0.2s var(--ease);
}
.skip:focus { top: 0.5rem; }

/* ---------- 3. Header / nav ---------------------------------------------- */

/* Transparent over the hero, paper-coloured once the page scrolls. */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: transparent;
  border-bottom: 1px solid transparent;
  --hdr-fg: rgba(248, 242, 232, .74);
  --hdr-fg-strong: #fbf5ea;
  --hdr-edge: rgba(248, 242, 232, .34);
  color: var(--hdr-fg-strong);
  transition: border-color .35s var(--ease), background .35s var(--ease), color .35s var(--ease);
}
.site-header[data-stuck="true"],
.site-header.is-solid {
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom-color: var(--rule-soft);
  --hdr-fg: var(--muted);
  --hdr-fg-strong: var(--ink);
  --hdr-edge: var(--rule);
  color: var(--ink);
}

.header-inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: var(--header-h);
}

.wordmark {
  font-family: var(--display);
  font-size: 1.06rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}
.wordmark .wm-mark {
  display: inline-block; width: 1.45rem; vertical-align: -0.34em;
  margin-right: 0.5rem; opacity: 0.95;
}

.nav { display: flex; align-items: center; gap: clamp(0.9rem, 1.8vw, 1.9rem); }

.nav a {
  font-family: var(--body);
  font-size: 0.74rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--hdr-fg);
  padding: 0.45rem 0;
  position: relative;
  transition: color 0.25s var(--ease);
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0.1rem;
  height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s var(--ease);
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--hdr-fg-strong); }
.nav a:hover::after, .nav a[aria-current="true"]::after { transform: scaleX(1); }

.icon-btn {
  appearance: none; background: none; border: 1px solid var(--rule);
  color: var(--muted); border-radius: 50%;
  width: 2.15rem; height: 2.15rem;
  display: grid; place-items: center; cursor: pointer; flex: none;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink); }
.site-header .icon-btn { color: var(--hdr-fg); border-color: var(--hdr-edge); }
.site-header .icon-btn:hover { color: var(--hdr-fg-strong); border-color: var(--hdr-fg-strong); }
.icon-btn svg { width: 1rem; height: 1rem; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

/* Language switcher — a <details> so it still opens without JavaScript. */
.lang { position: relative; flex: none; }
.lang > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 2.15rem; padding: 0 0.8rem;
  border: 1px solid var(--hdr-edge); border-radius: 999px;
  color: var(--hdr-fg);
  font-family: var(--body); font-size: 0.68rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  transition: color .25s var(--ease), border-color .25s var(--ease);
}
.lang > summary::-webkit-details-marker { display: none; }
.lang > summary::marker { content: ""; }
.lang > summary:hover { color: var(--hdr-fg-strong); border-color: var(--hdr-fg-strong); }
.lang > summary svg { width: 0.95rem; height: 0.95rem; flex: none; }
.lang-code { font-variant-numeric: tabular-nums; }

.lang-menu {
  position: absolute; right: 0; top: calc(100% + 0.55rem);
  min-width: 9.5rem; z-index: 70;
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  animation: fade .22s var(--ease) both;
}
@media (prefers-reduced-motion: reduce) { .lang-menu { animation: none; } }

.lang-menu a {
  font-family: var(--body); font-size: 0.8rem;
  letter-spacing: 0.04em; text-transform: none; text-decoration: none;
  color: var(--muted);
  padding: 0.5rem 0.7rem; border-radius: 2px;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.lang-menu a:hover { color: var(--ink); background: var(--paper-2); }
.lang-menu a[aria-current="true"] { color: var(--ink); font-weight: 700; }
.lang-menu a[aria-current="true"]::after { content: " ·"; color: var(--accent); }

.nav-toggle { display: none; }

/* Narrow phones: the wordmark plus three controls need every pixel, so the
   language button drops its globe and the whole row tightens up. */
/* The nav collapses early: seven items in Finnish or Estonian, plus the
   language and theme controls, need the room. */
@media (max-width: 1180px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: flex-start;
    gap: 0; padding: 1rem var(--gutter) 2rem;
    background: var(--paper);
    border-bottom: 1px solid var(--rule-soft);
    box-shadow: var(--shadow);
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
  }
  .nav[hidden] { display: none; }
  .nav a { font-size: 0.9rem; letter-spacing: 0.12em; padding: 0.8rem 0; width: 100%; border-bottom: 1px solid var(--rule-soft); color: var(--muted); }
  .nav a:hover, .nav a[aria-current="true"] { color: var(--ink); }
  .nav a:last-child { border-bottom: 0; }
  .nav a::after { display: none; }
}

/* ---------- 4. Hero ------------------------------------------------------ */

.hero {
  position: relative;
  min-height: min(94svh, 900px);
  display: grid; align-items: end;
  isolation: isolate;
  margin-top: calc(-1 * var(--header-h));
  padding-top: var(--header-h);
}
.hero-media { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.hero-media img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(18,14,10,.42) 0%, rgba(18,14,10,.06) 32%, rgba(18,14,10,.30) 62%, rgba(18,14,10,.82) 100%);
}

.hero-inner { padding-block: clamp(3rem, 9vw, 6.5rem); color: #f7f0e4; }

.hero h1 {
  font-size: clamp(3.1rem, 11.5vw, 8.2rem);
  font-weight: 400;
  letter-spacing: -0.028em;
  line-height: 0.92;
  color: #fbf5ea;
  text-shadow: 0 2px 40px rgba(10, 8, 5, .5);
}
.hero h1 .given { display: block; }
.hero h1 .family { display: block; font-style: italic; margin-left: 0.06em; }

.hero-tagline {
  margin: clamp(1.2rem, 3vw, 2rem) 0 0;
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
  letter-spacing: 0.28em;
  text-transform: lowercase;
  color: rgba(247, 240, 228, .88);
  font-family: var(--body);
  max-width: 34ch;
  line-height: 2;
}

.hero-caption {
  position: absolute; right: var(--gutter); bottom: 1.6rem;
  font-size: 0.66rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: rgba(247, 240, 228, .5); text-align: right; max-width: 18rem;
}

.scroll-cue {
  position: absolute; left: var(--gutter); bottom: 1.5rem;
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-size: 0.62rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: rgba(247, 240, 228, .62); text-decoration: none;
}
.scroll-cue .line {
  display: block; width: 2.6rem; height: 1px; background: currentColor;
  transform-origin: left; animation: cue 2.8s var(--ease) infinite;
}
@keyframes cue { 0%, 100% { transform: scaleX(.35); } 50% { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .scroll-cue .line { animation: none; } }
@media (max-width: 860px) { .hero-caption, .scroll-cue { display: none; } }

/* ---------- 5. Statement band -------------------------------------------- */

.statement {
  padding-block: clamp(3.5rem, 8vw, 6.5rem);
  border-bottom: 1px solid var(--rule-soft);
  position: relative;
}
.statement p {
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.1vw, 2.35rem);
  line-height: 1.42; font-weight: 400;
  max-width: 24ch;
  letter-spacing: -0.01em;
}
.statement em { font-style: italic; color: var(--accent); }

.themes {
  list-style: none; margin: 2.4rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.55rem 1.6rem;
  font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
}
.themes li { display: flex; align-items: center; gap: 1.6rem; }
.themes li + li::before { content: "·"; margin-left: -1.05rem; opacity: .55; }

/* ---------- 6. Sections -------------------------------------------------- */

.section { padding-block: var(--section-y); position: relative; }
.panel-lede { margin-block: 0 clamp(2rem, 4vw, 3rem); }
.eyebrow.eyebrow-quiet { color: var(--muted); }   /* beats .eyebrow's accent */
.section-lede-centred { margin-inline: auto; text-align: center; }
.section > .wrap, .statement > .wrap { position: relative; z-index: 1; }
.section + .section { border-top: 1px solid var(--rule-soft); }
.section-alt { background: var(--paper-2); }

.section-head { margin-bottom: clamp(2.5rem, 5vw, 4.25rem); }
.eyebrow {
  display: block;
  font-size: 0.68rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1.1rem;
}
.section-head h2 { font-size: clamp(2.1rem, 5.2vw, 3.6rem); font-weight: 400; }
.section-head h2 em { font-style: italic; }
.section-lede {
  margin-top: 1.5rem; max-width: var(--readw);
  color: var(--ink-soft); font-size: 1.02em;
}

.subhead {
  display: flex; align-items: baseline; gap: 1.2rem;
  margin: clamp(3rem, 6vw, 5rem) 0 2rem;
}
.subhead:first-of-type { margin-top: 0; }
.subhead h2, .subhead h3, .subhead h4 {
  font-size: clamp(1.3rem, 2.4vw, 1.85rem); font-weight: 500;
  letter-spacing: 0.005em; flex: none;
}
.subhead .rule { flex: 1; height: 1px; background: var(--rule); }
.subhead .count { font-size: 0.68rem; letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase; flex: none; }

/* ---------- 7. Portfolio tabs -------------------------------------------- */

.tabs {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: clamp(2.25rem, 4vw, 3.25rem);
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 1rem;
}
.tab {
  appearance: none; background: none; border: 1px solid transparent;
  font-family: var(--body); font-size: 0.72rem;
  letter-spacing: 0.17em; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
  padding: 0.55rem 1.05rem; border-radius: 999px;
  transition: color .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease);
}
.tab:hover { color: var(--ink); border-color: var(--rule); }
.tab[aria-selected="true"] {
  color: var(--paper); background: var(--ink); border-color: var(--ink);
}

.panel[hidden] { display: none; }
.panel { animation: fade .5s var(--ease) both; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

/* ---------- 8. Book cards ------------------------------------------------ */

.books { display: grid; gap: clamp(3rem, 6vw, 5rem); }

.book {
  display: grid;
  grid-template-columns: clamp(190px, 25vw, 330px) minmax(0, 1fr);
  gap: clamp(1.75rem, 4vw, 3.75rem);
  align-items: start;
}
/* On a phone the cover used to fill the screen, pushing the title below the
   fold. It now floats beside the title, with the description running on
   underneath — a grid would let the button widths dictate the columns. */
@media (max-width: 780px) {
  .book { display: block; }
  .book-cover {
    float: left; width: 38%; max-width: 9.5rem;
    margin: 0.25rem 1.15rem 0.9rem 0;
  }
  .book-head { margin-bottom: 0.9rem; }
  .actions { clear: left; }
}

.book-cover {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--paper-3);
  transition: transform .55s var(--ease);
}
.book-cover img { width: 100%; }
.book:hover .book-cover { transform: translateY(-4px); }
@media (prefers-reduced-motion: reduce) { .book:hover .book-cover { transform: none; } }

.book-cover.is-placeholder {
  aspect-ratio: 3 / 4;
  display: grid; place-items: center;
  box-shadow: none;
  border: 1px dashed var(--rule);
  background:
    repeating-linear-gradient(135deg, transparent 0 9px, color-mix(in srgb, var(--rule) 40%, transparent) 9px 10px);
}
.book-cover.is-placeholder span {
  font-family: var(--display); font-style: italic; font-size: 1.05rem;
  color: var(--muted); text-align: center; padding: 1.5rem; line-height: 1.5;
  background: var(--paper); box-shadow: 0 0 0 0.8rem var(--paper);
}

.book-body h3 {
  font-size: clamp(1.6rem, 3.4vw, 2.5rem); font-weight: 400; font-style: italic;
  margin-bottom: 0.55rem;
}
.book-body p.book-meta {
  font-size: 0.7rem; letter-spacing: 0.19em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1.5rem; text-wrap: pretty;
  max-width: none;
}
.book-meta .sep, .si-meta .sep { opacity: .5; margin-inline: 0.5rem; }
.book-body p { color: var(--ink-soft); max-width: 52ch; }

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.9rem; }

.btn {
  --btn-fg: var(--ink);
  --btn-bg: transparent;
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--body); font-size: 0.7rem;
  letter-spacing: 0.17em; text-transform: uppercase; text-decoration: none;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid currentColor;
  padding: 0.78rem 1.4rem; border-radius: 999px;
  transition: color .3s var(--ease), background .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn-solid { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.btn-solid:hover { background: var(--accent); border-color: var(--accent); }
.btn-ghost:hover { color: var(--accent); }
.btn svg { width: 0.8rem; height: 0.8rem; flex: none; }
.btn-label { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .btn:hover { transform: none; } }

.btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.chev { transition: transform .3s var(--ease); }

/* ---------- 8b. Book pages ---------------------------------------------- */

.book-page { padding-top: clamp(2rem, 5vw, 3.5rem); }

.crumbs ol {
  list-style: none; margin: 0 0 clamp(2rem, 5vw, 3.25rem); padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.3rem 0;
  font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
}
.crumbs li + li::before { content: "/"; margin-inline: 0.7rem; opacity: 0.5; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs [aria-current="page"] { color: var(--ink-soft); }

.book-body h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.6rem); font-weight: 400; font-style: italic;
  margin-bottom: 0.7rem;
}
.book-part { margin-top: clamp(3.5rem, 8vw, 6rem); }
.book-part .subhead { margin-top: 0; }
.book-part .reviews + .article-list { margin-top: clamp(2rem, 4vw, 3rem); }
.book-part .shop-item h3 { margin-bottom: 0.2rem; }

a.book-cover { display: block; }
.book-body h3 a { text-decoration: none; }
.book-body h3 a:hover { color: var(--accent); }

/* ---------- 9. Image grid / masonry -------------------------------------- */

/* Row-order masonry: CSS grid gives left-to-right reading order (so book
   spreads stay in sequence); script.js packs the columns by giving every
   figure a row span. Without JS this degrades to a plain aligned grid. */
.grid {
  --col: 265px;
  --gap: clamp(0.9rem, 1.8vw, 1.5rem);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--col), 100%), 1fr));
  gap: var(--gap);
  align-items: start;
}
.grid.grid-wide  { --col: 340px; }
.grid.grid-tight { --col: 215px; }
.grid.is-masonry { grid-auto-rows: 1px; }

/* A twenty-spread book is nine screens of scrolling one-up on a phone. Two to
   a row halves that and quarters the bytes; the viewer is a tap away.
   Keep in sync with the `sizes` attributes in tools/build.py. */
@media (max-width: 560px) {
  .grid, .grid.grid-tight {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    --gap: 0.6rem;
  }
  .grid.grid-wide { grid-template-columns: minmax(0, 1fr); }
  .piece figcaption { font-size: 0.66rem; gap: 0 0.5rem; margin-top: 0.5rem; }
}

.piece {
  margin: 0;
  display: block; width: 100%;
  min-width: 0;
}
.piece-btn {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  display: block; width: 100%;
  text-align: left; cursor: zoom-in; color: inherit;
  border-radius: 2px;
}
.piece-frame {
  display: block;
  position: relative; overflow: hidden;
  background: var(--paper-3);
  border-radius: 2px;
  box-shadow: var(--shadow);
}
.piece-frame img {
  width: 100%;
  transition: transform .75s var(--ease), filter .5s var(--ease);
}
.piece-btn:hover .piece-frame img,
.piece-btn:focus-visible .piece-frame img { transform: scale(1.035); }
.piece-frame::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(60, 45, 25, .13);
  pointer-events: none;
}
:root[data-theme="dark"] .piece-frame::after { box-shadow: inset 0 0 0 1px rgba(240, 230, 210, .10); }
.piece figcaption {
  margin-top: 0.7rem;
  font-size: 0.72rem; letter-spacing: 0.06em; line-height: 1.55;
  color: var(--muted);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.1rem 1rem;
}
.piece figcaption .t { color: var(--ink-soft); min-width: 0; }
.piece figcaption .n { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .piece-btn:hover .piece-frame img { transform: none; } }

/* transparent-background pieces sit directly on the paper */
.piece.is-cutout .piece-frame { background: none; box-shadow: none; }
.piece.is-cutout .piece-frame::after { display: none; }

/* ---------- 9b. Illustrations tab ---------------------------------------- */
/* A few pictures from each book; the book's own page has the rest. */

.illus-group + .illus-group { margin-top: clamp(2.5rem, 5vw, 3.75rem); }
.illus-group .subhead { margin-top: 0; }
.illus-group .subhead h3 { font-style: italic; }
.illus-group .subhead a { text-decoration: none; }
.illus-group .subhead h3 a:hover { color: var(--accent); }
.illus-group .subhead .count:hover { color: var(--ink); }

/* ---------- 10. Murals note ---------------------------------------------- */

.note-card {
  border: 1px dashed var(--rule);
  border-radius: 3px;
  padding: clamp(2rem, 5vw, 3.5rem);
  max-width: 46rem;
  background: color-mix(in srgb, var(--card) 55%, transparent);
}
.note-card h3 { font-size: 1.35rem; font-style: italic; font-weight: 400; margin-bottom: 0.9rem; }
.note-card p { color: var(--muted); margin-bottom: 0; }

/* ---------- 10b. Events and visits --------------------------------------- */

.events {
  display: grid; gap: clamp(1.1rem, 2.2vw, 1.75rem);
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}
.event-card {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 3px;
  padding: clamp(1.6rem, 3vw, 2.35rem);
}
.event-card h3 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); font-style: italic; font-weight: 400; margin-bottom: 1rem; }
.event-card p { color: var(--ink-soft); }
.topics {
  list-style: none; margin: 1.3rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.topics li {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.4rem 0.85rem;
}
.topics li:last-child { border-style: dashed; color: var(--muted); }   /* "or suggest a theme" */
.events-cta {
  margin: clamp(2rem, 4vw, 2.75rem) 0 0;
  font-family: var(--display); font-style: italic;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem); line-height: 1.5;
}
.events-cta a { color: var(--accent); text-decoration-thickness: 1px; }

/* ---------- 11. Exhibitions ---------------------------------------------- */

.exhibition {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(1.75rem, 4.5vw, 4rem);
  align-items: start;
}
@media (max-width: 820px) { .exhibition { grid-template-columns: 1fr; } }
/* Tall images stay readable without turning into a screen and a half of
   scrolling. Keep the widths in step with `sizes` in tools/build.py. */
@media (max-width: 700px) { .exh-poster { max-width: 62%; margin-inline: auto; } }

.exh-poster { box-shadow: var(--shadow-lg); border-radius: 2px; overflow: hidden; }

.exh-title { font-size: clamp(1.75rem, 4vw, 2.7rem); font-weight: 400; font-style: italic; }
.exh-dates {
  margin: 1rem 0 1.9rem;
  font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent);
}
.exh-facts {
  margin: 2.2rem 0 0; padding: 1.6rem 0 0;
  border-top: 1px solid var(--rule);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1.4rem 2rem;
}
.exh-facts div { display: grid; gap: 0.35rem; }
.exh-facts dt { font-size: 0.63rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.exh-facts dd { margin: 0; font-size: 0.92rem; line-height: 1.6; }

/* ---------- 12. Features / press ----------------------------------------- */

.reviews { display: grid; gap: clamp(1.1rem, 2.2vw, 1.75rem); grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }

.review {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 3px;
  padding: clamp(1.6rem, 3vw, 2.35rem);
  display: flex; flex-direction: column; gap: 1.15rem;
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .4s var(--ease);
}
.review:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--rule); }
@media (prefers-reduced-motion: reduce) { .review:hover { transform: none; } }

.review .source {
  font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent);
}
.review .translated {
  color: var(--muted); text-transform: none; font-style: italic;
  letter-spacing: 0.02em; font-size: 0.78rem;
}
.review .translated::before { content: "· "; }
.review blockquote {
  margin: 0; font-family: var(--display); font-size: clamp(1rem, 1.5vw, 1.13rem);
  line-height: 1.6; color: var(--ink); font-style: italic;
}
.review blockquote::before { content: "“"; }
.review blockquote::after { content: "”"; }
.review .byline { font-size: 0.78rem; color: var(--muted); margin-top: auto; }
.review .byline a { color: var(--ink-soft); text-decoration-color: var(--rule); }
.review .byline a:hover { color: var(--accent); text-decoration-color: currentColor; }

.article-list { list-style: none; margin: 0; padding: 0; }
.article-list > li { border-top: 1px solid var(--rule-soft); }
.article-list > li:last-child { border-bottom: 1px solid var(--rule-soft); }

.article {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 2rem; align-items: start;
  padding: clamp(1.4rem, 2.6vw, 2rem) 0;
  text-decoration: none;
  transition: padding-inline .35s var(--ease), background .35s var(--ease);
}
.article:hover { background: color-mix(in srgb, var(--card) 70%, transparent); padding-inline: 1.1rem; }
.article .pub { font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); grid-column: 1 / -1; margin-bottom: 0.3rem; }
.article h3, .article h4 { font-size: clamp(1.05rem, 1.9vw, 1.35rem); font-weight: 400; line-height: 1.32; }
.article .meta { font-size: 0.78rem; color: var(--muted); grid-column: 1; margin-top: 0.45rem; }
.article .arrow { grid-row: 2; grid-column: 2; color: var(--muted); transition: transform .35s var(--ease), color .35s var(--ease); }
.article:hover .arrow { transform: translate(4px, -4px); color: var(--accent); }
.article svg { width: 1rem; height: 1rem; }
@media (prefers-reduced-motion: reduce) { .article:hover { padding-inline: 0; } .article:hover .arrow { transform: none; } }

.article-quote {
  grid-column: 1 / -1; margin: 0.9rem 0 0;
  font-family: var(--display); font-style: italic; font-size: 1.02rem;
  line-height: 1.62; color: var(--ink-soft);
  border-left: 2px solid var(--rule); padding-left: 1.15rem; max-width: 68ch;
}

/* ---------- 13. About ---------------------------------------------------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
@media (max-width: 880px) { .about { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .portrait { max-width: 70%; margin-inline: auto; } }

.about-text p { font-size: 1.04em; color: var(--ink-soft); max-width: 58ch; }
.about-text p:first-of-type::first-letter {
  font-family: var(--display); font-size: 3.6em; line-height: 0.82;
  float: left; padding: 0.06em 0.12em 0 0; color: var(--accent); font-weight: 500;
}

.portrait { position: relative; }
.portrait img { border-radius: 2px; box-shadow: var(--shadow-lg); width: 100%; }
.portrait figcaption {
  margin-top: 0.9rem; font-size: 0.7rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.piece.signing { max-width: 640px; margin-top: clamp(2.5rem, 5vw, 4rem); }

/* ---------- 14. Shop ----------------------------------------------------- */

.shop-list { display: grid; gap: clamp(1rem, 2vw, 1.5rem); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.shop-item {
  display: flex; gap: 1.25rem; align-items: center;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 3px;
  padding: 1.15rem; text-decoration: none;
  transition: transform .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
}
.shop-item:hover { transform: translateY(-3px); border-color: var(--rule); box-shadow: var(--shadow); }
.shop-item img { width: 4.6rem; flex: none; border-radius: 1px; box-shadow: var(--shadow); }
.shop-item .si-body { display: grid; gap: 0.3rem; }
.shop-item h3 { font-size: 1.02rem; font-weight: 400; font-style: italic; }
.shop-item .si-meta { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.shop-item .si-cta { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .shop-item:hover { transform: none; } }

/* ---------- 15. Contact -------------------------------------------------- */

.contact { text-align: center; }
.contact-quote {
  font-family: var(--display); font-style: italic;
  font-size: clamp(1.5rem, 4.2vw, 3rem); line-height: 1.34;
  font-weight: 400; max-width: 18ch; margin-inline: auto;
}
.contact-attrib {
  margin-top: 1.5rem; font-size: 0.7rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--muted);
}
.contact-links {
  margin-top: clamp(2.5rem, 5vw, 4rem);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem 1rem;
}

/* An address is read and copied letter for letter, so it keeps its case. */
.btn-email { text-transform: none; letter-spacing: 0.06em; font-size: 0.8rem; }

/* ---------- 16. Decorative vignettes ------------------------------------- */

.vignette {
  position: absolute; pointer-events: none; user-select: none;
  z-index: 0; opacity: .95;
  filter: drop-shadow(0 18px 26px rgba(60, 45, 25, .16));
  animation: drift 14s ease-in-out infinite;
}
:root[data-theme="dark"] .vignette { filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .5)); }
@keyframes drift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-14px) rotate(-1.6deg); }
}
.statement { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .vignette { animation: none; } }

.v-shell  { width: clamp(130px, 16vw, 250px); right: 5%; top: 4.5rem; animation-delay: -2s; }
.v-adder  { width: clamp(170px, 19vw, 300px); right: 5%; top: 5rem; animation-delay: -4s; }
.v-sprite { width: clamp(80px, 8vw, 125px);  right: 9%; top: 4.5rem; animation-delay: -6s; }
.v-puffer { width: clamp(160px, 22vw, 340px); right: 6%; top: 50%; translate: 0 -50%; animation-delay: -9s; }
@media (max-width: 1000px) { .vignette { display: none; } }

/* ---------- 17. Lightbox ------------------------------------------------- */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--paper) 96%, #000 4%);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  opacity: 0; visibility: hidden;
  transition: opacity .32s var(--ease), visibility .32s;
}
.lightbox[data-open="true"] { opacity: 1; visibility: visible; }
:root[data-theme="dark"] .lightbox { background: #0d0b08; }

.lb-bar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--rule-soft);
}
.lb-counter { font-size: 0.7rem; letter-spacing: 0.2em; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: auto; }

.lb-stage {
  /* explicit single definite track, so the image's max-height: 100% has
     something real to resolve against */
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  min-height: 0; position: relative;
  overflow: hidden;
}
.lb-stage img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  animation: lbin .4s var(--ease) both;
}
@keyframes lbin { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lb-stage img { animation: none; } }

.lb-nav {
  position: absolute; top: calc(50% + 0.5rem); translate: 0 -50%;
  width: 2.9rem; height: 2.9rem;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.lb-prev { left: clamp(0.4rem, 2vw, 1.5rem); }
.lb-next { right: clamp(0.4rem, 2vw, 1.5rem); }

.lb-caption {
  padding: 1rem clamp(1rem, 3vw, 2rem) 1.6rem;
  border-top: 1px solid var(--rule-soft);
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.2rem; align-items: baseline;
}

.lb-title { font-family: var(--display); font-style: italic; font-size: 1.1rem; }
.lb-sub { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

/* Locking the page while the viewer is open. iOS Safari ignores plain
   overflow:hidden on the body, hence the fixed position and the saved
   scroll offset that script.js puts back on close. */
body.lb-open {
  position: fixed; inset-inline: 0; width: 100%;
  overflow: hidden;
}

/* Pinch or double-tap to look closely; while zoomed the image is dragged
   rather than swiped, so the viewer does not skip to the next picture. */
.lb-stage img { touch-action: none; cursor: zoom-in; will-change: transform; }
.lb-stage img.is-zoomed { cursor: grab; }


/* On a phone the arrows sat on top of the artwork and the bars ate a fifth
   of the screen. The controls move into one compact row under the picture. */
@media (max-width: 700px) {
  .lb-bar { padding: 0.6rem clamp(0.75rem, 4vw, 1.25rem); }
  .lb-stage { padding: 0.5rem; }
  .lb-nav {
    position: static; translate: none;
    background: none; backdrop-filter: none;
  }
  .lb-caption {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center; gap: 0.15rem 0.9rem;
    padding: 0.5rem clamp(0.75rem, 4vw, 1.25rem) max(0.9rem, env(safe-area-inset-bottom));
  }
  .lb-caption .lb-prev { grid-row: 1 / span 2; grid-column: 1; }
  .lb-caption .lb-next { grid-row: 1 / span 2; grid-column: 3; }
  .lb-title { grid-column: 2; text-align: center; }
  .lb-sub { grid-column: 2; text-align: center; }
}

/* ---------- 18. Footer --------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: clamp(2.5rem, 5vw, 4rem);
  background: var(--paper-2);
}
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem;
  align-items: baseline; justify-content: space-between;
  font-size: 0.72rem; letter-spacing: 0.1em; color: var(--muted);
}
.footer-inner .fname { font-family: var(--display); font-size: 1rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); }
.footer-note { max-width: 42ch; line-height: 1.9; }

/* ---------- 19. Reveal on scroll ----------------------------------------- */

.reveal { opacity: 0; transform: translateY(22px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity .8s var(--ease), transform .8s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 20. Phones --------------------------------------------------- */
/* Near the end on purpose: these override the desktop rules above, which
   carry the same specificity and would otherwise win on source order. */

@media (max-width: 560px) {
  :root { --header-h: 3.9rem; }

  /* one scrolling row of tabs instead of two wrapped ones */
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--gutter);   /* or snapping eats the start padding */
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; scroll-snap-align: start; }
}

@media (max-width: 460px) {
  .header-inner { gap: 0.5rem; }
  .wordmark { font-size: 0.9rem; letter-spacing: 0.1em; }
  .lang > summary { padding-inline: 0.7rem; gap: 0; }
  .lang > summary svg { display: none; }
}

/* ---------- 21. Touch targets -------------------------------------------- */
/* Last in the file on purpose: these override the sizes set above, which are
   tuned for a mouse. Anything tapped rather than clicked gets ~44px. */

@media (pointer: coarse) {
  .icon-btn { width: 2.75rem; height: 2.75rem; }
  .lang > summary { height: 2.75rem; padding-inline: 0.9rem; }
  .lang-menu { padding: 0.4rem; }
  .lang-menu a { padding: 0.75rem 0.8rem; font-size: 0.88rem; }
  .tab { padding: 0.85rem 1.15rem; }
  .btn { padding: 0.92rem 1.5rem; }
  .nav a { padding-block: 0.95rem; }
  .wordmark { padding-block: 0.6rem; }
  .lb-nav { width: 2.9rem; height: 2.9rem; }
}
