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

:root {
  --color--background: rgb(60, 60, 60);
  --color--foreground: #c4d5bc;
  --color--accent: rgb(170, 170, 170);
  --font-primary: "Inter", sans-serif;
  --font-secondary: "Inter", sans-serif;
  --margin: 32px;
  --gutter: 16px;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  font-weight: 700;
  background: transparent; /* Remove gradient - video is background */
  color: var(--color--foreground);
  letter-spacing: -0.03em;
  position: relative;
  overflow: hidden;
}

body.loading-active {
  overflow: hidden !important;
}

body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: transparent url("./assets/images/noise.png") repeat
    0 0;
  background-size: 300px 300px;
  animation: noise-animation 0.3s steps(5) infinite;
  opacity: 0.9; /* Restored noise overlay */
  will-change: transform;
  z-index: -100; /* Above video but below text */
  pointer-events: none;
}

@keyframes noise-animation {
  0% {
    transform: translate(0, 0);
  }

  10% {
    transform: translate(-2%, -3%);
  }

  20% {
    transform: translate(-4%, 2%);
  }

  30% {
    transform: translate(2%, -4%);
  }

  40% {
    transform: translate(-2%, 5%);
  }

  50% {
    transform: translate(-4%, 2%);
  }

  60% {
    transform: translate(3%, 0);
  }

  70% {
    transform: translate(0, 3%);
  }

  80% {
    transform: translate(-3%, 0);
  }

  90% {
    transform: translate(2%, 2%);
  }

  100% {
    transform: translate(1%, 0);
  }
}

#canvas {
  display: none; /* Glass cursor effect disabled */
}

.video-background {
  background: #000;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -101; /* Behind everything including noise */
}

.video-foreground {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.video-background iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw; /* 16:9 aspect ratio */
  min-height: 100vh;
  min-width: 177.77vh; /* 16:9 aspect ratio */
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@media (min-aspect-ratio: 16/9) {
  .video-foreground {
    height: 300%;
    top: -100%;
  }
}

@media (max-aspect-ratio: 16/9) {
  .video-foreground {
    width: 300%;
    left: -100%;
  }
}

.fallback-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("./assets/images/red-protocol-poster-03-bg.jpg");
  background-size: cover;
  background-position: center;
  z-index: -99;
  opacity: 0;
  transition: opacity 1s ease-out;
}

.fallback-bg.active {
  opacity: 1;
}

.container {
  display: flex;
  width: 100%;
  height: 100vh;
  padding: var(--gutter);
  position: relative;
  z-index: 10;
  transition: filter 0.1s ease-out;
}

.text-element {
  position: fixed;
  font-family: var(--font-primary);
  font-weight: 700;
  color: var(--color--foreground);
  text-transform: uppercase;
  z-index: 10;
  opacity: 0;
  transform: translateY(30px);
}

.logo {
  top: 12%;
  left: 50%;
  transform: translate(-50%, 0) translateY(30px);
  font-family: "Courier Prime", "Courier New", "Courier", monospace;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
  white-space: pre;
  text-transform: none;
  text-align: left;
  color: var(--color--foreground);
  z-index: 10;
  letter-spacing: 0;
  width: max-content;
  max-width: 95vw;
  overflow: hidden;
}

.audio-enable {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 12px;
  color: #c4d5bc;
  text-transform: uppercase;
  gap: 2rem;
  text-align: center;
  padding: 1rem;
}

.enable-button {
  border: 1px solid #00ff00;
  background: transparent;
  color: #00ff00;
  padding: 1rem 2rem;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
}

.enable-button:hover {
  background: #00ff00;
  color: #0a0a0a;
}

.no-audio-button {
  border: none;
  background: transparent;
  color: #ff0000;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.no-audio-button:hover {
  opacity: 1;
}

.description {
  top: 120px;
  left: 50px;
  width: 360px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.audio-toggle {
  position: fixed;
  top: 100px;
  left: 50px;
  border: 1px solid var(--color--foreground);
  background: transparent;
  color: var(--color--foreground);
  padding: 0.5rem 1rem;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.625rem;
  text-transform: uppercase;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
  opacity: 0;
  z-index: 10;
  pointer-events: none;
}

.audio-toggle:hover {
  opacity: 1;
  background: rgba(196, 213, 188, 0.1);
}

.audio-toggle.audio-on {
  opacity: 1;
}

.audio-toggle.audio-off {
  opacity: 0.4;
}

.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0a0a0a;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 12px;
  color: #c4d5bc;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 1;
  transition: opacity 0.8s ease-out;
}

