/* =====================================================================
   Ian Clements — a sheet of cold-pressed watercolour paper.
   Palette taken from the paintings: bare paper, ultramarine, Payne's grey,
   raw sienna, sap green, and one warm accent (the red of his seal).
   No rounded corners, no glass, no neon.
   Performance: grain, torn edges and washes are small pre-made images in
   /static/tex (built by build_assets.py) — no live SVG filters on scroll.
   ===================================================================== */
:root {
  --paper: #f3eee3;
  --sheet: #fbf8f1;
  --ink: #3a414a;          /* Payne's grey */
  --ink-soft: #5d646d;
  --pencil: #7a7266;
  --ultra: #27489a;        /* French ultramarine */
  --cerulean: #5e7fbd;
  --sienna: #c49a5a;       /* raw sienna */
  --sap: #8a9a3c;
  --red: #b8202b;          /* the seal */
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", "URW Palladio L", Georgia, serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --torn: url("/static/tex/sheet.png");
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  background: var(--paper) url("/static/tex/paper.jpg") repeat;
  font: 18px/1.65 var(--serif); font-feature-settings: "onum" 1, "liga" 1;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: rgba(39, 72, 154, .22); color: var(--ink); }
:focus-visible { outline: 2px dashed var(--ultra); outline-offset: 4px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.wrap { width: min(1180px, calc(100% - 48px)); margin-inline: auto; }
.skip-link { position: absolute; left: 16px; top: -80px; z-index: 50; background: var(--sheet); padding: 8px 14px; border: 1px solid var(--ink); }
.skip-link:focus { top: 12px; }

/* ---------- header: a pencilled line at the top of the sheet */
.site-header {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 22px 0 14px;
}
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 6' preserveAspectRatio='none'%3E%3Cpath d='M0 3.4 C120 2 240 4.6 380 3 C520 1.6 660 4.4 800 3.2 C880 2.6 940 3.8 1000 3' stroke='%233a414a' stroke-width='1.1' fill='none' opacity='.55'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.seal { width: 44px; height: 44px; clip-path: circle(48.5%); transform: rotate(-4deg); transition: transform .6s var(--ease); }
.brand:hover .seal { transform: rotate(6deg) scale(1.06); }
.brand-name { display: block; font-size: 25px; letter-spacing: .01em; line-height: 1.05; }
.brand-sub { display: block; font-style: italic; color: var(--pencil); font-size: 14.5px; }
.nav { display: flex; gap: 6px 26px; flex-wrap: wrap; }
.nav a { position: relative; text-decoration: none; font-size: 17px; padding: 4px 1px; color: var(--ink-soft); transition: color .3s; }
.nav a::after, .ink-link::after {
  content: ""; position: absolute; left: -2px; right: -2px; bottom: -2px; height: 7px; clip-path: inset(0 100% 0 0);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M2 5 C40 2.5 80 6.5 120 4 C150 2.6 175 5.5 198 3.5' stroke='%233a414a' stroke-width='2.2' fill='none' stroke-linecap='round' opacity='.8'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transition: clip-path .55s var(--ease);
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a:hover::after, .nav a[aria-current="page"]::after, .ink-link:hover::after { clip-path: inset(0 0 0 0); }

/* ---------- type */
h1, h2, h3 { font-weight: 400; letter-spacing: -.012em; margin: 0; color: var(--ink); }
.kicker { font-size: 13.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--sienna); margin: 0 0 10px; }
.lede { font-size: 21px; font-style: italic; color: var(--ink-soft); max-width: 660px; }
.pencil-line, .pencil { font-style: italic; color: var(--pencil); font-size: 15.5px; }
.charcoal-head { position: relative; display: inline-block; font-size: clamp(30px, 4vw, 46px); line-height: 1.12; padding-bottom: 12px; margin-bottom: 14px; }
.charcoal-head.big { font-size: clamp(38px, 6vw, 72px); }
.charcoal-head::after {
  content: ""; position: absolute; left: -4px; bottom: 0; width: min(100%, 420px); height: 11px; clip-path: inset(0 100% 0 0);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 12' preserveAspectRatio='none'%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3CfeDisplacementMap in='SourceGraphic' scale='3'/%3E%3C/filter%3E%3Cpath filter='url(%23c)' d='M3 7 C70 3.5 140 9 220 6 C290 3.6 340 8 397 5' stroke='%233a414a' stroke-width='3.4' fill='none' stroke-linecap='round' opacity='.75'/%3E%3C/svg%3E") left center / 100% 100% no-repeat;
  transition: clip-path 1.3s var(--ease) .25s;
}
.charcoal-head.is-visible::after, .is-visible .charcoal-head::after, html:not(.js) .charcoal-head::after { clip-path: inset(0 0 0 0); }
.note-text { font-size: 19px; color: var(--ink); max-width: 560px; }

/* ink link: a quick wash of ultramarine behind the words */
.ink-link { position: relative; display: inline-block; text-decoration: none; font-size: 19px; color: var(--ultra); margin-right: 26px; padding: 2px 4px; isolation: isolate; }
.ink-link::before {
  content: ""; position: absolute; inset: -8px -14px -6px -12px; z-index: -1; opacity: 0; transform: scale(.7) rotate(-2deg);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 70'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.03' numOctaves='3'/%3E%3CfeDisplacementMap in='SourceGraphic' scale='18'/%3E%3CfeGaussianBlur stdDeviation='1.5'/%3E%3C/filter%3E%3Cellipse filter='url(%23w)' cx='100' cy='36' rx='88' ry='24' fill='%235e7fbd' opacity='.28'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transition: opacity .5s var(--ease), transform .7s var(--ease);
}
.ink-link:hover::before { opacity: 1; transform: none; }
.ink-link.quiet { color: var(--ink-soft); }

/* ---------- reveal on scroll: settle onto the table (opacity/transform only = cheap) */
.js [data-reveal] { opacity: 0; transform: translateY(22px) rotate(var(--tilt, 0deg)); transition: opacity .9s var(--ease), transform 1.1s var(--ease); }
.js [data-reveal].is-visible { opacity: 1; transform: rotate(var(--tilt, 0deg)); }

/* ---------- torn sheet of paper (9-slice image, no filters) */
.sheet-paper {
  position: absolute; inset: -16px -16px -20px; pointer-events: none;
  border: 26px solid transparent; border-image: var(--torn) 52 fill round;
}

/* ---------- hero: the painting fills the whole screen (dark, dusk version of Loipe Engelberg) */
.hero { position: relative; height: 100vh; height: 100svh; min-height: 520px; overflow: hidden; background: #1b2232; color: var(--sheet); }
.hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 58%;
  -webkit-mask: url("/static/tex/blot.png") 46% 62% / 12% 12% no-repeat; mask: url("/static/tex/blot.png") 46% 62% / 12% 12% no-repeat;
  animation: bloomBig 2.2s var(--ease) .1s forwards;
}
.hero::after { /* soft dusk at the top (for the menu) and the bottom (for the words) */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(12, 16, 26, .55) 0%, rgba(12, 16, 26, 0) 22%, rgba(12, 16, 26, 0) 50%, rgba(12, 16, 26, .55) 100%);
}
@keyframes bloomBig {
  from { -webkit-mask-size: 12% 12%; mask-size: 12% 12%; }
  to { -webkit-mask-size: 560% 560%; mask-size: 560% 560%; }
}
.hero-img.bloomed { -webkit-mask: none; mask: none; animation: none; }
.hero-words { position: absolute; z-index: 2; left: max(28px, calc((100% - 1180px) / 2)); bottom: clamp(60px, 11vh, 120px); max-width: 640px; }
.hand-date { font-style: italic; color: rgba(251, 248, 241, .75); margin: 0 0 4px; font-size: 17px; }
.hero-title { font-size: clamp(58px, 9vw, 150px); line-height: .92; letter-spacing: -.035em; color: var(--sheet); text-shadow: 0 2px 30px rgba(10, 14, 22, .35); }
.hero-line { font-size: clamp(18px, 1.8vw, 22px); font-style: italic; color: rgba(251, 248, 241, .88); margin: 12px 0 18px; max-width: 480px; }
.hero .ink-link { color: var(--sheet); }
.hero .ink-link.quiet { color: rgba(251, 248, 241, .8); }
.hero .ink-link::after { filter: invert(1); }
.hero-words > * { opacity: 0; animation: inkIn 1.4s var(--ease) forwards; }
.hero-words > :nth-child(1) { animation-delay: .9s; }
.hero-words > :nth-child(2) { animation-delay: 1.05s; }
.hero-words > :nth-child(3) { animation-delay: 1.3s; }
.hero-words > :nth-child(4) { animation-delay: 1.5s; }
@keyframes inkIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hero-credit { position: absolute; z-index: 2; right: max(28px, calc((100% - 1180px) / 2)); bottom: 26px; font-style: italic; font-size: 14px; color: rgba(251, 248, 241, .7); text-decoration: none; }
.hero-credit:hover { color: var(--sheet); }
.hero-down { position: absolute; z-index: 2; left: 50%; bottom: 22px; transform: translateX(-50%); color: rgba(251, 248, 241, .75); text-decoration: none; font-size: 22px; animation: drift 2.6s ease-in-out infinite; }
@keyframes drift { 50% { transform: translate(-50%, 7px); } }

