/* ==========================================================================
   La Galería — Public stylesheet (index.php, artists.php, artist.php,
   gallery.php, artwork.php)

   Minimal high-end gallery theme: white background, black type, a single
   muted neutral for secondary text. Deliberately separate from the main
   cdlav.org site's dark "smoked glass" / teal-mustard-terracotta look — La
   Galería is its own identity now. Plain CSS, no preprocessor, no framework.
   Load once via header_public.php.

   This is NOT the admin theme (gallery-admin.css is a separate file).
   ========================================================================== */

:root {
  --color-bg: #ffffff;
  --color-bg-subtle: #f6f5f2;
  --color-fg: #111111;
  --color-muted: #6b6b6b;
  --color-border: #e2e0da;
  --color-border-strong: #111111;
  --color-accent: #d9442f;
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Inter', sans-serif;
  --transition: all 0.25s ease;
}

/* ---- Dark theme (?theme=dark, set via header_public.php's $theme /
   data-theme attribute — see gallery_theme_toggle_href()). Not a naive
   invert: near-black instead of pure #000 (less harsh, keeps shadow detail
   in artwork photos), soft off-white instead of pure #fff (avoids halation).
   Contrast checked against WCAG AA (4.5:1 for normal text):
     --color-fg #f2f2f2 on --color-bg #121212   -> ~16.7:1
     --color-muted #a3a3a3 on --color-bg #121212 -> ~7.4:1
     #d4d4d4 (bio/stat body text) on #121212     -> ~11.8:1
   Every component below (.btn-nav, .lang-toggle, .filter-chip, .empty-state,
   .artwork-image-area, etc.) already reads color through these custom
   properties, so overriding just the tokens re-themes the whole page —
   including the invert-on-hover/active interactions, which flip to solid
   white-on-dark automatically since they're built from var(--color-fg)/
   var(--color-bg) rather than hardcoded black/white. The lightbox
   (rgba(0,0,0,0.92) scrim + white close button) is intentionally NOT
   touched here — a dark viewing scrim is correct in both page themes. */
:root[data-theme="dark"] {
  --color-bg: #121212;
  --color-bg-subtle: #1e1e1e;
  --color-fg: #f2f2f2;
  --color-muted: #a3a3a3;
  --color-border: #2a2a2a;
  --color-border-strong: #f2f2f2;
  --color-accent: #ee5a43;
}

:root[data-theme="dark"] .artist-bio,
:root[data-theme="dark"] .stat-value {
  color: #d4d4d4;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-fg);
  overflow-x: hidden;
}

a { color: inherit; }

.page-wrapper { min-height: 100vh; }

/* ---- Flat bordered surface (the one reused frame for every panel) ------- */

.smoked-glass {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.card { padding: 2.5rem; margin-bottom: 2rem; }

.card h2, .card h3 {
  color: var(--color-fg);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 15px;
  margin-top: 0;
  font-family: var(--font-serif);
  font-weight: 400;
}

/* ---- Navbar: thin, static, print-catalog style --------------------------- */

.site-navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--color-bg);
  padding: 20px 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
}

