/**
 * Gallery Page Styles
 * おしゃれなギャラリーレイアウト
 */

/* ===== Page Layout ===== */
.page-gallery {
  background: linear-gradient(180deg, var(--color-bg-tertiary) 0%, var(--color-bg-primary) 100%);
  min-height: 100vh;
}

/* ===== Header ===== */
.gallery-header {
  padding: var(--space-lg) 0;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(8px);
}

.gallery-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.gallery-header__back {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.gallery-header__back:hover {
  color: var(--color-accent-primary);
}

.gallery-header__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin: 0;
  color: var(--color-text-primary);
}

.gallery-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ===== Hero Section ===== */
.gallery-hero {
  padding: var(--space-3xl) 0 var(--space-2xl);
  text-align: center;
}

.gallery-hero__title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gallery-hero__description {
  color: var(--color-text-secondary);
  font-size: var(--font-size-lg);
  max-width: 600px;
  margin: 0 auto var(--space-xl);
}

/* ===== Gallery Tabs ===== */
.gallery-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.gallery-tab {
  padding: var(--space-sm) var(--space-lg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gallery-tab:hover {
  border-color: var(--color-accent-primary);
  color: var(--color-accent-primary);
}

.gallery-tab--active {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: #ffffff;
}

.gallery-tab--active:hover {
  color: #ffffff;
}

/* ===== Gallery Panels ===== */
.gallery__panel {
  display: none;
}

.gallery__panel--active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Tag Filter ===== */
.tag-filter {
  padding: var(--space-lg) 0;
}

.tag-filter__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-filter__tag {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-filter__tag:hover,
.tag-filter__tag.is-active {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: #ffffff;
}

.tag-filter__tag.is-active {
  box-shadow: 0 2px 8px rgba(224, 120, 80, 0.3);
}

/* ===== Gallery Content ===== */
.gallery-content {
  padding: var(--space-xl) 0 var(--space-3xl);
}

.gallery__section {
  margin-bottom: var(--space-3xl);
}

.gallery__section-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-accent-primary);
  display: inline-block;
}

.gallery__section-desc {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}

.gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

/* ===== Gallery Item ===== */
.gallery-item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  aspect-ratio: 3 / 4;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.gallery-item__image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.gallery-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-item__image {
  transform: scale(1.05);
}

.gallery-item__overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: var(--space-xl) var(--space-md) var(--space-md);
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-item__overlay {
  opacity: 1;
}

.gallery-item__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-item__year {
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

.gallery-item__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.gallery-item__tag {
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
}

/* Hidden item (filtered out) */
.gallery-item.is-hidden {
  display: none;
}

/* ===== Commission History ===== */
.commission-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-width: 700px;
}

.commission-history-item {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-accent-secondary);
  transition: all var(--transition-base);
}

.commission-history-item:hover {
  transform: translateX(8px);
  box-shadow: var(--shadow-md);
}

.commission-history-item__date {
  flex-shrink: 0;
  width: 80px;
  text-align: center;
}

.commission-history-item__year {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent-secondary);
  line-height: 1;
}

.commission-history-item__month {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.commission-history-item__content {
  flex: 1;
}

.commission-history-item__client {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.commission-history-item__project {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.commission-history-item__note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: var(--space-sm);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  font-style: italic;
}

/* ===== Event History ===== */
.event-history {
  padding: var(--space-2xl) 0 var(--space-3xl);
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 700px;
}

.event-card {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-accent-primary);
  transition: all var(--transition-base);
}

.event-card:hover {
  transform: translateX(8px);
  box-shadow: var(--shadow-md);
}

.event-card__date {
  flex-shrink: 0;
  width: 80px;
  text-align: center;
}

.event-card__year {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent-primary);
  line-height: 1;
}

