/* ============================================================================
   ARTIST PORTFOLIO — STYLESHEET
   ============================================================================
   Sections in this file:
     1. Reset & base
     2. Design tokens (colors, type scale, spacing, timing)
     3. Typography
     4. Accessibility helpers (skip link, focus states)
     5. Header & filter navigation
     6. Gallery layout (masonry via CSS columns)
     7. Artwork cards & hover interaction
     8. Filtering animation states
     9. Footer
     10. Responsive breakpoints
   ============================================================================ */


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

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

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

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

ul {
  list-style: none;
}


/* ----------------------------------------------------------------------------
   2. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette — restrained on purpose. The artwork provides the color. */
  --color-bg: #FFFFFF;
  --color-bg-alt: #FAFAFA;
  --color-text: #111111;
  --color-text-secondary: #666666;
  --color-border: #EAEAEA;
  --color-placeholder-bg: #F2F2F2;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.75rem;
  --space-lg: 3rem;
  --space-xl: 5rem;

  /* Motion — kept short and consistent site-wide (250–400ms per spec) */
  --transition-fast: 250ms ease;
  --transition-base: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Gallery column gap, referenced by both CSS and the layout comments below */
  --gallery-gap: 2rem;
}


/* ----------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.site-title {
  display: block;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.intro {
  max-width: 40rem;
  margin: var(--space-lg) auto var(--space-md);
  padding: 0 var(--space-lg);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.artwork-card__title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.artwork-card__meta {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 0.15rem;
}


/* ----------------------------------------------------------------------------
   4. Accessibility helpers
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -3rem;
  left: var(--space-sm);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  border-radius: 2px;
  z-index: 100;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-sm);
}

/* Visible, consistent focus ring for keyboard users across all interactive
   elements. Uses :focus-visible so mouse clicks don't show the ring. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

.noscript-message {
  max-width: 30rem;
  margin: var(--space-xl) auto;
  text-align: center;
  color: var(--color-text-secondary);
  padding: 0 var(--space-lg);
}


/* ----------------------------------------------------------------------------
   5. Header & filter navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
}

.filter-nav__list {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
}

.filter-nav__button {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  padding: 0.25rem 0.1rem;
  position: relative;
  transition: color var(--transition-fast);
}

.filter-nav__button::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background-color: var(--color-text);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-fast);
}

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

/* Active category — indicated with color + an animated underline rather
   than a heavy background/border treatment, to stay minimal. */
.filter-nav__button[aria-pressed="true"] {
  color: var(--color-text);
}

.filter-nav__button[aria-pressed="true"]::after {
  transform: scaleX(1);
}


/* ----------------------------------------------------------------------------
   6. Gallery layout (masonry via CSS multi-column)
   -------------------------------------------------------------------------- */
/*
  CSS columns give a true Pinterest-style masonry (items flow into the
  shortest column, aspect ratios are preserved, no JS layout math needed)
  without pulling in a masonry library. The column count changes at each
  breakpoint in section 10 below: 4 desktop / 2 tablet / 1 mobile.
*/
.gallery {
  column-count: 4;
  column-gap: var(--gallery-gap);
  padding: 0 var(--space-lg) var(--space-xl);
  max-width: 90rem;
  margin: 0 auto;
}

.artwork-card {
  display: inline-block; /* required for break-inside to behave in columns */
  width: 100%;
  break-inside: avoid;
  margin-bottom: var(--gallery-gap);
}


/* ----------------------------------------------------------------------------
   7. Artwork cards & hover interaction
   -------------------------------------------------------------------------- */
.artwork-card__frame {
  overflow: hidden; /* clips the zoomed image on hover */
  background-color: var(--color-placeholder-bg);
}

.artwork-card__image {
  width: 100%;
  transition: transform 500ms cubic-bezier(0.25, 0.8, 0.25, 1);
}

.artwork-card:hover .artwork-card__image,
.artwork-card:focus-within .artwork-card__image {
  transform: scale(1.035);
}

.artwork-card__caption {
  margin-top: var(--space-xs);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.artwork-card:hover .artwork-card__caption,
.artwork-card:focus-within .artwork-card__caption {
  opacity: 1;
  transform: translateY(0);
}

/* Touch devices can't hover — always show captions there so metadata
   isn't hidden behind an interaction that doesn't exist on the device. */
@media (hover: none) {
  .artwork-card__caption {
    opacity: 1;
    transform: none;
  }
}


/* ----------------------------------------------------------------------------
   8. Filtering animation states
   -------------------------------------------------------------------------- */
/*
  scripts/main.js toggles the "is-hidden" class when a filter is applied.
  The card fades + scales down, and only after the transition finishes does
  the script set display:none (see main.js for the transitionend handling).
  This is what produces the "smooth rearrangement" feel without a full
  animation library.
*/
.artwork-card {
  opacity: 1;
  transform: scale(1);
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.artwork-card.is-hidden {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}


/* ----------------------------------------------------------------------------
   9. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-lg);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.site-footer p + p {
  margin-top: var(--space-xs);
}

.site-footer__meta {
  font-size: 0.75rem;
  color: #999999;
}


/* ----------------------------------------------------------------------------
   10. Responsive breakpoints
   -------------------------------------------------------------------------- */
/* Tablet: 2-column gallery */
@media (max-width: 900px) {
  .gallery {
    column-count: 2;
  }

  .site-header__inner {
    padding: var(--space-sm) var(--space-md);
  }
}

/* Mobile: 1-column gallery */
@media (max-width: 560px) {
  .gallery {
    column-count: 1;
    padding: 0 var(--space-md) var(--space-xl);
  }

  .filter-nav__list {
    gap: var(--space-sm);
    flex-wrap: wrap;
    justify-content: center;
  }

  .intro {
    padding: 0 var(--space-md);
  }

  /* Metadata is always visible on mobile (no hover state to fade it in) */
  .artwork-card__caption {
    opacity: 1;
    transform: none;
  }
}

/* Respect users who've asked for reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
  }
}