/* Slim bar above the header linking to the parent organization's site. */
.parent-bar {
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  padding: 7px 5%;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.parent-bar a { color: var(--color-muted); text-decoration: none; }
.parent-bar a strong { color: var(--color-fg); font-weight: 600; }
.parent-bar a:hover, .parent-bar a:focus-visible { color: var(--color-fg); text-decoration: underline; }

.site-navbar .brand {
  margin: 0;
  color: var(--color-fg);
  font-family: var(--font-serif);
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

/* Wordmark: light lowercase geometric sans; the accented í is the one touch of color. */
.site-navbar .brand .brand-word {
  display: block;
  font-family: 'Montserrat', var(--font-sans);
  font-weight: 300;
  font-size: 1.85rem;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.site-navbar .brand .brand-accent { color: var(--color-accent); }

.site-navbar .brand .brand-tagline {
  display: block;
  font-size: 0.68rem;
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-muted);
  margin-top: 2px;
}

.nav-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.btn-nav {
  display: inline-block;
  color: var(--color-fg);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-nav:hover { background: var(--color-fg); color: var(--color-bg); }

.btn-nav.active { background: var(--color-fg); color: var(--color-bg); }

/* ---- EN/ES toggle + Light/Dark toggle (same pill component) -------------- */

.lang-toggle,
.theme-toggle {
  display: flex;
  border: 1px solid var(--color-border-strong);
  overflow: hidden;
}

.lang-toggle a,
.theme-toggle a {
  padding: 6px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--color-fg);
  text-decoration: none;
  transition: var(--transition);
}

.theme-toggle a { font-size: 0.9rem; line-height: 1; padding: 5px 12px; }

.lang-toggle a:not(.active):hover,
.theme-toggle a:not(.active):hover { background: var(--color-bg-subtle); }

.lang-toggle a.active,
.theme-toggle a.active { background: var(--color-fg); color: var(--color-bg); }

/* ---- Page hero / heading ------------------------------------------------- */

.page-hero { padding: 80px 5% 30px; text-align: center; overflow-x: clip; }

/* ---- Exhibition label ("Now on the Walls") --------------------------------
   With reduced motion: plain text. Otherwise a brush-bodied walker tows the
   letters into place (see the script in index.php), full size from 900px up
   and a smaller version on phones. The label stays hidden until that script
   has built it, so nothing flashes at its final position first. */

.page-eyebrow {
  display: block;
  font-family: var(--font-sans);
  font-size: clamp(14px, 3.45vw, 28.5px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-fg);
  margin-bottom: 18px;
}

.eyebrow-ch { display: inline-block; white-space: pre; }

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

@media (min-width: 900px) {
  .page-eyebrow { letter-spacing: 4px; }
}

@media (prefers-reduced-motion: no-preference) {
  .page-eyebrow { position: relative; height: 52px; white-space: nowrap; }
  .page-eyebrow:not(.is-walker) { visibility: hidden; }
  .page-eyebrow .c-line { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; }
  .page-eyebrow .c-layer {
    position: absolute; inset: 0; width: 100%; height: 100%;
    overflow: visible; pointer-events: none; color: var(--color-fg);
  }
}

@media (prefers-reduced-motion: no-preference) and (min-width: 900px) {
  .page-eyebrow { height: 70px; }
}

.page-hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 3rem;
  margin: 0 0 10px 0;
  letter-spacing: 0.5px;
}

.page-hero p {
  color: var(--color-muted);
  font-size: 1.05rem;
  max-width: 700px;
  margin: 0 auto;
}

main.page-main {
  max-width: 1200px;
  margin: 40px auto 80px;
  padding: 0 5%;
}

/* ---- Artist hero (photo + bio block); wraps to stacked under 700px ------ */

.artist-hero {
  padding: 3rem;
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

.artist-photo,
.artist-photo-empty {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 3 / 4;
  flex-shrink: 0;
  align-self: flex-start;
}

.artist-photo {
  object-fit: cover;
  border: 1px solid var(--color-border);
}

.artist-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  font-size: 3rem;
  color: var(--color-muted);
}

.artist-info { flex: 1; min-width: 280px; }

.artist-info h2 {
  font-size: 2.4rem;
  color: var(--color-fg);
  font-family: var(--font-serif);
  font-weight: 400;
  margin: 0 0 5px 0;
}

.artist-subtitle {
  margin: 0 0 20px 0;
  font-size: 0.85rem;
  color: var(--color-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.artist-bio {
  font-size: 1.05rem;
  line-height: 1.85;
  color: #333333;
  white-space: pre-wrap;
}

/* ---- Social link row ------------------------------------------------------ */

.social-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 25px; }

.social-link {
  padding: 8px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  text-decoration: none;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
  color: var(--color-fg);
}

.social-link:hover { background: var(--color-fg); color: var(--color-bg); }

/* ---- Artwork grid ---------------------------------------------------------
   Cards use object-fit: contain (not cover) inside a fixed-height image
   area — artwork aspect ratios vary far more than portrait photos, and
   cropping the actual art to fill a box is not acceptable here. Letterboxed
   space is filled by a very light neutral so it reads like a gallery wall. */

.artwork-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 3rem 2.5rem;
}

.artwork-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

.artwork-card:hover { border-color: var(--color-border-strong); }

.artwork-image-area {
  height: 320px;
  background: var(--color-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.artwork-image-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.artwork-image-empty {
  color: var(--color-border-strong);
  opacity: 0.3;
  font-size: 2.5rem;
}

.artwork-body {
  padding: 1.5rem 1.75rem 1.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  border-top: 1px solid var(--color-border);
}

.artwork-title {
  margin: 0 0 6px 0;
  color: var(--color-fg);
  font-size: 1.1rem;
  font-family: var(--font-serif);
  font-weight: 400;
}

.artwork-artist {
  font-size: 0.82rem;
  color: var(--color-muted);
  text-decoration: none;
  margin-bottom: 14px;
}

.artwork-artist:hover { color: var(--color-fg); }

.artwork-price {
  margin-top: auto;
  font-weight: 600;
  color: var(--color-fg);
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.artwork-price.sold { color: var(--color-muted); text-decoration: line-through; }

/* ---- Full-size image on artwork.php's detail page ------------------------ */

.artwork-detail-image {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
}

.artwork-detail-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

/* ---- Price / stat detail block ------------------------------------------- */

.detail-card { text-align: center; border-top: 2px solid var(--color-fg); }

.price-tag { font-size: 2.5rem; font-weight: 400; color: var(--color-fg); margin: 15px 0 5px 0; font-family: var(--font-serif); }
.price-sub { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; }
.price-context { font-size: 0.85rem; color: var(--color-muted); font-style: italic; margin-bottom: 20px; }

.stat-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--color-border); padding: 15px 0; font-size: 0.95rem; text-align: left; }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-weight: 600; color: var(--color-fg); text-transform: uppercase; font-size: 0.78rem; letter-spacing: 1px; }
.stat-value { text-align: right; color: #333333; }

/* ---- Filter chips (gallery.php category/medium filters) — plain <a>
   links with query strings, full-page GET reload. No JS: a small,
   low-traffic gallery doesn't need an HTMX partial-swap for this. --------- */

.filter-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 2.5rem; }

.filter-chip {
  background: var(--color-bg);
  color: var(--color-fg);
  border: 1px solid var(--color-border-strong);
  padding: 8px 18px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: var(--transition);
}

.filter-chip:hover { background: var(--color-bg-subtle); }

.filter-chip.active { background: var(--color-fg); color: var(--color-bg); border-color: var(--color-fg); font-weight: 600; }

/* ---- Empty states — never a placeholder image URL; always a styled,
   on-brand message/box instead. ---------------------------------------- */

.empty-state {
  text-align: center;
  color: var(--color-muted);
  font-style: italic;
  padding: 80px 40px;
  background: var(--color-bg-subtle);
  border: 1px dashed var(--color-border-strong);
}

.empty-state h3 {
  font-style: normal;
  color: var(--color-fg);
  font-family: var(--font-serif);
  font-weight: 400;
  margin-top: 0;
}

/* ---- Footer ---------------------------------------------------------------- */

.site-footer {
  text-align: center;
  padding: 40px 5% 60px;
  color: var(--color-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--color-border);
  margin-top: 60px;
}

.visit-us { margin-bottom: 32px; }
.visit-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--color-fg);
  margin: 0 0 18px;
}
.visit-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px 56px; font-size: 0.95rem; line-height: 1.6; }
.visit-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-muted);
}
.visit-grid a { color: var(--color-fg); text-underline-offset: 3px; }

