:root {
  --space1: clamp(0.9rem, 1vw, 1rem);
  --space13: clamp(1.1rem, 1.3vw, 1.3rem);
  --space15: clamp(1.2rem, 1.5vw, 1.5rem);
  --space165: clamp(1.3rem, 1.65vw, 1.65rem);
  --space2: clamp(1.4rem, 2vw, 2rem);
  --space325: clamp(2.2rem, 3.25vw, 3.25rem);
  --space42: clamp(2.52rem, 4.2vw, 4.2rem);
}

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

body {
  font-family: "Mona Sans", sans-serif; /* weights 400, 600, 900 */
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-variation-settings:
    "wdth" 100;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.25;
  background: #000;
  color: #fff;
}

a {
  text-decoration: none;
  transition: all 0.3s ease;
}

a:hover {
  transition: all 0.15s ease;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: var(--space15) var(--space325);
  z-index: 50;
}

header h1 {
  font-size: var(--space165);
  font-weight: 600;
  color: #fff;
  text-transform: lowercase;
}

header span {
  display: inline-block;
  transform: scaleX(-1);
  transition: all 0.3s ease;
}

header .logo:hover span {
  transform: scaleX(1);
  transition: all 0.15s ease-in-out;
}

/* Mobile logo flip state - higher specificity than hover */
@media (max-width: 768px) {
  header span.mobile-flipped {
    transform: scaleX(1) !important;
    transition: all 0.15s ease-in-out;
  }
}

header nav {
  display: flex;
  gap: var(--space165);
}

/* Hamburger base (hidden on desktop) */
.menu-toggle {
  display: none;
  position: relative;
  width: 40px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 60;
}
.menu-toggle .bar {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease, top 0.3s ease;
}
.menu-toggle .bar:nth-child(1) { top: 9px; }
.menu-toggle .bar:nth-child(2) { top: 15px; }
.menu-toggle .bar:nth-child(3) { top: 21px; }
.menu-toggle[aria-expanded="true"] .bar:nth-child(1) { top: 15px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .bar:nth-child(3) { top: 15px; transform: rotate(-45deg); }

/* Mobile nav behavior */
@media (max-width: 768px) {
  .menu-toggle { display: inline-block; }
  header { align-items: center; gap: var(--space1); }
  header nav { display: none; }
  #site-nav {
    position: fixed;
    inset: 0 0 auto 0;
    top: calc(var(--space15) * 3 + var(--space1)); /* approx header height */
    height: calc(100dvh - (var(--space15) * 2 + 0.5rem));
    background: linear-gradient(130deg, rgba(30,20,50,0.25), rgba(12,16,36,0.75));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: grid;
    grid-auto-rows: min-content;
    align-content: start;
    padding: var(--space15) var(--space325) var(--space2);
    gap: var(--space1);
    transform: translateY(-4%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 55;
  }
  #site-nav a { padding: 0.75rem 0.25rem; font-size: var(--space15); }
  header.nav-open #site-nav { transform: translateY(0); opacity: 1; pointer-events: auto; }

  .hero {
    padding: 0 var(--space325);
    /* Ensure scrollable area always exists on mobile */
    min-height: calc(100dvh + 1px);
  }
  article {
    max-width: 80dvw !important;
  }
  
  /* Improve mobile touch scrolling */
  main {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
  }
  
  section {
    -webkit-overflow-scrolling: touch;
  }
}

nav a {
  position: relative;
  font-size: var(--space1);
  font-weight: 400;
  color: #fff;
  text-decoration: none;
}

nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: rgba(255, 255, 255, 0.2);
  z-index: 1;
}

nav a::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(
    130deg,
    hsla(260, 100%, 70%, 0.75),
    hsla(300, 100%, 70%, 0.75),
    hsla(320, 100%, 70%, 0.75),
    hsla(180, 100%, 70%, 0.75),
    hsla(240, 100%, 70%, 0.75),
    hsla(280, 100%, 70%, 0.75),
    hsla(300, 100%, 70%, 0.75)
  );
  background-size: 400% 100%;
  background-repeat: repeat;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
}

nav a:hover::before {
  opacity: 1;
  transition: opacity 0.15s ease;
  animation: moveGradient 2s linear infinite;
}

nav a.active::after {
  background: rgba(255, 255, 255, 0.08);
  transition: all 2s;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  width: 0%;
  z-index: 75;
  transition: width 0.2s ease;
}

