/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #1a1a2e;
  color: #eaeaea;
  min-height: 100vh;
  line-height: 1.6;
}

header {
  background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
  padding: 2rem 1rem;
  text-align: center;
  border-bottom: 3px solid #FF9F43;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

h1 span {
  color: #FF9F43;
}

.search-container {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#search {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  border: 2px solid #FF9F43;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #eaeaea;
  transition: all 200ms ease;
}

#search:focus {
  outline: none;
  border-color: #ffb366;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.2);
}

#search::placeholder {
  color: rgba(234, 234, 234, 0.6);
}

#result-count {
  font-size: 0.9rem;
  color: rgba(234, 234, 234, 0.8);
  text-align: right;
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.year-section {
  margin-bottom: 2rem;
}

.year-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #FF9F43;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #FF9F43;
}

/* Files Grid */
.files-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.file-card {
  background: #16213e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 200ms ease;
  cursor: pointer;
  border: 2px solid transparent;
}

.file-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
  border-color: #FF9F43;
}

.preview-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  overflow: hidden;
  position: relative;
}

.preview-frame {
  width: 400px;
  height: 300px;
  border: none;
  background: #fff;
  transform-origin: 0 0;
  /* scale set dynamically by scaleIframes() */
}

.file-info {
  padding: 0.875rem;
}

.file-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #eaeaea;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-date {
  font-size: 0.8rem;
  color: #888;
}

.hidden {
  display: none !important;
}

/* Load More Button */
.load-more-container {
  text-align: center;
  margin-top: 2rem;
}

#load-more {
  padding: 0.875rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
  background: #FF9F43;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms ease;
}

#load-more:hover {
  background: #ffb366;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(255, 159, 67, 0.3);
}

#load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .files-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.75rem;
  }

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

  .preview-container {
    height: 120px;
  }

  .file-info {
    padding: 0.625rem;
  }

  .file-title {
    font-size: 0.85rem;
  }
}

@media (max-width: 400px) {
  .files-grid {
    grid-template-columns: 1fr;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: #888;
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: #FF9F43;
}