.event-card__month {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.event-card__content {
  flex: 1;
}

.event-card__code {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.event-card__name {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.event-card__note {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: var(--space-sm);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
}

/* ===== Modal/Lightbox - Fixed for vertical images ===== */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-modal.is-active {
  opacity: 1;
  visibility: visible;
}

.gallery-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(4px);
}

.gallery-modal__content {
  position: relative;
  max-width: 1200px;
  max-height: 95vh;
  width: 100%;
  display: flex;
  gap: var(--space-lg);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.gallery-modal.is-active .gallery-modal__content {
  transform: scale(1);
}

.gallery-modal__close {
  position: fixed;
  top: var(--space-sm);
  right: var(--space-lg);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 24px;
  font-weight: bold;
}

.gallery-modal__close:hover {
  background: rgba(224, 120, 80, 0.9);
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.1);
}

.gallery-modal__image-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.gallery-modal__image {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.gallery-modal__info {
  width: 350px;
  flex-shrink: 0;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  padding-top: calc(var(--space-xl) + 40px);
  max-height: 90vh;
  overflow-y: auto;
}

.gallery-modal__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-sm);
}

.gallery-modal__meta {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.gallery-modal__description {
  color: var(--color-text-secondary);
  line-height: var(--line-height-loose);
  margin-bottom: var(--space-lg);
}

.gallery-modal__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.gallery-modal__tag {
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.gallery-modal__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gallery-modal__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-accent-primary);
  color: #ffffff;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  transition: background 0.2s ease;
}

.gallery-modal__link:hover {
  background: var(--color-accent-primary-hover);
  color: #ffffff;
}

/* Video embed in modal */
.gallery-modal__video {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .gallery-modal__content {
    flex-direction: column;
    max-height: 100vh;
    padding: var(--space-lg);
    padding-top: 80px;
    overflow-y: auto;
  }

  .gallery-modal__image-wrapper {
    flex: none;
  }

  .gallery-modal__image {
    max-height: 50vh;
  }

  .gallery-modal__info {
    width: 100%;
    max-height: none;
    padding-top: var(--space-xl);
  }

  .gallery-modal__close {
    top: var(--space-md);
    right: var(--space-md);
  }
}

@media (max-width: 768px) {
  .gallery-header__inner {
    flex-wrap: wrap;
  }

  .gallery-header__actions {
    order: 3;
    width: 100%;
    justify-content: space-between;
    margin-top: var(--space-sm);
  }

  .gallery-hero__title {
    font-size: var(--font-size-3xl);
  }

  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }

  .gallery-item {
    aspect-ratio: 1;
  }

  .gallery-item__overlay {
    opacity: 1;
    background: linear-gradient(transparent 30%, rgba(0, 0, 0, 0.8) 100%);
    padding: var(--space-md) var(--space-sm) var(--space-sm);
  }

  .gallery-item__title {
    font-size: var(--font-size-sm);
  }

  .gallery-item__tags {
    display: none;
  }

  .event-card {
    flex-direction: column;
    gap: var(--space-md);
  }

  .event-card__date {
    width: auto;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
  }

  .event-card__year {
    font-size: var(--font-size-xl);
  }
}

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

  .gallery-item {
    aspect-ratio: 4 / 5;
  }

  .gallery-modal {
    padding: 0;
  }

  .gallery-modal__content {
    padding: var(--space-md);
    padding-top: 70px;
    border-radius: 0;
  }

  .gallery-modal__close {
    top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
    right: var(--space-md);
    width: 44px;
    height: 44px;
  }
}

/* ===== Scroll to Top Button ===== */
.scroll-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-lg);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent-secondary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition-base);
  z-index: var(--z-fixed);
}

.scroll-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  background: var(--color-accent-primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.scroll-to-top svg {
  stroke: currentColor;
}

/* ===== Loading State ===== */
.gallery__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl);
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
}

.gallery__loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Error State ===== */
.gallery__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl);
  text-align: center;
  color: var(--color-text-secondary);
}

.gallery__error-icon {
  width: 48px;
  height: 48px;
  color: var(--color-accent-primary);
}

.gallery__error-message {
  font-size: var(--font-size-lg);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
}

.gallery__error-details {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.gallery__error-retry {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.gallery__error-retry:hover {
  background: var(--color-accent-primary-hover);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .gallery__loading-spinner {
    animation: none;
  }
}
