/* goodsiri — aurora over a fjord, a hundred years from now.
   Unbounded (geometric display) + Instrument Sans (UI). Glass, ice, aurora light. */

:root {
  --bg: #030710;
  --bg-raise: #071120;
  --bg-card: rgba(14, 28, 46, 0.5);
  --bg-card-solid: #0c1a2c;
  --line: rgba(170, 220, 240, 0.10);
  --line-strong: rgba(170, 220, 240, 0.24);
  --ink: #eaf7fb;
  --ink-dim: #9fc3d6;
  --ink-faint: #587489;
  --teal: #3fe8c8;
  --blue: #4d9dff;
  --violet: #9b83f5;
  --aurora-soft: rgba(63, 232, 200, 0.14);
  --aurora-glow: rgba(77, 157, 255, 0.35);
  --rec: #ff5f6d;
  --rec-glow: rgba(255, 95, 109, 0.45);
  --display: "Unbounded", "Instrument Sans", sans-serif;
  --sans: "Instrument Sans", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Atmosphere ------------------------------------------------------------
   A slow aurora ribbon drifting behind everything, plus faint ice-field grain. */

.grain {
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 40;
  opacity: 0.3;
  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'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  animation: grain-shift 9s steps(6) infinite;
}
@keyframes grain-shift {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 1%); }
  40% { transform: translate(1%, -2%); }
  60% { transform: translate(-1%, 2%); }
  80% { transform: translate(2%, -1%); }
}

.glow {
  position: fixed; z-index: 0; inset: -20vh -20vw;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60vw 50vh at 18% -10%, rgba(63, 232, 200, 0.16), transparent 60%),
    radial-gradient(ellipse 55vw 50vh at 85% 10%, rgba(155, 131, 245, 0.14), transparent 60%),
    radial-gradient(ellipse 70vw 60vh at 50% 115%, rgba(77, 157, 255, 0.18), transparent 65%);
  animation: aurora-drift 22s ease-in-out infinite alternate;
  transition: opacity 0.6s var(--ease);
}
@keyframes aurora-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); filter: hue-rotate(0deg); }
  50%  { transform: translate3d(1.5%, -1%, 0) scale(1.03); filter: hue-rotate(8deg); }
  100% { transform: translate3d(-1.5%, 1%, 0) scale(1); filter: hue-rotate(-6deg); }
}
body.recording .glow {
  background:
    radial-gradient(ellipse 60vw 60vh at 50% 115%, rgba(255, 95, 109, 0.22), transparent 65%);
  animation: none;
}

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px;
  animation: drop-in 0.9s var(--ease) both;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  box-shadow: 0 0 14px var(--aurora-glow);
}
.brand-name {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.signin {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--bg-card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease),
              transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.signin:hover {
  border-color: var(--blue);
  box-shadow: 0 0 24px rgba(77, 157, 255, 0.18);
  transform: translateY(-1px);
}
.signin:active { transform: translateY(0); }
.signin.authed { border-color: rgba(63, 232, 200, 0.4); }

.masthead-actions { display: flex; align-items: center; gap: 10px; }

/* --- Voice replies toggle --------------------------------------------------
   Same glass pill language as the sign-in button; the track lights up with
   aurora colors when spoken replies are on. */

.voice-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  background: var(--bg-card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 14px 9px 18px;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease),
              box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}
.voice-toggle:hover {
  border-color: var(--teal);
  box-shadow: 0 0 24px rgba(63, 232, 200, 0.16);
  transform: translateY(-1px);
}
.voice-toggle:active { transform: translateY(0); }
.voice-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.voice-toggle-track {
  position: relative;
  width: 32px; height: 18px;
  border-radius: 999px;
  background: rgba(88, 116, 137, 0.35);
  border: 1px solid var(--line-strong);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease),
              box-shadow 0.3s var(--ease);
  flex-shrink: 0;
}
.voice-toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease),
              box-shadow 0.3s var(--ease);
}

.voice-toggle[aria-checked="true"] { color: var(--ink); }
.voice-toggle[aria-checked="true"] .voice-toggle-track {
  background: linear-gradient(135deg, rgba(63, 232, 200, 0.55), rgba(77, 157, 255, 0.55));
  border-color: rgba(63, 232, 200, 0.5);
  box-shadow: 0 0 12px rgba(63, 232, 200, 0.25);
}
.voice-toggle[aria-checked="true"] .voice-toggle-knob {
  transform: translateX(14px);
  background: var(--ink);
  box-shadow: 0 0 8px rgba(234, 247, 251, 0.5);
}

/* --- Stage --------------------------------------------------------------- */

.stage {
  position: relative; z-index: 5;
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 0 24px;
  min-height: 0;
}

.hero {
  text-align: center;
  padding: 4vh 0 3vh;
  overflow: hidden;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease),
              max-height 0.6s var(--ease), padding 0.6s var(--ease);
  max-height: 40vh;
  animation: drop-in 1.1s 0.1s var(--ease) both;
}
body.conversing .hero {
  opacity: 0; max-height: 0; padding: 0;
  transform: translateY(-16px);
  pointer-events: none;
}

.eyebrow {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.28em;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  margin-bottom: 18px;
}

