/* ── Session loading ── */
.session-loading {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

body[data-view="loading"] .session-loading {
  opacity: 1;
  visibility: visible;
}

body:not([data-view="loading"]) .session-loading {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.session-loading__ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: hsl(var(--landing-accent-h, 320), 90%, 65%);
  animation: sessionSpin 0.85s linear infinite;
}

@keyframes sessionSpin {
  to { transform: rotate(360deg); }
}

body[data-view="landing"] .ambient-canvas,
body[data-view="landing"] .trail-canvas {
  display: none;
}

body[data-view="landing"] {
  background: #000;
  overflow: hidden;
}

/* ── App shell transitions ── */
.app-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.55s cubic-bezier(0.25, 0.1, 0.25, 1);
  pointer-events: none;
}

.app-shell.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.app-shell[hidden] {
  display: none !important;
}

/* ── Landing page — single viewport + global hue (~6s rotation) ── */
@property --landing-accent-h {
  syntax: "<number>";
  inherits: false;
  initial-value: 320;
}

@keyframes landingHueCycle {
  from { --landing-accent-h: 0; }
  to { --landing-accent-h: 360; }
}

.landing {
  --landing-accent-h: 320;
  position: fixed;
  inset: 0;
  z-index: 2;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #000;
  color: #f5f5f7;
  opacity: 0;
  visibility: hidden;
  animation: landingHueCycle 6s linear infinite;
  transition:
    opacity 0.55s cubic-bezier(0.25, 0.1, 0.25, 1),
    visibility 0.55s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.landing.is-visible {
  opacity: 1;
  visibility: visible;
}

.landing[hidden] {
  display: none !important;
}

.landing:not(.is-visible) .landing__reveal {
  opacity: 0;
  transform: translateY(16px);
}

/* ── Ambient background ── */
.landing__ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.landing__ambient-hue {
  position: absolute;
  inset: -30%;
  animation: landingAmbientHue 6s linear infinite;
}

@keyframes landingAmbientHue {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

.landing__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.42;
  will-change: transform;
}

.landing__glow--1 {
  bottom: -25%;
  left: -20%;
  width: min(85vw, 680px);
  height: min(85vw, 680px);
  background: radial-gradient(circle, rgba(255, 60, 140, 0.55) 0%, transparent 68%);
  animation: landingGlowBreathe1 10s ease-in-out infinite;
}

.landing__glow--2 {
  top: -30%;
  right: -22%;
  width: min(75vw, 600px);
  height: min(75vw, 600px);
  background: radial-gradient(circle, rgba(80, 120, 255, 0.45) 0%, transparent 70%);
  animation: landingGlowBreathe2 12s ease-in-out infinite;
}

.landing__glow--3 {
  top: 35%;
  left: 50%;
  width: min(60vw, 480px);
  height: min(60vw, 480px);
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(180, 80, 255, 0.28) 0%, transparent 72%);
  opacity: 0.28;
  animation: landingGlowBreathe3 14s ease-in-out infinite;
}

@keyframes landingGlowBreathe1 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.38; }
  50% { transform: translate(4vw, -3vh) scale(1.06); opacity: 0.48; }
}

@keyframes landingGlowBreathe2 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.32; }
  50% { transform: translate(-3vw, 4vh) scale(1.05); opacity: 0.42; }
}

@keyframes landingGlowBreathe3 {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.22; }
  50% { transform: translateX(-50%) scale(1.08); opacity: 0.32; }
}

.landing__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Screen layout ── */
.landing__screen {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding:
    calc(14px + env(safe-area-inset-top, 0px))
    calc(20px + env(safe-area-inset-right, 0px))
    calc(14px + env(safe-area-inset-bottom, 0px))
    calc(20px + env(safe-area-inset-left, 0px));
}

.landing__signin {
  position: fixed;
  top: calc(28px + env(safe-area-inset-top, 0px));
  right: calc(40px + env(safe-area-inset-right, 0px));
  z-index: 3;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(245, 245, 247, 0.85);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    border-color 0.25s ease,
    background 0.25s ease,
    box-shadow 0.25s ease;
}

.landing__signin:hover,
.landing__signin:focus-visible {
  border-color: hsla(var(--landing-accent-h), 85%, 65%, 0.4);
  background: hsla(var(--landing-accent-h), 85%, 65%, 0.08);
  box-shadow: 0 0 20px hsla(var(--landing-accent-h), 85%, 65%, 0.12);
  outline: none;
}

.landing__stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(14px, 2.2vh, 22px);
  min-height: 0;
  width: 100%;
}