.preloader.fade-out {
  opacity: 0;
}

.error-message {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  padding: 10px;
  font-size: 12px;
  display: none;
  z-index: 3000;
}

.description {
  top: 120px;
  left: 50px;
  width: 360px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.nav-links {
  top: 50%;
  left: 50px;
  transform: translateY(-50%);
}

.nav-links a {
  position: relative;
  display: block;
  margin-bottom: 8px;
  color: var(--color--foreground);
  text-decoration: none;
  z-index: 1;
  transition: color 0.3s ease;
  padding: 4px 8px;
}

.nav-links a::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background-color: var(--color--foreground);
  z-index: -1;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-links a:hover {
  color: #1a1a1a;
}

.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  background: transparent;
  border: 1px solid var(--color--foreground);
  color: var(--color--foreground);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  cursor: pointer;
  z-index: 1000;
  font-family: var(--font-primary);
  font-weight: 700;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 70px;
  right: 20px;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid var(--color--foreground);
  z-index: 998;
  flex-direction: column;
  padding: 1rem;
  min-width: 180px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.mobile-menu.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mobile-menu a {
  color: var(--color--foreground);
  text-decoration: none;
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 0.75rem 1rem;
  display: block;
  transition: all 0.3s ease;
  border-bottom: 1px solid transparent;
}

.mobile-menu a:last-child {
  border-bottom: none;
}

.mobile-menu a:hover,
.mobile-menu a:active {
  background: rgba(196, 213, 188, 0.1);
  color: var(--color--foreground);
}

.footer {
  bottom: 120px;
  right: 50px;
  font-size: 1.25rem;
}

.footer a {
  color: var(--color--foreground);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: #c4d5bc;
}

.division {
  bottom: 120px;
  left: 50px;
  font-size: 0.625rem;
}

.division a {
  color: var(--color--foreground);
  text-decoration: none;
  transition: color 0.3s ease;
}

.division a:hover {
  color: #c4d5bc;
  text-decoration: underline;
}

.signal {
  top: 50%;
  right: 100px;
  font-size: 0.625rem;
  transform: translateY(-50%);
}

.contact-toggle {
  font-size: 1rem !important;
  cursor: pointer;
  transition: color 0.3s ease;
  user-select: none;
}

.contact-toggle:hover {
  color: #c4d5bc;
}

.contact-info {
  position: fixed;
  top: 50%;
  right: 100px;
  transform: translateY(calc(-50% + 1.5rem));
  display: none;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--color--foreground);
  text-align: right;
  white-space: nowrap;
}

.contact-info.active {
  display: block;
  cursor: pointer;
}

.magazine-content {
  position: fixed;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  z-index: 100;
  text-align: justify;
  color: var(--color--foreground);
  font-family: var(--font-primary);
  max-width: 800px;
  padding: 2rem;
}

.magazine-content.active {
  display: block;
}

.magazine-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 3rem;
  text-transform: none;
  letter-spacing: -0.02em;
  text-align: center;
}

