/* The door: a full-bleed lacquer surface, the cast name, one button, one dialog. */

.landing {
  overflow: hidden;
  height: 100dvh;
  background: oklch(0.06 0.02 300);
}

.surface {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.8s var(--out-quint);
}
.gl-ready .surface {
  opacity: 1;
}

/* Without WebGL the surface is a still pour of the same film. */
.no-gl .landing {
  background:
    radial-gradient(60% 50% at 28% 30%, oklch(0.45 0.2 300 / 0.5), transparent 70%),
    radial-gradient(50% 45% at 76% 68%, oklch(0.5 0.22 338 / 0.34), transparent 70%),
    radial-gradient(40% 40% at 60% 20%, oklch(0.55 0.13 238 / 0.25), transparent 70%),
    oklch(0.06 0.02 300);
}

.door {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto auto auto 1.15fr;
  justify-items: center;
  padding: 0 1.25rem;
  transition: opacity 0.7s var(--out-quint), filter 0.7s var(--out-quint);
}

.mark {
  grid-row: 2;
  font-size: clamp(3.6rem, 17.5vw, 17rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.035em;
  white-space: nowrap;
  color: var(--text);
  user-select: none;
}
/* When the surface is live the name is cast in it; the heading stays for readers and layout. */
.gl-ready .mark {
  color: transparent;
}

.line {
  grid-row: 3;
  margin-top: clamp(1.25rem, 3.4vh, 2.5rem);
  font-size: clamp(1rem, 0.6vw + 0.85rem, 1.125rem);
  color: var(--text);
  text-align: center;
  text-shadow: 0 1px 14px oklch(0.04 0.02 300), 0 0 3px oklch(0.04 0.02 300);
  animation: rise 1.1s var(--out-expo) 0.35s backwards;
}

/* The line under the name is a strip of ciphertext: characters keep changing
   and a bright run of them travels along it. It says nothing on purpose. */
.cipher {
  min-height: 1.6em;
  font-family: var(--mono);
  font-size: clamp(0.875rem, 0.5vw + 0.7rem, 1.05rem);
  letter-spacing: 0.2em;
  white-space: nowrap;
  user-select: none;
}
.cipher span {
  display: inline-block;
  width: 1ch;
  text-align: center;
  opacity: 0.4;
  transition: opacity 0.35s var(--out-quint);
}
.cipher .is-warm {
  opacity: 0.75;
}
.cipher .is-hot {
  opacity: 1;
  transition-duration: 0.05s;
}

/* ---- Start ----------------------------------------------------------------
   The pill itself is a bead raised in the liquid by the shader; this is its label and hit area. */

.start {
  grid-row: 4;
  margin-top: clamp(1.5rem, 4vh, 2.75rem);
  height: 3.75rem;
  padding: 0 1.7rem 0 2.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  animation: rise 1.1s var(--out-expo) 0.5s backwards;
  -webkit-tap-highlight-color: transparent;
}
.start .icon {
  transition: transform 0.5s var(--out-expo);
}
.start:hover .icon {
  transform: translateX(5px);
}
.start:active .start__label,
.start:active .icon {
  opacity: 0.7;
}
/* No WebGL, no bead: the pill becomes a plain lacquer slab with a film rim. */
.no-gl .start {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--lacquer-1), oklch(0.07 0.02 300)) padding-box,
    var(--film) border-box;
  box-shadow: var(--drop);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(6px);
  }
}

/* ---- The gate dialog ------------------------------------------------------ */

.gate {
  width: min(27rem, calc(100vw - 2rem));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
}
.gate::backdrop {
  background: oklch(0.05 0.02 300 / 0.3);
}
.gate[open] {
  animation: gate-in 0.6s var(--out-expo);
}
.gate[open]::backdrop {
  animation: veil-in 0.6s var(--out-quint);
}

@keyframes gate-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.955);
    filter: blur(10px);
  }
}
@keyframes veil-in {
  from {
    opacity: 0;
  }
}

.gate__form {
  position: relative;
  isolation: isolate;
  padding: 2.4rem 2rem 2rem;
  border: 1px solid transparent;
  border-radius: 1.75rem;
  background:
    linear-gradient(oklch(0.115 0.026 300), oklch(0.075 0.02 300)) padding-box,
    var(--film) border-box;
  box-shadow:
    0 40px 80px -30px oklch(0.02 0.03 300),
    0 12px 28px -12px oklch(0.02 0.03 300 / 0.9);
}
.gate__close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  transition: background-color 0.25s, color 0.25s;
}
.gate__close:hover {
  background: var(--lacquer-3);
  color: var(--text);
}

