/* SGIA access gate. Visual design from the owner's intro draft (sgia_intro_portal.html), used
   as is; the site additions (BGM, motion, skip, connection hand-off) are at the end. */
:root {
  --bg-void: #040608;
  --bg-slate: #090d12;
  --ice-white: #dce6f0;
  --cold-blue: #8ba3b8;
  --steel-grey: #485665;
  --accent-mint: #5ce1c6;
  --accent-crimson: #9e1b24;
  --scanline-opacity: 0.14;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-void);
  color: var(--ice-white);
  font-family: 'JetBrains Mono', monospace;
}

/* Global X-Ray & Monochrome Optical Filter Wrapper */
#optical-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 48%, #0d131a 0%, #05070a 62%, #020304 100%);
  transition: filter 0.65s cubic-bezier(0.22, 1, 0.36, 1), background 0.65s ease;
}

/* Pure Monochrome Mode */
body.mode-mono #optical-viewport {
  filter: grayscale(100%) contrast(1.25) brightness(0.96);
}

/* X-Ray Radiograph Inversion Mode (Inspired by Ref 7 & 8) */
body.mode-xray #optical-viewport {
  filter: invert(93%) hue-rotate(185deg) contrast(1.38) brightness(0.94);
}

/* High-Density Micro-Pixel ASCII Canvas */
#ascii-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Subtle Cold Vignette & Analog CRT Scanlines */
.crt-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 50% 50%, transparent 46%, rgba(2, 4, 7, 0.86) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(220, 230, 240, var(--scanline-opacity)) 0px,
      rgba(220, 230, 240, var(--scanline-opacity)) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: overlay;
}

/* Fine Analog Grain */
.analog-noise {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  pointer-events: none;
  z-index: 3;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 0.35s steps(2) infinite;
}

@keyframes grainShift {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-1.5%, 1%); }
  100% { transform: translate(1%, -1.5%); }
}

/* Top Minimalist Utility Bar (Language, Audio, Optical Spectrum) */
.top-utility-bar {
  position: absolute;
  top: 22px;
  left: 28px;
  right: 28px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(220, 230, 240, 0.52);
  opacity: 0;
  animation: fadeSlow 1.6s ease 0.6s forwards;
}

.util-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.util-btn {
  background: none;
  border: none;
  color: rgba(220, 230, 240, 0.48);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.25s ease, text-shadow 0.25s ease;
}

.util-btn:hover,
.util-btn.active {
  color: var(--ice-white);
  text-shadow: 0 0 8px rgba(220, 230, 240, 0.5);
}

.util-btn.audio-on {
  color: var(--accent-mint);
  text-shadow: 0 0 8px rgba(92, 225, 198, 0.45);
}

.util-divider {
  color: rgba(139, 163, 184, 0.25);
}

/* Center Minimalist Hero Overlay */
.hero-center-stage {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 76px 24px 48px;
  pointer-events: none;
}

/* Top Institution Title */
.agency-header {
  text-align: center;
  opacity: 0;
  transform: translateY(-8px);
  animation: fadeSlideDown 1.8s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}

.agency-acronym {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: clamp(2.1rem, 4.5vw, 3.6rem);
  letter-spacing: 0.42em;
  margin-right: -0.42em;
  color: var(--ice-white);
  text-shadow: 0 0 28px rgba(139, 163, 184, 0.28);
}

.agency-fullname {
  margin-top: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  letter-spacing: 0.34em;
  margin-right: -0.34em;
  text-transform: uppercase;
  color: rgba(186, 204, 222, 0.72);
}

.agency-sub-kr {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.26em;
  margin-right: -0.26em;
  color: rgba(139, 163, 184, 0.46);
}

/* Interactive Core Touch Target (No Rectangular Box Shape) */
.core-touch-zone {
  position: relative;
  width: min(360px, 68vw);
  height: min(360px, 68vw);
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.core-touch-zone:hover {
  transform: scale(1.03);
}

/* Subtle Whispering Access Prompt Directly Integrated into the Void */
.access-whisper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  animation: fadeSlow 2s ease 1.8s forwards;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.access-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--accent-mint);
  box-shadow: 0 0 12px var(--accent-mint), 0 0 24px rgba(92, 225, 198, 0.6);
  animation: pulseBeacon 2.6s ease-in-out infinite;
}

.core-touch-zone:hover .access-dot {
  background-color: #ffffff;
  box-shadow: 0 0 18px #ffffff, 0 0 32px var(--accent-mint);
}

.access-label {
  font-size: 11px;
  letter-spacing: 0.38em;
  margin-right: -0.38em;
  color: rgba(220, 230, 240, 0.78);
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(4, 6, 8, 0.95), 0 0 4px rgba(4, 6, 8, 1);
  transition: color 0.3s ease, letter-spacing 0.4s ease;
}

.core-touch-zone:hover .access-label {
  color: #ffffff;
  letter-spacing: 0.46em;
  margin-right: -0.46em;
}

.access-subhint {
  font-size: 9px;
  letter-spacing: 0.24em;
  margin-right: -0.24em;
  color: rgba(139, 163, 184, 0.45);
  text-shadow: 0 0 10px rgba(4, 6, 8, 1);
}

@keyframes pulseBeacon {
  0%, 100% { opacity: 0.45; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.35); }
}

