/* ===================================================================
   PORTFOLIO STYLING
   =================================================================== */

:root {
  --bg-primary: #0a0c10;
  --bg-header: rgba(14, 18, 24, 0.88);
  --bg-card: #14171f;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.25);
  --text-main: #f0f3f6;
  --text-muted: #8b949e;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --qst-accent: #f59e0b;
  --nsfw-accent: #f43f5e;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===================================================================
   HEADER & CONTROLS
   =================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Rating Checklist / Toggle Controls */
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-control,
.nsfw-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-control:hover,
.nsfw-control:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.filter-control input[type="checkbox"],
.nsfw-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Custom styled checkbox indicator */
.checkbox-custom {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  position: relative;
  background-color: transparent;
  flex-shrink: 0;
}

.checkbox-custom::after {
  content: "";
  display: none;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

/* Questionable Checkbox (Amber) */
.filter-questionable input[type="checkbox"]:checked~.checkbox-custom {
  background-color: var(--qst-accent);
  border-color: var(--qst-accent);
}

.filter-questionable input[type="checkbox"]:checked~.checkbox-custom::after {
  display: block;
}

.filter-questionable input[type="checkbox"]:checked~.filter-label {
  color: var(--qst-accent);
  font-weight: 600;
}

/* NSFW Checkbox (Rose / Red) */
.filter-nsfw input[type="checkbox"]:checked~.checkbox-custom,
.nsfw-control input[type="checkbox"]:checked~.checkbox-custom {
  background-color: var(--nsfw-accent);
  border-color: var(--nsfw-accent);
}

.filter-nsfw input[type="checkbox"]:checked~.checkbox-custom::after,
.nsfw-control input[type="checkbox"]:checked~.checkbox-custom::after {
  display: block;
}

.filter-nsfw input[type="checkbox"]:checked~.filter-label,
.nsfw-control input[type="checkbox"]:checked~.nsfw-label {
  color: var(--nsfw-accent);
  font-weight: 600;
}

/* Return to bio button */
.return-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.return-button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.return-button:active {
  transform: translateY(0);
}

.return-icon {
  transition: transform 0.2s ease;
}

.return-button:hover .return-icon {
  transform: translateX(-3px);
}

/* ===================================================================
   GALLERY MASONRY / GRID LAYOUT
   =================================================================== */
.gallery-wrapper {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem 1.5rem;
}

/* Horizontal Grid Layout (Right-to-Left) */
.art-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  direction: ltr;
  /* Organizes horizontally from right to left */
  align-items: start;
}

@media (max-width: 1300px) {
  .art-gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 850px) {
  .site-header {
    padding: 0.75rem 1.25rem;
  }

  .header-container {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand return"
      "filters filters";
    row-gap: 0.65rem;
    column-gap: 0.75rem;
    align-items: center;
  }

  .header-left {
    grid-area: brand;
    min-width: 0;
  }

  .site-title {
    font-size: 1.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
  }

  .header-controls {
    display: contents; /* Places filter-group and return-button directly into the header-container grid */
  }

  .return-button {
    grid-area: return;
    justify-self: end;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
  }

  .filter-group {
    grid-area: filters;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }

  .filter-control,
  .nsfw-control {
    flex: 1;
    justify-content: center;
    font-size: 0.82rem;
    padding: 0.38rem 0.6rem;
  }

  .art-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 540px) {
  .site-header {
    padding: 0.65rem 0.9rem;
  }

  .header-container {
    row-gap: 0.5rem;
  }

  .site-title {
    font-size: 1.05rem;
  }

  .return-button {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    gap: 0.35rem;
  }

  .filter-group {
    gap: 0.4rem;
  }

  .filter-control,
  .nsfw-control {
    font-size: 0.76rem;
    padding: 0.35rem 0.45rem;
    gap: 0.4rem;
  }

  .checkbox-custom {
    width: 16px;
    height: 16px;
  }

  .art-gallery {
    grid-template-columns: 1fr;
  }
}

/* Art Item Card */
.art-card {
  direction: ltr;
  /* Keeps card content, captions, and badges properly oriented */
  margin-bottom: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, opacity 0.3s ease;
}

.art-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  border-color: var(--border-focus);
}

.art-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.art-card:hover img {
  transform: scale(1.02);
}

/* Content Rating Badges on cards when visible */
.art-card .card-badge,
.art-card .card-nsfw-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
}

.art-card .badge-questionable {
  background: rgba(217, 119, 6, 0.9);
}

.art-card .badge-nsfw,
.art-card .card-nsfw-badge {
  background: rgba(244, 63, 94, 0.9);
}

/* Title caption overlay on hover */
.art-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem 1rem 0.8rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.art-card:hover .art-caption {
  opacity: 1;
}

.art-caption-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 6rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.hidden {
  display: none !important;
}

/* ===================================================================
   LIGHTBOX FULLSCREEN MODAL
   =================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 8, 0.92);
  backdrop-filter: blur(8px);
}

.lightbox-content {
  position: relative;
  z-index: 1001;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 3D Collectible Card Stage & Viewer */
.card-3d-stage {
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  max-width: 95vw;
  max-height: 90vh;
}

.card-3d {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-style: preserve-3d;
  will-change: transform, box-shadow;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.card-3d:active {
  cursor: grabbing;
}

.card-3d.card-resetting {
  transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.6s ease-out;
}

.card-inner {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #11141c;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 35px rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(0);
}

.card-inner img {
  display: block;
  max-width: min(84vw, 850px);
  max-height: min(76vh, 760px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  pointer-events: none;
}

/* Dynamic specular glare (light reflection) */
.card-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 65%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
}

/* Subtle holographic / iridescent foil sheen */
.card-foil {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(115deg,
      transparent 0%,
      rgba(255, 100, 180, 0.08) 25%,
      rgba(100, 220, 255, 0.1) 45%,
      rgba(255, 230, 100, 0.08) 65%,
      rgba(120, 255, 180, 0.08) 85%,
      transparent 100%);
  background-size: 200% 200%;
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 3;
}

.card-3d.active-inspect .card-glare {
  opacity: 1;
}

.card-3d .lightbox-caption {
  margin-top: 0.9rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
  font-weight: 500;
  transform: translateZ(15px);
  /* 3D depth pop */
  pointer-events: none;
}

/* Lightbox Buttons */
.lightbox-close {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: white;
  font-size: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1002;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1002;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-prev {
  left: 1.5rem;
}

.lightbox-next {
  right: 1.5rem;
}

@media (max-width: 768px) {
  .lightbox-nav {
    display: none;
    /* Swipe / tap for mobile */
  }
}