/* ─── TOKENS ──────────────────────────────────────── */
:root {
  --bg:     #07080f;
  --fg:     #dce3ee;
  --sub:    rgba(220, 227, 238, 0.36);
  --mute:   rgba(220, 227, 238, 0.09);
  --accent: #00c4b4;
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── BASE ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  cursor: none;
  -webkit-font-smoothing: antialiased;
}

/* ─── DEPTH GRADIENT ──────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(
    ellipse 110% 60% at 50% -8%,
    rgba(14, 24, 52, 0.7) 0%,
    transparent 68%
  );
}

/* ─── GRAIN ───────────────────────────────────────── */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='250' height='250' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 185px 185px;
}

/* ─── SCANLINES ───────────────────────────────────── */
.scanlines {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, transparent 0px, transparent 2px,
    rgba(0, 0, 0, 0.044) 2px, rgba(0, 0, 0, 0.044) 3px
  );
  background-size: 100% 3px;
  animation: scan 90s linear infinite;
}
@keyframes scan {
  from { background-position: 0 0; }
  to   { background-position: 0 270px; }
}

/* ─── MATRIX RAIN CANVAS ──────────────────────────── */
#rain {
  position: fixed; inset: 0;
  z-index: 1;
  opacity: 1;
  transition: opacity 1.4s ease;
  pointer-events: none;
}
#rain.bg { opacity: 0.09; }

/* ─── RAIN LENS CANVAS ────────────────────────────── */
/* Sits above dim rain; redraws current chars at full brightness
   clipped to a circle around the cursor. Ghost columns decode
   into hidden messages inside the beam. */
#rain-lens {
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#rain-lens.on { opacity: 1; }

/* ─── INTRO OVERLAY ───────────────────────────────── */
#intro {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
#intro.out { opacity: 0; }

.intro-clip { overflow: hidden; line-height: 1; }

#intro-name {
  display: block;
  font-size: clamp(10vw, 13vw, 200px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: .9;
  text-transform: uppercase;
  background: linear-gradient(
    158deg,
    #ffffff 0%, #cce9f8 24%, #ffffff 50%, #b4dff5 76%, #ffffff 100%
  );
  background-size: 260% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ice 12s ease-in-out infinite;
  filter: drop-shadow(0 0 55px rgba(0, 196, 180, 0.3));
  opacity: 0;
  transition: opacity 0.2s ease;
}

#intro-cur {
  font-size: 1.3rem;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  opacity: 0;
}
#intro-cur.blink { animation: caret 0.6s step-end 5; }

@keyframes caret {
  0%, 49% { opacity: 1; }
  50%,100% { opacity: 0; }
}

/* ─── CUSTOM CURSOR ───────────────────────────────── */
#cur {
  position: fixed; z-index: 9999; pointer-events: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transform: translate(-50%, -50%);
  transition: width .18s ease, height .18s ease,
              background .18s ease, box-shadow .18s ease;
  will-change: left, top;
}
#cur.ring {
  width: 30px; height: 30px;
  background: transparent;
  box-shadow: none;
  border: 1px solid rgba(0, 196, 180, 0.5);
}

/* ─── LAYOUT SHELL ────────────────────────────────── */
.shell {
  position: relative; z-index: 3;
  height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 0 clamp(1.6rem, 5vw, 4.5rem);
}

/* ─── NAV ─────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--mute);
}
.nav-id {
  font-size: .68rem; font-weight: 700;
  letter-spacing: .28em; text-transform: uppercase;
  color: var(--sub);
}

/* ─── HERO ────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: center;
  padding: clamp(1.5vh, 2.5vh, 3.5vh) 0;
  min-height: 0;
  -webkit-user-select: none;
  user-select: none;
}
.hero-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.name-outer { overflow: hidden; line-height: 1; }

.name {
  display: block;
  font-size: clamp(12vw, 15.5vw, 250px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: .9;
  text-transform: uppercase;
  background: linear-gradient(
    165deg,
    #ffffff 0%, #e4f2ff 12%, #ffffff 30%,
    #96c8e6 48%, #d8eef8 62%, #ffffff 74%,
    #7ab8d6 88%, #ffffff 100%
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ice 5s ease-in-out infinite;
  filter:
    drop-shadow(0 1px 0 rgba(185, 195, 210, 0.95))
    drop-shadow(0 2px 0 rgba(130, 142, 158, 0.75))
    drop-shadow(0 4px 0 rgba(75,  88, 105, 0.50))
    drop-shadow(0 12px 32px rgba(0, 0, 0, 0.82));
  will-change: filter;
}

/* Each letter: inline so parent's background-clip:text gradient still shows */
.name > span { display: inline; }

/* The actively glitching letter — inline-block for transforms,
   explicit fill since inline-block breaks the parent gradient */
.name > span.g {
  display: inline-block;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.9);
  animation: lglitch 0.18s ease-out forwards;
}

@keyframes lglitch {
  0%   { transform: translate(-3px, -1px) skewX(-8deg); opacity: 0.45; filter: brightness(3); }
  30%  { transform: translate(2px,  1px)  skewX( 4deg); opacity: 1;    filter: brightness(1.8); }
  65%  { transform: translate(-1px, 0)    skewX(-2deg);                filter: brightness(1.2); }
  100% { transform: none;                                               filter: none; }
}

@keyframes ice {
  0%, 100% { background-position:   0% center; }
  50%       { background-position: 100% center; }
}

.hero-sub {
  margin-top: clamp(.9rem, 1.8vh, 1.6rem);
  font-size: clamp(.62rem, .95vw, .82rem);
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--sub);
}

