/* ==========================================================================
   Madhu Dhanuka Jain — gallery site
   Palette sampled from the paintings themselves: ultramarine, burnt sienna,
   vermilion, ochre, sage, and the warm impasto whites of raw canvas.
   No external fonts or assets — everything here is self-contained.
   ========================================================================== */

:root {
  /* light: a gallery wall / unprimed linen, never clinical white */
  --paper:      #F6F2E9;
  --paper-2:    #EFE9DB;
  --paper-3:    #E5DCC9;
  --ink:        #1A1512;
  --ink-soft:   #4B4239;
  --muted:      #8A7D70;
  --rule:       #DBD1BE;

  /* pulled straight from the canvases */
  --vermilion:  #BF4526;
  --ultramarine:#26417C;
  --ochre:      #B98622;
  --sage:       #77896C;

  --accent:     var(--vermilion);

  --measure:    68ch;
  --gutter:     clamp(1.25rem, 4vw, 4.5rem);
  --radius:     2px;          /* paintings have corners, not pills */

  --ease:       cubic-bezier(.2, .7, .2, 1);
  --shadow-art: 0 1px 2px rgba(26,21,18,.10), 0 12px 32px -12px rgba(26,21,18,.28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #14100E;
    --paper-2:  #1C1715;
    --paper-3:  #262019;
    --ink:      #F3EDE2;
    --ink-soft: #C3B8A8;
    --muted:    #8E8375;
    --rule:     #302823;
    --vermilion:#E4653F;
    --ultramarine:#7A9AD8;
    --ochre:    #D9A63C;
    --shadow-art: 0 1px 2px rgba(0,0,0,.5), 0 18px 44px -14px rgba(0,0,0,.7);
  }
}
/* the viewer's explicit choice must win in both directions */
:root[data-theme="light"] {
  --paper:#F6F2E9; --paper-2:#EFE9DB; --paper-3:#E5DCC9;
  --ink:#1A1512; --ink-soft:#4B4239; --muted:#8A7D70; --rule:#DBD1BE;
  --vermilion:#BF4526; --ultramarine:#26417C; --ochre:#B98622;
  --shadow-art: 0 1px 2px rgba(26,21,18,.10), 0 12px 32px -12px rgba(26,21,18,.28);
}
:root[data-theme="dark"] {
  --paper:#14100E; --paper-2:#1C1715; --paper-3:#262019;
  --ink:#F3EDE2; --ink-soft:#C3B8A8; --muted:#8E8375; --rule:#302823;
  --vermilion:#E4653F; --ultramarine:#7A9AD8; --ochre:#D9A63C;
  --shadow-art: 0 1px 2px rgba(0,0,0,.5), 0 18px 44px -14px rgba(0,0,0,.7);
}

/* --- type ---------------------------------------------------------------- */
/* Palatino/Iowan give an editorial, catalogue-raisonné feel and ship with
   Windows and macOS respectively, so no webfont request is needed. */
:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
           "URW Palladio L", Georgia, serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
           Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, .35vw + .95rem, 1.075rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .display {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -.015em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.5rem, 7vw, 5.5rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3rem); }
h3 { font-size: clamp(1.15rem, 1.6vw, 1.4rem); }

p { margin: 0 0 1.2em; max-width: var(--measure); }

a { color: inherit; text-decoration: none; }

/* label: the small tracked caps used for section eyebrows and metadata */
.label {
  font-family: var(--sans);
  font-size: .70rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 1.9vw, 1.6rem);
  line-height: 1.5;
  color: var(--ink-soft);
  letter-spacing: -.01em;
}