.gate__title {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.gate__hint {
  margin-top: 0.5rem;
  color: var(--text-soft);
}

.field {
  display: block;
  margin-top: 1.75rem;
}
.field__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-soft);
}
.field__box {
  display: flex;
  align-items: center;
  height: 3.5rem;
  border: 1px solid var(--field-edge);
  border-radius: 1rem;
  background: oklch(0.075 0.02 300);
  box-shadow: inset 0 2px 6px oklch(0.02 0.02 300 / 0.8);
  transition: border-color 0.25s;
}
.field__box:focus-within {
  border-color: var(--violet);
}
.field__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 0 0 1.1rem;
  border: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--text);
}
.field__input::-ms-reveal,
.field__input::-ms-clear {
  display: none;
}
.field__input:focus {
  outline: none;
}
.field__peek {
  width: 3rem;
  height: 3rem;
  margin-right: 0.2rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 1rem;
  background: transparent;
  color: var(--text-faint);
  transition: color 0.25s, background-color 0.25s;
}
.field__peek:hover {
  color: var(--text);
  background: var(--lacquer-2);
}
.field__peek .peek-off,
.field__peek[aria-pressed="true"] .peek-on {
  display: none;
}
.field__peek[aria-pressed="true"] .peek-off {
  display: block;
}

.gate__msg {
  min-height: 1.5rem;
  margin-top: 0.7rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--danger);
}

.gate__submit {
  position: relative;
  width: 100%;
  height: 3.5rem;
  margin-top: 0.9rem;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 1rem;
  background:
    linear-gradient(oklch(0.24 0.05 300), oklch(0.15 0.034 300)) padding-box,
    var(--film) border-box;
  color: var(--text);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 500;
  box-shadow: 0 14px 26px -16px oklch(0.02 0.03 300);
  transition: transform 0.4s var(--out-expo), filter 0.3s, opacity 0.3s;
}
.gate__submit:hover {
  filter: brightness(1.25);
}
.gate__submit:active {
  transform: translateY(1px) scale(0.99);
  transition-duration: 0.1s;
}
.gate__submit:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  filter: saturate(0.4);
}

.gate__spinner {
  position: absolute;
  width: 1.3rem;
  height: 1.3rem;
  border: 2px solid oklch(0.95 0.02 300 / 0.25);
  border-top-color: var(--text);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
}
.gate__submit-label {
  transition: opacity 0.2s;
}

/* States */
.gate[data-state="loading"] .gate__submit {
  opacity: 1;
  filter: none;
  cursor: progress;
}
.gate[data-state="loading"] .gate__submit-label {
  opacity: 0;
}
.gate[data-state="loading"] .gate__spinner {
  opacity: 1;
}
.gate[data-state="error"] .field__box {
  border-color: var(--danger);
  animation: refuse 0.42s var(--out-quint);
}
.gate[data-state="open"] .gate__form {
  transition: transform 0.7s var(--out-expo), opacity 0.6s var(--out-quint), filter 0.7s var(--out-quint);
  transform: scale(1.06);
  opacity: 0;
  filter: blur(12px);
}
.gate[data-state="open"]::backdrop {
  transition: opacity 0.6s;
  opacity: 0;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}
@keyframes refuse {
  20% {
    transform: translateX(-7px);
  }
  45% {
    transform: translateX(6px);
  }
  70% {
    transform: translateX(-3px);
  }
}

/* Passing through: the surface floods, then everything goes to black. */
.is-leaving .door {
  opacity: 0;
  filter: blur(8px);
}
.is-leaving .surface {
  transition: opacity 0.7s 0.55s var(--out-quint);
  opacity: 0;
}

/* ---- Visits: one quiet chip, top left ----------------------------------------- */

.visits {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: max(1rem, env(safe-area-inset-left));
  z-index: 2;
  height: 3rem;
  padding: 0 1.1rem 0 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--edge-strong);
  border-radius: 999px;
  background: oklch(0.075 0.02 300);
  box-shadow: 0 10px 20px -10px oklch(0.02 0.03 300);
  transition: opacity 0.6s var(--out-quint);
  animation: rise 1.1s var(--out-expo) 0.7s backwards;
}
.visits .icon {
  color: var(--text-soft);
}
.visits__label {
  font-size: 0.875rem;
  color: var(--text-soft);
}
.visits__count {
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 500;
}
.is-leaving .visits {
  opacity: 0;
}

