:root {
  --black: #000000;
  --white: #ffffff;
  --font_family: "Josefin Sans", sans-serif;
}

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

html { font-size: .10976948408342481vh; }

body {
  font-size: 12rem;
  top: 0; left: 0;
  width: 100%;
  background-color: var(--black);
  color: var(--black);
  overflow: hidden;
}

span {
  display: inline-block;
  overflow: hidden;
  line-height: 1;
  font-size: inherit;
  font-family: inherit;
  vertical-align: bottom;
}

a { text-decoration: none; font-size: 50rem; }

h1 {
  color: var(--black);
  font-size: 100rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ── WebGL canvas ─────────────────────────────────────── */
.webgl {
  position: fixed;
  top: 0; left: 0;
  outline: none;
  opacity: 0;
  z-index: -1;
}

/* ── Controls group (keyboard guide, bottom-center) ─────── */
.controls_group {
  position: fixed;
  bottom: 50rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 32rem;
  mix-blend-mode: difference;
  transition: opacity .3s ease-in-out;
  opacity: 0;
  pointer-events: none;
}

.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8rem;
}

.ctrl_keys {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4rem;
}

.ctrl_row {
  display: flex;
  gap: 4rem;
}

.ctrl_key {
  width: 34rem;
  height: 34rem;
  border: 1rem solid rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font_family);
  font-size: 16rem;
  font-weight: 100;
  color: rgba(255,255,255,0.75);
  user-select: none;
}

.ctrl_key_esc {
  font-size: 11rem;
  letter-spacing: 1rem;
}