/* Bottom Minimal Coordinate & Cryptic Motifs */
.bottom-telemetry {
  width: 100%;
  max-width: 1180px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: rgba(139, 163, 184, 0.42);
  opacity: 0;
  animation: fadeSlow 1.8s ease 1.4s forwards;
}

.telemetry-anomaly {
  color: rgba(158, 27, 36, 0.78);
}

/* =========================================================================
   HANDSHAKE / STATIC GLITCH / CONNECTION SEQUENCE OVERLAY
========================================================================= */
#transmission-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgba(3, 5, 7, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#transmission-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Static Interference Canvas during Handshake */
#glitch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.38;
  mix-blend-mode: screen;
  pointer-events: none;
}

.handshake-terminal {
  position: relative;
  z-index: 2;
  width: min(460px, 88vw);
  text-align: center;
}

.handshake-line {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: rgba(220, 230, 240, 0.65);
  margin-bottom: 12px;
  min-height: 16px;
}

.handshake-progress-track {
  width: 100%;
  height: 1px;
  background: rgba(139, 163, 184, 0.2);
  margin: 18px 0;
  overflow: hidden;
}

.handshake-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent-mint);
  box-shadow: 0 0 12px var(--accent-mint);
  transition: width 0.25s linear;
}

.handshake-verdict {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.38em;
  margin-right: -0.38em;
  color: var(--accent-mint);
  text-shadow: 0 0 18px rgba(92, 225, 198, 0.6);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.handshake-verdict.visible {
  opacity: 1;
  transform: scale(1);
}

/* Screen Shake / Signal Jitter Class */
.signal-jitter {
  animation: jitterFrame 0.12s steps(2) infinite;
}

@keyframes jitterFrame {
  0% { transform: translate(0, 0) skewX(0deg); }
  25% { transform: translate(-3px, 1px) skewX(-0.8deg); }
  50% { transform: translate(3px, -1px) skewX(0.8deg); }
  75% { transform: translate(-2px, -2px) skewX(0.4deg); }
  100% { transform: translate(2px, 2px) skewX(-0.4deg); }
}

@keyframes fadeSlow {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .top-utility-bar {
    top: 14px;
    left: 16px;
    right: 16px;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  .bottom-telemetry {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
  }
}

/* ---------- site additions ---------- */
#optical-viewport {
  height: 100dvh;
}
.skip-intro {
  color: rgba(186, 204, 222, 0.62);
  text-decoration: none;
  pointer-events: auto;
  border-bottom: 1px solid rgba(139, 163, 184, 0.25);
  transition: color 0.25s ease, border-color 0.25s ease;
}
.skip-intro:hover {
  color: var(--ice-white);
  border-color: var(--accent-mint);
}
.telemetry-right {
  display: flex;
  gap: 18px;
  align-items: flex-end;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 1px solid var(--accent-mint);
  outline-offset: 4px;
}

/* Connection hand-off: the warp stays visible behind a translucent handshake terminal. */
.handshake {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.connecting .handshake {
  opacity: 1;
}
body.connecting .hero-center-stage,
body.connecting .top-utility-bar {
  opacity: 0 !important;
  filter: blur(6px);
  transition: opacity 0.5s ease, filter 0.5s ease;
}
.handshake-frame {
  width: min(520px, calc(100vw - 40px));
  padding: 22px 24px;
  border: 1px solid rgba(92, 225, 198, 0.4);
  border-radius: 14px;
  background: rgba(4, 6, 8, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--ice-white);
  box-shadow: 0 0 80px -20px rgba(92, 225, 198, 0.45);
}
.handshake-head {
  display: flex;
  justify-content: space-between;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(220, 230, 240, 0.14);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(220, 230, 240, 0.42);
}
.handshake-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 6.4em;
  line-height: 1.6;
  color: rgba(220, 230, 240, 0.7);
}
.handshake-lines li::before {
  content: '› ';
  color: var(--accent-mint);
}
.handshake-lines .ok {
  color: var(--accent-mint);
}
.handshake-bar {
  margin: 12px 0 0;
  font: inherit;
  white-space: pre;
  overflow: hidden;
}
.handshake .handshake-verdict {
  margin: 14px 0 0;
  font-size: clamp(13px, 2.2vw, 18px);
  text-align: left;
}
body.verified .handshake-verdict {
  opacity: 1;
  transform: none;
}
.fx-flash {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, #fff 0, #bff5ea 35%, #040608 80%);
}
body.flash .fx-flash {
  animation: introFlash 0.7s ease-out forwards;
}
@keyframes introFlash {
  0% { opacity: 0; }
  30% { opacity: 0.9; }
  100% { opacity: 1; background: #040608; }
}

/* Motion off / reduced motion: everything is shown at once and stays still. */
html[data-motion='off'] .top-utility-bar,
html[data-motion='off'] .agency-header,
html[data-motion='off'] .access-whisper,
html[data-motion='off'] .bottom-telemetry {
  opacity: 1;
  transform: none;
  animation: none;
}
html[data-motion='off'] .analog-noise,
html[data-motion='off'] .access-dot {
  animation: none;
}
@media (max-width: 640px) {
  .telemetry-right {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
}
@media (max-width: 640px) {
  .hero-center-stage {
    padding-top: 128px;
  }
  .top-utility-bar .util-group {
    justify-content: center;
    row-gap: 2px;
  }
}