/* ---- Drift: what the owner works with, as keycaps afloat on the pool -------------
   One shape for everything: languages are short caps, fields of work are longer ones
   with a film rim. They sit around the edges and never over the name. */

.drift {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.6s var(--out-quint);
}
.is-leaving .drift {
  opacity: 0;
}
.cap {
  position: absolute;
  left: var(--x);
  top: var(--y);
  opacity: 0;
  transform: translate(calc(-50% + var(--px, 0px)), calc(-50% + var(--py, 0px)));
  transition: transform 0.9s var(--out-expo), opacity 1.4s var(--out-quint);
}
.drift.is-in .cap {
  opacity: var(--o);
}
.cap__body {
  height: 2.5rem;
  min-width: 2.5rem;
  padding: 0 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--edge-strong);
  border-radius: 1rem;
  background: linear-gradient(oklch(0.17 0.035 300), oklch(0.085 0.02 300));
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 14px 22px -14px oklch(0.02 0.03 300);
  animation: cap-float var(--dur) ease-in-out var(--delay) infinite alternate;
}
.cap--field .cap__body {
  border-color: transparent;
  background:
    linear-gradient(var(--lacquer-2), var(--lacquer-0)) padding-box,
    var(--film) border-box;
  color: var(--text);
  font-family: var(--display);
  font-weight: 500;
}
@keyframes cap-float {
  from {
    transform: translate(calc(var(--dx) * -1), calc(var(--dy) * -1)) rotate(calc(var(--rot) * -1));
  }
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
  }
}

/* ---- Sound ---------------------------------------------------------------- */

.sound {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 2;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--edge-strong);
  border-radius: 999px;
  background: oklch(0.075 0.02 300);
  color: var(--text);
  box-shadow: 0 10px 20px -10px oklch(0.02 0.03 300);
  transition: border-color 0.3s, opacity 0.6s var(--out-quint), transform 0.4s var(--out-expo);
  animation: rise 1.1s var(--out-expo) 0.7s backwards;
}
.sound:hover {
  border-color: var(--violet);
}
.sound:active {
  transform: scale(0.94);
  transition-duration: 0.1s;
}
.sound__off,
.sound[aria-pressed="false"] .sound__on {
  display: none;
}
.sound[aria-pressed="false"] .sound__off {
  display: block;
}
.sound[aria-pressed="false"] {
  color: var(--text-soft);
}
.is-leaving .sound {
  opacity: 0;
}

/* ---- Reach: two lacquer chips at the foot of the door ---------------------- */

.reach {
  position: fixed;
  inset: auto 0 max(1.25rem, env(safe-area-inset-bottom)) 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 1rem;
  transition: opacity 0.6s var(--out-quint);
  animation: rise 1.1s var(--out-expo) 0.85s backwards;
}
.reach__chip {
  height: 2.75rem;
  padding: 0 1.05rem 0 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--edge-strong);
  border-radius: 999px;
  background: oklch(0.075 0.02 300);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 10px 20px -10px oklch(0.02 0.03 300);
  transition: border-color 0.3s, transform 0.4s var(--out-expo);
}
.reach__chip .icon {
  color: var(--text-soft);
  transition: color 0.3s;
}
.reach__net {
  font-size: 0.875rem;
  color: var(--text-soft);
}
.reach__handle {
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 500;
}
.reach__chip:hover {
  border-color: var(--violet);
  transform: translateY(-2px);
}
.reach__chip:hover .icon,
.reach__chip.is-done .icon {
  color: var(--magenta);
}
.reach__chip:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.1s;
}
.reach__chip.is-done {
  border-color: var(--magenta);
}
.is-leaving .reach {
  opacity: 0;
}

.noscript {
  position: fixed;
  inset: auto 0 5rem 0;
  z-index: 2;
  text-align: center;
  color: var(--text-soft);
}

@media (max-width: 480px) {
  .gate__form {
    padding: 2.2rem 1.35rem 1.4rem;
  }
}

@media (max-width: 760px) {
  .visits__label {
    display: none;
  }
  .cap__body {
    height: 2.1rem;
    min-width: 2.1rem;
    padding: 0 0.6rem;
  }
}