/* ── Logo ── */
.landing__logo {
  display: inline-flex;
  flex-shrink: 0;
  text-decoration: none;
  filter: drop-shadow(0 0 28px hsla(var(--landing-accent-h), 85%, 60%, 0.18));
  transition: filter 0.4s ease, transform 0.25s ease;
}

.landing__logo:hover,
.landing__logo:focus-visible {
  transform: translateY(-1px);
  filter: drop-shadow(0 0 36px hsla(var(--landing-accent-h), 85%, 60%, 0.28));
  outline: none;
}

.landing__logo-img {
  display: block;
  width: auto;
  height: clamp(40px, 6.5vh, 58px);
  object-fit: contain;
}

/* ── Hero ── */
.landing__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.6vh, 14px);
  max-width: 560px;
}

.landing__headline {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.landing__headline-text {
  color: hsl(var(--landing-accent-h), 88%, 82%);
  text-shadow: 0 0 48px hsla(var(--landing-accent-h), 90%, 60%, 0.22);
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.landing__tagline {
  margin: 0;
  max-width: 420px;
  font-size: clamp(0.88rem, 2.2vw, 1.05rem);
  line-height: 1.55;
  color: rgba(245, 245, 247, 0.55);
}

/* ── Claim ── */
.landing__claim {
  width: 100%;
  max-width: 480px;
}

.landing__claim-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

.landing__url-bar {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 6px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid hsla(var(--landing-accent-h), 70%, 65%, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4) inset,
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 32px hsla(var(--landing-accent-h), 85%, 65%, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: text;
  transition:
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.landing__url-bar:focus-within {
  border-color: hsla(var(--landing-accent-h), 85%, 65%, 0.48);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4) inset,
    0 20px 48px rgba(0, 0, 0, 0.45),
    0 0 40px hsla(var(--landing-accent-h), 85%, 65%, 0.16);
}

.landing__url-bar[data-state="available"] {
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.08) inset,
    0 16px 40px rgba(0, 0, 0, 0.4),
    0 0 28px rgba(52, 211, 153, 0.12);
}

.landing__url-bar[data-state="taken"],
.landing__url-bar[data-state="reserved"],
.landing__url-bar[data-state="invalid"] {
  border-color: rgba(255, 107, 107, 0.5);
}

.landing__url-prefix {
  flex-shrink: 0;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 500;
  color: rgba(245, 245, 247, 0.42);
  letter-spacing: -0.02em;
  user-select: none;
}

.landing__url-input {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: clamp(1rem, 2.8vw, 1.12rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  outline: none;
}

.landing__url-input::placeholder {
  color: rgba(134, 134, 139, 0.45);
  font-weight: 500;
}

.landing__url-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.landing__url-status-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.landing__url-status[data-status="checking"] .landing__url-status-indicator {
  animation: landingStatusPulse 1s ease-in-out infinite;
}

.landing__url-status[data-status="available"] .landing__url-status-indicator {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.landing__url-status[data-status="available"] .landing__url-status-text {
  color: #34d399;
}

.landing__url-status[data-status="taken"] .landing__url-status-indicator,
.landing__url-status[data-status="reserved"] .landing__url-status-indicator,
.landing__url-status[data-status="invalid"] .landing__url-status-indicator {
  background: #ff6b6b;
}

.landing__url-status[data-status="taken"] .landing__url-status-text,
.landing__url-status[data-status="reserved"] .landing__url-status-text,
.landing__url-status[data-status="invalid"] .landing__url-status-text {
  color: #ff6b6b;
}

.landing__url-status-text {
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  color: rgba(245, 245, 247, 0.55);
}

@keyframes landingStatusPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

.landing__claim-btn {
  width: 100%;
  min-height: 50px;
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    hsl(var(--landing-accent-h), 88%, 58%) 0%,
    hsl(calc(var(--landing-accent-h) + 35), 88%, 52%) 100%
  );
  color: #000;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow:
    0 0 28px hsla(var(--landing-accent-h), 90%, 55%, 0.32),
    0 10px 28px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.25s ease,
    box-shadow 0.35s ease,
    opacity 0.25s ease;
}

.landing__claim-btn:not(:disabled):hover,
.landing__claim-btn:not(:disabled):focus-visible {
  transform: translateY(-1px);
  box-shadow:
    0 0 40px hsla(var(--landing-accent-h), 90%, 55%, 0.42),
    0 14px 32px rgba(0, 0, 0, 0.4);
  outline: none;
}

.landing__claim-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.landing__claim-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(245, 245, 247, 0.5);
}

.landing__claim-hint.is-error {
  color: #ff6b6b;
}

/* ── Feature pills ── */
.landing__features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 560px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.landing__feature {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: clamp(0.62rem, 1.8vw, 0.72rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(245, 245, 247, 0.68);
  box-shadow: 0 0 16px hsla(var(--landing-accent-h), 85%, 65%, 0.04);
  transition:
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.landing__feature::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: hsl(var(--landing-accent-h), 90%, 62%);
  box-shadow: 0 0 8px hsla(var(--landing-accent-h), 90%, 62%, 0.55);
  flex-shrink: 0;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.landing__feature--showcase {
  border-color: hsla(var(--landing-accent-h), 70%, 65%, 0.2);
  background: hsla(var(--landing-accent-h), 85%, 65%, 0.06);
  color: rgba(245, 245, 247, 0.78);
  box-shadow: 0 0 20px hsla(var(--landing-accent-h), 85%, 65%, 0.1);
}

.landing__micro {
  margin: 0;
  font-size: clamp(0.62rem, 1.6vw, 0.72rem);
  letter-spacing: 0.06em;
  color: rgba(245, 245, 247, 0.28);
}

/* ── Entrance ── */
.landing__reveal {
  opacity: 0;
  transform: translateY(16px);
}

.landing.is-visible .landing__reveal {
  animation: landingReveal 0.75s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes landingReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Desktop: horizontal claim on wide screens ── */
@media (min-width: 560px) {
  .landing__claim-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
  }

  .landing__url-bar {
    flex: 1 1 280px;
  }

  .landing__claim-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 148px;
    align-self: stretch;
  }

  .landing__claim-hint {
    flex: 1 1 100%;
  }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .landing__screen {
    padding-inline:
      calc(16px + env(safe-area-inset-right, 0px))
      calc(16px + env(safe-area-inset-left, 0px));
  }

  .landing__signin {
    top: calc(18px + env(safe-area-inset-top, 0px));
    right: calc(18px + env(safe-area-inset-right, 0px));
    padding: 7px 14px;
    font-size: 0.72rem;
  }

  .landing__stack {
    gap: clamp(10px, 1.8vh, 16px);
  }

  .landing__headline {
    font-size: clamp(2.1rem, 10vw, 2.75rem);
  }

  .landing__url-prefix,
  .landing__url-input {
    font-size: 16px;
    line-height: 1.25;
  }

  .landing__url-input {
    padding-block: 0;
    padding-inline: 8px 6px;
    min-height: 0;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
  }

  .landing__glow {
    filter: blur(70px);
    opacity: 0.34;
  }
}

@media (max-height: 700px) {
  .landing__logo-img {
    height: clamp(34px, 5vh, 44px);
  }

  .landing__headline {
    font-size: clamp(1.9rem, 7vw, 2.6rem);
  }

  .landing__stack {
    gap: 10px;
  }

  .landing__feature {
    padding: 5px 10px;
    font-size: 0.6rem;
  }

  .landing__micro {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .session-loading__ring {
    animation: none;
  }

  .landing,
  .landing__ambient-hue {
    animation: none;
  }

  .landing__glow {
    animation: none !important;
  }

  .landing__reveal {
    opacity: 1;
    transform: none;
  }

  .landing.is-visible .landing__reveal {
    animation: none;
  }

  .app-shell,
  .landing {
    transition: none;
  }

  .landing__claim-btn:hover,
  .landing__claim-btn:focus-visible {
    transform: none;
  }

  .landing__url-status[data-status="checking"] .landing__url-status-indicator {
    animation: none;
  }
}

/* ── Profile not found ── */
.profile-not-found {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.55s cubic-bezier(0.25, 0.1, 0.25, 1),
    visibility 0.55s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.profile-not-found.is-visible {
  opacity: 1;
  visibility: visible;
}

.profile-not-found[hidden] {
  display: none !important;
}

.profile-not-found__content {
  max-width: 420px;
  text-align: center;
}

.profile-not-found__title {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  text-shadow: 0 0 24px var(--accent-glow-soft);
}

.profile-not-found__text {
  margin: 0 0 28px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.profile-not-found__home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-r), 0.35);
  background: rgba(var(--accent-r), 0.1);
  box-shadow: 0 0 16px var(--accent-glow-soft);
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.profile-not-found__home:hover,
.profile-not-found__home:focus-visible {
  background: rgba(var(--accent-r), 0.16);
  border-color: var(--accent-border);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .profile-not-found {
    transition: none;
  }
}