main {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: auto;
  touch-action: pan-x;
  overscroll-behavior: contain;
  scroll-padding: 0;
  height: 100dvh;
  width: 100dvw;
}

section {
  flex: 0 0 100dvw;
  scroll-snap-align: start;
  height: 100dvh;
  position: relative;
  overflow-y: auto;
  touch-action: manipulation;
}

@keyframes moveGradient {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 0%;
  }
}

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  min-height: 100dvh;
  padding: var(--space325) 0;
  touch-action: manipulation;
}

.hero.sub {
  align-items: flex-start;
  padding: var(--space325) var(--space325);
}

/* Content fade mask when using flex-start */
@media (max-aspect-ratio: 3/2) and (max-height: 600px) {
  .hero {
    mask: linear-gradient(
      180deg,
      transparent 0%,
      rgba(0, 0, 0, 0.3) 3%,
      rgba(0, 0, 0, 0.8) 6%,
      black 10%
    );
    -webkit-mask: linear-gradient(
      180deg,
      transparent 0%,
      rgba(0, 0, 0, 0.3) 3%,
      rgba(0, 0, 0, 0.8) 6%,
      black 10%
    );
  }
}

@media (max-height: 500px) {
  .hero {
    mask: linear-gradient(
      180deg,
      transparent 0%,
      rgba(0, 0, 0, 0.4) 4%,
      rgba(0, 0, 0, 0.9) 8%,
      black 12%
    );
    -webkit-mask: linear-gradient(
      180deg,
      transparent 0%,
      rgba(0, 0, 0, 0.4) 4%,
      rgba(0, 0, 0, 0.9) 8%,
      black 12%
    );
  }
}

/* When content overflows on landscape/wide screens, use flex-start and proper spacing */
@media (max-aspect-ratio: 3/2) and (max-height: 600px) {
  .hero {
    justify-content: flex-start;
    padding-top: calc(var(--space15) * 4 + var(--space42)); /* Extra space for fade + header */
    padding-bottom: var(--space325);
    min-height: calc(100% + var(--space325)); /* Ensure hero extends beyond section for scrolling */
  }
  
  .hero.sub {
    padding-top: calc(var(--space15) * 4 + var(--space42));
    min-height: calc(100% + var(--space325));
  }
  
  /* Ensure frontpage is also scrollable on mobile */
  .hero:not(.sub) {
    min-height: calc(100% + var(--space2));
  }
}

@media (max-aspect-ratio: 3/4) and (max-height: 600px) {
  .hero {
    padding-top: calc(var(--space15) * 3 + var(--space325));
    padding-bottom: var(--space2);
    min-height: calc(100% + var(--space2));
  }
  
  .hero.sub {
    padding-top: calc(var(--space15) * 3 + var(--space325));
    min-height: calc(100% + var(--space2));
  }
}

/* Very constrained screens */
@media (max-height: 500px) {
  .hero {
    justify-content: flex-start;
    padding-top: calc(var(--space15) * 3 + var(--space2));
    padding-bottom: var(--space15);
    min-height: calc(100% + var(--space15));
  }
  
  .hero.sub {
    padding-top: calc(var(--space15) * 3 + var(--space2));
    padding-left: var(--space325);
    padding-right: var(--space325);
    min-height: calc(100% + var(--space15));
  }
}

.hero h1,
.hero h2,
.hero p,
.hero a,
.hero article {
  z-index: 10;
  pointer-events: auto;
  touch-action: inherit;
}

/* Ensure hero container can receive touch events for scrolling */
.hero {
  pointer-events: auto;
}

.hero h1 {
  font-size: var(--space42);
  font-weight: 400;
  line-height: 1.4;
  padding-bottom: var(--space2);
  margin-bottom: var(--space325);
  text-align: center;
  border-bottom: solid 2px rgb(255, 255, 255, 0.2);
}

/* Only add side margins for frontpage h1 border */
.hero:not(.sub) h1 {
  margin-left: var(--space325);
  margin-right: var(--space325);
}

/* Only add side margins for frontpage h2 text */
.hero:not(.sub) h2 {
  margin-left: var(--space325);
  margin-right: var(--space325);
}

.hero h1 span {
  font-family: "Brygada 1918", sans-serif;
  font-style: italic;
}

/* .hero h1 span:last-child {
  font-family: "Brygada 1918", sans-serif;
  font-style: italic;
  font-weight: 700;
} */

.hero h2 {
  font-size: var(--space13);
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
}