/* --- layout -------------------------------------------------------------- */
.wrap { width: 100%; max-width: 1560px; margin-inline: auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.section { padding-block: clamp(4rem, 9vw, 9rem); }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* --- header -------------------------------------------------------------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.site-head[data-scrolled="true"] { border-bottom-color: var(--rule); }

.site-head__inner {
  display: flex; align-items: center; gap: 1.5rem;
  min-height: 4.5rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.28rem;
  letter-spacing: .005em;
  white-space: nowrap;
  margin-right: auto;
}
.brand span { color: var(--muted); }

.nav { display: flex; align-items: center; gap: clamp(.9rem, 2vw, 2rem); }
.nav a {
  font-size: .82rem; letter-spacing: .04em;
  color: var(--ink-soft);
  padding-block: .4rem;
  position: relative;
  transition: color .25s var(--ease);
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: .1rem;
  height: 1px; background: var(--accent);
  transition: right .35s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after,
.nav a[aria-current="page"]::after { right: 0; }
.nav a[aria-current="page"] { color: var(--ink); }

.icon-btn {
  display: grid; place-items: center;
  width: 2.3rem; height: 2.3rem;
  border: 1px solid var(--rule); border-radius: 50%;
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.6; }

.nav-toggle { display: none; }

@media (max-width: 800px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed; inset: 4.5rem 0 auto;
    flex-direction: column; align-items: flex-start; gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: .5rem var(--gutter) 1.75rem;
    transform: translateY(-130%);
    transition: transform .45s var(--ease);
    max-height: calc(100vh - 4.5rem); overflow-y: auto;
  }
  .nav[data-open="true"] { transform: translateY(0); }
  .nav a { font-size: 1.35rem; font-family: var(--serif); padding-block: .6rem; width: 100%; }
  .nav a::after { display: none; }
}

/* --- hero ---------------------------------------------------------------- */
.hero { position: relative; }
.hero__media {
  position: relative;
  height: clamp(26rem, 82vh, 54rem);
  overflow: hidden;
  background: var(--paper-3);
}
.hero__media img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 38%;
  display: block;
  /* let the canvas colour bleed rather than sit in a hard box */
  transform: scale(1.03);
}
.hero__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(
    to bottom,
    color-mix(in oklab, var(--paper) 30%, transparent) 0%,
    transparent 28%,
    transparent 45%,
    color-mix(in oklab, var(--paper) 92%, transparent) 100%);
}
.hero__caption {
  position: absolute; left: 0; right: 0; bottom: clamp(2rem, 6vw, 4.5rem);
  z-index: 2;
}
.hero h1 { max-width: 20ch; }
.hero__sub {
  margin-top: 1.1rem;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(1.05rem, 1.6vw, 1.4rem);
  color: var(--ink-soft);
}
.hero__credit {
  margin-top: 1.6rem;
  font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}

/* --- gallery grid -------------------------------------------------------- */
/* CSS columns give a true masonry flow, so tall and wide canvases sit
   together without being cropped to a common aspect ratio. */
.grid {
  columns: 4 300px;
  column-gap: clamp(.85rem, 1.6vw, 1.6rem);
}
.grid--wide { columns: 3 380px; }

.card {
  break-inside: avoid;
  margin-bottom: clamp(.85rem, 1.6vw, 1.6rem);
  display: block;
  cursor: zoom-in;
}
.card__frame {
  position: relative;
  overflow: hidden;
  background: var(--paper-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-art);
}
.card__frame img {
  display: block; width: 100%; height: auto;
  transition: transform .9s var(--ease), filter .6s var(--ease);
  will-change: transform;
}
.card:hover .card__frame img { transform: scale(1.045); }
.card__frame::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 9%, transparent);
  border-radius: var(--radius);
  pointer-events: none;
}
.card__meta {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .7rem .1rem 0;
}
.card__title {
  font-family: var(--serif); font-size: 1rem; line-height: 1.3;
  color: var(--ink);
}
.card__dim { font-size: .76rem; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* --- reveal on scroll ---------------------------------------------------- */
/* Scoped to .js, which an inline script in <head> adds. With JS off or broken,
   the artwork is simply visible — never a blank page waiting on a script. */
.js .reveal { opacity: 0; transform: translateY(18px); }
.js .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity .85s var(--ease), transform .85s var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal, .js .reveal.is-in { opacity: 1; transform: none; transition: none; }
  .card__frame img, .card:hover .card__frame img { transition: none; transform: none; }
  .hero__media img { transform: none; }
}