/* on the home page the menu floats over the painting */
.page-home .site-header { position: absolute; z-index: 10; top: 0; left: 0; right: 0; }
.page-home .site-header::after { filter: invert(1); opacity: .6; }
.page-home .brand-name, .page-home .nav a:hover, .page-home .nav a[aria-current="page"] { color: var(--sheet); }
.page-home .brand-sub, .page-home .nav a { color: rgba(251, 248, 241, .78); }
.page-home .nav a::after { filter: invert(1); }

/* the visit page keeps a framed painting on its sheet */
.hero-sheet { position: relative; padding: 16px 16px 20px; }
.hero-sheet .sheet-paper { inset: 0; }
.hero-sheet .hero-img { position: relative; inset: auto; height: min(46vh, 440px); min-height: 260px; object-position: 50% 50%; }

/* ---------- a painting on the table */
.sheet { position: relative; margin: 0 0 46px; padding: 16px 16px 20px; --tilt: 0deg; }
.sheet .sheet-paper { inset: 0; }
.sheet-link { display: block; position: relative; text-decoration: none; color: inherit; }
.sheet-art { position: relative; display: block; overflow: hidden; }
.sheet-art img { width: 100%; height: auto; transition: transform 1.2s var(--ease); }
.sheet-link:hover .sheet-art img { transform: scale(1.025); }
.sheet { transition: opacity .9s var(--ease), transform .8s var(--ease); }
.sheet:has(.sheet-link:hover) { transform: translateY(-4px) rotate(var(--tilt, 0deg)); }
/* the painting blooms out of the paper like a wet wash spreading (mask = one small image) */
.js .sheet .sheet-art { -webkit-mask: url("/static/tex/blot.png") var(--bx, 50%) var(--by, 50%) / 0% 0% no-repeat; mask: url("/static/tex/blot.png") var(--bx, 50%) var(--by, 50%) / 0% 0% no-repeat; }
.js .sheet.is-visible .sheet-art { animation: bloom 1.5s var(--ease) .1s forwards; }
.js .sheet.bloomed .sheet-art { -webkit-mask: none; mask: none; animation: none; }
@keyframes bloom {
  0% { -webkit-mask-size: 18% 18%; mask-size: 18% 18%; }
  100% { -webkit-mask-size: 520% 520%; mask-size: 520% 520%; }
}
.sheet figcaption { position: relative; margin-top: 10px; display: flex; flex-direction: column; gap: 1px; }
.sheet figcaption .t { font-style: normal; color: var(--ink); font-size: 17.5px; }
.sheet figcaption .m { font-size: 14px; }
.sheet.xl { margin-bottom: 0; }

