/* Meet You in the Middle.
   One field of light behind everything; it gathers into Middle in the room. */

@font-face {
  font-family: "Middle Optical";
  src: url("/fonts/roboto-flex.woff2") format("woff2");
  font-weight: 100 1000;
  font-stretch: 25% 151%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Middle Serif";
  src: url("/fonts/instrument-serif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Middle Serif";
  src: url("/fonts/instrument-serif-italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --ground: #020408;
  --text: #f5f7f8;
  --ink: rgba(236, 243, 250, 0.82);
  --ghost: rgba(229, 237, 244, 0.68);
  --muted: rgba(226, 236, 246, 0.56);
  --line: rgba(218, 230, 240, 0.36);
  --hair: rgba(210, 219, 226, 0.22);
  --story: #d9e6f8;
  --story-soft: #c2d4eb;
  --lavender: #aeb9eb;
  --blue: #77bde7;
  --ember: #ffd18c;

  --ui: "Middle Optical", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Middle Serif", "Instrument Serif", Georgia, serif;
  --mark: "Helvetica Neue", Helvetica, Arial, sans-serif;

  --head: 84px;
  --gutter: 48px;
  --column: 700px;
  --fine: 12.5px;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--ui);
  font-optical-sizing: auto;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; }
button { cursor: pointer; }
:focus-visible { outline: 1px solid var(--ember); outline-offset: 4px; }
[hidden] { display: none !important; }

/* ---------- the scene: the field of light lives here (presence.js draws into it) ---------- */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: var(--ground); }
.scene canvas { position: absolute; inset: 0; z-index: 0; }
.scene .veil {
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(2, 4, 8, 0.0) 0%, rgba(2, 4, 8, 0.0) 60%, rgba(2, 4, 8, 0.55) 100%);
}

/* ---------- header ---------- */
.head {
  position: fixed; top: 0; left: 0; right: 0; height: var(--head); z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 var(--gutter);
}
.head .mark { justify-self: start; }
.head .wordmark {
  font-family: var(--mark); font-weight: 800; font-size: 32px; letter-spacing: -0.04em; line-height: 1;
  color: var(--text); user-select: none;
}
.head .product {
  justify-self: end; font-size: 13.8px; letter-spacing: 0.02em; color: var(--ink);
  font-variation-settings: "opsz" 14;
}

/* ---------- rail ---------- */
.rail {
  position: fixed; right: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; align-items: flex-end; gap: 34px;
  padding-right: 18px;
}
.rail::before { content: ""; position: absolute; right: 0; top: -22px; bottom: -22px; width: 1px; background: var(--hair); }
.rail-people { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.rail .person {
  position: relative; text-align: right; font-size: var(--fine); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); line-height: 1.2; transition: color 0.8s var(--ease);
  font-variation-settings: "opsz" 12;
}
.rail .person.here { color: var(--ink); }
.rail .person::after {
  content: ""; position: absolute; right: -18px; top: 50%; width: 12px; height: 1px; background: var(--line); transform: translateY(-50%);
}
.rail .person i {
  position: absolute; right: -21px; top: 50%; width: 5px; height: 5px; border-radius: 50%; transform: translate(0, -50%);
  background: var(--ember); opacity: 0; transition: opacity 0.8s var(--ease);
  box-shadow: 0 0 8px rgba(255, 209, 140, 0.6);
}
.rail .person.here i { opacity: 1; }
.rail .person small { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: none; color: var(--muted); opacity: 0.8; margin-top: 3px; }
.rail-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }

/* ---------- cues ---------- */
.cue {
  font-size: var(--fine); letter-spacing: 0.03em; color: var(--muted); font-variation-settings: "opsz" 12;
  transition: color 0.4s var(--ease);
}
button.cue:hover { color: var(--text); }
button.cue.on { color: var(--ember); }
.cues {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: 26px; z-index: 5;
  display: flex; justify-content: space-between; pointer-events: none;
}
.cues span { font-size: var(--fine); letter-spacing: 0.03em; color: var(--muted); font-variation-settings: "opsz" 12; transition: opacity 0.6s var(--ease); }
.cues .cue-right { text-align: right; }
.cues .cue-right.live { color: var(--lavender); }
.cues .cue-right.warn { color: var(--story-soft); }

/* ---------- stage ---------- */
.stage { position: fixed; inset: 0; z-index: 2; }
.screen { position: absolute; inset: 0; animation: rise 1.1s var(--ease) both; }
.screen.leaving { animation: leave 0.9s var(--ease) both; }
@keyframes leave { to { opacity: 0; transform: scale(1.06); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%);
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  text-align: center;
}
.center.wide { width: min(640px, calc(100vw - 2 * var(--gutter))); }

