/* fish-realtime — immersive Fish Audio surface, tuned to platform-web's
   warm gray system and softly pastel product language. */

:root {
  color-scheme: light;

  --gray-50: #fdfcfc;
  --gray-100: #faf8f5;
  --gray-200: #f3eeec;
  --gray-300: #eee9e8;
  --gray-400: #d1cecc;
  --gray-500: #bbb6b4;
  --gray-600: #857e7b;
  --gray-700: #504b49;
  --gray-800: #393634;
  --gray-900: #2a2926;
  --gray-950: #0f0e0d;

  /* Fish semantic color layer, aligned with platform-web / Figma tokens. */
  --surface-canvas: var(--gray-50);
  --surface-app: var(--gray-100);
  --surface-card: #ffffff;
  --fish-coral: #f56138;
  --fish-teal: #2a9d90;
  --fish-blue-light: #53b1fd;
  --fish-green-light: #3ccb7f;

  --radius: 0.4rem;
  --paper-strong: var(--surface-card);
  --text: var(--gray-950);
  --text-body: var(--gray-900);
  --text-dim: var(--gray-600);
  --border: var(--gray-300);
  --shadow-button: 0 1px 0 rgba(255, 255, 255, 0.62) inset, 0 14px 38px -28px rgba(42, 41, 38, 0.7);

  --tint: var(--fish-teal);
  --glow: var(--fish-green-light);
  --tint-soft: color-mix(in srgb, var(--tint) 15%, white);

  --font: "Onest", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(circle at 50% 72%, var(--tint-soft) 0, transparent 32rem),
    linear-gradient(145deg, var(--surface-canvas), var(--surface-app) 48%, var(--surface-canvas));
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.48), transparent 28%, rgba(255, 255, 255, 0.22) 64%, transparent),
    radial-gradient(circle at 20% 18%, color-mix(in srgb, var(--fish-coral) 18%, transparent), transparent 22rem),
    radial-gradient(circle at 78% 14%, color-mix(in srgb, var(--fish-blue-light) 18%, transparent), transparent 24rem),
    radial-gradient(circle at 75% 82%, color-mix(in srgb, var(--fish-green-light) 16%, transparent), transparent 24rem);
  mix-blend-mode: soft-light;
}

body::after {
  background-image:
    linear-gradient(rgba(15, 14, 13, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 14, 13, 0.016) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(circle at 50% 54%, rgba(0, 0, 0, 0.34), transparent 70%);
  opacity: 0.32;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--tint) 72%, white);
  outline-offset: 4px;
}

#scene,
#scene-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) clamp(18px, 4vw, 54px)
           calc(16px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.mark {
  width: 42px;
  height: 28px;
  flex: 0 0 auto;
  overflow: visible;
  filter: drop-shadow(0 10px 18px color-mix(in srgb, var(--tint) 30%, transparent));
  transition: filter 900ms ease;
}
.mark-main { fill: var(--text); }
.mark-accent {
  fill: color-mix(in srgb, var(--tint) 72%, var(--text-dim));
  transition: fill 900ms ease;
}

.brand-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
}

#dock {
  position: relative;
}

#orb {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.orb-ring {
  position: absolute;
  inset: 0;
}

.persona {
  appearance: none;
  min-width: 0;
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) * 3);
  background: rgba(255, 255, 255, 0.28);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background 220ms ease, border-color 220ms ease, color 220ms ease, transform 180ms ease, box-shadow 220ms ease;
}
.persona:hover {
  background: rgba(255, 255, 255, 0.58);
  color: var(--text);
  transform: translateY(-1px);
}
.persona.on {
  border-color: color-mix(in srgb, var(--p-tint, var(--tint)) 34%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--p-tint, var(--tint)) 13%, white), rgba(255, 255, 255, 0.54));
  color: var(--text);
  box-shadow: 0 12px 34px -28px var(--p-tint, var(--tint)), 0 1px 0 rgba(255, 255, 255, 0.72) inset;
}
.persona .p-name {
  display: block;
  color: inherit;
  font-size: clamp(15px, 1.7vw, 18px);
  font-weight: 620;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: normal;
  white-space: nowrap;
}
.persona .p-tag {
  display: block;
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 520;
  line-height: 1.35;
  letter-spacing: 0;
}

