/* ============================================================
   RICHGALLERY.ART — Main Stylesheet
   Cormorant Garamond (serif) + system-ui (UI elements)
   Mobile-first, vanilla CSS
   ============================================================ */

/* ---- Custom Properties ---- */
:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-light: #6b6b6b;
  --color-border: #e5e5e5;
  --color-overlay: rgba(0, 0, 0, 0.92);
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --max-width: 1400px;
  --grid-gap: 12px;
  --nav-height: 60px;
  --transition-fast: 200ms ease;
  --transition-normal: 300ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  line-height: 1.6;
  min-height: 100vh;
}

body.lightbox-open {
  overflow: hidden;
}

img, video {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

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

ul {
  list-style: none;
}

/* ---- Focus Styles ---- */
:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

/* ---- Container ---- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
}

.nav-links {
  display: flex;
  gap: 32px;
  align-items: center;
}

.nav-links a {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-light);
  transition: color var(--transition-fast);
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--color-text);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 28px;
  height: 28px;
  padding: 8px 4px;
  flex-shrink: 0;
  box-sizing: content-box;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* Mobile nav open state */
.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Page offset for fixed nav */
.page-body {
  padding-top: var(--nav-height);
}

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-body {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}

.home-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  text-align: center;
}

.signature-link {
  display: block;
  line-height: 1;
}

.signature-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  font-weight: 400;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.1;
  transition: opacity var(--transition-normal);
}

.signature-link:hover .signature-text {
  opacity: 0.6;
}

.enter-link {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-light);
  transition: color var(--transition-fast), letter-spacing var(--transition-normal);
}

.enter-link:hover {
  color: var(--color-text);
  letter-spacing: 0.3em;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar-wrap {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.filter-bar {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-light);
  padding: 16px 16px;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--color-text);
}

.filter-btn.is-active {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
}

/* ============================================================
   ARTWORKS GRID
   ============================================================ */
.gallery-section {
  padding: 24px 0 60px;
}

.artworks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 12px;
}

/* Artwork Card */
.artwork-card {
  cursor: pointer;
  overflow: hidden;
  background: #f4f4f2;
}

.artwork-card figure {
  /* 2 artworks per screen: half viewport minus nav + filter bar + gap */
  height: calc(50vh - 60px);
  overflow: hidden;
}

.artwork-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms ease, opacity var(--transition-normal);
  opacity: 0;
}

.artwork-card img.loaded {
  opacity: 1;
}

.artwork-card:hover img {
  transform: scale(1.03);
}

/* Fade-in on scroll */
.fade-item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms ease, transform 500ms ease;
}

.fade-item.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Filtered-out state */
.artwork-card.is-hidden {
  display: none;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: stretch;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

#lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-overlay);
}

.lb-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Close button */
.lb-close {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.7);
  transition: color var(--transition-fast);
  z-index: 10;
  line-height: 1;
}

.lb-close:hover {
  color: #ffffff;
}

/* Media wrap */
.lb-media-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 50vh;
  padding: 56px 8px 8px;
}

.lb-media {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: calc(100vh - 200px);
}

.lb-image {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  object-fit: contain;
  cursor: zoom-in;
  transition: transform var(--transition-normal);
  transform-origin: center center;
  user-select: none;
}

.lb-image.is-zoomed {
  transform: scale(1.8);
  cursor: zoom-out;
}

.lb-video {
  max-width: 100%;
  max-height: calc(100vh - 200px);
}

/* Nav arrows */
.lb-prev,
.lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3.2rem;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.08);
  width: 56px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
  z-index: 5;
}

.lb-prev { left: 0; }
.lb-next { right: 0; }

.lb-prev:hover,
.lb-next:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

/* Dots */
.lb-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.lb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.lb-dot.is-active {
  background: rgba(255, 255, 255, 0.85);
}

/* Info panel */
.lb-info {
  padding: 20px 24px 32px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}

.lb-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 400;
  font-style: italic;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.lb-meta {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.8;
}

.lb-meta-sep {
  color: rgba(255, 255, 255, 0.25);
}

.lb-description {
  margin-top: 14px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.7;
  font-style: italic;
}

/* ============================================================
   BIO PAGE
   ============================================================ */
.bio-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.bio-portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #f0ede8;
  margin-bottom: 48px;
  /* Placeholder: will contain portrait photo */
}

.bio-portrait-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-border);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.bio-heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.bio-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.85;
  color: var(--color-text);
}

.bio-text p + p {
  margin-top: 1.4em;
}

/* ============================================================
   CONTACT PAGE
   ============================================================ */
.contact-section {
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  text-align: center;
}

.contact-heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 48px;
}

.contact-items {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.contact-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-light);
}

.contact-value {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--color-text);
  transition: color var(--transition-fast);
}

.contact-value:hover {
  color: var(--color-text-light);
}

.contact-cta {
  font-style: italic;
  letter-spacing: 0.04em;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  text-decoration: none;
}

/* ============================================================
   EXHIBITIONS PAGE (placeholder)
   ============================================================ */
.exhibitions-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  padding: 40px 24px;
  text-align: center;
}

.exhibitions-heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.exhibitions-note {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-light);
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.gallery-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text-light);
  letter-spacing: 0.06em;
}

/* ============================================================
   RESPONSIVE — Tablet (768px+)
   ============================================================ */
@media (min-width: 768px) {
  .artworks-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 0 20px;
  }

  /* Switch from vh-based height to a fixed aspect ratio on larger screens */
  .artwork-card figure {
    height: auto;
    aspect-ratio: 3 / 4;
  }

  .lb-media-wrap {
    padding: 60px 80px 20px;
  }

  .lb-media,
  .lb-image,
  .lb-video {
    max-height: calc(100vh - 260px);
  }

  .lb-info {
    padding: 20px 40px 40px;
  }

  .lb-title {
    font-size: 1.6rem;
  }

  .bio-portrait {
    aspect-ratio: 3 / 2;
  }
}

/* ============================================================
   RESPONSIVE — Mobile nav
   ============================================================ */
@media (max-width: 767px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    padding: 14px 24px;
    font-size: 0.8rem;
  }
}

/* ============================================================
   RESPONSIVE — Desktop (1024px+)
   ============================================================ */
@media (min-width: 1024px) {
  :root {
    --grid-gap: 20px;
  }

  .artworks-grid {
    /* Fixed max column width + center justification → partial rows stay centered */
    grid-template-columns: repeat(4, minmax(0, 320px));
    justify-content: center;
    gap: 20px;
    padding: 0 24px;
  }

  .filter-bar {
    padding: 0 24px;
  }

  .lb-image.is-zoomed {
    transform: scale(2.2);
  }
}

/* ============================================================
   RESPONSIVE — Large desktop (1400px+)
   ============================================================ */
@media (min-width: 1400px) {
  .artworks-grid {
    padding: 0 32px;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .fade-item {
    opacity: 1;
    transform: none;
  }

  .artwork-card:hover img {
    transform: none;
  }

  .lb-image.is-zoomed {
    transition: none;
  }
}
