/* --- 1. CORE CONFIGURATION --- */
:root {
  /* Cinematic Pure Black */
  --bg-void: #020202; 
  --ink-white: #f0f0f0;
  --ink-dim: rgba(240, 240, 240, 0.6);
  
  /* LUXURY TIMING CONFIGURATION */
  /* Used for Backgrounds & Splash */
  --ease-cinematic: cubic-bezier(0.19, 1, 0.22, 1); 
  /* Used for Text Reveals - Ultra Smooth "Drift" */
  --ease-luxury: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Used for Opacity Fades - Soft Sine */
  --ease-soft: cubic-bezier(0.4, 0.0, 0.6, 1);
  
  /* --- IMAGE SOURCES (Local Paths Active) --- */
  --img-land: url('images/cinintiriks-landscaping.png');
  --img-paint: url('images/paintiriks-painting.png');
  --img-drywall: url('images/cinintiriks-drywall.png');
  --img-floor: url('images/flotiriks-flooring.png');
  --img-fence: url('images/fentiriks-fence.png');
}

/* --- 2. RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background-color: var(--bg-void);
  font-family: 'Montserrat', sans-serif;
  color: var(--ink-white);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* --- 3. SPLASH SCREEN --- */
#splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  /* Very subtle gradient to help grain pop without washing out black */
  background: radial-gradient(circle at center, #0a0a0a 0%, #000000 100%);
  display: flex; align-items: center; justify-content: center;
  transition: transform 1.8s var(--ease-cinematic);
}

#splash-screen.slide-up { transform: translateY(-100%); }

.splash-content {
  text-align: left;
  display: flex; flex-direction: column;
  align-items: flex-start;
  mix-blend-mode: normal;
  position: relative;
  z-index: 2;
}

.splash-logo {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(4rem, 11vw, 9rem);
  letter-spacing: 0.1em;
  line-height: 0.9;
  color: #fff;
  opacity: 0;
  white-space: nowrap;
  animation: splashTextReveal 2.4s var(--ease-luxury) forwards 0.3s;
  margin-left: -5px; 
}

.splash-logo .tm { 
  font-family: 'Montserrat', sans-serif; 
  font-size: 0.2em; 
  vertical-align: top; 
  top: 0.1em; 
  opacity: 0.6; 
}

.splash-sub {
  font-family: 'Montserrat', sans-serif;
  font-weight: 400;
  font-size: clamp(0.6rem, 1.5vw, 0.9rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ink-dim);
  opacity: 0;
  margin-top: 5px;
  margin-left: 5px; 
  animation: splashFadeUp 2.4s var(--ease-luxury) forwards 0.8s;
}

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

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

