/* ===== Design system ===== */
:root {
  --color-bg: #ffffff;
  --color-bg-muted: #f3f3f3;
  --color-text: #111111;
  --color-text-muted: #767676;
  --color-text-faint: #b3aea3;
  --color-accent: #d60000;
  --color-border: #e6e4e0;
  --color-focus: #1a73e8;
  --color-link: #1a73e8;

  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --fs-h1: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
  --fs-h2: 1.125rem;
  --fs-body: 1rem;
  --fs-small: 0.9375rem;
  --fs-xs: 0.8125rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --header-h: 72px;
  /* One layout column for header, content and footer: a side gutter, and a cap on the content width.
     --side-pad resolves against the full-width parent where it is used. */
  --gutter: clamp(16px, 5vw, 64px);
  --content-max: 1312px;
  --side-pad: max(var(--gutter), calc((100% - var(--content-max)) / 2));
  --radius: 2px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s var(--ease);
  --transition-base: 0.25s var(--ease);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 56px); }
body {
  margin: 0;
  font-family: var(--font-base);
  font-size: var(--fs-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 700; margin: 0 0 var(--space-4); letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, select { font-family: inherit; font-size: inherit; }

a, button, select, .work-card, .work-card-image img {
  transition: color var(--transition-fast), background-color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast),
    box-shadow var(--transition-fast);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

.button {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--color-text);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: var(--fs-small);
}
.button:hover { background: var(--color-text); color: var(--color-bg); }
.button:active { transform: scale(0.97); }
.button + .button { margin-left: var(--space-3); }

:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* Prevent a flash of the wrong language before assets/js/main.js applies translations */
html.i18n-pending [data-i18n] { visibility: hidden; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--side-pad);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  z-index: 30;
}
.site-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  line-height: 0;
}
.site-logo img { width: 40px; height: 40px; }
.site-logo:hover { transform: translate(-50%, -50%) scale(1.12); }

.nav-toggle {
  display: none;
  color: var(--color-text); /* iOS Safari paints button content blue by default */
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

.site-nav ul { display: flex; gap: var(--space-5); }
.site-nav a {
  font-size: var(--fs-small);
  color: var(--color-text);
  padding-bottom: 2px;
}
.site-nav a:hover { color: var(--color-accent); }
.site-nav a[aria-current="page"] {
  color: var(--color-accent);
  font-weight: 700;
}

.site-preferences { position: relative; }
.preferences-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-small);
  color: var(--color-text);
  padding: var(--space-2);
  border-radius: var(--radius);
}
.preferences-toggle:hover { background: var(--color-bg-muted); }
.preferences-toggle svg { width: 18px; height: 18px; display: block; }

.preferences-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 220px;
  z-index: 20;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--transition-base), transform var(--transition-base);
}
.preferences-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.preference-group { display: flex; flex-direction: column; gap: var(--space-1); }
.preference-group label { font-size: var(--fs-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.preference-group select {
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
}
.preference-group select:hover { border-color: var(--color-text); }

@media (max-width: 767px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
    z-index: 15;
  }
  .site-nav[data-collapsed="false"] { max-height: 260px; }
  .site-nav ul { flex-direction: column; gap: 0; padding: var(--space-2) var(--space-4) var(--space-4); }
  .site-nav a { display: block; padding: var(--space-3) 0; }
  .preferences-summary { display: none; }
}

/* ===== Hero ===== */
/* The slides sit in the layout column; the section spans the page so the arrows can sit in the gutters. */
.hero {
  position: relative;
  padding: 0 var(--side-pad);
}
.hero-slides {
  position: relative;
  width: 100%;
  aspect-ratio: 1.414 / 1; /* ISO paper (A-series), the format most works are painted on */
  max-height: calc(100vh - var(--header-h) - 4px);
  min-height: 220px;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}
.hero-slides:active { cursor: grabbing; }
.hero-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.55s var(--ease);
}
.hero-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

/* Thin chevrons in the side gutters (home hero, artwork page); red and bold on hover.
   The clickable area is the whole gutter, full height of the artwork. */
.edge-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--side-pad);
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.edge-arrow svg { width: 18px; height: 34px; overflow: visible; }
.edge-arrow path { fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; transition: stroke-width var(--transition-fast); }
.edge-arrow:hover { color: var(--color-accent); }
.edge-arrow:hover path { stroke-width: 2.5; }
.edge-arrow-prev { left: 0; }
.edge-arrow-next { right: 0; }
.edge-arrow-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 767px) {
  /* Phones: the slider fills the screen width and is swiped; no arrows. */
  .hero { padding: 0; }
  .hero .edge-arrow { display: none; }
}

/* Indicator bar under the hero — one equal segment per slide, red = active, grey = inactive,
   with a thin white line dividing each of the 4 segments (not a loading/progress animation). */