/* --- collection teasers -------------------------------------------------- */
.collections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: clamp(1rem, 2vw, 2rem);
}
.teaser { display: block; group: none; }
.teaser__frame {
  position: relative; overflow: hidden; border-radius: var(--radius);
  aspect-ratio: 4 / 5; background: var(--paper-3);
  box-shadow: var(--shadow-art);
}
.teaser__frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 1s var(--ease);
}
.teaser:hover .teaser__frame img { transform: scale(1.06); }
.teaser__frame::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top,
    color-mix(in oklab, #14100E 78%, transparent) 0%,
    transparent 55%);
}
.teaser__text {
  position: absolute; left: 0; bottom: 0; z-index: 2;
  padding: 1.4rem;
  color: #F6F2E9;
}
.teaser__text h3 { color: inherit; }
.teaser__count {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  opacity: .78; margin-top: .35rem;
}

/* --- statement / prose --------------------------------------------------- */
.prose { font-size: 1.06rem; }
.prose h2 { margin: 2.4em 0 .7em; }
.prose h3 { margin: 2em 0 .5em; font-family: var(--sans); font-size: .78rem;
            letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.prose p { color: var(--ink-soft); }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: .18em;
           text-decoration-thickness: 1px; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose ul { padding-left: 1.1rem; color: var(--ink-soft); }

/* drop cap for the opening statement — a nod to catalogue typography */
.prose--lead > p:first-of-type::first-letter {
  float: left;
  font-family: var(--serif);
  font-size: 3.9em;
  line-height: .82;
  padding: .06em .1em 0 0;
  color: var(--accent);
}

/* --- CV list ------------------------------------------------------------- */
.cv { display: grid; gap: clamp(2rem, 4vw, 3.5rem); }
@media (min-width: 900px) { .cv { grid-template-columns: repeat(2, 1fr); } }
.cv__block h3 {
  font-family: var(--sans); font-size: .72rem; letter-spacing: .17em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: .7rem; margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}
.cv__block p, .cv__block li { color: var(--ink-soft); font-size: .96rem; }

/* --- lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  background: color-mix(in oklab, #0D0A08 94%, transparent);
  backdrop-filter: blur(6px);
}
.lightbox[data-open="true"] {
  display: grid;
  /* minmax(0, 1fr) is load-bearing. A bare "1fr" is minmax(auto, 1fr), and that
     auto minimum is the image's *intrinsic* height — so a 700x1400 canvas forces
     the row taller than the screen, max-height:100% never resolves, and the
     bottom of the painting is cut off. Pinning the minimum to 0 lets the row be
     bounded by the viewport, which is what makes max-height:100% work below. */
  grid-template-rows: minmax(0, 1fr) auto;
  /* dvh so a mobile browser's collapsing address bar can't clip the artwork */
  height: 100dvh;
}
.lightbox__stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;            /* the flex item must be allowed to shrink */
  /* Vertical padding kept tight on purpose: every pixel here is height taken
     away from a tall canvas, which is the case that needs it most. */
  padding: clamp(.75rem, 2vw, 1.5rem) clamp(3.2rem, 8vw, 6rem) clamp(.4rem, 1vw, .75rem);
}
.lightbox__stage img {
  display: block;
  /* width/height auto + max-* means the box hugs the artwork, so the shadow
     traces the painting itself rather than an invisible letterbox. */
  width: auto; height: auto;
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  border-radius: var(--radius);
  animation: lb-in .45s var(--ease);
}
/* Older engines that mis-resolve the percentage still get a viewport-bounded
   cap, so the whole work stays visible even if max-height:100% is ignored. */
