/* ============================================================
   TOKENS & BASE
   ============================================================ */
@layer base, tokens, components, utilities;

@layer base {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  html {
    color-scheme: dark;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
  }

  body {
    min-height: 100dvh;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
  }

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

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

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

@layer tokens {
  :root {
    /* Dark palette — aligned with jobvanderwal.dev */
    --color-bg:           #0a0a0a;
    --color-surface:      #141414;
    --color-surface-2:    #1c1010;
    --color-border:       rgba(139, 26, 47, 0.2);
    --color-text:         #F0F0F0;
    --color-text-muted:   #888888;
    --color-accent:       #C2415A;   /* crimson — matches portfolio */
    --color-accent-dark:  #8B1A2F;   /* dark red — borders, dividers */

    /* Typography */
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    /* Motion */
    --ease:               cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast:      150ms;
    --duration-normal:    250ms;
    --duration-slow:      400ms;
  }
}

/* ============================================================
   SITE HEADER
   ============================================================ */
@layer components {
  .site-header {
    padding: 3.5rem 1.5rem 2rem;
    text-align: center;
    border-bottom: 1px solid rgba(139, 26, 47, 0.25);
  }

  .site-title {
    font-size: clamp(1.75rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    color: var(--color-text);
  }

  .site-title::after {
    content: '';
    display: block;
    width: 3rem;
    height: 3px;
    background: var(--color-accent-dark);
    border-radius: 9999px;
    margin: 0.75rem auto 0;
  }

  .site-subtitle {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--color-accent);
  }

  /* ============================================================
     FILTER BAR
     ============================================================ */
  .filter-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1.5rem 0;
  }

  .filter-btn {
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #D0D0D0;
    border: 1px solid rgba(139, 26, 47, 0.5);
    border-radius: 9999px;
    background: rgba(139, 26, 47, 0.08);
    transition:
      color var(--duration-fast) var(--ease),
      border-color var(--duration-fast) var(--ease),
      background var(--duration-fast) var(--ease);
  }

  .filter-btn:hover {
    color: var(--color-text);
    border-color: var(--color-accent-dark);
    background: rgba(139, 26, 47, 0.15);
  }

  .filter-btn.active {
    color: #fff;
    background: var(--color-accent);
    border-color: var(--color-accent);
  }

  /* ============================================================
     MASONRY GRID
     ============================================================ */
  .site-main {
    max-width: 1400px;
    margin-inline: auto;
    padding-bottom: 4rem;
  }

  .photo-grid {
    columns: 1;
    column-gap: 0.75rem;
    padding: 1.5rem;
  }

  @media (min-width: 480px) {
    .photo-grid { columns: 2; }
  }

  @media (min-width: 768px) {
    .photo-grid { columns: 3; }
  }

  @media (min-width: 1100px) {
    .photo-grid { columns: 4; }
  }

  /* Photo item */
  .photo-item {
    display: inline-block; /* required for CSS columns masonry */
    width: 100%;
    margin-bottom: 0.75rem;
    break-inside: avoid;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--color-surface);
    border: 1px solid rgba(139, 26, 47, 0.2);
    border-top: 2px solid var(--color-accent-dark);

    /* Animate in */
    animation: item-appear var(--duration-slow) var(--ease) both;
  }

  .photo-item.hidden {
    display: none;
  }

  @keyframes item-appear {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
  }

  .photo-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--duration-slow) var(--ease);
  }

  /* Hover overlay */
  .photo-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background var(--duration-normal) var(--ease);
    pointer-events: none;
  }

  .photo-item:hover::after {
    background: rgba(0,0,0,0.15);
  }

  .photo-item:hover img {
    transform: scale(1.02);
  }

  /* Empty state */
  .empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
  }

  /* ============================================================
     LIGHTBOX
     ============================================================ */
  .lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;

    /* Hidden state */
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease);
  }

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

  .lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .lightbox__figure {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: calc(100vw - 10rem);
    max-height: calc(100dvh - 6rem);
    transition: opacity var(--duration-fast) var(--ease);
  }

  .lightbox__figure.fading {
    opacity: 0;
  }

  .lightbox__img {
    max-width: 100%;
    max-height: calc(100dvh - 6rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.8);
    user-select: none;
  }

  /* Close button */
  .lightbox__close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #D0D0D0;
    border-radius: 0.375rem;
    background: rgba(139, 26, 47, 0.08);
    border: 1px solid rgba(139, 26, 47, 0.5);
    transition:
      color var(--duration-fast) var(--ease),
      background var(--duration-fast) var(--ease),
      border-color var(--duration-fast) var(--ease);
  }

  .lightbox__close:hover {
    color: white;
    background: rgba(139, 26, 47, 0.2);
    border-color: var(--color-accent-dark);
  }

  /* Nav arrows */
  .lightbox__nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #D0D0D0;
    border-radius: 0.375rem;
    background: rgba(139, 26, 47, 0.08);
    border: 1px solid rgba(139, 26, 47, 0.5);
    transition:
      color var(--duration-fast) var(--ease),
      background var(--duration-fast) var(--ease),
      border-color var(--duration-fast) var(--ease),
      opacity var(--duration-fast) var(--ease);
  }

  .lightbox__nav:hover {
    color: white;
    background: rgba(139, 26, 47, 0.2);
    border-color: var(--color-accent-dark);
  }

  .lightbox__nav.hidden {
    opacity: 0;
    pointer-events: none;
  }

  .lightbox__nav--prev { left: 1rem; }
  .lightbox__nav--next { right: 1rem; }

  /* Counter */
  .lightbox__counter {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.45);
    pointer-events: none;
  }

  /* ============================================================
     FOOTER
     ============================================================ */
  .site-footer {
    border-top: 1px solid rgba(139, 26, 47, 0.25);
    padding: 1.5rem;
    text-align: center;
  }

  .site-footer p {
    font-size: 0.75rem;
    color: #555555;
  }
}

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