/* AEON-X landing overlay - L9.
 * Everything lives in ONE design-space layer (#ui) that the scene fit
 * translates and scales, so chat, bubbles and the globe hit area stay locked to
 * the artwork at any window size. Type size is held at a readable floor with
 * max(<design px>, <design px> / --s) so it never shrinks to a speck on small
 * displays while the art keeps scaling.
 */

:root {
  --xp-green-1: #7fc44a;
  --xp-green-2: #4f9d20;
  --xp-green-3: #3d8514;
  --luna: #7f9db9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1b30;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }

/* ---------- the design-space overlay ---------- */

#ui {
  --s: 1;
  position: fixed;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  pointer-events: none;          /* the scene stays untouched except where opted in */
  z-index: 2;
}

/* invisible keyboard/mouse target over the globe: design centre 936.23,500.77
 * radius 269.26 -> 667,231 539x539, clipped to the circle so the corners stay
 * sky (and inert). */
#globe-hit {
  position: absolute;
  left: 667px;
  top: 231px;
  width: 539px;
  height: 539px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  clip-path: circle(50%);
  pointer-events: auto;
  cursor: pointer;
}
#globe-hit:focus-visible { outline: none; filter: drop-shadow(0 0 7px #fff); }

/* ---------- Thinker bubbles ---------- */

#bubbles {
  position: absolute;
  left: 700px;
  top: 170px;
  width: 480px;
  height: 590px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;      /* newest sits at the bottom */
  gap: 10px;
  pointer-events: none;
}

.balloon {
  position: relative;
  align-self: flex-start;
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid #000;
  border-radius: 6px;
  background: #ffffe1;
  color: #1b1b12;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(14px, calc(14px / var(--s)));
  line-height: 1.45;
  box-shadow: 2px 3px 7px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: opacity 260ms ease;
}

/* balloon tail: right, angled down toward the Thinker's head */
.balloon::before,
.balloon::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}
.balloon::before {
  right: -10px;
  top: 54%;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent #000;
}
.balloon::after {
  right: -8px;
  top: calc(54% + 1.5px);
  border-width: 8.5px 0 8.5px 8.5px;
  border-color: transparent transparent transparent #ffffe1;
}

.balloon.thinking { min-width: 58px; }
.balloon .dots { display: inline-flex; gap: 4px; vertical-align: 1px; }
.balloon .dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6b6b55;
  animation: dotpulse 1.05s infinite ease-in-out;
}
.balloon .dots i:nth-child(2) { animation-delay: 0.16s; }
.balloon .dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes dotpulse { 0%, 60%, 100% { opacity: 0.28; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* ---------- the user's own message, just above the input ---------- */

#user-slot {
  position: absolute;
  left: 700px;
  top: 800px;
  width: 520px;
  height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 5px;
  pointer-events: none;
}

.user-balloon {
  max-width: 340px;
  padding: 6px 10px;
  border: 1px solid #7fa6d9;
  border-radius: 6px;
  background: #ddebff;
  color: #13243c;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(13px, calc(13px / var(--s)));
  line-height: 1.4;
  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.22);
  animation: userfade 4s ease forwards;
}
@keyframes userfade { 0%, 72% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- input row + topic chips ---------- */

#chat {
  position: absolute;
  left: 700px;
  top: 896px;
  width: 520px;
  height: 34px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

#ask {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 7px;
  border: 1px solid var(--luna);
  border-radius: 2px;
  background: #fff;
  color: #14243a;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(13px, calc(13px / var(--s)));
  outline: none;
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.12);
}
#ask::placeholder { color: #7a8794; }
#ask:focus { border-color: #3169c6; box-shadow: inset 0 0 0 1px rgba(49, 105, 198, 0.35); }

#send {
  flex: 0 0 auto;
  width: 70px;
  height: 100%;
  border: 1px solid #2c6510;
  border-radius: 3px;
  background: linear-gradient(180deg, #9ad35f 0%, var(--xp-green-1) 22%, var(--xp-green-2) 62%, var(--xp-green-3) 100%);
  color: #fff;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(13px, calc(13px / var(--s)));
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(16, 60, 4, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 2px rgba(10, 35, 5, 0.4);
  cursor: pointer;
}
#send:hover { filter: brightness(1.07); }
#send:active { filter: brightness(0.95); transform: translateY(1px); }
#send:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

#chips {
  position: absolute;
  left: 700px;
  top: 942px;
  width: 520px;
  height: 26px;
  display: flex;
  gap: 7px;
  pointer-events: none;
}

