/**
 * Memoria - Archival Memory Design System
 * Theme: Soviet photographic archive meets modern AI
 * Palette: Sepia, amber, charcoal, documentary cream
 */

:root {
    /* Color Palette - Archival Memory */
    --color-sepia-dark: #1A1410;
    --color-sepia-mid: #2D2419;
    --color-sepia-light: #4A3B2A;
    --color-amber-primary: #D4A574;
    --color-amber-accent: #E8C4A0;
    --color-gold-archive: #CDA76E;
    --color-red-soviet: #C13E3E;
    --color-cream: #F5EFE7;
    --color-charcoal: #2B2520;
    --color-stamp: #8B6D4F;

    /* Typography Scale */
    --font-display: 'Unbounded', sans-serif;
    --font-body: 'Commissioner', sans-serif;
    --font-mono: 'Courier New', monospace;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    /* Borders */
    --border-width: 2px;
    --border-archive: var(--border-width) solid var(--color-stamp);
    --border-dashed: var(--border-width) dashed var(--color-stamp);

    /* Shadows */
    --shadow-paper: 0 2px 8px rgba(0, 0, 0, 0.3),
                     0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-lifted: 0 4px 16px rgba(0, 0, 0, 0.4),
                      0 12px 32px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    color: var(--color-cream);
    background-color: var(--color-sepia-dark);
    overflow-x: hidden;
    position: relative;
}

/* Film grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    z-index: 1;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2.5' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Typography */
h1, h2, h3, h4, h5, h6, .font-display {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin-bottom: var(--space-md);
}

h2 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: var(--space-md);
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    margin-bottom: var(--space-sm);
}

p {
    margin-bottom: var(--space-sm);
    line-height: 1.75;
}

/* Archive Paper Panel */
.archive-panel {
    background: linear-gradient(135deg,
        var(--color-sepia-mid) 0%,
        var(--color-charcoal) 100%);
    border: var(--border-archive);
    border-radius: 0;
    padding: var(--space-md);
    position: relative;
    box-shadow: var(--shadow-paper);
}

.archive-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(212, 165, 116, 0.02) 2px,
        rgba(212, 165, 116, 0.02) 4px
    );
    pointer-events: none;
}

/* Photo Frame */
.photo-frame {
    position: relative;
    background: var(--color-cream);
    padding: 12px;
    border: 1px solid var(--color-stamp);
    box-shadow: var(--shadow-paper);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.photo-frame::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid rgba(139, 109, 79, 0.3);
    pointer-events: none;
}

.photo-frame:hover {
    transform: rotate(-1deg) translateY(-4px);
    box-shadow: var(--shadow-lifted);
}

.photo-frame img {
    display: block;
    width: 100%;
    height: auto;
    filter: sepia(0.15) contrast(1.1);
}

/* Archive Stamp */
.stamp {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border: var(--border-dashed);
    border-radius: 4px;
    background: linear-gradient(45deg,
        rgba(193, 62, 62, 0.1),
        rgba(193, 62, 62, 0.05));
    color: var(--color-red-soviet);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transform: rotate(-2deg);
    position: relative;
}

.stamp::after {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid currentColor;
    opacity: 0.5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 1rem 2rem;
    min-height: 48px;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #F5D799 0%, #E8AA5B 100%);
    color: #1A1410;
    border: 3px solid #FFF4E0;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow:
        0 4px 20px rgba(245, 215, 153, 0.4),
        0 8px 40px rgba(232, 170, 91, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: pulse-glow 3s ease-in-out infinite;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 30px rgba(245, 215, 153, 0.6),
        0 12px 50px rgba(232, 170, 91, 0.4);
    border-color: #FFFFFF;
}

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

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(245, 215, 153, 0.4),
            0 8px 40px rgba(232, 170, 91, 0.3);
    }
    50% {
        box-shadow:
            0 4px 30px rgba(245, 215, 153, 0.6),
            0 8px 50px rgba(232, 170, 91, 0.5),
            0 0 60px rgba(232, 170, 91, 0.3);
    }
}

.btn-secondary {
    background: transparent;
    color: var(--color-amber-accent);
    border: var(--border-archive);
}

.btn-secondary:hover {
    background: rgba(212, 165, 116, 0.1);
    border-color: var(--color-amber-accent);
}

.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Film Strip Progress Bar */
.film-progress {
    position: relative;
    height: 24px;
    background: var(--color-sepia-mid);
    border: 1px solid var(--color-stamp);
    overflow: hidden;
}

.film-progress::before,
.film-progress::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    background: repeating-linear-gradient(
        0deg,
        var(--color-stamp),
        var(--color-stamp) 3px,
        transparent 3px,
        transparent 6px
    );
}

.film-progress::before { left: 0; }
.film-progress::after { right: 0; }