/* Splash Grain (Balanced: Cinematic but not overwhelming) */
.splash-grain {
  position: absolute; inset: 0; z-index: 1;
  /* Reduced opacity significantly from 0.85 */
  opacity: 0.15; 
  /* Using 'screen' blend mode works better on black than 'overlay' */
  mix-blend-mode: screen; 
  /* High frequency (3.0) for fine film grain */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.0' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* --- 4. GLOBAL GRAIN OVERLAY (Ultra Fine) --- */
.grain-overlay {
  position: fixed; inset: 0; z-index: 99999; pointer-events: none;
  opacity: 0.18; 
  /* Increased frequency to 5 for extremely fine grain */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* --- 5. FIXED UI LAYER --- */
.ui-layer {
  position: fixed; inset: 0; z-index: 100; pointer-events: none;
  padding: clamp(30px, 4vw, 60px);
  display: grid; 
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  opacity: 0; animation: uiFadeIn 2s ease forwards 2s;
}

@keyframes uiFadeIn { to { opacity: 1; } }

.brand { 
  grid-column: 1; grid-row: 1;
  pointer-events: auto; 
  align-self: start; justify-self: start;
}

.logo-text {
  font-family: 'Cormorant Garamond', serif; font-weight: 500;
  font-size: clamp(16px, 1.6vw, 20px);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  text-align: left;
}
.logo-text .tm { font-family: 'Montserrat', sans-serif; font-size: 0.4em; top: -0.2em; opacity: 0.7; margin-left: 2px; }

.logo-sub {
  font-family: 'Montserrat', sans-serif; 
  font-weight: 400; text-transform: uppercase;
  font-size: 9px; color: var(--ink-dim); margin-top: 5px; letter-spacing: 0.3em;
}

.chapter-counter {
  grid-column: 1; grid-row: 2;
  align-self: end; justify-self: start;
  font-family: 'Montserrat', sans-serif; font-size: 10px;
  letter-spacing: 0.25em; opacity: 0.8;
  text-shadow: 0 2px 5px rgba(0,0,0,0.5);
  margin-bottom: 5px; 
}

/* --- 6. SCROLL PROGRESS LINE --- */
.scroll-line-container {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 90;
  height: clamp(60px, 15vh, 120px);
  width: 40px; 
  display: flex; justify-content: center; align-items: flex-end;
  pointer-events: none;
  padding-bottom: 20px;
}

.scroll-line-track {
  width: 1px; height: 100%;
  background: rgba(255,255,255,0.15);
  position: relative;
  overflow: hidden;
}

.scroll-line-progress {
  position: absolute; top: 0; left: 0; width: 100%; height: 0%;
  background: #fff;
  transition: height 0.1s linear; 
}

/* --- 7. MAIN SCROLL CONTAINER --- */
main {
  height: 100%; width: 100%;
  overflow-y: scroll; scroll-snap-type: y mandatory; scroll-behavior: smooth;
}

/* --- 8. SLIDE STYLES --- */
.slide {
  position: relative; height: 100vh; width: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* BACKGROUNDS */
.bg-layer { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.bg-img {
  width: 100%; height: 100%;
  background-size: cover; background-position: center;
  transform: scale(1.15); 
  filter: brightness(0.4) contrast(1.1); 
  /* Ultra-slow background movement */
  transition: transform 10s var(--ease-cinematic), filter 4s ease;
}

.slide.active .bg-img { transform: scale(1.0); filter: brightness(0.5) contrast(1.1); }

/* VIGNETTE */
.bg-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,0.95) 100%);
}

/* IMAGES */
#cinintiriks .bg-img { background-image: var(--img-land); }
#paintiriks .bg-img { background-image: var(--img-paint); }
#daltiriks .bg-img { background-image: var(--img-drywall); }
#flotiriks .bg-img { background-image: var(--img-floor); }
#fentiriks .bg-img { background-image: var(--img-fence); }

/* STATUS INDICATOR */
.status-indicator {
  position: absolute;
  top: clamp(30px, 4vw, 60px); 
  right: clamp(30px, 4vw, 60px);
  z-index: 20;
  
  font-family: 'Montserrat', sans-serif;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.25em;
  color: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  
  opacity: 0; transform: translateY(-10px);
  /* Status fade speed */
  transition: opacity 1.0s var(--ease-soft) 0.5s, transform 1.0s var(--ease-luxury) 0.5s;
}

.slide.active .status-indicator {
  opacity: 1; transform: translateY(0);
}

.status-indicator .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 5px currentColor;
}