@supports not (height: 100dvh) {
  .lightbox__stage img { max-height: calc(100vh - 11rem); }
}
@keyframes lb-in { from { opacity: 0; transform: scale(.975); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .lightbox__stage img { animation: none; } }

.lightbox__bar {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  padding: .7rem clamp(1rem, 4vw, 3.5rem) clamp(.8rem, 2vw, 1.2rem);
  color: #EDE6DA;
}
.lightbox__title { font-family: var(--serif); font-size: 1.15rem; }
.lightbox__dim { font-size: .82rem; opacity: .68; }
.lightbox__count { margin-left: auto; font-size: .75rem; letter-spacing: .14em; opacity: .6; }

.lightbox button {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 2.9rem; height: 2.9rem;
  display: grid; place-items: center;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  color: #EDE6DA; cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.lightbox button:hover { background: rgba(255,255,255,.16); }
.lightbox button:active { transform: translateY(-50%) scale(.93); }
.lightbox__prev { left: clamp(.5rem, 2vw, 1.5rem); }
.lightbox__next { right: clamp(.5rem, 2vw, 1.5rem); }
.lightbox__close { top: clamp(.9rem, 2vw, 1.6rem); right: clamp(.5rem, 2vw, 1.5rem); translate: 0; }
.lightbox button svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.7; }

@media (max-width: 640px) {
  /* The two arrows cost ~100px of a 375px screen. Swiping is already wired up
     on touch, so drop them and give the width back to the painting.
     Note the "button" in the selector: ".lightbox button" above is specificity
     (0,1,1) and sets display:grid, so a bare ".lightbox__prev" (0,1,0) would
     lose — a media query adds no specificity of its own. */
  .lightbox button.lightbox__prev,
  .lightbox button.lightbox__next { display: none; }
  .lightbox__stage { padding-inline: .75rem; }
}

body[data-lb-open="true"] { overflow: hidden; }

/* --- footer -------------------------------------------------------------- */
.site-foot {
  border-top: 1px solid var(--rule);
  padding-block: clamp(3rem, 6vw, 5rem);
  background: var(--paper-2);
}
.foot-grid {
  display: grid; gap: 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}
.foot-grid h4 {
  font-size: .72rem; letter-spacing: .17em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .9rem; font-weight: 600;
}
.foot-grid a { color: var(--ink-soft); font-size: .93rem; display: block; padding-block: .22rem; }
.foot-grid a:hover { color: var(--accent); }
.foot-bottom {
  display: flex; flex-wrap: wrap; gap: .6rem 1.5rem;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: .8rem; color: var(--muted);
}
.foot-bottom p { margin: 0; }

/* --- page header -------------------------------------------------------- */
.page-head { padding-block: clamp(3rem, 7vw, 6rem) clamp(1.75rem, 4vw, 3rem); }
.page-head h1 { max-width: 22ch; }
.page-head .lede { margin-top: 1.2rem; }
.page-head__count { margin-top: 1.4rem; }

/* --- small helpers ------------------------------------------------------- */
/* These exist as classes rather than inline style="" attributes so the site
   can ship a Content-Security-Policy without 'unsafe-inline' for styles. */
.section-title { margin: .6rem 0 2.5rem; }
.section-title--narrow { max-width: 24ch; }

.link-more {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
}
.link-more:hover { text-decoration-thickness: 2px; }

.after-grid { margin-top: 2.5rem; }

.foot-note { color: var(--ink-soft); font-size: .93rem; margin: 0; }

.portrait { max-width: 24rem; margin-bottom: 3rem; }

/* --- utilities ----------------------------------------------------------- */
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper);
  padding: .7rem 1.1rem; z-index: 200;
}
.skip:focus { left: .5rem; top: .5rem; }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden;
      clip: rect(0 0 0 0); white-space: nowrap; }