.ctrl_key.ctrl_key_enter {
  width: 52rem;
  height: 48rem;
  border: none;
  padding: 0;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl_label {
  font-family: var(--font_family);
  font-size: 10rem;
  font-weight: 100;
  letter-spacing: 3rem;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  white-space: nowrap;
}

.ctrl_enter {
  display: none !important;
  opacity: 0;
}

.ctrl_esc {
  display: none !important;
  opacity: 0;
}

.ctrl_enter.is-active,
.ctrl_esc.is-active {
  display: flex !important;
}

.ctrl_esc .ctrl_key_esc {
  border-color: rgba(255,255,255,0.75);
  color: rgba(255,255,255,0.75);
}

/* ── AGI button ────────────────────────────────────────── */
.menu_button {
  position: absolute;
  top: 31rem;
  right: 50rem;
  user-select: none;
  z-index: 20;
  overflow: visible;
}

.menu_button button {
  font-family: var(--font_family);
  font-size: 18rem;
  font-weight: 300;
  letter-spacing: 4rem;
  color: var(--white);
  text-transform: uppercase;
  background: transparent;
  border: none;
  opacity: 0;
  cursor: pointer;
}

.menu_button button:focus:not(:focus-visible) { outline: none; box-shadow: none; }

/* ── Menu ──────────────────────────────────────────────── */
.menu {
  font-family: var(--font_family);
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  user-select: none;
  overflow: hidden;
  z-index: 10;
  pointer-events: none;
}


.menu_text {
  height: 100%;
  padding: 50rem;
  display: flex;
  justify-content: center;
  mix-blend-mode: difference;
  position: absolute;
  top: 0; left: 0;
  z-index: 11;
}

.search_bar {
  position: absolute;
  bottom: 50rem;
  right: 50rem;
  width: 200rem;
  text-align: left;
  display: flex;
  column-gap: 5rem;
  opacity: 0;
}

.search_bar input {
  background: none;
  border: none;
  font-family: var(--font_family);
  font-size: 15rem;
  color: var(--white);
  pointer-events: none;
  caret-color: var(--white);
}

.search_bar input::placeholder { font-family: var(--font_family); color: var(--white); }
.search_bar input:focus { background-color: none; border: none; outline: none; }

.menu_main_links {
  height: 100%;
  text-align: right;
  display: flex;
  flex-direction: column;
  width: 120rem;
  font-family: var(--font_family);
}

.menu_main_links span { position: relative; width: 100%; }

.menu_links {
  height: 95%;
  width: 200rem;
  overflow-y: scroll;
}

.menu_links ul li { overflow: hidden; position: relative; }
.menu_links ul li a { color: var(--white); font-family: var(--font_family); }
.menu_links::-webkit-scrollbar { display: none; }

.menu_main_links a {
  color: var(--white);
  font-weight: 350;
  transform: translateY(-110%);
  font-size: 30rem;
  display: inline-block;
  margin-bottom: 0rem;
  width: 100%;
  padding-right: 5rem;
  transition: opacity .2s ease-in-out;
}

.menu_links a {
  font-size: 15rem;
  transform: translateY(-100%);
  display: block;
  margin-left: 5rem;
  padding-bottom: 2rem;
}

.menu_links_hover {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url(images/hover_small.png);
  background-repeat: no-repeat;
  background-position: 0 0;
  pointer-events: none;
  mix-blend-mode: difference;
  display: none;
}

.menu_line {
  height: 0%;
  width: 1rem;
  background-color: var(--white);
  margin-left: 30rem;
  margin-right: 30rem;
}

.menu_links ul li:hover .menu_links_hover { display: block; }
.menu_main_links span a:hover { opacity: .4; }

.menu_canvas_container {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: 80%;
  padding: 50rem;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  opacity: 0;
}

.menu_canvas_container img {
  width: 100vh;
  height: 100vh;
  object-fit: cover;
  object-position: 0rem 50rem;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

.menu_actif { opacity: .2; }

.menu_contact, .menu_insta {
  position: absolute;
  color: var(--white);
  bottom: 0; right: 0;
  border: none;
  background: transparent;
  font-family: var(--font_family);
  font-size: 15rem;
  text-align: right;
  opacity: 0;
  pointer-events: none;
  margin-bottom: 50rem;
  margin-right: 50rem;
  transition: opacity .2s ease-in-out;
  z-index: 20;
}

.menu_contact::after {
  content: "";
  position: absolute;
  bottom: 2rem;
  right: -12rem;
  width: 10rem;
  height: 17rem;
  background-color: var(--white);
  animation: clignote 1s infinite;
}

.menu_contact:hover, .menu_insta:hover { cursor: pointer; opacity: 1; }
.menu_insta { bottom: 25rem; margin-right: 40rem; }

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

/* ── Loader ────────────────────────────────────────────── */
.loader {
  width: 100vw;
  height: 100%;
  position: fixed;
  top: 0; left: 0;
  background-color: transparent;
  color: var(--white);
  font-family: var(--font_family);
  z-index: 999;
  display: none;
  align-items: space-between;
  justify-content: center;
  flex-direction: column;
  padding: 50rem;
}

.loader_line {
  width: 0%;
  height: 1rem;
  background-color: var(--white);
  margin-top: 10rem;
  margin-left: auto;
  margin-bottom: 10rem;
}

.loader_title {
  color: var(--white);
  font-size: 40rem;
  text-transform: none;
  text-align: right;
  transform: translateY(110%);
}

.loader_countdown {
  font-size: 110rem;
  font-weight: 200;
  letter-spacing: -3rem;
  font-family: var(--font_family);
}

.loader_sub {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 15rem;
  letter-spacing: 10rem;
}

.loader_subtitle { transform: translate(10rem, -110%); }
.loader_number   { transform: translateY(-110%); }

/* ── Shared animated underline for hover + one-time load hint ─ */
.loader_name        { position: relative; display: inline-block; }
.menu_button button { position: relative; }

.loader_name::after,
.menu_button button::after {
  content: '';
  display: block;
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4rem;
  height: 1rem;
  width: 0;
  background: #ffffff;
  transition: width 0.35s ease-out;
  pointer-events: none;
  z-index: 1;
}

/* Hover: line draws in from left to right */
.loader_brand:hover .loader_name::after,
.menu_button button:hover::after {
  width: 100%;
}

/* One-time load hint: draws in, holds, fades out */
@keyframes hintUnderline {
  0%   { width: 0;    opacity: 1; }
  35%  { width: 100%; opacity: 1; }
  75%  { width: 100%; opacity: 1; }
  100% { width: 100%; opacity: 0; }
}

.loader_name.show-hint::after,
.menu_button button.show-hint::after {
  animation: hintUnderline 1.6s ease-out 0s;
}

/* ── Loader brand (top-left) ───────────────────────────── */
.loader_brand {
  position: fixed;
  top: 20rem;
  left: 20rem;
  display: flex;
  align-items: center;
  column-gap: 12rem;
  opacity: 0;
  pointer-events: all;
  z-index: 202;
  cursor: pointer;
}


.loader_logo {
  height: 32rem;
  width: auto;
  display: block;
}

.loader_name {
  font-family: var(--font_family);
  font-size: 18rem;
  color: var(--white);
  letter-spacing: 4rem;
  text-transform: uppercase;
  font-weight: 300;
  line-height: 1;
  margin-top: 4rem;
  overflow: visible;
}

/* ── AGI hover expand ──────────────────────────────────── */
#agi_abbr {
  border-bottom: 1rem solid rgba(255, 255, 255, 0.4);
  cursor: default;
}

#agi_expand {
  position: absolute;
  bottom: 50rem;
  left: 50rem;
  font-family: var(--font_family);
  font-size: 11rem;
  color: var(--white);
  letter-spacing: 4rem;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 820px) {
  html { font-size: .10976948408342481vh; }

  .controls_group { display: none; }

  .menu_canvas_container img,
  .menu_canvas_container video { display: none; }

  .menu { display: flex; justify-content: center; align-items: center; overflow: hidden; }
  .menu_text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 80%;
    padding: 30rem;
  }
  .menu_main_links { width: 95rem; }
  .menu_links { height: 80%; }
}