/* ---- Full-screen lightbox (artwork.php main image) ------------------------
   Vanilla JS toggles .is-open (fit-to-screen) and .is-zoomed (true native
   size, scrollable); see the <script> at the bottom of artwork.php. Dark
   scrim reads best for focusing on art against this page's light theme. --- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}

.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  cursor: zoom-in;
}

/* Second click stage: true full-size image, scrollable to inspect detail.
   Switches the container to scrollable/top-left-anchored so panning to
   every corner is predictable, and drops the 95vw/95vh cap so the image
   renders at its real pixel dimensions (usually larger than the viewport). */
.lightbox.is-zoomed {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
}

.lightbox.is-zoomed img {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  cursor: zoom-out;
  margin: auto;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: #ffffff;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-sans);
  padding: 10px;
}

/* ---- Responsive ----------------------------------------------------------- */

@media (max-width: 700px) {
  .site-navbar { padding: 14px 4%; }
  .page-hero h1 { font-size: 2.1rem; }
  .artist-hero { flex-direction: column; padding: 1.75rem; }
  .artist-photo, .artist-photo-empty { max-width: 200px; margin: 0 auto; }
  .artist-info { text-align: center; }
  .social-bar { justify-content: center; }
  .card { padding: 1.5rem; }
  .artwork-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.5rem 1rem; }
  .artwork-image-area { height: 180px; }
  .artwork-detail-image { max-width: 100%; }
}

