/* WWJS — a luminescent golden orb against dusk. The orb is the entire
   interface: it breathes, listens, thinks, and speaks. Nothing is written. */

:root {
  --bg-hi: #57503f;
  --bg-lo: #2c271f;
  --ink: #e9e2d2;
  --ink-dim: #a89e8a;
  --line: #5d5546;
  --accent: #c4503c;
  --serif: Georgia, "Times New Roman", serif;
  --level: 0; /* 0..1 audio level while speaking */
}

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

html, body {
  height: 100%;
  background: var(--bg-lo);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 44%, var(--bg-hi) 0%, var(--bg-lo) 78%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* The class rule above would otherwise override the hidden attribute. */
.screen[hidden] { display: none; }

.center {
  margin: auto;
  text-align: center;
  padding: 2rem;
  max-width: 26rem;
  width: 100%;
}

/* ---------- gate ---------- */

.wordmark {
  font-size: 1.05rem;
  font-weight: normal;
  letter-spacing: 0.6em;
  text-indent: 0.6em;
  color: var(--ink-dim);
  margin-bottom: 3rem;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  padding: 0.6rem 0.2rem;
  text-align: center;
  outline: none;
  border-radius: 0;
}
input::placeholder { color: var(--ink-dim); opacity: 0.65; }
input:focus { border-bottom-color: #e0b85c; }

button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  padding: 0.6rem 2.2rem;
  margin-top: 2rem;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.4s, background 0.4s;
  -webkit-tap-highlight-color: transparent;
}
button:hover, button:active {
  border-color: #e0b85c;
  background: rgba(232, 200, 120, 0.12);
}

.error {
  margin-top: 1.2rem;
  color: var(--accent);
  font-style: italic;
  font-size: 0.9rem;
}

/* ---------- threshold ---------- */

.wall-text {
  font-size: 1.45rem;
  line-height: 1.7;
  font-style: italic;
  letter-spacing: 0.02em;
}

#threshold button { margin-top: 3.5rem; }

/* ---------- experience: the orb over the desert at twilight ---------- */

#experience {
  background: var(--bg-lo) url(bg.svg) center / cover no-repeat;
}

#stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#orb-wrap {
  position: relative;
  width: 210px;
  height: 210px;
}

/* a faint atmosphere, not a synthetic bloom */
#halo {
  position: absolute;
  inset: -38%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(238, 204, 128, 0.20) 0%,
    rgba(238, 204, 128, 0.10) 38%,
    rgba(238, 204, 128, 0.035) 62%,
    rgba(238, 204, 128, 0) 78%);
  animation: halo-breathe 7s ease-in-out infinite;
  pointer-events: none;
}

#orb {
  position: absolute;
  inset: 0;
  border: none;
  outline: none;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: radial-gradient(circle at 35% 28%,
    #fffbe9 0%,
    #f8e8b8 30%,
    #eccf85 58%,
    #ddb45e 80%,
    #c99840 100%);
  box-shadow:
    0 0 26px rgba(238, 204, 128, 0.30),
    0 0 70px rgba(238, 204, 128, 0.14),
    inset 0 0 30px rgba(255, 252, 235, 0.8);
  transition: box-shadow 0.6s;
  animation: orb-breathe 7s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
#orb:focus, #orb:focus-visible { outline: none; }

/* inner liquid light */
.swirl {
  position: absolute;
  inset: -35%;
  border-radius: 50%;
  filter: blur(16px);
  pointer-events: none;
}
.swirl.one {
  background: conic-gradient(from 0deg,
    transparent 0%,
    rgba(255, 255, 255, 0.65) 12%,
    transparent 30%,
    rgba(214, 164, 60, 0.5) 52%,
    transparent 70%,
    rgba(255, 244, 200, 0.55) 86%,
    transparent 100%);
  animation: spin 11s linear infinite;
}
.swirl.two {
  background: conic-gradient(from 180deg,
    transparent 0%,
    rgba(255, 250, 225, 0.5) 18%,
    transparent 42%,
    rgba(200, 150, 50, 0.4) 64%,
    transparent 88%);
  animation: spin-rev 17s linear infinite;
}
.sheen {
  position: absolute;
  left: 14%; top: 9%;
  width: 42%; height: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.85), rgba(255,255,255,0) 70%);
  filter: blur(4px);
  pointer-events: none;
}

@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.02); }
}
@keyframes halo-breathe {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.05); }
}

/* --- states --- */

#experience.listening .swirl.one { animation-duration: 4s; }
#experience.listening .swirl.two { animation-duration: 6.5s; }
#experience.listening #orb,
#experience.listening #halo { animation-duration: 3s; }
#experience.listening #orb {
  box-shadow:
    0 0 34px rgba(238, 204, 128, 0.42),
    0 0 90px rgba(238, 204, 128, 0.18),
    inset 0 0 34px rgba(255, 252, 235, 0.9);
}

#experience.thinking .swirl.one { animation-duration: 1.6s; }
#experience.thinking .swirl.two { animation-duration: 2.6s; }

/* speaking: the voice lives in the swirl, not in a pulse.
   JS rotates the swirls with speed proportional to the audio level;
   the body of the orb barely moves. */
#experience.speaking .swirl { animation: none; }
#experience.speaking #orb {
  animation: none;
  box-shadow:
    0 0 calc(28px + 18px * var(--level)) rgba(238, 204, 128, calc(0.32 + 0.22 * var(--level))),
    0 0 80px rgba(238, 204, 128, 0.16),
    inset 0 0 calc(30px + 14px * var(--level)) rgba(255, 252, 235, 0.85);
}
#experience.speaking .swirl.one { opacity: calc(0.75 + 0.25 * var(--level)); }
#experience.speaking .swirl.two { opacity: calc(0.65 + 0.35 * var(--level)); }

/* ---------- status (errors only) + crisis ---------- */

#status {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(5.4rem + env(safe-area-inset-bottom));
  min-height: 1.4rem;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--ink-dim);
  text-align: center;
  padding: 0 2rem;
  pointer-events: none;
}

#words {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(30rem, calc(100% - 3rem));
  z-index: 2;
}

/* the crisis response deliberately breaks the form: plain card, it stays */
#words .crisis-card {
  display: block;
  background: #fffdf8;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: left;
  color: #2b2722;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
}

/* ---------- typed fallback, barely there ---------- */

#text-form {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  display: flex;
  gap: 0.6rem;
  max-width: 26rem;
  width: 100%;
  margin: 0 auto;
  padding: 0.8rem 1.6rem calc(1.2rem + env(safe-area-inset-bottom));
  opacity: 0.4;
  transition: opacity 0.4s;
}
#text-form:focus-within, #text-form:hover { opacity: 1; }
#text-form input {
  flex: 1;
  text-align: left;
  font-size: 0.95rem;
  border-bottom-color: rgba(93, 85, 70, 0.6);
}
#text-form button {
  margin-top: 0;
  padding: 0.3rem 0.95rem;
}
