/* Enhanced styles.css with visual polish and mobile improvements */

/* === Base Reset & Box Sizing === */
*, *::before, *::after { 
  box-sizing: border-box; 
}

body, h1, h2, h3, h4, p, ul, li, figure { 
  margin: 0; 
  padding: 0;
}

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

/* === CSS Variables === */
:root {
  --bg: #2a2a2a;
  --bg-2: #333333;
  --panel: #3a3a3a;
  --panel-hover: #424242;
  --text: #e8e8e8;
  --muted: #a0a0a0;
  --brand: #ff8c42;
  --brand-2: #ffad77;
  --accent: #ff6b35;
  --success: #4ade80;
  --ring: rgba(255,140,66,0.4);
  --shadow: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
  --shadow-xl: 0 12px 40px rgba(0,0,0,.5);
  --radius: 12px;
  --radius-sm: 8px;
  --container: 1200px;
  --border: #4a4a4a;
  --border-strong: #5a5a5a;
  --tint: #454545;
  
  /* Animation variables */
  --transition-fast: 0.15s;
  --transition-base: 0.25s;
  --transition-slow: 0.4s;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Light theme support */
[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f9f9f9;
  --text: #1a1a1a;
  --muted: #666666;
  --border: #e0e0e0;
  --border-strong: #cccccc;
  --tint: #f0f0f0;
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --shadow-xl: 0 12px 40px rgba(0,0,0,.15);
}

/* === Base Styles === */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Skip to content link for accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--brand);
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* === Links === */
a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition-base) var(--ease-out);
}

a:hover,
a:focus {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--brand);
}

/* === Banner === */
.banner {
  padding: 4rem 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  position: relative;
}

.banner__inner { 
  max-width: var(--container); 
  margin: 0 auto; 
}

.banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.banner h1 { 
  font-size: 2.5rem; 
  line-height: 1.2; 
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.banner p { 
  color: var(--muted); 
  margin-top: .5rem; 
  font-size: 1.05rem; 
}

/* Icon button for theme toggle */
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  font-size: 1.25rem;
}

.icon-btn:hover {
  background: var(--panel-hover);
  border-color: var(--brand);
  transform: scale(1.05) rotate(15deg);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Statistics bar */
.stats-bar {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
  text-align: center;
}

/* === Breadcrumbs === */
.crumbs {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: .5rem;
}

.crumbs a {
  color: var(--brand);
  transition: color var(--transition-fast);
}

.crumbs a:hover {
  color: var(--accent);
}

/* === Album Styles === */
.album-title {
  font-size: 2rem;
  color: var(--text);
  font-weight: 700;
}

.album-meta {
  color: var(--muted);
  font-size: 1rem;
}

/* === Layout === */
.layout {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 340px);
  gap: 1.5rem;
  align-items: start;
}

/* === Card Grid === */
.sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  --card-thumb-height: 200px;
}

/* === Card Component === */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 100%;
  transition: all var(--transition-base) var(--ease-out);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,140,66,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-base) var(--ease-out);
  pointer-events: none;
  z-index: 1;
}

.card:hover,
.card:focus-within { 
  transform: translateY(-6px); 
  box-shadow: var(--shadow-xl);
  border-color: var(--brand);
  background: var(--panel-hover);
}

.card:hover::before {
  opacity: 1;
}

.card.touch-active {
  transform: translateY(-4px) scale(0.98);
}

.card__link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
  position: relative;
  z-index: 2;
}

.card__thumb {
  width: 100%;
  height: var(--card-thumb-height, 200px);
  object-fit: cover;
  background: var(--bg);
  transition: transform var(--transition-slow) var(--ease-out), opacity var(--transition-base);
  display: block;
  opacity: 0;
}

.card__thumb.loaded {
  opacity: 1;
}

.card:hover .card__thumb {
  transform: scale(1.08);
}

.card__body { 
  padding: 1.15rem 1.25rem; 
}

.card--wide {
  grid-column: span 2;
}

.card__title { 
  font-weight: 700; 
  font-size: 1.1rem;
  color: var(--text);
  transition: color var(--transition-base) var(--ease-out);
  margin-bottom: 0.25rem;
}

.card:hover .card__title {
  color: var(--brand);
}

.card__desc { 
  color: var(--muted); 
  font-size: .9rem; 
  margin-top: .25rem;
  transition: color var(--transition-fast);
}

.card:hover .card__desc {
  color: var(--text);
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: 1.5rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-section {
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-base);
}

.sidebar-section:hover {
  box-shadow: var(--shadow-lg);
}

.sidebar h2,
.sidebar h3 {
  font-size: 1.15rem;
  margin-bottom: .75rem;
  color: var(--brand);
  font-weight: 700;
}

.sidebar h3 {
  font-size: 1rem;
}

/* === Credits List === */
.credits { 
  list-style: none; 
  padding: 0; 
  margin: 0 0 1rem; 
}

