:root {
  --scale-factor: 1;
}

/* Reset basic browser styling and create the black letterbox */
body, html {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden; 
  background-color: #000000; 
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: none; 
}

/* THE VIRTUAL MACBOOK CANVAS */
#appContainer {
  position: relative;
  width: 1440px; 
  height: 900px;
  transform: scale(var(--scale-factor));
  transform-origin: center center;
  overflow: hidden;
  background-color: #ffffff; 
}

/* --- THE NEW RIGID 16:9 BOX --- */
/* --- NEW: LAYER 0: WARNING SCREEN --- */
.warning-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10005; /* Absolute top layer above everything */
  transition: opacity 0.5s ease; /* Smooth fade to black when leaving */
  cursor: default;
}
/* Assuming your warning SVG is widescreen (16:9). This box dynamically scales to 
   match the SVG exactly and centers itself on the screen. */
   .warning-box {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    max-width: calc(100vh * (16 / 9));
    max-height: calc(100vw * (9 / 16));
  }
  
  /* Stack both images perfectly on top of each other */
  .warning-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Because the box is exactly 16:9, we can safely use cover! */
    opacity: 0; 
    transition: opacity 0.8s ease; 
  }
  
  #warningLoading {
    animation: fadeInWarning 0.6s ease 0.8s forwards; 
  }
  
  /* --- THE CSS LOADING SPINNER --- */
  .loading-spinner {
    position: absolute;
    
    /* THE FIX: These percentages now anchor to the SVG, not the screen! */
    bottom: 8%; 
    right: 6%; 
    
    /* The size scales with the SVG instead of the monitor */
    width: 4%; 
    aspect-ratio: 1 / 1;
    border: 5px solid rgba(255, 255, 255, 0.2); 
    border-top: 5px solid #ffffff; 
    border-radius: 50%;
    opacity: 0; 
    z-index: 10007;
    
    animation: spin 1s linear infinite, fadeInWarning 0.6s ease 0.8s forwards;
    transition: opacity 0.8s ease; 
  }

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Hard hides the screen after the transition is completely done */
.warning-container.hidden {
  display: none !important;
}

/* The class JS triggers to fade the whole container to black */
.warning-container.fade-out {
  opacity: 0;
}

@keyframes fadeInWarning {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* --- NEW: WARNING LINK OVERLAY --- */
.warning-link {
  position: absolute;
  
  /* Use this to slide the box UP or DOWN */
  top: 61%; 
  
  /* Keeps the box perfectly centered left-to-right */
  left: 50%;
  transform: translate(-50%, -50%);
  
  /* Change these to match the exact size of your blue text */
  width: 63vw; 
  height: 9vh; 
  
  z-index: 10006; /* Sits on top of the image */
  cursor: none; /* Keeps your custom Wii cursor */
  cursor: pointer;
  
  /* DEV TRICK: Keep this red border on so you can see the box! 
     Once you have it lined up perfectly, delete this line! */
  border: 0px solid red; 
}

/* --- LAYER 1: BACKGROUND --- */
.wii-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Prevents stretching */
  z-index: 0; /* Pushes it to the back */
}

/* --- LAYER 4: SLIDER SYSTEM --- */
.slider-viewport {
  position: absolute; /* Anchors the window securely to the screen */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%; /* Fills the whole screen */
  overflow: hidden; /* This is the "window" that hides the off-screen pages */
  z-index: 1; /* Keeps it behind your fixed menu buttons */
}

.slider-track {
  display: flex;
  width: 100%;
  height: 100%; /* Ensures the track fills the viewport */
  transition: transform 0.4s ease-in-out; /* This controls the speed and smoothness of the slide */
}

