@font-face {
  font-family: "Space Grotesk";
  src: url("assets/fonts/space-grotesk-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Oxanium";
  src: url("assets/fonts/oxanium-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

#app {
  --steel: #edf2f3;
  --cold: #91c8d6;
  --warm: #d9aa82;
  --identity-bottom: 26px;
  --name-glitch-period: 2.7s;
  --decoder-duration: .58s;
  --scan-period: 2s;
}

#app[data-mode="user"] .editor-only { display: none; }
#app[data-mode="user"] #scene { cursor: default; }

.view-switch {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid #829aa839;
  border-radius: 6px;
  background: #0f1519dc;
  box-shadow: inset 0 1px 0 #d4edff14, 0 6px 26px #0006;
}

.view-switch button {
  border: 1px solid transparent;
  background: transparent;
  color: #a9b8bf;
  width: 42px;
  height: 40px;
  border-radius: 3px;
  font: 600 13px/1 "Space Grotesk", sans-serif;
}

.view-switch button[aria-pressed="true"] {
  color: #f0f5f8;
  background: linear-gradient(150deg, #91a9b340, #384a5728);
  border-color: #a9c4d14a;
  box-shadow: inset 0 1px 0 #d4edff20;
}

#app > .counter { top: 72px; right: max(18px, env(safe-area-inset-right)); }
.tools button svg { display: block; width: 17px; height: 17px; margin: auto; }

#app > .identity {
  top: auto;
  bottom: var(--identity-bottom);
  left: 50%;
  z-index: 3;
  width: min(94%, 1200px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.identity__name {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: .06em .53em;
  color: var(--steel);
  font: 560 clamp(15px, 3.65vw, 39px)/1.05 "Oxanium", "Space Grotesk", sans-serif;
  letter-spacing: .075em;
  text-shadow: 0 3px 16px #000c, 0 0 .48em #8eaeba22;
  white-space: nowrap;
}

.identity__name::before,
.identity__name::after {
  position: absolute;
  top: 50%;
  width: .14em;
  height: .61em;
  transform: translateY(-50%);
  border-block: 1px solid #89abb975;
  content: "";
}

.identity__name::before { left: 0; border-left: 1px solid #89abb975; }
.identity__name::after { right: 0; border-right: 1px solid #89abb975; }

.name-fragment,
.name-signal { position: relative; display: inline-block; }

.name-fragment--last { color: #cadce1; }

.name-signal::before,
.name-signal::after,
.name-fragment::after {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.name-fragment::after {
  color: var(--cold);
  content: attr(data-code-a);
}

.identity__name.is-decoding .name-fragment::after { animation: name-decoder var(--decoder-duration) steps(1, end) both; }
.identity__name.is-decoding .name-signal { animation: decoded-ink var(--decoder-duration) steps(1, end) both; }
.name-signal { animation: name-jolt var(--name-glitch-period) steps(1, end) infinite; }

.name-signal::before,
.name-signal::after { content: attr(data-text); }

.name-signal::before { color: #a3efff; animation: name-split-top var(--name-glitch-period) steps(1, end) infinite; }
.name-signal::after { color: #e7a990; animation: name-split-bottom var(--name-glitch-period) steps(1, end) infinite; }

.identity p { margin: 0; }
.identity .identity__role {
  margin-top: 9px;
  color: #c6d0d2;
  font: 600 clamp(8px, 1.3vw, 12px)/1.4 "Space Grotesk", sans-serif;
  letter-spacing: .19em;
}
.identity__role b { margin-inline: .26em; color: #8ba5ad; }

.identity .identity__wayfinding {
  margin-top: 8px;
  color: #92a4aa;
  font: 500 8px/1.3 "Space Grotesk", sans-serif;
  letter-spacing: .18em;
}
.identity__wayfinding b { margin-inline: .3em; color: #84989c; }

#field {
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--scene-cut, 0px) - 4px), transparent calc(100% - var(--scene-cut, 0px) + 9px));
}

.studio-link__word { top: var(--studio-nav-top, var(--word-top)); }
.studio-link__glass { opacity: .62; }
.studio-link__scan,
.studio-link__scan-line {
  opacity: 0;
  pointer-events: none;
  animation: studio-scan var(--scan-period) linear infinite;
}
.studio-link__scan-line { stroke-width: 1.1px; }
.studio-link--left { --scan-start: 930px; }
.studio-link--right { --scan-start: -930px; }

.studio-link__ink {
  animation: letter-tear 6.4s steps(1, end) infinite;
}
.studio-link--right .studio-link__ink { animation-delay: -1.35s; }

.thunder-arcs {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  overflow: visible;
  fill: none;
  pointer-events: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.thunder-arcs[hidden] { display: none; }
.thunder-halo {
  stroke: #55baff;
  stroke-width: 4.4px;
  filter: blur(2.4px) drop-shadow(0 0 6px #3596f5);
}
.thunder-core { stroke: #d6f7ff; stroke-width: 1.25px; }

@keyframes name-decoder {
  0% { opacity: .92; content: attr(data-code-a); }
  28% { opacity: .94; content: attr(data-code-b); }
  56% { opacity: .98; content: attr(data-code-c); }
  90%, 100% { opacity: 0; }
}
@keyframes decoded-ink { 0% { opacity: 0; } 90%, 100% { opacity: 1; } }

@keyframes name-jolt {
  0%, 20%, 26%, 100% { transform: none; }
  21% { transform: translateX(-.05em); }
  24% { transform: translateX(.035em); }
}

@keyframes name-split-top {
  0%, 20%, 26%, 100% { opacity: 0; transform: none; }
  21% { opacity: .89; clip-path: inset(8% 0 61%); transform: translate(-.13em,-.026em); }
  24% { opacity: .62; clip-path: inset(40% 0 37%); transform: translate(.09em,0); }
}
@keyframes name-split-bottom {
  0%, 20%, 26%, 100% { opacity: 0; transform: none; }
  21% { opacity: .85; clip-path: inset(54% 0 16%); transform: translate(.12em,.019em); }
  24% { opacity: .59; clip-path: inset(68% 0 5%); transform: translate(-.10em,0); }
}
@keyframes studio-scan {
  0% { transform: translateY(var(--scan-start)); opacity: 1; }
  66% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 0; }
}
@keyframes letter-tear {
  0%, 26%, 73.2%, 100% { filter: none; }
  24%, 72.6% { filter: url(#studio-tear-a); }
  24.8%, 72% { filter: url(#studio-tear-b); }
}

@media (max-width: 520px) {
  .identity .identity__role { margin-top: 9px; letter-spacing: .115em; }
  .identity .identity__wayfinding { margin-top: 6px; }
  .view-switch { right: 12px; top: 10px; }
  #app > .counter { top: 63px; right: 13px; }
}
@media (max-height: 580px) {
  .identity__name { font-size: clamp(14px, 3.45vw, 31px); }
  .identity .identity__role { margin-top: 6px; }
  .identity .identity__wayfinding { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .name-signal, .name-signal::before, .name-signal::after, .name-fragment::after,
  .studio-link__scan, .studio-link__scan-line, .studio-link__ink { animation: none !important; }
  .thunder-arcs { display: none; }
}
@media (forced-colors: active) {
  .studio-link__scan, .studio-link__scan-line, .studio-link__ink { animation: none; }
}