.credits li { 
  padding: .75rem; 
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast) var(--ease-out);
  margin-bottom: 0.25rem;
}

.credits li:hover { 
  background: var(--tint);
  transform: translateX(4px);
}

.credits a {
  color: var(--text);
  transition: color var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.credits a:hover {
  color: var(--brand);
  text-decoration: none;
}

.contributor-name {
  font-weight: 500;
}

.contributor-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

.loading-placeholder,
.empty-state,
.error-state {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
}

.error-state {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.btn-retry {
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-retry:hover {
  background: var(--tint);
  border-color: var(--brand);
  color: var(--brand);
}

/* === Buttons === */
.sidebar__actions { 
  margin-top: .75rem; 
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition-base) var(--ease-out);
  width: 100%;
  font-family: inherit;
  font-size: .95rem;
  text-align: center;
  min-height: 44px; /* Touch target size */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover,
.btn:focus { 
  border-color: var(--brand); 
  background: var(--tint);
  color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--success) !important;
  color: white !important;
  border-color: var(--success) !important;
}

/* === Contribute Panel === */
.contribute {
  grid-column: 1 / -1;
  margin-top: 1rem;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  position: relative;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.contribute h3 { 
  margin: 0 0 .75rem; 
  font-size: 1.3rem;
  color: var(--brand);
  font-weight: 700;
}

.contribute h4 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 600;
}

.contribute h3:first-child {
  margin-top: 0;
}

.contribute p {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
}

.contribute code { 
  background: var(--bg); 
  border: 1px solid var(--border); 
  padding: .3rem .5rem; 
  border-radius: 6px;
  color: var(--brand);
  font-size: .9rem;
  font-family: 'Monaco', 'Courier New', monospace;
}

.contribute__actions { 
  margin: 1rem 0; 
}

.contribute__list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.contribute__list li {
  padding: 0.5rem 0 0.5rem 1.5rem;
  position: relative;
  color: var(--text);
  font-size: 0.95rem;
}

.contribute__list li::before {
  content: '•';
  position: absolute;
  left: 0.5rem;
  color: var(--brand);
  font-weight: bold;
}

.contribute__note {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.contribute__footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* === Footer === */
.site-footer {
  max-width: var(--container);
  margin: 3rem auto 1.5rem;
  padding: 0 1.5rem;
  color: var(--muted);
  font-size: .92rem;
  text-align: center;
}

/* === Media Grid === */
.media-grid { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: 1.25rem; 
}

.media-item { 
  position: relative; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  overflow: hidden; 
  background: var(--panel); 
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  aspect-ratio: 1 / 1;
}

.media-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
}

.media-item:focus {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.media-item img, 
.media-item video { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block;
  transition: transform var(--transition-slow) var(--ease-out), opacity var(--transition-base);
  opacity: 0;
}

.media-item img.loaded,
.media-item video.loaded {
  opacity: 1;
}

.media-item:hover img,
.media-item:hover video {
  transform: scale(1.1);
}

.media-item .media-tag { 
  position: absolute; 
  left: .75rem; 
  bottom: .75rem; 
  padding: .4rem .7rem; 
  background: rgba(0,0,0,.85); 
  border: 1px solid rgba(255,140,66,.5); 
  border-radius: 999px; 
  font-size: .75rem; 
  color: #fff;
  font-weight: 600;
  backdrop-filter: blur(8px);
  z-index: 2;
  transition: all var(--transition-fast);
}

.media-item:hover .media-tag {
  background: rgba(0,0,0,.95);
  border-color: var(--brand);
  transform: translateY(-2px);
}

/* === Lightbox === */
.lb-backdrop { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,.92); 
  display: none; 
  align-items: center; 
  justify-content: center; 
  padding: 1.5rem; 
  z-index: 9999;
  backdrop-filter: blur(12px);
  animation: fadeIn var(--transition-base) var(--ease-out);
}

.lb-backdrop[aria-hidden="false"] { 
  display: flex; 
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lb { 
  position: relative; 
  width: min(1200px, 100%); 
  max-height: 90vh;
  background: var(--panel); 
  border: 1px solid var(--border-strong); 
  border-radius: var(--radius); 
  box-shadow: 0 25px 80px rgba(0,0,0,.6); 
  display: grid; 
  grid-template-columns: 1.2fr .8fr; 
  gap: 0; 
  overflow: hidden;
  animation: slideUp 0.3s var(--ease-out);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.lb-media { 
  background: var(--bg); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  min-height: 50vh;
  padding: 1rem;
}

.lb-media img, 
.lb-media video { 
  max-width: 100%; 
  max-height: 80vh; 
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lb-about { 
  border-left: 1px solid var(--border); 
  padding: 1.5rem; 
  display: flex; 
  flex-direction: column; 
  gap: .75rem;
  background: var(--panel);
  overflow-y: auto;
  max-height: 90vh;
}

.lb-about h3 { 
  margin: 0; 
  font-size: 1.3rem;
  color: var(--text);
  font-weight: 700;
}

.lb-about .about-meta { 
  font-size: .95rem; 
  color: var(--muted); 
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.lb-about .about-meta a {
  color: var(--brand);
  font-weight: 500;
}

.lb-about .about-meta a:hover {
  color: var(--accent);
}

.lb-about #lb-desc {
  color: var(--text);
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Lightbox controls */
.lb-close, 
.lb-prev, 
.lb-next { 
  position: absolute; 
  background: rgba(42, 42, 42, 0.9); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  padding: .6rem .9rem; 
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
  transition: all var(--transition-fast) var(--ease-out);
  backdrop-filter: blur(8px);
  z-index: 10;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-close:hover, 
.lb-prev:hover, 
.lb-next:hover {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand);
  transform: scale(1.1);
  box-shadow: var(--shadow);
}

.lb-close:active,
.lb-prev:active,
.lb-next:active {
  transform: scale(0.95);
}

.lb-close { 
  top: 1rem;
  right: 1rem; 
}

.lb-prev { 
  left: 1rem; 
  top: 50%; 
  transform: translateY(-50%); 
}

.lb-prev:hover {
  transform: translateY(-50%) scale(1.1);
}

.lb-next { 
  right: 1rem; 
  top: 50%; 
  transform: translateY(-50%); 
}

.lb-next:hover {
  transform: translateY(-50%) scale(1.1);
}

/* === Focus Styles === */
.card:focus-within, 
a:focus-visible, 
.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s var(--ease-out) both;
}

.fade-in {
  animation: fadeIn 0.3s var(--ease-out);
}

/* Stagger animation delays */
.sections .card:nth-child(1) { animation-delay: 0.05s; }
.sections .card:nth-child(2) { animation-delay: 0.1s; }
.sections .card:nth-child(3) { animation-delay: 0.15s; }
.sections .card:nth-child(4) { animation-delay: 0.2s; }
.sections .card:nth-child(5) { animation-delay: 0.25s; }

/* === Media Queries === */

/* Tablet */
@media (max-width: 900px) {
  .layout { 
    grid-template-columns: 1fr; 
    gap: 1.5rem; 
  }
  
  .sections {
    grid-template-columns: repeat(2, 1fr);
    max-width: 100%;
    margin: 0 auto;
    --card-thumb-height: 180px;
  }
  
  .card--wide { 
    grid-column: span 2; 
  }
  
  .sidebar { 
    position: relative; 
    top: 0; 
  }
  
  .media-grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem; 
  }
  
  .lb {
    grid-template-columns: 1fr;
    max-height: 95vh;
  }
  
  .lb-about {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }

  .stats-bar {
    gap: 1rem;
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .banner { 
    padding: 2.5rem 1rem 1.5rem; 
  }
  
  .banner h1 { 
    font-size: 1.75rem; 
  }

  .banner p {
    font-size: 0.95rem;
  }

  .stats-bar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .stat-item {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.85rem;
    margin-top: 0;
  }
  
  .layout { 
    padding: 1rem; 
  }
  
  .sections {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    --card-thumb-height: 140px;
  }
  
  .card--wide { 
    grid-column: span 2; 
  }
  
  .card__body {
    padding: 0.75rem 0.85rem;
  }
  
  .card__title {
    font-size: 0.95rem;
  }
  
  .card__desc {
    font-size: 0.8rem;
  }
  
  .media-grid { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 0.5rem; 
  }
  
  .media-item {
    aspect-ratio: 1 / 1;
  }
  
  .media-item .media-tag {
    left: 0.5rem;
    bottom: 0.5rem;
    padding: .3rem .5rem;
    font-size: .7rem;
  }

  .lb {
    padding: 0;
    border-radius: var(--radius-sm);
  }

  .lb-media {
    min-height: 40vh;
    padding: 0.5rem;
  }

  .lb-about {
    padding: 1rem;
  }

  .lb-close,
  .lb-prev,
  .lb-next {
    padding: .5rem .7rem;
    font-size: 1rem;
  }

  .lb-close {
    top: 0.5rem;
    right: 0.5rem;
  }

  .lb-prev {
    left: 0.5rem;
  }

  .lb-next {
    right: 0.5rem;
  }

  .contribute {
    padding: 1rem;
  }

  .contribute h3 {
    font-size: 1.15rem;
  }

  .contribute h4 {
    font-size: 1rem;
  }
}

/* Small mobile */
@media (max-width: 400px) {
  .banner h1 {
    font-size: 1.5rem;
  }

  .sections {
    --card-thumb-height: 160px;
  }

  .media-grid {
    gap: 0.35rem;
  }

  .lb-about h3 {
    font-size: 1.1rem;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
  .card {
    border-width: 2px;
  }

  .btn {
    border-width: 2px;
  }

  a {
    text-decoration: underline;
  }
}