/* ============================================================
   designsystem.art — Gallery Styles
   ============================================================ */

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

:root {
  /* Active theme — set by JS, defaults to first painting (Green Wheat Fields) */
  --surface: #C8DDD0;
  --on-surface: #2C522F;
  --on-surface-variant: #5A7860;
  --primary: #4a7c53;
  --on-primary: #ffffff;
  --primary-container: #e1e9e2;
  --on-primary-container: #151d17;
  --surface-container: #d6e4d1;
  --outline: #8AAA80;
  --brand-font: 'Lora', serif;
  --plain-font: 'Source Sans 3', sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--plain-font);
  background-color: var(--surface);
  color: var(--on-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* Material Symbols helper */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* --- Header --- */
.gallery-header {
  flex-shrink: 0;
  text-align: center;
  z-index: 10;
  pointer-events: none;
  padding: clamp(16px, 4vh, 48px) 24px clamp(12px, 2vh, 24px);
}

.header-label {
  font-family: var(--plain-font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin-bottom: 6px;
  transition: color 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              font-family 0.3s;
  opacity: 0.8;
}

.header-title {
  font-family: var(--brand-font);
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--on-surface);
  transition: color 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              font-family 0.3s;
}

.header-year {
  font-family: var(--plain-font);
  font-size: 14px;
  font-weight: 400;
  color: var(--on-surface-variant);
  margin-top: 4px;
  opacity: 0.6;
  transition: color 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-badge {
  font-family: var(--plain-font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  margin-top: 8px;
  opacity: 0.7;
  transition: color 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 20px;
  border-radius: 9999px;
  border: 1.5px solid var(--outline);
  background: transparent;
  color: var(--primary);
  font-family: var(--plain-font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-decoration: none;
  cursor: pointer;
  pointer-events: auto;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.download-btn:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

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

/* Text transition animation */
.header-label.text-exit,
.header-title.text-exit,
.header-year.text-exit,
.header-badge.text-exit {
  animation: textFadeOut 0.25s ease forwards;
}

.header-label.text-enter,
.header-title.text-enter,
.header-year.text-enter,
.header-badge.text-enter {
  animation: textFadeIn 0.35s ease forwards;
}

@keyframes textFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

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

/* --- Carousel --- */
.carousel-viewport {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  perspective: 1200px;
  touch-action: pan-y;
  /* Top padding accounts for stacked cards peeking above (translateY up to -124px) */
  padding-top: clamp(80px, 12vh, 130px);
  padding-bottom: 24px;
}

.card-stack {
  position: relative;
  width: clamp(260px, 42vw, 420px);
  aspect-ratio: 3 / 4;
  max-height: calc(100% - 40px);
}

.painting-card {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transform-origin: center center;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

.painting-card.no-transition {
  transition: none !important;
}

.painting-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Card glow/shadow */
.painting-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  pointer-events: none;
}

/* Active (front) card */
.painting-card[data-position="0"] {
  z-index: 8;
  transform: translateY(0) scale(1);
  opacity: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35),
              0 8px 24px rgba(0,0,0,0.2);
  cursor: pointer;
}

.painting-card[data-position="0"]:hover {
  box-shadow: 0 24px 72px rgba(0,0,0,0.4),
              0 10px 28px rgba(0,0,0,0.25);
  transform: translateY(-4px) scale(1.01);
}

/* Stacked cards behind — visible peek above front card */
.painting-card[data-position="1"] {
  z-index: 7;
  transform: translateY(-40px) scale(0.93);
  opacity: 0.9;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.painting-card[data-position="2"] {
  z-index: 6;
  transform: translateY(-72px) scale(0.86);
  opacity: 0.7;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.painting-card[data-position="3"] {
  z-index: 5;
  transform: translateY(-96px) scale(0.80);
  opacity: 0.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.painting-card[data-position="4"] {
  z-index: 4;
  transform: translateY(-114px) scale(0.74);
  opacity: 0.3;
}

.painting-card[data-position="5"],
.painting-card[data-position="6"],
.painting-card[data-position="7"] {
  z-index: 3;
  transform: translateY(-124px) scale(0.69);
  opacity: 0;
  pointer-events: none;
}

/* Back-card hover — "pull out" effect */
.painting-card[data-position="1"]:hover {
  transform: translateY(-56px) scale(0.94);
  opacity: 1;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  cursor: pointer;
}

.painting-card[data-position="2"]:hover {
  transform: translateY(-92px) scale(0.88);
  opacity: 0.9;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  cursor: pointer;
}

.painting-card[data-position="3"]:hover {
  transform: translateY(-120px) scale(0.82);
  opacity: 0.75;
  box-shadow: 0 10px 32px rgba(0,0,0,0.2);
  cursor: pointer;
}

.painting-card[data-position="4"]:hover {
  transform: translateY(-142px) scale(0.76);
  opacity: 0.55;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  cursor: pointer;
}

/* Swipe-exit animation */
.painting-card.swipe-exit-left {
  animation: swipeLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 10 !important;
}
.painting-card.swipe-exit-right {
  animation: swipeRight 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  z-index: 10 !important;
}

@keyframes swipeLeft {
  to {
    transform: translateX(-120%) rotate(-12deg);
    opacity: 0;
  }
}
@keyframes swipeRight {
  to {
    transform: translateX(120%) rotate(12deg);
    opacity: 0;
  }
}

/* --- Pagination Dots --- */
.pagination {
  position: absolute;
  right: clamp(16px, 4vw, 48px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

.pagination-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--on-surface-variant);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.4s, border-color 0.4s, transform 0.3s;
  opacity: 0.5;
}

.pagination-dot:hover {
  opacity: 0.8;
  transform: scale(1.3);
}

.pagination-dot.active {
  background: var(--on-surface);
  border-color: var(--on-surface);
  opacity: 1;
  transform: scale(1.2);
}

/* --- Click-to-preview hint --- */
.painting-card[data-position="0"]::before {
  content: 'Click to preview';
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 6px 16px;
  border-radius: 9999px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-family: var(--plain-font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10;
}

.painting-card[data-position="0"]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Preview Modal --- */
.preview-modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.preview-modal-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.preview-modal-surface {
  width: 96vw;
  height: 94vh;
  max-width: 1600px;
  background: var(--surface-container);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.8s;
}

.preview-modal-scrim.open .preview-modal-surface {
  transform: scale(1) translateY(0);
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--outline);
  flex-shrink: 0;
}

.preview-modal-title {
  font-family: var(--brand-font);
  font-size: 20px;
  font-weight: 600;
  color: var(--on-surface);
  transition: font-family 0.3s, color 0.8s;
}

.preview-modal-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.8s;
}

.preview-modal-close:hover {
  background: rgba(0,0,0,0.08);
}

.preview-modal-iframe {
  flex: 1;
  border: none;
  width: 100%;
  background: #fff;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.preview-modal-body {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  font-family: var(--plain-font);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.preview-loader.visible {
  opacity: 1;
}

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

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

/* --- Keyboard Hint --- */
.keyboard-hint {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.9);
  font-family: var(--plain-font);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
  z-index: 50;
  white-space: nowrap;
}

.keyboard-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
}

/* --- Site Footer --- */
.site-footer {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--plain-font);
  font-size: 11px;
  color: var(--on-surface-variant);
  opacity: 0.55;
  transition: opacity 0.3s, color 0.8s;
  z-index: 20;
  width: 90%;
  text-align: center;
  flex-wrap: wrap;
  justify-content: center;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .site-footer {
    bottom: 8px;
    gap: 4px;
    font-size: 10px;
  }
}

.site-footer:hover {
  opacity: 0.85;
}

.footer-sep {
  opacity: 0.5;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--on-surface-variant);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--primary);
}

.github-icon {
  flex-shrink: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .card-stack {
    width: clamp(220px, 70vw, 340px);
  }

  .pagination {
    right: 12px;
    gap: 10px;
  }

  .pagination-dot {
    width: 8px;
    height: 8px;
  }

  .header-label {
    font-size: 11px;
    letter-spacing: 2px;
  }

  .header-title {
    font-size: clamp(24px, 7vw, 36px);
  }

  .gallery-header {
    padding: 12px 16px 8px;
  }

  .painting-card[data-position="1"] {
    transform: translateY(-24px) scale(0.93);
  }
  .painting-card[data-position="2"] {
    transform: translateY(-42px) scale(0.86);
  }
  .painting-card[data-position="3"] {
    transform: translateY(-56px) scale(0.80);
    opacity: 0.35;
  }
  .painting-card[data-position="4"],
  .painting-card[data-position="5"],
  .painting-card[data-position="6"],
  .painting-card[data-position="7"] {
    transform: translateY(-64px) scale(0.75);
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 480px) {
  .gallery-header {
    padding: 10px 12px 6px;
  }

  .header-title {
    font-size: clamp(22px, 8vw, 32px);
  }
}
