@layer reset, base, components;

@layer reset {
  html, body, main, div, h1, span {
    box-sizing: border-box;
  }

  body, h1 {
    margin: 0;
    padding: 0;
  }
}

@layer base {
  :root {
    color-scheme: dark;
    --bg: #07080d;
    --bg-elevated: #0d111a;
    --text: #eef2f7;
    --cyan: #22e3ff;
    --cyan-glow: rgba(34, 227, 255, 0.42);
    --cyan-ambient: rgba(34, 227, 255, 0.11);
    --indigo-ambient: rgba(79, 70, 229, 0.08);
    --grid-dot: rgba(255, 255, 255, 0.07);
  }

  html {
    min-height: 100%;
    background-color: var(--bg);
  }

  body {
    position: relative;
    min-height: 100dvh;
    background-color: var(--bg);
    background-image:
      radial-gradient(circle at 50% 48%, var(--bg-elevated) 0%, var(--bg) 70%);
    color: var(--text);
    font-family: "Pixelify Sans", ui-monospace, "Cascadia Mono", "Courier New", monospace;
    font-size-adjust: from-font;
    line-height: 1.5;
    overflow-wrap: break-word;
    -webkit-font-smoothing: antialiased;
    display: grid;
    place-items: center;
    padding-top: max(1.5rem, calc(env(safe-area-inset-top, 0px) + 1rem));
    padding-right: max(1.5rem, calc(env(safe-area-inset-right, 0px) + 1rem));
    padding-bottom: max(1.5rem, calc(env(safe-area-inset-bottom, 0px) + 1rem));
    padding-left: max(1.5rem, calc(env(safe-area-inset-left, 0px) + 1rem));
  }

  ::selection {
    background: rgba(34, 227, 255, 0.25);
    color: #ffffff;
  }
}

@layer components {
  /* Subtle pixel dot grid fading out toward the edges */
  .bg-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(ellipse 68% 62% at 50% 50%, #000 18%, transparent 100%);
  }

  /* Soft atmospheric glow behind the domain */
  .bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
      radial-gradient(ellipse 46% 34% at 58% 50%, var(--cyan-ambient) 0%, transparent 70%),
      radial-gradient(ellipse 48% 38% at 38% 52%, var(--indigo-ambient) 0%, transparent 72%);

    @media (prefers-reduced-motion: no-preference) {
      animation: ambient-pulse 8s ease-in-out infinite alternate;
    }
  }

  /* Delicate dark CRT scanline texture */
  .bg-scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.22) 2px,
      rgba(0, 0, 0, 0.22) 4px
    );
    opacity: 0.45;
  }

  .stage {
    position: relative;
    z-index: 1;
    inline-size: 100%;
    min-inline-size: 0;
    max-inline-size: 100%;
    text-align: center;
  }

  .domain {
    position: relative;
    max-inline-size: 100%;
    font-size: clamp(2.4rem, 1rem + 6vw, 6rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.03em;
    text-wrap: balance;
    overflow-wrap: anywhere;
    user-select: text;
  }

  .domain .name {
    color: var(--text);
    text-shadow:
      0 2px 0 rgba(0, 0, 0, 0.7),
      0 0 28px rgba(238, 242, 247, 0.12);
  }

  .domain .tld {
    color: var(--cyan);
    text-shadow:
      0 2px 0 rgba(0, 26, 36, 0.85),
      0 0 18px var(--cyan-glow),
      0 0 42px rgba(34, 227, 255, 0.2);
  }

  @keyframes ambient-pulse {
    from {
      opacity: 1;
      transform: scale(1);
    }
    to {
      opacity: 0.78;
      transform: scale(0.97);
    }
  }

  .domain-char.is-scrambling {
    visibility: hidden;
  }

  .domain-glyph-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .domain-char-glyph {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    color: rgba(238, 242, 247, 0.52);
    text-shadow: none;
    opacity: 0.72;
    pointer-events: none;
  }

  @media (prefers-reduced-motion: no-preference) {
    html.home-intro:not(.is-intro-ready) .domain {
      opacity: 0;
    }

    html.home-intro:not(.is-glow-visible) .bg-glow {
      opacity: 0;
      animation: none;
    }

    html.home-intro.is-glow-visible:not(.is-glow-settled) .bg-glow {
      opacity: 1;
      animation: none;
      transition: opacity 600ms ease-out;
    }
  }

  @media (forced-colors: active) {
    .bg-grid,
    .bg-glow,
    .bg-scanlines {
      display: none;
    }
  }
}