.story {
  margin: 0; font-weight: 300; font-size: 36px; line-height: 1.32; letter-spacing: -0.015em; color: var(--story);
  font-variation-settings: "opsz" 36; text-wrap: balance;
}
.sub {
  margin: 18px auto 0; max-width: 46ch; font-size: 16.5px; font-weight: 380; line-height: 1.55; color: var(--ghost);
  text-wrap: pretty;
}

/* the door */
.door { margin-top: 44px; display: flex; flex-direction: column; align-items: center; gap: 26px; }
.field { display: block; width: min(360px, 100%); text-align: left; }
.center.wide .field { width: 100%; }
.field .label {
  display: block; font-size: var(--fine); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px; font-variation-settings: "opsz" 12;
}
.field input, .field textarea {
  display: block; width: 100%; padding: 8px 0 10px; font-size: 21px; font-weight: 300; line-height: 1.35; color: var(--text);
  border-bottom: 1px solid var(--line); border-radius: 0; caret-color: var(--ember);
  transition: border-color 0.5s var(--ease);
  font-variation-settings: "opsz" 20;
}
.field textarea { resize: none; min-height: 2.75em; max-height: 40vh; overflow: auto; }
.field input:focus, .field textarea:focus { outline: none; border-bottom-color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: rgba(226, 236, 246, 0.32); }

.enter {
  display: inline-block; padding: 13px 26px; border-radius: 2px; background: var(--text); color: #07101a;
  font-size: 15.5px; font-weight: 500; letter-spacing: 0.01em; line-height: 1.25;
  transition: background 0.4s var(--ease), transform 0.4s var(--ease), opacity 0.4s var(--ease);
}
.enter:hover { background: #ffffff; }
.enter:active { transform: translateY(1px); }
.enter:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; align-items: center; gap: 26px; }
.note { margin: -6px 0 0; max-width: 40ch; font-size: var(--fine); letter-spacing: 0.02em; line-height: 1.6; color: var(--muted); }
.err { min-height: 0; font-size: 13.5px; color: var(--story-soft); letter-spacing: 0.01em; }
.err:empty { display: none; }

/* ---------- the room: one column, Middle behind it, every line on a lens ---------- */
.room { display: grid; grid-template-rows: 1fr auto; grid-template-columns: 1fr; }
.figure { display: none; }
@media (min-width: 1180px) {
  .room .feed, .room .ground { padding-right: calc(var(--gutter) + 150px); padding-left: calc(var(--gutter) + 150px); }
}
.feed {
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--head) + 28px) var(--gutter) 28px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) - 8px), #000 calc(var(--head) + 40px), #000 100%);
  mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) - 8px), #000 calc(var(--head) + 40px), #000 100%);
}
.feed::-webkit-scrollbar { display: none; }
.feed .column { max-width: var(--column); margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }

.empty { margin: auto; text-align: center; animation: rise 1.4s var(--ease) both; }
.empty .lens { padding: 22px 30px 24px; text-align: center; }
.empty .story { font-size: 30px; }
.empty .sub { font-size: 15.5px; }

.day {
  text-align: center; margin: 44px 0 12px; font-size: var(--fine); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  font-variation-settings: "opsz" 12;
}
.day:first-child { margin-top: 0; }

.line { margin-top: 22px; animation: rise 0.9s var(--ease) both; }
.line.cont { margin-top: 10px; }
/* the lens: a piece of frosted glass the line sits on, so it reads over the field */
.lens {
  position: relative; display: inline-block; text-align: left; padding: 12px 18px 14px; border-radius: 18px;
  background: rgba(5, 8, 14, 0.36);
  -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
}
.lens::before {
  /* the edge of the glass catching light */
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05) 30%, rgba(255, 255, 255, 0.02) 55%, rgba(255, 255, 255, 0.14));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
.lens::after {
  /* frost */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0.16; mix-blend-mode: soft-light;
  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' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
.line .who {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px;
  font-size: var(--fine); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-variation-settings: "opsz" 12;
}
.line .who time { letter-spacing: 0.04em; text-transform: none; color: var(--muted); opacity: 0.6; }
.line .text {
  font-size: 18px; font-weight: 380; line-height: 1.5; color: rgba(242, 246, 252, 0.96); white-space: pre-wrap; overflow-wrap: anywhere;
  font-variation-settings: "opsz" 18;
}
.line.them { text-align: left; }
.line.me { text-align: right; }
.line.me .who { justify-content: flex-end; }
.line.them .lens, .line.me .lens { max-width: 72%; }
.line.middle { text-align: center; }
.line.middle .lens { max-width: 82%; text-align: center; background: rgba(14, 12, 30, 0.34); }
.line.middle .who { justify-content: center; color: var(--lavender); opacity: 0.9; }
.line.middle .text {
  font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 21.5px; line-height: 1.42; letter-spacing: 0.004em;
  color: #d6dcf6;
}

.thinking { margin-top: 30px; text-align: center; animation: rise 0.9s var(--ease) both; }
.thinking .who { justify-content: center; color: var(--lavender); opacity: 0.9; display: flex; align-items: center; gap: 10px; font-size: var(--fine); letter-spacing: 0.12em; text-transform: uppercase; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--lavender); animation: pulse 2.4s ease-in-out infinite; box-shadow: 0 0 10px rgba(174, 185, 235, 0.7); }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }

/* the ground: composer */
.ground { position: relative; z-index: 3; padding: 0 var(--gutter) 64px; }
.ground::before {
  content: ""; position: absolute; left: 0; right: 0; top: -56px; height: 56px; pointer-events: none;
  background: linear-gradient(180deg, rgba(2, 4, 8, 0), rgba(2, 4, 8, 0.7));
}
.composer {
  position: relative; max-width: var(--column); margin: 0 auto; display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 14px;
  border-top: 1px solid var(--line); padding-top: 14px;
  transition: border-color 0.6s var(--ease);
}
.composer:focus-within { border-top-color: rgba(218, 230, 240, 0.7); }
.composer textarea {
  width: 100%; resize: none; max-height: 200px; padding: 6px 0; font-size: 18px; font-weight: 380; line-height: 1.5; color: var(--text);
  font-variation-settings: "opsz" 18; caret-color: var(--ember);
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: rgba(226, 236, 246, 0.36); }
.glyph {
  width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); border-radius: 2px;
  transition: color 0.4s var(--ease), background 0.4s var(--ease), opacity 0.4s var(--ease); margin-bottom: 2px;
}
.glyph svg { width: 20px; height: 20px; fill: currentColor; }
.glyph:hover { color: var(--text); }
.glyph:disabled { opacity: 0.35; cursor: default; }
.glyph.send:not(:disabled) { color: var(--text); }
.glyph.mic.live { color: var(--ember); }
.glyph.mic.live svg { animation: pulse 1.6s ease-in-out infinite; }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen, .line, .thinking, .empty { animation-duration: 0.01s; }
}

/* ---------- narrower laptops ---------- */
@media (max-width: 1180px) {
  :root { --column: 640px; --gutter: 36px; }
  .rail { padding-right: 14px; }
}
@media (max-width: 980px) {
  /* the rail lies down under the header */
  .rail { top: var(--head); left: var(--gutter); right: var(--gutter); transform: none; flex-direction: row; justify-content: space-between; align-items: center; padding: 0; gap: 16px; }
  .rail::before { display: none; }
  .rail-people { flex-direction: row; align-items: baseline; gap: 22px; }
  .rail .person { padding-left: 12px; }
  .rail .person::after { display: none; }
  .rail .person i { right: auto; left: 0; }
  .rail .person small { display: inline; margin-left: 6px; }
  .rail-actions { flex-direction: row; gap: 18px; }
  .rail .cue, .rail .person { white-space: nowrap; }
  .head .product { display: none; }
  .feed { padding-top: calc(var(--head) + 56px); -webkit-mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) + 24px), #000 calc(var(--head) + 64px), #000 100%); mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) + 24px), #000 calc(var(--head) + 64px), #000 100%); }
  .line.them .lens, .line.me .lens { max-width: 84%; }
}
/* ---------- phones (not the target, but it must not break) ---------- */
@media (max-width: 720px) {
  :root { --head: 64px; --gutter: 18px; }
  .head .wordmark { font-size: 24px; }
  .head .mark { height: 26px; }
  .story { font-size: 28px; }
  .empty .story { font-size: 24px; }
  .center, .center.wide { top: 46%; }
  .line.them .lens, .line.me .lens { max-width: 92%; }
  .line.middle .lens { max-width: 100%; }
  .line.middle .text { font-size: 21px; }
  .ground { padding-bottom: 20px; }
  .rail { flex-wrap: wrap; row-gap: 8px; }
  .rail .person small { display: none; }
  .rail-people { gap: 16px; }
  .rail-actions { gap: 14px; margin-left: auto; }
  .feed { padding-top: calc(var(--head) + 84px); -webkit-mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) + 52px), #000 calc(var(--head) + 90px), #000 100%); mask-image: linear-gradient(180deg, transparent 0, transparent calc(var(--head) + 52px), #000 calc(var(--head) + 90px), #000 100%); }
  .cues { display: none; }
  .composer textarea, .line .text { font-size: 17px; }
}