/* gentle hand-laid tilts in the grids, so it looks placed, not gridded */
.salon > .sheet:nth-child(3n+1), .floor-item:nth-child(4n+1) .sheet { --tilt: -.5deg; }
.salon > .sheet:nth-child(3n+2), .floor-item:nth-child(4n+2) .sheet { --tilt: .35deg; }
.salon > .sheet:nth-child(3n), .floor-item:nth-child(4n+3) .sheet { --tilt: -.2deg; }

/* ---------- home sections */
.intro { padding: 100px 0 40px; }
.intro-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 48px; font-size: 20px; }
.intro-cols p:first-child { font-size: 25px; line-height: 1.45; font-style: italic; }
.featured { display: grid; grid-template-columns: 1.5fr 1fr; gap: 64px; align-items: center; padding: 70px 0; }
.featured .sheet { --tilt: -.6deg; }
.chapter { position: relative; padding: 70px 0 30px; isolation: isolate; }
.chapter-head { max-width: 720px; margin-bottom: 40px; }
.chapter-head p:not(.kicker) { font-size: 19.5px; color: var(--ink-soft); }
.salon { columns: 3 300px; column-gap: 46px; }
.salon.two { columns: 2 340px; }
.salon.three { columns: 3 260px; }
.salon > .sheet { break-inside: avoid; display: inline-block; width: 100%; }
.tide {
  position: absolute; z-index: -1; left: -8vw; right: -8vw; top: 30px; height: 70%; opacity: .5; pointer-events: none;
  background:
    radial-gradient(55% 50% at 22% 45%, rgba(94, 127, 189, .3), transparent 70%),
    radial-gradient(42% 46% at 72% 60%, rgba(196, 154, 90, .28), transparent 72%),
    radial-gradient(32% 36% at 52% 25%, rgba(138, 154, 60, .15), transparent 70%);
}
.charcoal-room::before {
  content: ""; position: absolute; z-index: -1; inset: 0 -6vw; opacity: .5; pointer-events: none;
  background: radial-gradient(48% 42% at 30% 55%, rgba(58, 65, 74, .16), transparent 70%), radial-gradient(38% 38% at 80% 40%, rgba(58, 65, 74, .1), transparent 70%);
}
.charcoal-room .sheet-art img { filter: grayscale(1) contrast(1.05); }