/* Touch-only overrides. Gated by both media query AND body.is-touch class
   (set by JS) so they cannot leak through on desktop. */
body.is-touch .controls_group,
body.is-touch .controls_group .ctrl_move,
body.is-touch .controls_group .ctrl_enter,
body.is-touch .controls_group .ctrl_esc { display: none !important; }

@media (hover: none) and (pointer: coarse) {

  /* AGI overlay: rescale layout + type for small touch viewports. */
  .agi-slide-content {
    justify-content: flex-start !important;
    padding: 9vh 5vw 2vh !important;
    gap: 10px !important;
  }
  .agi-row { gap: 4vw !important; }

  .agi-h-period { font-size: 26px !important; margin-bottom: 4px !important; }
  .agi-h-title  { font-size: 9px  !important; letter-spacing: 3px !important; }
  .agi-h-sub    { font-size: 7px  !important; letter-spacing: 3px !important; margin-top: 4px !important; }
  .agi-h-rule   { margin-top: 8px !important; }

  .agi-card { flex: 0 0 44% !important; }

  /* Body text: smaller font, tighter line-height */
  .agi-body { align-items: flex-start !important; }
  .agi-body-text { font-size: 10px !important; line-height: 1.55 !important; }

  .agi-researchers { margin-top: 10px !important; padding-top: 8px !important; gap: 4px !important; }
  .agi-researcher-row  { font-size: 8px !important; line-height: 1.3 !important; }
  .agi-researcher-name { font-size: 8px !important; letter-spacing: 2px !important; }
  .agi-researcher-role { font-size: 8px !important; letter-spacing: 0.5px !important; }

  /* Panel-view description text: pin to the very top + shrink so it
     doesn't sit over the website preview behind it. */
  .view-ui {
    top: 1.5% !important;
    width: min(92vw, 560px) !important;
    font-size: 10px !important;
    line-height: 1.45 !important;
    letter-spacing: 0.03em !important;
    text-align: center !important;
  }

  /* Final slide: shrink so all three rows fit on landscape phones */
  .agi-final-slide { padding: 0 24px !important; max-width: 480px !important; }
  .agi-final-logo  { height: 30px !important; margin-bottom: 10px !important; }
  .agi-final-title { font-size: 16px !important; letter-spacing: 6px !important; margin-bottom: 14px !important; }
  .agi-final-rule  { margin-bottom: 14px !important; }
  .agi-final-sub   { font-size: 8px  !important; letter-spacing: 4px !important; margin-bottom: 10px !important; }
  .agi-final-row   { padding: 8px 0 !important; gap: 10px !important; }
  .agi-final-num   { font-size: 8px  !important; letter-spacing: 2px !important; }
  .agi-final-desc  { font-size: 10px !important; line-height: 1.45 !important; }
}

/* ── Rotate-to-landscape prompt (touch + portrait) ─────── */
.rotate_prompt {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--black);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 38px;
  color: var(--white);
}
/* Default: tilt prompt asks user to go landscape (for game).
   `body.is-touch` is set by JS only on real touch devices, so the prompt
   cannot show on desktop even if (pointer: coarse) misfires. */
@media (orientation: portrait) {
  body.is-touch:not(.nerve-mode) .rotate_prompt { display: flex; }
}
/* Nerve mode: tilt prompt asks user to go portrait (for reading) */
@media (orientation: landscape) {
  body.is-touch.nerve-mode .rotate_prompt { display: flex; }
}

.rotate_phone {
  width: 78px;
  height: 117px;
  animation: rotate-phone-anim 2.2s ease-in-out infinite;
  transform-origin: center;
}
@keyframes rotate-phone-anim {
  0%, 22%   { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
/* Reverse animation: rotating from landscape back to portrait */
@keyframes rotate-phone-anim-rev {
  0%, 22%   { transform: rotate(-90deg); }
  55%, 100% { transform: rotate(0deg); }
}
body.nerve-mode .rotate_phone {
  animation-name: rotate-phone-anim-rev;
}

/* Text swap between the two prompt modes */
.rotate_text_portrait { display: none; }
body.nerve-mode .rotate_text_landscape { display: none; }
body.nerve-mode .rotate_text_portrait { display: block; }
.rotate_text {
  font-family: var(--font_family);
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  text-align: center;
  padding: 0 24px;
}

/* ── Touchscreen joystick ─────────────────────────────── */
.joystick {
  position: fixed;
  right: 28px;
  bottom: 32px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  display: none;
}
.joystick.enabled { display: block; }
.joystick.visible {
  opacity: 1;
  pointer-events: auto;
}
.joystick_stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.08s ease-out;
  will-change: transform;
}