/* ─── INFO STRIP ──────────────────────────────────── */
.strip {
  display: flex; align-items: stretch;
  border-top: 1px solid var(--mute);
  border-bottom: 1px solid var(--mute);
}
.strip-cell {
  display: flex; flex-direction: column; gap: .4rem;
  padding: 1.1rem 2.2rem 1.1rem 0;
  flex: 1;
}
.strip-cell + .strip-cell {
  padding-left: 2.2rem;
  border-left: 1px solid var(--mute);
}
.strip-lbl {
  font-size: .52rem; letter-spacing: .32em; text-transform: uppercase;
  color: rgba(0, 196, 180, 0.4);
}
.strip-val {
  font-size: .7rem; letter-spacing: .06em;
  color: var(--sub);
}
.avail-row {
  display: flex; align-items: center; gap: .55rem;
  font-size: .7rem; letter-spacing: .06em;
  color: var(--sub);
}
.dot {
  flex-shrink: 0; width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
  animation: pulse 2.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .2; }
}

/* ─── FOOTER ──────────────────────────────────────── */
.foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 0;
  border-top: 1px solid var(--mute);
  font-size: .6rem; letter-spacing: .16em; text-transform: uppercase;
}
.foot-yr { color: rgba(220, 227, 238, 0.3); }

/* ─── STAGGER REVEALS ─────────────────────────────── */
[data-r] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  will-change: opacity, transform;
}
.name-outer[data-r] { transform: translateY(32px); }
[data-r].in { opacity: 1; transform: translateY(0); }

/* Stagger delays — defined here instead of inline styles */
.name-outer[data-r]  { transition-delay: .08s; }
.hero-sub[data-r]    { transition-delay: .2s;  }
.strip[data-r]       { transition-delay: .32s; }
.foot[data-r]        { transition-delay: .42s; }

/* ─── MOBILE ──────────────────────────────────────── */
@media (max-width: 600px) {
  html, body { overflow: auto; cursor: auto; }
  #cur { display: none; }
  .strip { flex-direction: column; }
  .strip-cell + .strip-cell {
    padding-left: 0; padding-top: 1rem;
    border-left: none; border-top: 1px solid var(--mute);
  }
}

/* ─── FIXED CHAT WIDGET ───────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 1.6rem;
  right: 1.8rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .4rem;
}

/* The pill tab — always visible */
.chat-tab {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem 1rem;
  background: rgba(7, 8, 15, 0.88);
  border: 1px solid rgba(0, 196, 180, 0.22);
  color: rgba(220, 227, 238, 0.45);
  font-family: inherit; font-size: .58rem;
  letter-spacing: .22em; text-transform: uppercase;
  cursor: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: border-color .2s, color .2s;
}
.chat-tab:hover { border-color: rgba(0, 196, 180, 0.5); color: var(--fg); }
.chat-tab .dot { width: 5px; height: 5px; flex-shrink: 0; }

/* The expandable panel — slides up from the pill */
.chat-panel {
  width: 300px;
  display: flex; flex-direction: column;
  border: 1px solid rgba(0, 196, 180, 0.18);
  background: rgba(7, 8, 15, 0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.4s var(--ease), opacity 0.25s ease;
}
.chat-widget.open .chat-panel {
  max-height: 360px;
  opacity: 1;
  pointer-events: auto;
}

.chat-term-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--mute);
  flex-shrink: 0;
  font-size: .6rem; letter-spacing: .18em; text-transform: uppercase;
  color: rgba(0, 196, 180, 0.6);
}
.chat-term-dots { display: flex; gap: .3rem; }
.chat-dot-light {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); opacity: 0.4;
}
.chat-dot-light.active { opacity: 1; box-shadow: 0 0 4px var(--accent); }
.chat-term-title { flex: 1; }

#chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem;
  display: flex; flex-direction: column; gap: .45rem;
  min-height: 120px; max-height: 240px;
  font-size: .67rem; line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 196, 180, 0.18) transparent;
}
#chat-msgs::-webkit-scrollbar { width: 4px; }
#chat-msgs::-webkit-scrollbar-track { background: transparent; }
#chat-msgs::-webkit-scrollbar-thumb {
  background: rgba(0, 196, 180, 0.2); border-radius: 2px;
}

.chat-empty {
  color: rgba(220, 227, 238, 0.18);
  text-align: center; margin: auto 0;
  letter-spacing: .1em; line-height: 2.2;
}

.msg { word-break: break-word; }
.msg-handle {
  color: rgba(0, 196, 180, 0.65);
  font-size: .55rem; letter-spacing: .1em;
}
.msg.mine .msg-handle { color: rgba(57, 255, 20, 0.75); }
.msg-text { color: rgba(220, 227, 238, 0.58); }

.chat-form {
  display: flex; align-items: center;
  padding: .5rem 1rem;
  border-top: 1px solid var(--mute);
  gap: .3rem; flex-shrink: 0;
  font-size: .67rem;
}
.chat-prompt { color: rgba(0, 196, 180, 0.5); -webkit-user-select: none; user-select: none; }

#chat-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--fg); font-family: inherit; font-size: inherit;
  letter-spacing: .04em; caret-color: var(--accent); cursor: none;
}
#chat-input::placeholder { color: rgba(220, 227, 238, 0.15); }

@media (max-width: 600px) {
  .chat-widget { bottom: 1rem; right: 1rem; }
  .chat-panel { width: calc(100vw - 2rem); }
  .chat-tab, #chat-input { cursor: auto; }
}