/* sketchbook strip: torn sheets laid out straight in a row */
.sketchbook { padding: 70px 0 30px; }
.strip { display: flex; gap: 30px; overflow-x: auto; padding: 22px max(24px, calc((100% - 1180px) / 2)) 30px; scroll-snap-type: x proximity; cursor: grab; scrollbar-width: thin; scrollbar-color: var(--sienna) transparent; }
.strip.dragging { cursor: grabbing; scroll-snap-type: none; }
.strip-item { position: relative; flex: none; width: 240px; scroll-snap-align: start; text-decoration: none; padding: 14px 14px 16px; transition: transform .5s var(--ease); }
.strip-item .sheet-paper { inset: 0; }
.strip-item:hover { transform: translateY(-5px); }
.strip-item img { position: relative; height: 170px; width: 100%; object-fit: cover; pointer-events: none; }
.strip-title { position: relative; display: block; margin-top: 9px; font-style: italic; font-size: 15px; color: var(--ink-soft); }
.strip-hint { margin-top: 0; }
.closing { padding: 70px 0 120px; text-align: center; }
.closing-text { font-size: clamp(22px, 2.6vw, 30px); font-style: italic; max-width: 760px; margin: 0 auto 18px; color: var(--ink-soft); }

/* ---------- gallery */
.page-head { padding: 80px 0 26px; }
.filters { display: flex; gap: 6px 20px; flex-wrap: wrap; align-items: baseline; padding-bottom: 40px; }
.filters button { position: relative; font: italic 18px var(--serif); color: var(--ink-soft); background: none; border: 0; padding: 4px 6px; cursor: pointer; isolation: isolate; }
.filters button::before {
  content: ""; position: absolute; inset: -4px -8px; z-index: -1; opacity: 0; transform: scale(.6);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 70'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.03' numOctaves='3'/%3E%3CfeDisplacementMap in='SourceGraphic' scale='16'/%3E%3C/filter%3E%3Cellipse filter='url(%23w)' cx='100' cy='36' rx='88' ry='26' fill='%23c49a5a' opacity='.35'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transition: .5s var(--ease);
}
.filters button[aria-pressed="true"] { color: var(--ink); }
.filters button[aria-pressed="true"]::before, .filters button:hover::before { opacity: 1; transform: none; }
.floor { columns: 4 250px; column-gap: 40px; padding-bottom: 80px; }
.floor-item { break-inside: avoid; display: inline-block; width: 100%; }
.floor-item.out { display: none; }
.empty-note { padding-bottom: 80px; }