.hero .btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--space325);
  margin-bottom: var(--space2);
  display: inline-block;
  margin-top: var(--space325);
  padding: var(--space1) var(--space2);
  font-size: var(--space1);
  font-weight: 600;
  color: #fff;
  border: solid 2px rgb(255, 255, 255, 0.2);
  border-radius: 0.2rem;
  background: linear-gradient(
    130deg,
    hsla(0, 100%, 70%, 0),
    hsla(45, 100%, 70%, 0),
    hsla(120, 100%, 70%, 0),
    hsla(180, 100%, 70%, 0),
    hsla(240, 100%, 70%, 0),
    hsla(300, 100%, 70%, 0),
    hsla(360, 100%, 70%, 0)
  );
  background-size: 300% 300%;
  animation: rainbowShift 3s ease-in-out infinite;
  animation-play-state: paused;
  transition: all 0.3s ease;
}

/* Make buttons relative when content overflows */
@media (max-aspect-ratio: 3/2) and (max-height: 600px) {
  .hero .btn {
    position: relative;
    left: auto;
    transform: none;
    bottom: auto;
    margin-top: var(--space325);
    align-self: center;
  }
  
  .hero .btn.right {
    align-self: flex-end; /* Keep right buttons on the right */
    margin-left: 0;
  }
}

@media (max-aspect-ratio: 3/4) and (max-height: 600px) {
  .hero .btn {
    margin-top: var(--space2);
  }
}

@media (max-height: 500px) {
  .hero .btn {
    position: relative;
    left: auto;
    transform: none;
    bottom: auto;
    margin-top: var(--space15);
    align-self: center;
  }
  
  .hero .btn.right {
    align-self: flex-start;
    margin-left: 0;
  }
}

.hero .btn:hover {
  border-color: #fff;
  background: linear-gradient(
    130deg,
    hsla(0, 100%, 70%, 0.2),
    hsla(45, 100%, 70%, 0.2),
    hsla(120, 100%, 70%, 0.2),
    hsla(180, 100%, 70%, 0.2),
    hsla(240, 100%, 70%, 0.2),
    hsla(300, 100%, 70%, 0.2),
    hsla(360, 100%, 70%, 0.2)
  );
  background-size: 300% 300%;
  mix-blend-mode: screen;
  animation-play-state: running;
  border-radius: 0.25rem;
}

.hero .btn.right {
  left: unset;
  transform: unset;
  right: var(--space325);
}

/* Responsive button positioning adjustments */
@media (max-aspect-ratio: 3/2) and (max-height: 600px) {
  .hero .btn.right {
    right: auto;
    align-self: flex-end; /* Keep right alignment */
  }
}

@media (max-height: 500px) {
  .hero .btn.right {
    right: auto;
    align-self: flex-start;
  }
}

.overlay-rainbow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    ellipse at center,
    rgba(20, 8, 45, 0.9) 0%,
    rgba(35, 15, 55, 0.7) 25%,
    rgba(25, 35, 60, 0.5) 60%,
    rgba(15, 25, 45, 0.3) 100%
  );
  opacity: 0.25;
}

.overlay-bg {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    130deg,
    hsl(280, 100%, 65%),
    hsl(300, 100%, 70%),
    hsl(320, 100%, 68%),
    hsl(180, 100%, 70%),
    hsl(240, 100%, 72%),
    hsl(260, 100%, 70%),
    hsl(300, 100%, 68%)
  );
  background-size: 300% 300%;
  mix-blend-mode: screen;
  animation: rainbowShift 12s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.75;
}

@keyframes rainbowShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -10;
  opacity: 0.5;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.cursor-trail {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  backdrop-filter: blur(0.3rem);
  mix-blend-mode: soft-light;
  transform: translate(-50%, -50%) rotate(0deg);
  z-index: 9;
  transition: opacity 0.4s ease-out;
  will-change: transform, opacity, width, height;
  opacity: 0.6;
  background: radial-gradient(
    circle,
    hsla(280, 80%, 70%, 0.3) 0%,
    hsla(300, 70%, 65%, 0.2) 40%,
    hsla(320, 60%, 60%, 0.1) 80%,
    transparent 100%
  );
}

article {
  max-width: 50dvw;
}

article h2 {
  margin-bottom: var(--space2);
  text-align: left !important;
  font-size: var(--space165) !important;
  font-weight: 600 !important;
}

article p {
  font-size: var(--space13);
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: var(--space15);
}

.hero.end article h2,
.hero.end article p {
  text-align: center !important;
}