.status-indicator.available { color: #fff; }
.status-indicator.coming-soon { color: rgba(255,255,255,0.5); }

/* CONTENT LAYER */
.content-layer {
  position: relative; z-index: 10;
  text-align: center;
  max-width: 100%; 
  padding: 0 20px; 
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

/* TYPOGRAPHY ANIMATIONS */

/* Meta Tag */
.meta-tag {
  font-family: 'Montserrat', sans-serif; font-weight: 400;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.4em;
  margin-bottom: clamp(15px, 3vh, 25px);
  color: rgba(255,255,255,0.8);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  
  opacity: 0; 
  transform: translateY(20px); 
  
  /* Faster timing (0.9s) */
  transition: opacity 0.9s var(--ease-soft), transform 0.9s var(--ease-luxury);
  will-change: opacity, transform;
}

/* Hero Title */
.hero-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(3rem, 8vw, 7.5rem); 
  line-height: 0.95;
  font-weight: 300;
  text-transform: uppercase;
  margin: 0 0 clamp(20px, 4vh, 40px) 0;
  color: #fff;
  text-shadow: 0 20px 60px rgba(0,0,0,0.7);
  letter-spacing: -0.02em; 
  
  opacity: 0; 
  transform: translateY(30px); 
  
  /* Faster timing (1.0s) - Snappier reveal */
  transition: opacity 1.0s var(--ease-soft) 0.1s, transform 1.0s var(--ease-luxury) 0.1s;
  will-change: opacity, transform;
}

.hero-title .tm {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.15em; vertical-align: top; top: -0.8em; margin-left: 8px;
  opacity: 0.6; letter-spacing: 0; font-weight: 400;
}

/* Action Wrap */
.action-wrap {
  opacity: 0; 
  transform: translateY(20px);
  
  /* Faster timing (1.1s) */
  transition: opacity 1.1s var(--ease-soft) 0.2s, transform 1.1s var(--ease-luxury) 0.2s;
  will-change: opacity, transform;
}

.text-link {
  position: relative;
  display: inline-flex; align-items: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.35em; 
  color: #fff;
  text-decoration: none;
  padding: 10px 0;
  transition: opacity 0.6s ease;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.text-link::before {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 0%; height: 1px;
  background-color: rgba(255,255,255,0.7);
  transition: width 0.8s var(--ease-cinematic);
}

.text-link:hover { opacity: 0.9; letter-spacing: 0.4em; }
.text-link:hover::before { width: 100%; }

/* ACTIVE STATES */
.slide.active .meta-tag,
.slide.active .hero-title,
.slide.active .action-wrap {
  opacity: 1; transform: translateY(0);
}

/* --- 9. MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
  .ui-layer { padding: 30px 24px; }
  
  .hero-title { 
    font-size: clamp(3.2rem, 11vw, 5rem);
    letter-spacing: -0.01em;
    line-height: 0.95;
    transform: translateY(20px); 
  }
  
  .slide.active .hero-title {
    transform: translateY(0);
  }

  .meta-tag { 
    margin-bottom: 25px; 
  }
  
  .scroll-line-container {
    height: 80px;
    padding-bottom: 15px;
  }

  .chapter-counter {
    justify-self: start;
    align-self: end;
  }
}

/* --- 10. 404 PAGE STYLES --- */
body.page-404 {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
}

/* Header Visibility Override for 404 (No animation, instant show) */
.page-404 .ui-layer {
  opacity: 1 !important;
  animation: none !important;
  pointer-events: none; /* Changed from auto to none so we can click the button underneath */
}

/* Container for centered error content */
.error-container {
  position: relative; 
  z-index: 10;
}

.error-code {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(6rem, 20vw, 12rem);
  line-height: 1;
  color: #fff;
  font-weight: 300;
  opacity: 0;
  /* Reusing splashTextReveal for consistent "Drift" effect on content only */
  animation: splashTextReveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.3s;
}

.error-msg {
  font-family: 'Montserrat', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-size: clamp(0.7rem, 2vw, 1rem);
  color: rgba(240, 240, 240, 0.6);
  margin-top: 10px;
  margin-bottom: 40px;
  opacity: 0;
  animation: splashTextReveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.5s;
}

.home-btn {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 15px 30px;
  color: #fff;
  text-decoration: none;
  font-family: 'Montserrat', sans-serif;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.25em;
  transition: all 0.4s ease;
  opacity: 0;
  animation: splashTextReveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 0.7s;
}

.home-btn:hover {
  background: #fff;
  color: #000;
  border-color: #fff;
}