@font-face {
    font-family: "Geist Mono";
    src: url("fonts/GeistMono-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@property --a {
    syntax: "<color>";
    inherits: true;
    initial-value: #ff5a1f;
}
@property --b {
    syntax: "<color>";
    inherits: true;
    initial-value: #ffb347;
}

:root {
    --a: #ff5a1f;
    --b: #ffb347;
    --bg: #080706;
    --fg: #f5f2ee;
    --muted: #a39b92;
    --dim: #857d75;
    --border: rgba(255, 255, 255, 0.08);
    --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root.ready {
    transition: --a 2.5s ease, --b 2.5s ease;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--mono);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    cursor: crosshair;
    /* dragging spins the globe; pinch-zoom stays available */
    touch-action: pinch-zoom;
    -webkit-user-select: none;
            user-select: none;
}

body.dragging,
body.dragging * {
    cursor: grabbing;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--b);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

::selection {
    background: color-mix(in srgb, var(--a) 35%, transparent);
}

/* ---------- Background ---------- */

.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.aurora {
    position: absolute;
    left: 50%;
    top: 50%;
    border-radius: 50%;
    opacity: 0.45;
    will-change: transform;
}

.aurora--a {
    width: 55vmax;
    height: 55vmax;
    margin: -36vmax 0 0 -40vmax;
    background: radial-gradient(circle, color-mix(in srgb, var(--a) 42%, transparent), color-mix(in srgb, var(--a) 14%, transparent) 38%, transparent 70%);
    animation: drift-a 24s ease-in-out infinite alternate;
}

.aurora--b {
    width: 45vmax;
    height: 45vmax;
    margin: -16vmax 0 0 -6vmax;
    background: radial-gradient(circle, color-mix(in srgb, var(--b) 30%, transparent), color-mix(in srgb, var(--b) 10%, transparent) 38%, transparent 70%);
    animation: drift-b 28s ease-in-out infinite alternate;
}

@keyframes drift-a {
    to { transform: translate3d(8vmax, 6vmax, 0) scale(1.1); }
}
@keyframes drift-b {
    to { transform: translate3d(-10vmax, 4vmax, 0) scale(0.9); }
}

#globe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: fade 0.8s var(--ease) forwards;
}

.grain {
    position: absolute;
    inset: 0;
    opacity: 0.08;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(8, 7, 6, 0.9) 100%);
}

/* ---------- Layout ---------- */

.page {
    position: relative;
    z-index: 1;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding:
        max(24px, env(safe-area-inset-top))
        max(28px, env(safe-area-inset-right))
        max(24px, env(safe-area-inset-bottom))
        max(28px, env(safe-area-inset-left));
}

/* ---------- HUD ---------- */

.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--muted);
    opacity: 0;
    animation: fade 1.2s var(--ease) 1.4s forwards;
}

.hud__right {
    display: inline-flex;
    align-items: center;
    gap: 22px;
}

.hud__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.hud__label {
    color: var(--dim);
    text-transform: uppercase;
}

.hud__label + span + .hud__label {
    margin-left: 6px;
}

.hud__glyph {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--fg);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.02em;
    transition: border-color 0.3s, box-shadow 0.3s;
    /* the badge is long-pressed on touch screens */
    touch-action: none;
    -webkit-touch-callout: none;
}

.hud__glyph:hover {
    border-color: color-mix(in srgb, var(--a) 60%, transparent);
    box-shadow: 0 0 20px -4px color-mix(in srgb, var(--a) 60%, transparent);
}

.hud__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: inherit;
    color: var(--muted);
    transition: color 0.3s;
}

.hud__btn:hover,
.hud__btn[aria-pressed="true"] {
    color: var(--fg);
}

.bars {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 10px;
}

.bars i {
    width: 2px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.hud__btn[aria-pressed="true"] .bars i {
    background: var(--b);
    animation: bar 0.9s ease-in-out infinite alternate;
}
.hud__btn[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -0.3s; }
.hud__btn[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -0.6s; }
.hud__btn[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -0.15s; }

@keyframes bar {
    to { height: 10px; }
}

/* ---------- Hero ---------- */

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 0;
    pointer-events: none;
    transition: opacity 1.4s var(--ease);
}