.film-progress-bar {
    height: 100%;
    background: linear-gradient(90deg,
        var(--color-amber-primary),
        var(--color-gold-archive));
    transition: width 0.5s ease;
    position: relative;
}

.film-progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.1) 10px,
        rgba(0, 0, 0, 0.1) 12px
    );
}

/* Navigation */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg,
        rgba(26, 20, 16, 0.95) 0%,
        rgba(26, 20, 16, 0.85) 100%);
    backdrop-filter: blur(12px);
    border-bottom: var(--border-archive);
    padding: var(--space-sm) var(--space-md);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--color-cream);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.nav-logo svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(212, 165, 116, 0.3));
}

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

.nav-link {
    color: var(--color-amber-accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.3s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.nav-credit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(212, 165, 116, 0.1);
    border: 1px solid var(--color-stamp);
    border-radius: 4px;
    color: var(--color-amber-primary);
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Mobile Menu */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-amber-primary);
    transition: all 0.3s ease;
}

/* Grid Layouts */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.grid {
    display: grid;
    gap: var(--space-md);
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Masonry Grid for History */
.masonry-grid {
    column-count: 4;
    column-gap: var(--space-md);
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: var(--space-md);
}

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

@keyframes shutterClick {
    0% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
    100% { transform: scaleY(1); }
}

@keyframes photoReveal {
    0% {
        opacity: 0;
        filter: brightness(2) blur(10px);
    }
    100% {
        opacity: 1;
        filter: brightness(1) blur(0);
    }
}

@keyframes stampAppear {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(-2deg);
    }
    100% {
        transform: scale(1) rotate(-2deg);
        opacity: 1;
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-photo-reveal {
    animation: photoReveal 1s ease-out forwards;
}

.animate-stamp {
    animation: stampAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Responsive Typography */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    h1 { font-size: clamp(1.75rem, 7vw, 2.5rem); }
    h2 { font-size: clamp(1.5rem, 5vw, 2rem); }
    h3 { font-size: clamp(1.15rem, 3.5vw, 1.5rem); }

    .btn {
        min-height: 52px;
        padding: 1.125rem 2rem;
        font-size: 1rem;
    }

    .masonry-grid {
        column-count: 2;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--color-sepia-dark);
        border-top: var(--border-archive);
        flex-direction: column;
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    .nav-links.active {
        display: flex;
    }
}

@media (max-width: 480px) {
    .masonry-grid {
        column-count: 1;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 375px) {
    h1 {
        font-size: clamp(1.5rem, 9vw, 2rem);
    }
}

/* Selection */
::selection {
    background: var(--color-amber-primary);
    color: var(--color-sepia-dark);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--color-sepia-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--color-stamp);
    border: 2px solid var(--color-sepia-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-amber-primary);
}

/* Focus States */
*:focus-visible {
    outline: 2px solid var(--color-amber-primary);
    outline-offset: 4px;
}

/* ========================================
 Before/After Comparison Slider
 ======================================== */

.comparison-section {
  width: 100%;
  max-width: 800px;
  margin: var(--space-xl) auto;
  position: relative;
}

.comparison-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: var(--color-charcoal);
  border: 2px solid var(--color-stamp);
  box-shadow: var(--shadow-lifted);
}

.comparison-frame {
  position: absolute;
  inset: 0;
  background: transparent;
  padding: 0;
}

.comparison-images {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-charcoal);
}

.comparison-before,
.comparison-after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-before {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: grayscale(1) sepia(0.3);
  width: 100%;
  clip-path: none;
}

.comparison-after {
  background: transparent;
}

.comparison-after video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.comparison-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-amber-primary);
  cursor: ew-resize;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  box-shadow: 0 0 8px rgba(212, 165, 116, 0.5);
}

.comparison-divider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: var(--color-amber-primary);
  border: 2px solid var(--color-sepia-dark);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.comparison-divider::after {
  content: '⟷';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-sepia-dark);
  font-weight: bold;
  pointer-events: none;
}

.comparison-labels {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

.comparison-label {
  padding: var(--space-xs) var(--space-sm);
  background: rgba(26, 20, 16, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-stamp);
  color: var(--color-amber-accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@media (max-width: 768px) {
  .comparison-slider {
      aspect-ratio: 16 / 9;
  }

  .comparison-divider::before {
      width: 32px;
      height: 32px;
  }

  .comparison-label {
      font-size: 0.65rem;
      padding: 0.25rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .comparison-slider {
      aspect-ratio: 16 / 9;
  }

  .comparison-divider::before {
      width: 28px;
      height: 28px;
  }
}

/* ========================================
 Footer
 ======================================== */

.footer {
    padding: var(--space-lg) 0;
    border-top: var(--border-archive);
    background: var(--color-sepia-dark);
}

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

.footer-links {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.footer-link {
    color: var(--color-gold-archive);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

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

.footer-copyright {
    color: var(--color-stamp);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}