.headline {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  line-height: 1.16;
  letter-spacing: -0.01em;
}
.headline em {
  font-style: normal;
  font-weight: 300;
  background: linear-gradient(100deg, var(--teal) 0%, var(--blue) 45%, var(--violet) 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* --- Transcript ---------------------------------------------------------- */

.transcript-wrap {
  position: relative;
  width: min(640px, 100%);
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column;
}

.transcript {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 28px 6px 16px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 28px);
          mask-image: linear-gradient(to bottom, transparent 0, black 28px);
}

.transcript-fade { display: none; }

.turn {
  max-width: 78%;
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.55;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  animation: turn-in 0.5s var(--ease) both;
}
@keyframes turn-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.turn.you {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(63, 232, 200, 0.14), rgba(77, 157, 255, 0.10));
  border: 1px solid rgba(77, 157, 255, 0.28);
  border-bottom-right-radius: 6px;
  color: var(--ink);
}
.turn.siri {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  color: var(--ink-dim);
}
.turn .who {
  display: block;
  font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.22em;
  margin-bottom: 5px;
}
.turn.you  .who { color: var(--teal); }
.turn.siri .who { color: var(--ink-faint); }

.turn.pending { font-style: italic; color: var(--ink-faint); }
.turn.pending::after {
  content: "…";
  animation: ellipsis 1.4s steps(4) infinite;
}
@keyframes ellipsis {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "…"; }
}

/* --- Push-to-talk orb ------------------------------------------------------
   A glass sphere holding a slow-turning ribbon of aurora light. */

.talk-dock {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 30px;
  animation: drop-in 1.2s 0.25s var(--ease) both;
}

.orb-wrap {
  position: relative;
  width: 168px; height: 168px;
  display: grid; place-items: center;
}

.orb-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  pointer-events: none;
  transition: border-color 0.4s var(--ease);
}
.ring-1 { animation: breathe 4.5s var(--ease) infinite; }
.ring-2 { inset: -14px; opacity: 0.5; animation: breathe 4.5s 0.4s var(--ease) infinite; }
.ring-3 { inset: -30px; opacity: 0.25; animation: breathe 4.5s 0.8s var(--ease) infinite; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.045); }
}

body.recording .orb-ring { border-color: var(--rec); }
body.recording .ring-1 { animation: pulse-ring 1.3s var(--ease) infinite; }
body.recording .ring-2 { animation: pulse-ring 1.3s 0.2s var(--ease) infinite; }
body.recording .ring-3 { animation: pulse-ring 1.3s 0.4s var(--ease) infinite; }
@keyframes pulse-ring {
  0%   { transform: scale(1);    opacity: 0.8; }
  100% { transform: scale(1.22); opacity: 0; }
}

.orb {
  width: 128px; height: 128px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.18), transparent 45%),
    conic-gradient(from 0deg, var(--teal), var(--blue), var(--violet), var(--teal));
  background-size: 100%, 220% 220%;
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 20px 50px rgba(3, 7, 16, 0.65),
    0 0 40px rgba(77, 157, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: orb-swirl 14s linear infinite;
  transition: transform 0.25s var(--ease), box-shadow 0.35s var(--ease),
              color 0.3s var(--ease), border-color 0.3s var(--ease);
}
@keyframes orb-swirl {
  to { background-position: 0 0, 100% 100%; }
}
.orb:hover {
  transform: scale(1.03);
  border-color: var(--blue);
  box-shadow:
    0 24px 60px rgba(3, 7, 16, 0.7),
    0 0 55px var(--aurora-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
body.recording .orb {
  transform: scale(0.94);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.16), transparent 45%),
    radial-gradient(circle, var(--rec), #a52d38 80%);
  animation: none;
  border-color: var(--rec);
  box-shadow:
    0 12px 32px rgba(3, 7, 16, 0.55),
    0 0 55px var(--rec-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.orb-icon { position: relative; z-index: 1; filter: drop-shadow(0 1px 3px rgba(3, 7, 16, 0.6)); }
.orb:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

.talk-hint {
  margin-top: 20px;
  font-size: 0.74rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.24em;
  color: var(--ink-faint);
  transition: color 0.3s var(--ease), opacity 0.5s var(--ease), max-height 0.5s var(--ease),
              margin 0.5s var(--ease);
  max-height: 40px;
  overflow: hidden;
}
body.recording .talk-hint { color: var(--rec); }
/* Once a conversation is underway, drop the hint so it never crosses the
   transcript — the orb speaks for itself by then. */
body.conversing .talk-hint {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  pointer-events: none;
}

/* --- Colophon ------------------------------------------------------------ */

.colophon {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 0 24px 18px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.colophon-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--ink-faint);
}

/* --- Shared -------------------------------------------------------------- */

@keyframes drop-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
  .masthead { padding: 16px 18px; }
  .signin span:last-child { display: none; } /* icon-only on small screens */
  .signin { padding: 10px 12px; }
  .voice-toggle-label { display: none; }      /* track-only on small screens */
  .voice-toggle { padding: 10px 12px; }
  .masthead-actions { gap: 8px; }
  .orb-wrap { width: 148px; height: 148px; }
  .orb { width: 112px; height: 112px; }
  .turn { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .orb-ring, .glow, .orb { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}