.hero-progress {
  display: flex;
  width: 100%;
  height: 4px;
  background: var(--color-bg);
  gap: 3px;
}
.hero-progress-segment {
  flex: 1 1 0;
  height: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--color-border);
}
.hero-progress-segment.is-active { background: var(--color-accent); }
.hero-progress-segment:not(.is-active):hover { background: var(--color-text-muted); }
.hero-progress-segment:active { opacity: 0.8; }

.nav-toggle:active, .preferences-toggle:active { transform: scale(0.94); }

/* ===== Main content width ===== */
main { display: block; }
.gallery-header, .gallery-grid-section, .work-detail, .work-not-found, .about-artist {
  padding-left: var(--side-pad);
  padding-right: var(--side-pad);
}

/* ===== Gallery ===== */
.gallery-header { padding-top: var(--space-6); }
.gallery-header h1 { font-size: var(--fs-h1); }

.series-tabs-wrap {
  position: sticky;
  top: var(--header-h);
  background: var(--color-bg);
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
}
.series-tabs {
  padding: 0 var(--side-pad);
  display: flex;
  gap: var(--space-5);
}
.series-tabs a {
  display: inline-block;
  padding: var(--space-3) 0;
  font-size: var(--fs-small);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.series-tabs a:hover { color: var(--color-text); }
.series-tabs a[aria-current="true"] { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 700; }

.gallery-status { padding: var(--space-6) var(--side-pad); color: var(--color-text-muted); }

/* Anchor offset for the sticky header + series tabs comes from scroll-padding-top on <html> alone;
   a scroll-margin here would add to it and land the heading ~128px too low. */
.series-section { padding-top: var(--space-6); }
.series-section h2 { font-size: var(--fs-h1); padding: 0 var(--side-pad); margin: 0 0 var(--space-5); }

.gallery-grid {
  padding: 0 var(--side-pad) var(--space-8);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}
@media (min-width: 600px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }

.work-card { display: block; color: var(--color-text); }
/* Grey frame (4:3) with a white mat inset by a fixed margin. The mat is positioned rather than
   sized with height: 100%, because Safari doesn't treat an aspect-ratio box's height as definite
   for percentage heights; the mat then overflowed and hid the grey frame top and bottom. */
.work-card-image {
  position: relative;
  background: var(--color-bg-muted);
  aspect-ratio: 4 / 3;
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.work-card-image-mat {
  position: absolute;
  inset: var(--space-5);
  background: var(--color-bg);
  padding: var(--space-3);
}
.work-card-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.work-card:hover .work-card-image img { transform: scale(1.035); }
.work-card h3 {
  font-size: var(--fs-small);
  font-weight: 700;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}
.work-card:hover h3 { color: var(--color-accent); }
.work-card p { margin: 0 0 2px; font-size: var(--fs-small); color: var(--color-text); line-height: 1.4; }
.work-card h3, .work-card p { padding: 0 var(--space-4); }
.work-card .work-card-price,
.work-card .work-card-sold { text-align: right; margin-top: var(--space-1); }
.work-card .work-card-price { color: var(--color-text-muted); }
.work-card .work-card-sold { color: var(--color-accent); font-weight: 600; }

/* ===== Work detail ===== */
/* Artwork flush left in a frame of fixed height (sized for A-paper landscape, capped by the screen),
   so the page, and the gutter arrows centred on it, keep the same geometry from work to work.
   Details sit in a narrow column on the right. */
.work-detail {
  position: relative;
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  column-gap: var(--space-7);
  align-items: start;
  /* cqw resolves against this element's content box (inside the side padding) in its children:
     the image column is that width minus the details column and the gap. */
  --art-h: min(calc(100vh - var(--header-h)), calc((100cqw - 250px - var(--space-7)) / 1.414));
}
.work-image { margin: 0; height: var(--art-h); display: flex; justify-content: flex-start; align-items: flex-start; touch-action: pan-y; overflow: hidden; }
/* Contain (never crop). */
/* The image box fills the frame; the artwork sits top-left inside it (object-fit/position), so the
   blurred placeholder behind it (background, same contain + position) covers exactly the same area. */
.work-image img { width: 100%; height: 100%; object-fit: contain; object-position: left top; }
.work-image img.lqip { background-position: left top; }
.work-detail .edge-arrow { bottom: auto; height: var(--art-h); }
.work-info { padding: var(--space-7) 0; }
.work-series { font-size: var(--fs-small); margin-bottom: var(--space-2); }
.work-series a { color: var(--color-text-muted); }
.work-series a:hover { color: var(--color-accent); }
.work-info h1 { font-size: clamp(1.5rem, 1.2rem + 0.8vw, 1.875rem); line-height: 1.15; margin-bottom: var(--space-5); }
.work-meta { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.work-meta dt { color: var(--color-text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.work-meta dd { margin: 0; font-size: var(--fs-small); }
.work-request {
  display: inline-block;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-link);
  text-decoration: underline;
}
.work-request:hover { color: var(--color-accent); }

/* Prev / next: on-page links and swipe only (no keyboard binding), by request.
   Phones, and tablets held upright (iPad portrait), get the stacked layout: full-width artwork,
   details and a Previous/Next row below. Keep in step with WORK_SIZES in works.js. */
@media (max-width: 767px), (max-width: 1100px) and (orientation: portrait) {
  .work-detail { grid-template-columns: 1fr; padding-bottom: var(--space-7); }
  /* Edge to edge: landscape pieces fill the width; tall pieces are capped so the piece and its
     title fit on one screen. */
  .work-image { height: auto; margin: 0 calc(-1 * var(--gutter)); justify-content: center; }
  .work-image img { height: auto; max-height: calc(100svh - var(--header-h) - 120px); object-position: center; }
  .work-image img.lqip { background-position: center; }
  .work-info { padding-top: var(--space-4); padding-bottom: 0; }
  .work-nav {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
  }
  .work-detail .edge-arrow { position: static; width: auto; height: auto; margin: 0; gap: var(--space-2); font-size: var(--fs-small); color: var(--color-text); }
  .work-detail .edge-arrow svg { width: 10px; height: 18px; }
  .work-detail .edge-arrow-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

.work-not-found { padding-top: var(--space-8); padding-bottom: var(--space-8); text-align: center; }

/* ===== Home intro ===== */
.home-intro { padding: var(--space-7) var(--side-pad) var(--space-6); }
.home-intro h1 { font-size: var(--fs-h1); }
.home-intro p { color: var(--color-text-muted); line-height: 1.7; }
.home-intro .home-links a { color: var(--color-text); text-decoration: underline; }
.home-intro .home-links a:hover { color: var(--color-accent); }

/* ===== About ===== */
/* Photo flush left, text on the right, like the artwork page. */
.about-artist {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--space-7);
  align-items: start;
}
.about-photo { margin: 0; }
.about-photo img { width: 100%; height: auto; max-height: calc(100vh - var(--header-h)); object-fit: cover; }
.about-text { padding: var(--space-7) 0 var(--space-8); max-width: 600px; }
.about-text h1 { font-size: clamp(1.5rem, 1.2rem + 0.8vw, 1.875rem); line-height: 1.15; margin-bottom: var(--space-5); }
.about-bio p { color: var(--color-text-muted); line-height: 1.7; }
@media (max-width: 767px) {
  .about-artist { grid-template-columns: 1fr; }
  .about-photo { margin: 0 calc(-1 * var(--gutter)); }
  .about-photo img { max-height: none; }
  .about-text { padding-top: var(--space-5); padding-bottom: var(--space-7); }
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-7) var(--side-pad) var(--space-6);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}
@media (min-width: 700px) { .site-footer { grid-template-columns: 1fr auto; } }
.site-footer h2 { font-size: var(--fs-h2); margin-bottom: var(--space-2); }
.footer-inquiries p { margin: 0; color: var(--color-text-muted); }
.footer-inquiries a { color: var(--color-text); text-decoration: underline; }
.footer-follow { justify-self: start; }
@media (min-width: 700px) { .footer-follow { justify-self: end; text-align: right; } }
.social-links { display: flex; gap: var(--space-3); }
@media (min-width: 700px) { .social-links { justify-content: flex-end; } }
.social-links a { display: flex; width: 28px; height: 28px; }
.social-links a:hover { transform: translateY(-2px); opacity: 0.85; }
.social-links svg { width: 100%; height: 100%; }
.footer-bottom {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.footer-copyright { color: var(--color-text-faint); font-size: var(--fs-xs); margin: 0; }
.footer-credit { color: var(--color-text-faint); font-size: var(--fs-xs); letter-spacing: 0.04em; }
.footer-credit:hover { color: var(--color-text-muted); }

/* ===== Blurred image previews =====
   Images built with a placeholder carry it as an inline background (class lqip). It shows until the
   image loads; main.js then adds is-loaded, which drops it. An image that had to wait sharpens from
   a blur instead of popping in; one already cached shows at once. */
.lqip { background-repeat: no-repeat; background-position: center; background-size: contain; }
.lqip.is-loaded { background-image: none !important; }
.lqip-wait.is-loaded { animation: lqip-sharpen 0.45s ease-out; }
@keyframes lqip-sharpen { from { filter: blur(10px); } to { filter: blur(0); } }
@media (prefers-reduced-motion: reduce) { .lqip-wait.is-loaded { animation: none; } }
