/* ===== Fonts ===== */

@font-face { 
  font-family: 'Maksimal'; 
  src: url('../fonts/Maksimal.ttf'); 
}

@font-face { 
  font-family: 'NeueMachina'; 
  src: url('../assets/fonts/NeueMachina-Light.otf'); 
}

/* ===== Reset ===== */

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

/* =====================================================
   GLOBAL VARS
===================================================== */

:root{
  --ticker-h: 48px;

  /* keep unit off the left/right edges */
  --safe-inline: clamp(32px, 6vw, 80px);

  /* bottom breathing room */
  --edge-gap: clamp(16px, 3vh, 48px);

  /* ✅ (3) double space between ticker and central unit */
  --stack-gap: clamp(50px, 7.6vh, 100px);

  /* ✅ (4) allow the unit to scale up to 1550px */
  --stage-max-w: 1550px;

  /* 1300 / 620 */
  --stage-ratio: 2.0967741935;

  /* monitor content nudge (kept for non-BG content) */
  --content-shift: clamp(10px, 3.5vh, 25px);

  /* ✅ (2) reduce horizontal space between cards and monitor by ~20% */
  --layout-gap: clamp(50px, 0.5vw, 16px);

  /* cards size (kept from your last iteration) */
  --card-scale: 1.16;

  /* BG.svg scale (kept: -20%) */
  --bg-svg-scale: 0.8;
}

/* =====================================================
   BODY: ticker stays top, unit stays centered below
===================================================== */

body { 
  background: #000; 
  font-family: 'NeueMachina', sans-serif;

  min-height: 100svh;
  width: 100%;

  display: grid;
  grid-template-rows: var(--ticker-h) 1fr;
  row-gap: var(--stack-gap);

  padding-bottom: var(--edge-gap);

  overflow: hidden;
}

/* =====================================================
   BACKGROUND GRID (independent layer)
===================================================== */

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.background::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      to right,
      #272727 0,
      #272727 1px,
      transparent 1px,
      transparent 50px
    ),
    repeating-linear-gradient(
      to bottom,
      #272727 0,
      #272727 1px,
      transparent 1px,
      transparent 50px
    );
}

/* =====================================================
   TICKER: sticky to top edge
===================================================== */

.ticker { 
  background: #e53935; 
  overflow: hidden; 
  display: flex;
  height: var(--ticker-h);
  width: 100%;
  align-items: center;

  position: sticky;
  top: 0;
  z-index: 1000;
}

.track { 
  display: flex; 
  gap: 40px;
  align-items: center;
  white-space: nowrap;
  animation: scroll 70s linear infinite;
}

.track img { 
  height: 32px;
  display: block;
}

@keyframes scroll { 
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* =====================================================
   STAGE (3 cards + BG + monitor)
===================================================== */

.layout {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(
    var(--stage-max-w),
    calc(100vw - (2 * var(--safe-inline)))
  );

  max-height: calc(
    100svh - var(--ticker-h) - var(--stack-gap) - (2 * var(--edge-gap))
  );

  aspect-ratio: 1300 / 620;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--layout-gap);

  margin-inline: auto; /* ✅ THIS fixes the shift */
}


/* =====================================================
   SIDE NAV (3 cards)
===================================================== */

/* FULL REPLACEMENT: side-nav sizing + scaling that DOESN'T shift the whole unit */

.side-nav { 
  /* Make the nav *layout* account for the scaling */
  width: calc(18.307% * var(--card-scale));
  height: 61.694%;
  flex-shrink: 0;

  display: flex; 
  flex-direction: column; 
  justify-content: center;

  gap: 12.5%;
}

.side-nav a {
  display: block;
  transition: transform 0.2s ease;
  transform-origin: center;

  /* IMPORTANT: do NOT use scale here, because it visually grows without affecting layout */
  /* scale: var(--card-scale);  <-- removed */
}

.side-nav a:hover {
  transform: translateX(5px);
}

.side-nav img { 
  width: 100%;
  height: auto;
  display: block;
}

/* Fallback no longer needed because we're not using scale/transform for sizing.
   Keeping an empty @supports block is optional; you can delete it entirely. */
@supports not (scale: 1) {
  .side-nav a { transform-origin: center; }
  .side-nav a:hover { transform-origin: center; }
}


/* =====================================================
   MONITOR (+10% sizing kept)
===================================================== */

.monitor { 
  position: relative;
  width: 65%;
  height: 110%;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;
}

.monitor-frame { 
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
  display: block;
}

.monitor-content {
  position: absolute;
  width: 95%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - var(--content-shift)));
  z-index: 1;
  display: block;
}

.monitor img[src*="BG.svg"],
.monitor img[src*="bg.svg"] {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 115%;
  height: auto;

  /* override any previous nudge */
  transform: translate(-50%, -50%) translateY(-15px) scale(var(--bg-svg-scale));
  transform-origin: center;

  z-index: 0;           /* behind content (1) and frame (2) */
  display: block;
  pointer-events: none;
}

/* =====================================================
   MOBILE FALLBACK (< 768px)
===================================================== */