.chip {
  pointer-events: auto;
  border: 1px solid var(--luna);
  border-radius: 3px;
  background: linear-gradient(180deg, #ffffff 0%, #e8eff7 100%);
  color: #16304d;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(12px, calc(12px / var(--s)));
  line-height: 1;
  padding: 5px 9px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.chip:hover { border-color: #3169c6; background: linear-gradient(180deg, #ffffff 0%, #dbe8f8 100%); }
.chip:focus-visible { outline: 2px solid #3169c6; outline-offset: 1px; }

#boot {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 40%, #2b6bb5 0%, #10254a 60%, #081427 100%);
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  transition: opacity 420ms ease;
}

#boot.gone { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .balloon, .user-balloon { transition: none; animation: none; }
  .balloon .dots i { animation: none; opacity: 0.6; }
  #boot { transition: none; }
}

/* ---------- the dive locks the overlay without tearing it down ---------- */

body.diving #globe-hit,
body.diving #chat,
body.diving .chip,
body.diving .balloon { pointer-events: none !important; }
body.diving #ask { background: #eef2f7; color: #7a8794; }
body.diving .chip { opacity: 0.75; }

/* ---------- L13: the Thinker toggles the chat ---------- */

#chat-close {
  position: absolute;
  left: 1226px;
  top: 896px;
  width: 26px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--luna);
  border-radius: 2px;
  background: linear-gradient(180deg, #ffffff 0%, #e8eff7 100%);
  color: #16304d;
  font-family: Tahoma, "Segoe UI", sans-serif;
  font-size: max(14px, calc(14px / var(--s)));
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 180ms ease, transform 180ms ease;
}
#chat-close:hover { border-color: #3169c6; background: linear-gradient(180deg, #ffffff 0%, #dbe8f8 100%); }
#chat-close:focus-visible { outline: 2px solid #3169c6; outline-offset: 1px; }

#bubbles, #user-slot, #chat, #chips { transition: opacity 180ms ease, transform 180ms ease; }

/* closed: the chat fades and sinks, and stops taking pointer events. The
   history, the chips and anything typed stay exactly as they were. */
#ui.chat-closed #bubbles,
#ui.chat-closed #user-slot,
#ui.chat-closed #chat,
#ui.chat-closed #chips,
#ui.chat-closed .balloon,
#ui.chat-closed #chat-close {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none !important;
}

/* ---------- L-widget: the coin is the Tellr widget trigger ---------- */

#coin {
  position: absolute;
  left: 182px;
  top: 96px;
  width: 320px;
  height: 292px;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#coin:focus-visible { outline: 2px dashed rgba(255, 255, 255, 0.75); outline-offset: 2px; }
body.diving #coin { pointer-events: none !important; }

/* ---------- L14.1: hero copy (DOM, viewport units, system fonts only) ---------- */

#hero {
  position: fixed;
  top: 5.2vh;
  right: 4vw;
  width: min(46vw, 780px);
  text-align: right;
  pointer-events: none;
  z-index: 4;
  user-select: none;
}
#hero h1 {
  margin: 0;
  color: #ffffff;
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 400;
  font-size: clamp(32px, 5.5vw, 88px);
  line-height: 1.04;
  letter-spacing: 0.005em;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.42), 0 1px 3px rgba(0, 0, 0, 0.52);
}
#hero .hero-sub {
  margin: 0.75em 0 0;
  color: #ffffff;
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: clamp(12px, 1.5vw, 27px);
  line-height: 1.38;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.55);
}
#hero #tag {
  display: block;
  width: 22vw;
  height: auto;
  margin: 1.7vh 0 0 auto;
  transform: rotate(-6deg);
  transform-origin: 100% 50%;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.32));
}

/* narrow: stack top-centre, smaller, above the globe */
@media (max-width: 480px) {
  #hero {
    top: 2.4vh;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    text-align: center;
  }
  #hero h1 { font-size: clamp(28px, 9.2vw, 40px); }
  #hero .hero-sub { margin-top: 0.55em; font-size: 3.5vw; }
  #hero #tag { width: 44vw; margin: 1.1vh auto 0; }
}