/* --- LAYER 4: CHANNEL GRID --- */
.grid-container {
  display: grid;
  
  /* 1. Cap the maximum column widths */
  grid-template-columns: repeat(4, calc(min(100vw, 177.78vh) * 0.19875)); 
  
  /* 2. Automatically center the grid tracks on ultrawide screens */
  justify-content: center; 
  
  /* 3. Cap the gap spacing */
  gap: calc(min(100vw, 177.78vh) * 0.005) calc(min(100vw, 177.78vh) * 0.015); 
  
  /* 4. Cap the top/bottom padding so it permanently clears the menu bar! */
  padding: 0; 
  padding-top: calc(min(100vw, 177.78vh) * 0.08);
  padding-bottom: calc(min(100vw, 177.78vh) * 0.228); 
  
  height: 100%; 
  align-content: center; 
  
  width: 100%;
  flex: 0 0 100%; 
  box-sizing: border-box;
}

/* Apply base styling to both images and our new videos */
.channel img,
.channel video {
  width: 100%;
  aspect-ratio: 16 / 9; /* Keeps the widescreen shape */
  object-fit: cover; /* Ensures the video fills the box perfectly */
  transition: transform 0.2s ease; 
  cursor: none; /* Keeps native cursor hidden over videos */
  pointer-events: none; /* Optional: Stops the video from eating clicks */
}

/* THE FIX: Apply the hover "Pop" to the wrapper container instead of the media! */
.channel.project-trigger:hover img,
.channel.project-trigger:hover video {
  transform: scale(1.05); 
}

/* Force the wrapper container to catch all mouse interactions */
.channel.project-trigger {
  pointer-events: auto;
}

/* Ensure the media inside ignores the mouse so it doesn't block the wrapper */
.channel.project-trigger img,
.channel.project-trigger video {
  pointer-events: none;
}

/* --- LAYER 2 & 3: MENU BAR --- */
.menu-bar-container {
  position: fixed;
  bottom: 0;
  
  /* Center the bar and cap its width so it never outgrows the screen height! */
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 177.78vh); 
  
  height: auto; 
  display: flex; 
  z-index: 10; 
}

.menu-bar-bg {
  width: 100%;
  height: auto; 
  display: block;
}

.menu-btn {
  position: absolute;
  bottom: 20%; 
  /* Switched to percentages so the buttons scale safely inside the capped menu bar */
  width: 10%; 
  aspect-ratio: 1 / 1; 
  transition: transform 0.2s ease;
}

.menu-btn:hover {
  transform: scale(1.1);
  cursor: none; 
}

/* Switched to percentages for perfect placement */
.left-btn { left: 4.5%; }
.right-btn { right: 3.2%; }

/* --- LAYER 5: PAGINATION NAVIGATION --- */
.nav-btn {
  position: fixed;
  
  /* THE MAGIC MATH: Calculates the exact vertical center of the middle grid row! */
  top: calc(50vh - min(100vw, 177.78vh) * 0.074); 
  
  /* Caps the size of the arrows so they don't get massive on ultrawide monitors */
  width: calc(min(100vw, 177.78vh) * 0.06); 
  aspect-ratio: 1 / 1;
  transition: transform 0.2s ease, opacity 0.3s ease;
  z-index: 10; 
}

/* HORIZONTAL LOCK: Center the arrow, then push it to the left edge of the grid */
.nav-left {
  left: 50%;
  transform: translate(calc(-50% - min(100vw, 177.78vh) * 0.46), -50%);
}

/* HORIZONTAL LOCK: Center the arrow, then push it to the right edge of the grid */
.nav-right {
  left: 50%;
  transform: translate(calc(-50% + min(100vw, 177.78vh) * 0.46), -50%);
}

/* HOVER EFFECTS: We have to re-declare the translate math here to keep them locked while scaling! */
.nav-left:hover {
  transform: translate(calc(-50% - min(100vw, 177.78vh) * 0.46), -50%) scale(1.1); 
  cursor: none; 
}

.nav-right:hover {
  transform: translate(calc(-50% + min(100vw, 177.78vh) * 0.46), -50%) scale(1.1); 
  cursor: none; 
}

/* Utility class to handle the visibility logic */
.hidden {
  opacity: 0;
  pointer-events: none; /* Prevents the user from clicking it while invisible */
}