#latency {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0;
  opacity: 0;
  transition: opacity 500ms ease;
}
#latency.show { opacity: 1; }

/* /comparison/blind: the one control that breaks the blind, idle view only. */
.reveal {
  display: none;
  margin: 18px auto 0;
  padding: 8px 14px;
  border: 1px solid rgba(15, 14, 13, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
body.idle .reveal { display: block; }

@media (max-width: 820px) {
  #app {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (max-width: 560px) {
  #app {
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .brand-name { font-size: 14px; }
  .mark { width: 38px; height: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
  }
}

/* --- persona-first idle layout ------------------------------------------- */

body.idle main {
  justify-content: stretch;
}

body.idle #dock {
  flex: 1;
  display: block;
  width: min(1440px, 100%);
  min-height: 0;
  /* bottom margin mirrors the space above the grid (app top padding + header)
     minus the app's own bottom padding, so the frame reads symmetric */
  margin: clamp(16px, 3vh, 28px) auto calc(clamp(16px, 3vh, 28px) + 30px);
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.idle #orb,
body.idle #mute {
  display: none;
}

body.idle #personas {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 1.5vw, 18px);
  width: 100%;
  height: 100%;
  min-height: 0;
}

body.idle #personas .persona:nth-child(3),
body.idle #personas .persona:nth-child(4) {
  grid-column: auto;
}

body.idle .persona {
  position: relative;
  display: flex;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(22px, 3vw, 40px);
  border: 1px solid color-mix(in srgb, var(--p-tint, var(--tint)) 22%, var(--border));
  border-radius: calc(var(--radius) * 4);
  background:
    radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--p-tint, var(--tint)) 24%, transparent), transparent 34%),
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.86), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--p-tint, var(--tint)) 14%, white), rgba(255, 255, 255, 0.58));
  box-shadow:
    0 26px 70px -54px var(--p-tint, var(--tint)),
    0 1px 0 rgba(255, 255, 255, 0.75) inset;
  color: var(--text);
  isolation: isolate;
}

body.idle .persona::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), transparent 44%),
    repeating-linear-gradient(90deg, rgba(15, 14, 13, 0.035) 0 1px, transparent 1px 24px);
  mask-image: linear-gradient(180deg, transparent, #000 35%);
  opacity: 0.32;
}

body.idle .persona:hover,
body.idle .persona.on {
  border-color: color-mix(in srgb, var(--p-tint, var(--tint)) 42%, white);
  background:
    radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--p-tint, var(--tint)) 34%, transparent), transparent 36%),
    radial-gradient(circle at 16% 12%, rgba(255, 255, 255, 0.95), transparent 36%),
    linear-gradient(145deg, color-mix(in srgb, var(--p-tint, var(--tint)) 20%, white), rgba(255, 255, 255, 0.7));
  box-shadow:
    0 34px 86px -58px var(--p-tint, var(--tint)),
    0 1px 0 rgba(255, 255, 255, 0.82) inset;
}

/* The lift is hover feedback only — the selected card gets the highlight
   above at rest, so it still visibly responds when hovered. */
body.idle .persona:hover {
  transform: translateY(-2px);
}

body.idle .persona .p-name {
  font-size: clamp(34px, 5.4vw, 82px);
  font-weight: 300;
  line-height: 0.95;
  letter-spacing: 0;
  transform: translateX(-3px);
}

body.idle .persona .p-tag {
  width: min(28ch, 100%);
  margin-top: 13px;
  color: var(--text-dim);
  font-size: clamp(14px, 1.45vw, 18px);
  font-weight: 450;
  line-height: 1.45;
}