/* Let a shape take the stage, unless the text is in use */
.shape-on .hero:not(:has(:focus-visible, .plain)) {
    opacity: 0.2;
}

.hero > * {
    pointer-events: auto;
}

.title {
    position: relative;
    font-weight: 500;
    font-size: clamp(64px, 15vw, 176px);
    line-height: 1;
    letter-spacing: -0.06em;
    white-space: nowrap;
    cursor: default;
    opacity: 0;
    animation: fade 0.6s var(--ease) 0.3s forwards;
}

.title > span {
    display: inline-block;
}

.title__x {
    background: linear-gradient(135deg, var(--a), var(--b));
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}

.title__word {
    background: linear-gradient(180deg, #ffffff 25%, rgba(255, 255, 255, 0.4));
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}

/* Glitch */
.title::before,
.title::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

.title.glitch::before {
    opacity: 0.9;
    color: var(--a);
    animation: slice-a 0.5s steps(1) both;
}

.title.glitch::after {
    opacity: 0.9;
    color: var(--b);
    animation: slice-b 0.5s steps(1) both;
}

.title.glitch > span {
    animation: jolt 0.5s steps(2) both;
}

@keyframes slice-a {
    0%   { clip-path: inset(10% 0 70% 0); transform: translate(-0.05em, 0); }
    20%  { clip-path: inset(55% 0 20% 0); transform: translate(0.04em, 0); }
    40%  { clip-path: inset(30% 0 45% 0); transform: translate(-0.03em, 0); }
    60%  { clip-path: inset(75% 0 5% 0);  transform: translate(0.06em, 0); }
    80%  { clip-path: inset(0 0 85% 0);   transform: translate(-0.04em, 0); }
    100% { clip-path: inset(50% 0 50% 0); transform: none; }
}

@keyframes slice-b {
    0%   { clip-path: inset(60% 0 15% 0); transform: translate(0.05em, 0); }
    20%  { clip-path: inset(5% 0 80% 0);  transform: translate(-0.06em, 0); }
    40%  { clip-path: inset(40% 0 40% 0); transform: translate(0.03em, 0); }
    60%  { clip-path: inset(20% 0 60% 0); transform: translate(-0.04em, 0); }
    80%  { clip-path: inset(85% 0 0 0);   transform: translate(0.05em, 0); }
    100% { clip-path: inset(50% 0 50% 0); transform: none; }
}

@keyframes jolt {
    0%   { transform: none; }
    25%  { transform: translate(0.015em, -0.01em) skewX(-6deg); }
    50%  { transform: translate(-0.02em, 0.01em); }
    75%  { transform: skewX(4deg); }
    100% { transform: none; }
}

/* Signal */
.signal {
    margin-top: 28px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: clamp(10px, 2.9vw, 14px);
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
    opacity: 0;
    animation: fade 1.2s var(--ease) 1.1s forwards;
    transition: background-color 0.3s;
}

.signal:hover {
    background: rgba(255, 255, 255, 0.03);
}

.signal span {
    transition: color 0.9s var(--ease), text-shadow 0.9s var(--ease);
}

.signal .hot {
    color: var(--b);
    text-shadow: 0 0 12px var(--b);
    transition: none;
}

.signal .pre {
    color: var(--a);
}

.signal .plain {
    color: var(--fg);
    letter-spacing: 0.22em;
    text-shadow: 0 0 18px color-mix(in srgb, var(--b) 60%, transparent);
}

@keyframes fade {
    to { opacity: 1; }
}

/* ---------- Responsive ---------- */

/* The coordinates only track a mouse */
@media (hover: none), (pointer: coarse) {
    .hud__coords { visibility: hidden; }
}

@media (max-width: 600px) {
    .hud { font-size: 11px; }
    .hud__right { gap: 14px; }
    .signal { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }
}