/* ---- Homepage carousel (public/assets/js/gallery-carousel.js) ------------------
   Without JS this is a plain scrolling strip of links; the script sizes and tilts the items. */

.cf-stage { position: relative; margin: 0 auto 10px; max-width: 1240px; padding: 0 2%; }
.cf-wrap { position: relative; }
.cf {
  display: flex; align-items: center; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding-block: 28px;
}
.cf::-webkit-scrollbar { display: none; }
.cf:focus-visible { outline: 2px solid var(--color-fg); outline-offset: 2px; }
.cf-stage.is-live .cf { cursor: grab; }
.cf-stage.is-live .cf.dragging { cursor: grabbing; }
.cf-item {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center; scroll-snap-align: center;
  position: relative; padding: 0 10px; box-sizing: border-box;
  will-change: transform, opacity; -webkit-tap-highlight-color: transparent; user-select: none;
}
.cf-stage.is-live .cf-item { padding: 0; }
.cf-item img {
  flex: none; display: block; max-height: 320px; width: auto; height: auto; background: var(--color-bg-subtle);
  box-shadow: 0 14px 26px -14px rgba(0, 0, 0, .35); -webkit-user-drag: none;
}
.cf-item.is-center img { box-shadow: 0 22px 40px -16px rgba(0, 0, 0, .4); }
.cf-nav, .cf-step { display: none; }
.cf-stage.is-live .cf-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--color-border); background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  color: var(--color-fg); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 200;
}
.cf-nav:hover { border-color: var(--color-fg); }
.cf-nav.prev { left: 4px; } .cf-nav.next { right: 4px; }
.cf-nav svg, .cf-step svg { width: 18px; height: 18px; }
.cf-stage.narrow .cf-nav { display: none; }   /* phones swipe; the arrows would sit on the peeking neighbours */
.cf-controls { display: none; justify-content: center; align-items: center; gap: 18px; margin-top: 4px; }
.cf-stage.is-live .cf-controls { display: flex; }
.cf-count { text-align: center; color: var(--color-muted); font-size: 12px; letter-spacing: 1.5px; font-variant-numeric: tabular-nums; min-width: 64px; }
.cf-stage.is-live.narrow .cf-step {
  display: inline-flex; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--color-border);
  background: var(--color-bg); color: var(--color-fg); cursor: pointer; align-items: center; justify-content: center;
}

/* ---- Artist bio: clamped to a few lines, expanded by a button (added by index.php's script) ---- */

.artist-bio.is-clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.bio-toggle {
  margin-top: 10px; padding: 0; background: none; border: 0; border-bottom: 1px solid currentColor;
  font: inherit; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.3px; color: var(--color-fg); cursor: pointer;
}