/* --- LAYER 6: CUSTOM CURSOR --- */
#customCursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 64px; /* Adjust this to make the hand bigger or smaller! */
  z-index: 9999; /* Keeps it on top of absolutely everything */
  pointer-events: none; /* CRITICAL: Lets you click "through" the image */
  transform: translate(-10px, -5px); /* Centers the fingertip to the actual click point */
  transition: transform 0.1s ease-out, opacity 0.2s ease;
}

/* --- FONTS --- */
@font-face {
  font-family: 'DS-Digital';
  src: url('assets/DS-DIGIB.TTF') format('truetype');
}

@font-face {
  font-family: 'ATTFShingo';
  src: url('assets/ATTFShinGoProBold.ttf') format('truetype');
}

@font-face {
  font-family: 'WiiSystem';
  src: url('assets/wiisystemfont.otf') format('opentype');
}

/* --- LAYER 7: DATE & TIME --- */
.datetime-container {
  position: fixed;
  /* Locks the distance from the bottom */
  bottom: calc(min(100vw, 177.78vh) * 0.012); 
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 15; 
  pointer-events: none; 
}

#wiiTime {
  font-family: 'DS-Digital', monospace;
  /* Locks the font size */
  font-size: calc(min(100vw, 177.78vh) * 0.06); 
  line-height: 1;
  letter-spacing: 0.1em;
  color: #b8b8b8; 
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1); 
}

#wiiDate {
  font-family: 'ATTFShingo', Arial, sans-serif; 
  /* Locks the font size */
  font-size: calc(min(100vw, 177.78vh) * 0.038); 
  font-weight: bold;
  
  /* Locks the gap between the time and date */
  margin-top: calc(min(100vw, 177.78vh) * 0.02); 
  
  color: #8c8c8c; 
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* --- NEW: LAYER 7: TRANSITION FLASH --- */
.white-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: white;
  opacity: 0;
  pointer-events: none;
  z-index: 9998; /* Sits right underneath your custom cursor */
  transition: opacity 0.4s ease-in-out;
}

.white-flash.active {
  opacity: 1;
  pointer-events: all;
}

/* --- NEW: LAYER 8: ABOUT PAGE --- */
.about-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20; 
  display: flex;
  flex-direction: column;   /* Stacks the Mii/Bio block and the Buttons block vertically */
  justify-content: center;  /* Centers the whole group vertically on the screen */
  
  /* CHANGE THIS: This is the exact gap between the Mii/Bio and the Buttons! */
  gap: 5vh; 
}

/* New About Page Background */
.about-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0; 
}

/* Hard hide for swapping screens */
.hidden-page {
  display: none !important;
}

/* Centers the Mii and Text side-by-side */
.about-content {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  right: 1vw;
  gap: min(3vw, 4vh);
}

/* Buttons Container */
.about-buttons {
  display: flex;
  justify-content: center;
  gap: 4vw; /* Space between the two buttons */
  margin-bottom: 4vh;
  margin-top: -5vh;
  opacity: 0;
  animation: slideUpFade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.5s; 
}

.mii-character {
  height: min(75vh, 40vw); /* Keep whatever numbers worked well for you! */
  
  /* THE FIX: Add these 3 lines */
  width: auto;
  max-width: 40vw; /* Forces the Mii to never take up more than 40% of the screen width */
  object-fit: contain; 
  
  opacity: 0;
  position: relative;
  right: 0; /* Make sure this is 0 so it doesn't push into the text! */
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.2s; 
}

.bio-text {
  height: min(50vh, 28vw); 
  
  /* THE FIX: Add these 3 lines */
  width: auto;
  max-width: 48vw; /* Forces the text to stay in its half of the screen */
  object-fit: contain;
  
  opacity: 0;
  margin-top: 5vh;
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.35s; 
}

.about-btn {
  /* THE FIX: Sets a minimum floor of 24vh so it never gets too small */
  width: max(28vw, 24vh); 
  height: auto;
  cursor: none; 
  transition: transform 0.1s ease, filter 0.1s ease;
}