body.session-fullscreen #dock {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  width: auto;
  margin: 0;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  gap: 8px;
}

body.session-fullscreen #personas {
  display: none;
}

body.session-fullscreen #orb {
  display: block;
  width: 94px;
  height: 48px;
  grid-column: auto;
  grid-row: auto;
  border-radius: 999px;
  transition: transform 180ms ease, filter 180ms ease;
  order: 2;
}

body.session-fullscreen #orb::after {
  content: "End";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
  color: var(--text-body);
  font: 650 12px/1 var(--font);
  letter-spacing: 0.01em;
  pointer-events: none;
}

body.session-fullscreen #orb:hover { transform: translateY(-2px); }
body.session-fullscreen #orb:active { transform: translateY(0) scale(0.97); }

body.session-fullscreen .orb-ring {
  border: 1px solid rgba(15, 14, 13, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 16px 40px -26px rgba(15, 14, 13, 0.72),
    0 1px 0 rgba(255, 255, 255, 0.92) inset;
  opacity: 1;
  animation: none !important;
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
}

.session-action {
  display: none;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 94px;
  min-width: 94px;
  padding: 0 14px;
  border: 1px solid rgba(15, 14, 13, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-body);
  box-shadow:
    0 16px 40px -26px rgba(15, 14, 13, 0.72),
    0 1px 0 rgba(255, 255, 255, 0.92) inset;
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  cursor: pointer;
  font: 650 12px/1 var(--font);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

body.session-fullscreen .session-action { display: inline-flex; }
body.session-fullscreen #mute { order: 1; }
.session-action:hover { transform: translateY(-2px); }
.session-action:active { transform: translateY(0) scale(0.97); }
.session-action.on { border-color: color-mix(in srgb, var(--fish-coral) 34%, var(--gray-300)); }


@media (max-width: 820px) {
  body.idle #dock {
    /* Vertical space is scarce here: skip the desktop's symmetric bottom
       frame and let the persona list run to the app's own bottom padding. */
    margin-top: clamp(12px, 3vh, 24px);
    margin-bottom: 0;
  }

  body.idle #personas {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
  }

  body.idle #personas .persona:nth-child(3),
  body.idle #personas .persona:nth-child(4) {
    grid-column: 1;
  }

  body.idle .persona {
    flex: 0 0 58px;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    min-height: 58px;
    padding: 13px 12px;
    border-radius: calc(var(--radius) * 3);
  }

  body.idle .persona.on {
    flex: 1 1 auto;
    width: 100%;
    min-width: 100%;
    min-height: 0;
    padding: clamp(22px, 8vw, 36px);
    padding-inline: clamp(16px, 4vw, 22px);
  }

  body.idle .persona:not(.on) {
    align-items: flex-start;
    justify-content: center;
    background:
      radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--p-tint, var(--tint)) 18%, transparent), transparent 42%),
      rgba(255, 255, 255, 0.88);
    box-shadow:
      0 18px 44px -34px rgba(15, 14, 13, 0.65),
      0 1px 0 rgba(255, 255, 255, 0.82) inset;
  }

  body.idle .persona .p-name {
    font-size: clamp(14px, 4vw, 17px);
    font-weight: 620;
    line-height: 1.1;
    transform: translateX(-1px);
  }

  body.idle .persona .p-tag {
    display: none;
  }

  body.idle .persona.on .p-name {
    font-size: clamp(48px, 16vw, 72px);
    font-weight: 300;
    line-height: 0.95;
    transform: translateX(-3px);
  }

  body.idle .persona.on .p-name,
  body.idle .persona.on .p-tag {
    align-self: stretch;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    text-align: left;
  }

  body.idle .persona.on .p-tag {
    display: block;
    margin-top: 14px;
    font-size: 16px;
  }

}

@media (max-width: 560px) {
  body.idle #personas {
    min-height: 0;
  }
}