/* ---------- story */
.story-row { display: grid; grid-template-columns: 1fr 1.1fr; gap: 70px; align-items: center; padding: 60px 0; }
.story-row.flip .story-text { order: 2; }
.story-text p:not(.chapter-no) { font-size: 19.5px; }
.chapter-no { font-size: 92px; line-height: .8; color: var(--sienna); opacity: .5; margin: 0 0 4px; font-style: italic; }
.process { padding: 60px 0; }
.steps { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 34px; }
.steps svg { width: 100%; height: 90px; display: block; margin-bottom: 10px; }
.steps .draw { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 2.2s var(--ease) .3s; }
.steps li.is-visible .draw, html:not(.js) .steps .draw { stroke-dashoffset: 0; }
.steps h3 { font-size: 24px; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--ink-soft); font-size: 17px; }
.story-end { padding: 60px 0 120px; text-align: center; }

/* ---------- artwork detail */
.easel { display: grid; grid-template-columns: 1.55fr 1fr; gap: 64px; align-items: start; padding: 60px 0 40px; }
.easel-art .sheet { --tilt: -.4deg; }
.easel-notes { position: sticky; top: 30px; }
.back { display: inline-block; margin-bottom: 26px; text-decoration: none; }
.back:hover { color: var(--ink); }
.mount-notes { margin: 24px 0; border-top: 1px solid rgba(58, 65, 74, .18); }
.mount-notes div { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid rgba(58, 65, 74, .12); }
.mount-notes dt { font-style: italic; color: var(--pencil); }
.mount-notes dd { margin: 0; }
.prevnext { display: flex; justify-content: space-between; gap: 16px; margin-top: 36px; }
.prevnext a { text-decoration: none; }
.prevnext a:hover { color: var(--ink); }

/* ---------- visit */
.visit-hero { padding-top: 30px; }
.visit-words { padding: 30px 0 10px; }
.letters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 50px; padding: 40px 0 120px; }
.letter p { font-size: 18.5px; }
.letter a:not(.ink-link) { color: var(--ultra); text-decoration-color: rgba(39, 72, 154, .35); text-underline-offset: 3px; }

/* ---------- footer: a wash of sky pooled at the bottom of the sheet (one pre-made image) */
.site-footer { position: relative; margin-top: 40px; padding: 170px 0 56px; color: var(--sheet); isolation: isolate; }
.footer-wash { position: absolute; inset: 0; z-index: -1; background: url("/static/tex/wash.webp") center bottom / 100% 100% no-repeat; }
.footer-inner { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.footer-line { font-size: clamp(22px, 2.6vw, 30px); font-style: italic; margin: 0 0 8px; }
.footer-small { font-size: 14.5px; opacity: .88; margin: 0; }
.footer-small a { color: var(--sheet); }

/* ---------- small screens */
@media (max-width: 900px) {
  body { font-size: 17px; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .intro-cols, .featured, .story-row, .easel, .letters { grid-template-columns: 1fr; gap: 30px; }
  .story-row.flip .story-text { order: 0; }
  .steps { grid-template-columns: 1fr 1fr; }
  .hero-img { object-position: 30% 60%; }
  .hero-words { left: 22px; right: 22px; bottom: 70px; }
  .hero-credit { display: none; }
  .page-home .site-header { padding-inline: 22px; width: 100%; }
  .easel-notes { position: static; }
  .intro { padding-top: 70px; }
}

/* ---------- people who prefer stillness get the finished page straight away */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .js .sheet .sheet-art, .hero-img { -webkit-mask: none !important; mask: none !important; }
  .js [data-reveal] { opacity: 1; transform: none; }
}