/* The Hover "Pop" Effect */
.about-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.05); /* Makes the SVG slightly brighter when hovered */
}

/* --- ANIMATION KEYFRAMES --- */
@keyframes popIn {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slideUpFade {
  0% { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* --- NEW: LAYER 9: CONTACT PAGE --- */
.contact-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 20; 
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Update the container alignment */
.contact-content {
  display: flex;
  align-items: flex-end; 
  justify-content: center;
  
  /* THE FIX: This replaces your rigid 4vw gap */
  gap: min(4vw, 5vh); 
  
  margin-top: -5vh; 
}

.contact-mii {
  height: min(75vh, 40vw); 
  
  /* THE FIX */
  width: auto;
  max-width: 40vw; 
  object-fit: contain;
  
  opacity: 0;
  margin-bottom: min(23vh, 15vw); 
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.2s;
}

.contact-text {
  height: min(58vh, 30vw); 
  
  /* THE FIX */
  width: auto;
  max-width: 48vw; 
  object-fit: contain;
  
  opacity: 0;
  position: relative;
  left: 0; /* Make sure this is 0 so it doesn't push horizontally! */
  margin-bottom: min(16vh, 10vw);
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.35s;
}

.contact-mii { animation-delay: 0.2s; }
.contact-text { animation-delay: 0.35s; }

.contact-bottom-bar {
  position: absolute;
  bottom: 12vh; /* Distance from the bottom of the screen */
  left: 0;
  width: 100vw;
  padding: 0 8vw; /* Spacing from the left and right edges */
  box-sizing: border-box;
  display: flex;
  /* 1. Change this from space-between to center */
  justify-content: center; 
  align-items: center;
  
  /* 2. Add a gap to control the exact distance between them */
  gap: 6vw;
  opacity: 0;
  animation: slideUpFade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.5s;
}

.social-buttons {
  display: flex;
  gap: 1.5vw; /* Spacing between the circle buttons */
}

.circle-btn {
  /* Ensures the social icons stay tappable on narrow screens */
  width: max(9vw, 8vh); 
  height: auto;
  cursor: none;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.circle-btn:hover {
  transform: scale(1.1);
  filter: brightness(1.05);
}

/* --- TOOLTIP STYLING (PILL SHAPE) --- */
.wii-tooltip {
  position: fixed;
  font-family: 'WiiSystem', Arial, sans-serif;
  font-size: 1.5vw;
  color: #555; 
  background-color: #ffffff; 
  border: 3px solid #a0a0a0; 
  border-radius: 50px; 
  padding: 0.6vw 2vw; 
  opacity: 0;
  pointer-events: none;
  z-index: 9997; 
  transition: opacity 0.15s ease-in-out;
  
  /* DEFAULT: Centered horizontally, hangs down from the top coordinate */
  transform: translateX(-50%); 
}

/* FLIPPED STATE: Forces the bubble to sit exactly above the coordinate */
.wii-tooltip.shift-up {
  transform: translate(-50%, -100%) !important; 
}

.wii-tooltip.shift-up {
  /* Shifts the bubble horizontally to center it, and vertically up by its own height! */
  transform: translate(-50%, -100%); 
}

/* --- THE WII CHANNEL ZOOM ANIMATION (CLONE) --- */
.zooming-clone {
  position: fixed; /* Locks it to the screen, completely escaping the slider grid */
  z-index: 9999 !important; /* Sits higher than the 9998 Black Flash */
  margin: 0 !important; /* Ignores grid spacing */
  pointer-events: none; 
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1) !important; 
  transform-origin: center center;
}

/* --- NEW: LAYER 10: PROJECT SCREEN --- */
.project-page {
  position: absolute; /* Changed from fixed so it stays inside the 1440x900 canvas */
  top: 0;
  left: 0;
  width: 100%; /* Changed from 100vw */
  height: 100%; /* Changed from 100vh */
  background-color: #000000; 
  z-index: 9999; 
}

/* Make sure your custom cursor is higher than the project page! */
#customCursor {
  z-index: 10000 !important;
}

/* The Invisible Screen Boundary */
.project-tv-screen {
  width: 100%; /* Changed from 100vw */
  height: 100%; /* Changed from 100vh */
  position: relative; 
  overflow: hidden; 
}

/* LAYER 1: The Image/Video */
.tv-image {
  position: absolute;
  top: 0; 
  left: 0;
  width: 100vw;
  height: 100vh;
  /* THE FIX: 'contain' forces the video to keep its original aspect ratio! */
  object-fit: contain; 
  z-index: 1; 
}

/* --- NEW: VIDEO SEQUENCE LAYERING --- */
.loop-video {
  z-index: 1; /* Bottom Layer */
}

.intro-video {
  z-index: 2; /* Top Layer */
}

/* LAYER 2: The Menu Bar */
.tv-bar {
  position: absolute;
  /* Maintains your perfect vertical letterbox math */
  bottom: calc(max(3vh, 50vh - 28.125vw + 1.5vw));
  
  /* THE FIX: Centers the bar horizontally */
  left: 50%;
  transform: translateX(-50%);
  
  /* THE FIX: Limits the width to exactly match the video on wide screens */
  width: min(100vw, 177.78vh); 
  height: calc(min(100vw, 177.78vh) * 0.125); 
  object-fit: fill;
  z-index: 2; 
}

/* LAYER 3: The Buttons Container */
.tv-buttons {
  position: absolute;
  bottom: calc(max(5vh, 50vh - 28.125vw + 3.5vw));
  
  /* Centers the button container horizontally */
  left: 50%;
  transform: translateX(-50%);
  
  width: min(100vw, 177.78vh); 
  height: auto; 
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* Locks your 8vw gap to the protected video width */
  gap: calc(min(100vw, 177.78vh) * 0.08); 
  z-index: 3; 
}

/* LAYER 4: The Buttons */
.project-btn {
  /* Locks your perfect 25vw size to the protected video width */
  width: calc(min(100vw, 177.78vh) * 0.34); 
  height: auto;
  cursor: none;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.project-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.05);
}

/* LAYER 4: The SVG Frame Overlay */
.tv-frame {
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%; /* Changed from 100vw */
  height: 100%; /* Changed from 100vh */
  object-fit: fill; 
  
  filter: drop-shadow(0px 0px 1px #000000) drop-shadow(0px 0px 5px #000000);
  transform: scaleX(1.09) scaleY(1.07); /* Keep this if your SVG needs it to act as a vignette! */
  
  z-index: 4; 
  pointer-events: none; 
}

/* --- EDGE FEATHERING EFFECT --- */
.feather-mask {
  -webkit-mask-image: radial-gradient(ellipse at center, black 70%, transparent 100%);
  mask-image: radial-gradient(ellipse at center, black 70%, transparent 100%);
}

/* --- NEW: SEE MORE INTERACTIVE GALLERY --- */
.see-more-gallery {
  display: flex;
  align-items: center;
  gap: 1vw; /* Space between arrows and the photo */
  opacity: 0;
  
  /* Copies the Mii's pop-in animation perfectly */
  animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-delay: 0.2s; 
}

/* --- SEE MORE GALLERY --- */
.gallery-main-img {
  height: min(60vh, 50vw); 
  width: auto;
  max-width: 40vw; 
  object-fit: cover;
  border: 4px solid #ffffff;
  border-radius: 15px;
  box-shadow: 0px 5px 15px rgba(0,0,0,0.2); 
  transition: opacity 0.2s ease; 
}

.gallery-arrow {
  width: max(4vw, 5vh); 
  cursor: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.gallery-arrow:hover {
  transform: scale(1.15);
}

/* We will use JavaScript to hide the arrows if a project only has 1 picture! */
.gallery-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- ADJUST SEE MORE BUTTONS ONLY --- */
#seeMorePage .about-buttons {
  /* Use margin-top to push them further down from the gallery/text */
  margin-top: 2vh; 
  
  /* Use margin-bottom if you need to push them up from the bottom of the monitor */
  margin-bottom: 0vh; 
}