@media (max-width: 767px) {
  body {
    overflow-y: auto;
  }

  .layout {
    place-self: start center;
    width: min(600px, calc(100vw - (2 * var(--safe-inline))));
    aspect-ratio: auto;
    height: auto;

    flex-direction: column;
    gap: 24px;
    margin: 24px 0;
  }

  .monitor {
    order: 1;
    width: 100%;
    height: auto;
    max-width: 600px;
  }

  .monitor-frame {
    height: auto;
  }

  .side-nav {
    order: 2;
    width: 100%;
    height: auto;
    max-width: 320px;

    gap: 20px;
    align-items: center;
  }

  .side-nav img {
    width: 180px;
  }

  .track img {
    height: 24px;
  }
}


@media (max-width: 600px) {
  .layout { gap: 18px; }
  .side-nav { max-width: 260px; gap: 15px; }
  .side-nav img { width: 150px; }
  .monitor { max-width: 500px; }
}

@media (max-width: 480px) {
  .side-nav { max-width: 210px; gap: 12px; }
  .side-nav img { width: 120px; }
  .monitor { max-width: 400px; }
}

/* =====================================================
   PAGE LOADER (CENTERED + FRAME ANIMATION)
===================================================== */

#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  background: transparent;

  opacity: 1;
  transition: opacity 0.35s ease;
}

/* Frame container */
.loader-frames {
  width: 120px;
  height: 120px;

  display: block;               /* 🔑 ensures box exists */
  flex-shrink: 0;               /* 🔑 prevents flex collapse */

  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

  animation: loaderFrames 1.2s steps(1) infinite;
}

/* =====================================================
   FRAME SEQUENCE
===================================================== */

@keyframes loaderFrames {
  0%   { background-image: url("../assets/loader/akbar1.png"); }
  16%  { background-image: url("../assets/loader/akbar2.png"); }
  32%  { background-image: url("../assets/loader/akbar3.png"); }
  48%  { background-image: url("../assets/loader/akbar5.png"); }
  64%  { background-image: url("../assets/loader/akbar4.png"); }
  80%  { background-image: url("../assets/loader/akbar6.png"); }
  100% { background-image: url("../assets/loader/akbar1.png"); }
}

/* =====================================================
   VISIBILITY STATES
===================================================== */

body.loading .layout,
body.loading .side-nav,
body.loading .monitor,
body.loading .ticker {
  opacity: 0;
  pointer-events: none;
}

body.loaded .layout,
body.loaded .side-nav,
body.loaded .monitor,
body.loaded .ticker {
  opacity: 1;
  transition: opacity 0.4s ease;
}

body.loaded #page-loader {
  opacity: 0;
  pointer-events: none;
}

/* =====================================================
   PAGE HIDE / SHOW STATES
===================================================== */

/* Hide content while loading */
body.loading .layout,
body.loading .side-nav,
body.loading .monitor,
body.loading .ticker {
  opacity: 0;
  pointer-events: none;
}

/* Reveal content */
body.loaded .layout,
body.loaded .side-nav,
body.loaded .monitor,
body.loaded .ticker {
  opacity: 1;
  transition: opacity 0.4s ease;
}

/* Fade loader out once loaded */
body.loaded #page-loader {
  opacity: 0;
  pointer-events: none;
}


/* =====================================================
   MOBILE LAYOUT — SINGLE SOURCE OF TRUTH
   (< 768px)
===================================================== */

@media (max-width: 768px) {

  body {
    display: block;
    overflow-y: auto;
    padding-bottom: 100px;
  }

  .ticker {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .layout {
    max-height: none;
  }

  /* ======================
     MAIN STACK
     (monitor defines width)
  ======================= */

  .layout {
    width: 100%;
    max-width: none;

    margin: 40px auto 50px;
    padding-inline: 16px;

    flex-direction: column;
    gap: 30px;

    aspect-ratio: auto;
    height: auto;
  }

  /* ======================
     MONITOR
  ======================= */

  .monitor {
    width: 90%;
    max-width: 100%;
    height: auto;
  }

  .monitor-frame {
    width: 100%;
    height: auto;
  }

  .monitor-content {
    width: 94%;
  }

  /* ======================
     SIDE NAV
     (matches monitor width)
  ======================= */

  .side-nav {
    width: 100%;
    max-width: 100%;

    display: flex;
    flex-direction: column;
    gap: 15px;

    align-items: center;
    justify-content: center;
  }

  /* Hide desktop SVG cards */
  .side-nav img {
    display: none;
  }

  /* ======================
     MOBILE CARDS
  ======================= */

  .side-nav a {
    display: block;
    width: 100%;
    height: 210px;

    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;

    transform: none;
  }

  /* ======================
     CARD IMAGES
  ======================= */

  .side-nav a[href*="projects"] {
    background-image: url("../assets/img/mobileprojects.png");
  }

  .side-nav a[href*="tech"] {
    background-image: url("../assets/img/mobiletech.png");
  }

  .side-nav a[href*="about"] {
    background-image: url("../assets/img/mobileaboutme.png");
  }

  /* ======================
     TICKER SCALE
  ======================= */

  .track img {
    height: 24px;
  }
}