.magazine-title a {
  color: var(--color--foreground);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.magazine-title a:hover {
  opacity: 0.7;
}

.magazine-description {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  text-align: justify;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2rem;
}

.magazine-description p {
  margin-bottom: 1.5rem;
}

.magazine-description a {
  color: var(--color--foreground) !important;
  text-decoration: none !important;
  transition: opacity 0.3s ease;
}

.magazine-description a:visited {
  color: var(--color--foreground) !important;
}

.magazine-description a:hover {
  opacity: 0.7;
  color: var(--color--foreground) !important;
}

.magazine-description a:active {
  color: var(--color--foreground) !important;
}

.internet-title {
  font-size: 1.75rem !important;
}

.magazine-link {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.magazine-link a {
  color: var(--color--foreground);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  transition: opacity 0.3s ease;
}

.magazine-link a:hover {
  opacity: 0.7;
}

.contact-info.active:hover {
  color: #c4d5bc;
}

.contact-info p {
  margin: 0.25rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.text-element.central-text {
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.5rem !important;
  width: max-content !important;
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.central-text .avatar-name-wrapper {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.75rem !important;
  flex-wrap: nowrap !important;
  flex-shrink: 0 !important;
}

.central-text .avatar {
  flex-basis: auto;
  flex-shrink: 0 !important;
}

.central-text .name {
  flex-basis: auto;
  flex-shrink: 1;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.central-text .subtitle {
  text-align: center;
  margin-top: 0;
}

.central-text .avatar,
.text-element.central-text .avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color--foreground);
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

.central-text .name,
.text-element.central-text .name,
.central-text h1.name {
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--color--foreground);
  text-transform: none;
  letter-spacing: -0.02em;
  margin: 0;
  padding: 0;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

.central-text h1.name a,
.central-text .avatar a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.central-text h1.name a:hover {
  color: #c4d5bc;
}

.central-text .avatar a {
  display: inline-block;
  border-radius: 50%;
  overflow: hidden;
}

.central-text .subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color--foreground);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  padding: 0;
  text-align: center;
  white-space: nowrap !important;
  opacity: 0.8;
}

.dg.ac {
  z-index: 3000 !important;
  position: fixed !important;
  top: 10px !important;
  right: 10px !important;
}

/* Responsive design */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .nav-links {
    display: none !important;
  }

  .mobile-menu {
    top: 70px;
    right: 20px;
  }

  .description,
  .division {
    left: 20px;
  }

  .footer,
  .signal {
    right: 20px;
  }

  .footer {
    font-size: 0.875rem;
  }

  .logo {
    font-size: 0.4rem;
    top: 80px;
    left: 50%;
    max-width: calc(100vw - 40px);
    overflow: visible;
    white-space: pre;
    transform: translateX(-50%);
    line-height: 1.1;
    z-index: 10;
    position: fixed;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .logo.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
  }

  .description {
    top: 200px;
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
    font-size: 0.7rem;
  }

  .audio-toggle {
    top: 20px;
    left: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.55rem;
    min-height: 44px;
    min-width: 90px;
  }

  .text-element.central-text {
    gap: 0.4rem;
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
    left: 50%;
    transform: translateX(-50%) scale(0.85);
    bottom: 35%;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .text-element.central-text.hidden {
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.85) translateY(-10px) !important;
    pointer-events: none !important;
  }

  .central-text .avatar-name-wrapper {
    gap: 0.3rem;
    flex-wrap: nowrap !important;
    max-width: 100%;
    transform: scale(0.9);
    transform-origin: center;
  }

  .central-text .avatar {
    width: 24px;
    height: 24px;
    flex-shrink: 0 !important;
  }

  .central-text .name {
    font-size: 0.6rem;
    white-space: nowrap !important;
    flex-shrink: 1;
    overflow: visible;
    text-overflow: clip;
    letter-spacing: -0.03em;
  }
  
  .central-text .subtitle {
    font-size: 0.65rem;
    white-space: nowrap !important;
    line-height: 1.2;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
  }


  .division {
    bottom: 100px;
    font-size: 0.55rem;
  }

  .footer {
    bottom: 100px;
    font-size: 0.875rem;
  }

  .signal {
    top: auto;
    bottom: 140px;
    right: 20px;
    transform: none;
    font-size: 0.55rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .contact-info {
    top: auto;
    bottom: 180px;
    right: 20px;
    transform: none;
    font-size: 0.75rem;
    text-align: right;
  }

  .magazine-content {
    top: 8%;
    left: 20px;
    right: 20px;
    max-width: calc(100vw - 40px);
    padding: 1rem;
    transform: none;
  }

  .magazine-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .magazine-description {
    font-size: 0.75rem;
    line-height: 1.4;
    margin-top: 1rem;
  }

  .magazine-description p {
    margin-bottom: 1rem;
  }

  /* Optimize GUI for mobile */
  .dg.ac {
    transform: scale(0.8);
    transform-origin: top right;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 0.35rem;
    top: 75px;
    left: 50%;
    max-width: calc(100vw - 30px);
    overflow: visible;
    white-space: pre;
    transform: translateX(-50%);
    line-height: 1.1;
    z-index: 10;
    position: fixed;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .logo.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
  }

  .description {
    top: 190px;
    font-size: 0.65rem;
    width: calc(100vw - 30px);
    max-width: calc(100vw - 30px);
  }

  .mobile-menu {
    top: 70px;
    right: 15px;
  }

  .audio-toggle {
    top: 20px;
    left: 15px;
    padding: 0.5rem 1rem;
    font-size: 0.55rem;
    min-height: 44px;
    min-width: 85px;
  }

  .mobile-menu-toggle {
    top: 20px;
    right: 15px;
  }

  .text-element.central-text {
    gap: 0.35rem;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    bottom: 32%;
    padding: 0 5px;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .text-element.central-text.hidden {
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.8) translateY(-10px) !important;
    pointer-events: none !important;
  }

  .central-text .avatar-name-wrapper {
    gap: 0.25rem;
    flex-wrap: nowrap !important;
    max-width: 100%;
    transform: scale(0.85);
    transform-origin: center;
  }

  .central-text .avatar {
    width: 20px;
    height: 20px;
    flex-shrink: 0 !important;
  }
  
  .central-text .name {
    font-size: 0.55rem;
    white-space: nowrap !important;
    flex-shrink: 1;
    overflow: visible;
    text-overflow: clip;
    letter-spacing: -0.04em;
  }
  
  .central-text .subtitle {
    font-size: 0.55rem;
    white-space: nowrap !important;
    line-height: 1.2;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
  }


  .division {
    bottom: 90px;
    left: 15px;
    font-size: 0.5rem;
  }

  .footer {
    bottom: 90px;
    right: 15px;
    font-size: 0.75rem;
  }

  .signal {
    bottom: 130px;
    right: 15px;
    font-size: 0.5rem;
    min-height: 44px;
  }

  .contact-info {
    bottom: 170px;
    right: 15px;
    font-size: 0.7rem;
  }

  .magazine-content {
    top: 6%;
    left: 15px;
    right: 15px;
    max-width: calc(100vw - 30px);
    padding: 0.75rem;
  }

  .magazine-title {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .magazine-description {
    font-size: 0.65rem;
    line-height: 1.3;
    margin-top: 0.75rem;
  }

  .magazine-description p {
    margin-bottom: 0.75rem;
  }

  /* Further scale down GUI on very small screens */
  .dg.ac {
    transform: scale(0.7);
  }
}

@media (max-width: 414px) {
  .text-element.central-text {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 0 4px;
    transform: translateX(-50%) scale(0.78);
    bottom: 32%;
  }

  .central-text .avatar-name-wrapper {
    gap: 0.25rem;
    transform: scale(0.88);
    transform-origin: center;
  }

  .central-text .avatar {
    width: 22px;
    height: 22px;
  }

  .central-text .name {
    font-size: 0.58rem;
    letter-spacing: -0.03em;
  }
}

@media (max-width: 360px) {
  .logo {
    font-size: 0.32rem;
    top: 70px;
    left: 50%;
    max-width: calc(100vw - 20px);
    overflow: visible;
    white-space: pre;
    transform: translateX(-50%);
    line-height: 1.1;
    z-index: 10;
    position: fixed;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .logo.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
  }

  .description {
    top: 180px;
    font-size: 0.6rem;
  }

  .mobile-menu {
    top: 70px;
    right: 10px;
  }

  .audio-toggle {
    top: 20px;
    left: 10px;
    font-size: 0.5rem;
    padding: 0.45rem 0.9rem;
    min-width: 85px;
  }

  .mobile-menu-toggle {
    top: 20px;
    right: 10px;
  }

  .text-element.central-text {
    bottom: 30%;
    gap: 0.3rem;
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    padding: 0 3px;
    transform: translateX(-50%) scale(0.75);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .text-element.central-text.hidden {
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.75) translateY(-10px) !important;
    pointer-events: none !important;
  }

  .central-text .avatar-name-wrapper {
    gap: 0.2rem;
    flex-wrap: nowrap !important;
    max-width: 100%;
    transform: scale(0.8);
    transform-origin: center;
  }

  .central-text .avatar {
    width: 18px;
    height: 18px;
  }

  .central-text .name {
    font-size: 0.5rem;
    white-space: nowrap !important;
    overflow: visible;
    text-overflow: clip;
    letter-spacing: -0.05em;
  }

  .central-text .subtitle {
    font-size: 0.5rem;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-links a {
    font-size: 0.65rem;
    padding: 5px 8px;
  }

  .division {
    font-size: 0.45rem;
  }

  .footer {
    font-size: 0.7rem;
  }

  .signal {
    font-size: 0.45rem;
  }

  .contact-info {
    font-size: 0.65rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .nav-links a:hover::after {
    width: 0;
  }

  .nav-links a:active::after {
    width: 100%;
  }

  .enable-button:hover {
    background: transparent;
    color: #c4d5bc;
  }

  .enable-button:active {
    background: #c4d5bc;
    color: #0a0a0a;
  }
}
