/* ==========================================================================
   Highlands — design tokens (mapped 1:1 from Figma)
   Desktop frame: 1440 × 1024 · Mobile frame: 375 × 812
   ========================================================================== */

@font-face {
  font-family: 'Biro Script Reduced';
  src: url('/assets/fonts/Biro_Script_reduced.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Inter Display';
  src: url('/assets/fonts/InterDisplay-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('/assets/fonts/InterDisplay-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter Display';
  src: url('/assets/fonts/InterDisplay-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  /* palette */
  --white: #ffffff;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-50: #fafaf9;

  --glass-card: rgba(0, 0, 0, 0.2);
  --glass-bubble: rgba(0, 0, 0, 0.3);
  --glass-pill-light: rgba(250, 250, 249, 0.3);
  --glass-pill-dark: rgba(0, 0, 0, 0.3);
  --hairline: rgba(231, 229, 228, 0.2);
  --input-border: rgba(255, 255, 255, 0.2);
  --text-muted: rgba(255, 255, 255, 0.6);

  /* radii (figma: border-radius/2xl = 16) */
  --radius-lg: 8px;
  --radius-2xl: 16px;
  --radius-3xl: 24px;
  --radius-full: 999px;

  /* glass — see the .glass block below. The bubbles and the composer sit
     *inside* the already-blurred card, so they take fill only; stacking a
     second backdrop-filter on them compounds the blur and is what made the
     interior read mushier than the Figma render. */
  --blur-glass: 12px;
  --glass-edge: 1px; /* thickness of the specular rim */

  /* layout — desktop */
  --edge-x: 80px;
  --dock-bottom: 64px;
  --dock-width: 420px;
  --card-px: 24px;
  --card-pb: 24px;
  --card-open-h: 512px;
  --header-h: 65px;
  --title-size: 24px;
  --title-tracking: -0.24px;
  --composer-h: 50px;
  --chat-gap: 16px;

  /* The artwork is object-fit: cover, so on a viewport wider than 45/32 it
     overflows vertically and something has to be cropped. Pinned hard to the
     top, a laptop-shaped window (≈16:9) cut the campfire off the bottom;
     centred, the clouds rode up behind the clock. 29% keeps both: the crop
     comes mostly off the empty sky, and the fire — which sits at 0.826 of the
     artwork height — stays in frame down to about a 1.9 aspect.

     --art-h is the height the artwork occupies and --art-top is where its top
     edge lands, so anything that has to sit on a feature of the *painting* can
     be positioned against the painting rather than against the window. */
  --art-h: max(100vh, calc(100vw / 1.40625));
  --art-anchor: 29%;
  --art-top: calc(-0.29 * (var(--art-h) - 100vh));

  --motion: 560ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Reset / page shell — the page never scrolls
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  background: #10314f;
  color: var(--white);
  font-family: 'Inter Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ==========================================================================
   Background + animated grain
   ========================================================================== */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  /* 24px placeholder of the artwork — first paint is the scene, not a flat colour */
  background-image: url('data:image/webp;base64,UklGRsIAAABXRUJQVlA4ILYAAAAQBQCdASoYABEAPtFcpU0oJSOiMBgIAQAaCWQvvciasGSZilABXk+JWn/NDzj8/qaAAP67htltkm3W9IsC2B48SqXpGdN3Hh20pewqGBWRUR2O6M71n9TB1BcULan2WX8MJgIUNulyz9KwYFz1HB0iT+RxpCKpVm/IkeCzMkhTyYMlg8HMInk/U+CkQ0yoToiomKHA+DcR6ODNn717EzDdbEIsOx23ZirsQtBGViRqQQ3nX/gAAA==');
  background-size: cover;
  background-position: center var(--art-anchor);
}

.backdrop__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center var(--art-anchor);
  display: block;
  pointer-events: none;
  user-select: none;
}

.grain {
  position: fixed;
  inset: -6px; /* headroom so a step never exposes an edge */
  /* Above everything, including the glass — the grain is on the whole picture,
     not just the artwork. It never takes a pointer event. */
  z-index: 10;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: overlay;
  background-image: url('/assets/img/noise.png');
  background-repeat: repeat;
  background-size: 160px 160px;
  /* Stepped, not continuous: real film grain jumps rather than slides, and a
     step animation repaints ~10×/s instead of 60×/s. That is the entire cost of
     this effect — one tiled repaint of a 26 KB texture, no compositor layer, no
     canvas, no WebGL. */
  animation: grain-shift 800ms steps(1, end) infinite;
}

@keyframes grain-shift {
  0% {
    background-position: 0 0;
  }
  12.5% {
    background-position: -37px 23px;
  }
  25% {
    background-position: 61px -49px;
  }
  37.5% {
    background-position: -88px -14px;
  }
  50% {
    background-position: 29px 77px;
  }
  62.5% {
    background-position: -53px -96px;
  }
  75% {
    background-position: 104px 41px;
  }
  87.5% {
    background-position: -19px -68px;
  }
}

/* ==========================================================================
   Liquid glass

   Apple's material is TRANSPARENT, not frosted-white. What sells it is not a
   heavy blur or an inner glow — it is a thin, bright, uneven edge: light enters
   the lens at one corner and exits at the opposite one, so the rim is brightest
   top-left and bottom-right and nearly gone along the middle of each side.

   Earlier this was a second backdrop-filter masked into a wide band, which read
   as a milky halo and, worse, cost a whole extra GPU pass per element. The rim
   is now a 1px gradient border — pure paint, effectively free — so the only
   compositor work left is one blur pass on the four surfaces that actually sit
   over the artwork.
   ========================================================================== */

.glass {
  position: relative;
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(112%);
  backdrop-filter: blur(var(--blur-glass)) saturate(112%);
}

.glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  padding: var(--glass-edge);
  background: linear-gradient(
    148deg,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(255, 255, 255, 0.15) 17%,
    rgba(255, 255, 255, 0.03) 36%,
    rgba(255, 255, 255, 0.03) 62%,
    rgba(255, 255, 255, 0.2) 84%,
    rgba(255, 255, 255, 0.48) 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* Surfaces inside the card: the card already frosts what is behind them, so
   they take the edge only — no second blur pass. */
.glass--inset {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.glass--inset::after {
  background: linear-gradient(
    148deg,
    rgba(255, 255, 255, 0.34) 0%,
    rgba(255, 255, 255, 0.08) 20%,
    rgba(255, 255, 255, 0.02) 40%,
    rgba(255, 255, 255, 0.02) 64%,
    rgba(255, 255, 255, 0.12) 86%,
    rgba(255, 255, 255, 0.26) 100%
  );
}

/* A bigger pane has a thicker edge. */
.card {
  --glass-edge: 1.5px;
}

/* Safari and Firefox without backdrop-filter: keep the fill readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass:not(.glass--inset) {
    background-color: rgba(12, 26, 38, 0.72);
  }
}

/* ==========================================================================
   Stage
   ========================================================================== */

.stage {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

/* --- top bar ------------------------------------------------------------ */

.topbar {
  position: absolute;
  top: 24px;
  right: 40px;
  display: flex;
  align-items: center;
  gap: 40px;
  height: 36px;
}

.sound {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--glass-card);
  color: var(--white);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background 200ms ease, transform 200ms var(--ease);
}

.sound:hover {
  background: rgba(0, 0, 0, 0.3);
}

.sound:active {
  transform: scale(0.97);
}

.sound__label {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: -0.14px;
  white-space: nowrap;
}

.sound__icon {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
}

.sound__icon .bar {
  transform-origin: center;
  transform-box: fill-box;
}

.sound[aria-pressed='true'] .bar {
  animation: bar-pulse 1100ms ease-in-out infinite;
}

.sound[aria-pressed='true'] .bar--1 {
  animation-delay: 0ms;
}
.sound[aria-pressed='true'] .bar--2 {
  animation-delay: 140ms;
}
.sound[aria-pressed='true'] .bar--3 {
  animation-delay: 280ms;
}
.sound[aria-pressed='true'] .bar--4 {
  animation-delay: 420ms;
}
.sound[aria-pressed='true'] .bar--5 {
  animation-delay: 560ms;
}

@keyframes bar-pulse {
  0%,
  100% {
    transform: scaleY(0.35);
  }
  50% {
    transform: scaleY(1);
  }
}

.clock {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.28px;
  color: var(--stone-200);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* --- wordmark ----------------------------------------------------------- */

.wordmark {
  position: absolute;
  left: 200px;
  top: 120px;
  margin: 0;
  font-family: 'Biro Script Reduced', cursive;
  font-weight: 400;
  font-size: 64px;
  line-height: 1.7031; /* Biro's "normal" ratio in Figma: 109 / 64 */
  letter-spacing: -0.64px;
  color: var(--white);
  white-space: nowrap;
}

/* --- quote -------------------------------------------------------------- */

.quote {
  position: absolute;
  /* 457 / 1024 down the artwork — just under the snow line, over the treetops.
     Measured from the painting's top edge, so it holds on any viewport. */
  top: calc(var(--art-top) + var(--art-h) * 0.4463);
  right: 115px;
  width: 283px;
  margin: 0;
  font-size: 14px;
  font-style: italic;
  line-height: 20px;
  color: var(--white);
}

/* --- credit ------------------------------------------------------------- */

.credit {
  position: absolute;
  right: 40px;
  bottom: 24px;
  margin: 0;
  font-size: 14px;
  font-style: italic;
  line-height: 20px;
  color: var(--stone-200);
  white-space: nowrap;
}

.credit a {
  color: inherit;
  text-decoration: none;
  transition: color 200ms ease;
}

.credit a:hover {
  color: var(--white);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Chat dock
   ========================================================================== */

.dock {
  position: absolute;
  left: var(--edge-x);
  bottom: var(--dock-bottom);
  width: var(--dock-width);
}

.dock__close {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-2xl);
  background: var(--glass-card);
  cursor: pointer;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms var(--ease), background 200ms ease;
}

.dock__close img {
  display: block;
  width: 24px;
  height: 24px;
}

.dock__close:hover {
  background: rgba(0, 0, 0, 0.32);
}

.dock[data-open='true'] .dock__close {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition-delay: 180ms;
}

/* --- card --------------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--header-h);
  padding: 0 var(--card-px);
  border-radius: var(--radius-3xl);
  background: var(--glass-card);
  overflow: hidden;
  transition: height var(--motion) var(--ease), padding-bottom var(--motion) var(--ease);
}

.dock[data-open='true'] .card {
  height: var(--card-open-h);
  padding-bottom: var(--card-pb);
}

/* header (also the button that opens the chat) */

.card__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: none;
  width: 100%;
  height: var(--header-h);
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 0 0 rgba(231, 229, 228, 0);
  transition: box-shadow var(--motion) var(--ease);
}

.dock[data-open='true'] .card__header {
  cursor: default;
  box-shadow: inset 0 -1px 0 var(--hairline);
}

.card__title {
  flex: 1 0 0;
  min-width: 0;
  font-family: 'Biro Script Reduced', cursive;
  font-weight: 400;
  font-size: var(--title-size);
  line-height: 1.7031; /* matches Figma: 41 / 24 desktop, 34 / 20 mobile */
  letter-spacing: var(--title-tracking);
  color: var(--white);
}

/* live viewer pill */

.wanderers {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: none;
  height: 28px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-full);
  background: var(--glass-pill-dark);
}

.wanderers__dot {
  position: relative;
  width: 6px;
  height: 6px;
  flex: none;
}

.wanderers__dot img {
  position: absolute;
  inset: -6px;
  display: block;
  width: 18px;
  height: 18px;
  max-width: none;
}

.wanderers__text {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  line-height: 16px;
  color: var(--stone-50);
  white-space: nowrap;
}

/* tooltip — 16px to the right of the card, centred on the header row */

.tooltip {
  position: absolute;
  left: calc(100% + 16px);
  /* Anchored from the bottom, because that edge of the card never moves —
     the header rides up as the card grows. */
  bottom: calc(var(--header-h) / 2);
  display: flex;
  align-items: center;
  width: max-content;
  max-width: 355px;
  height: 40px;
  padding: 12px 16px;
  border-radius: var(--radius-2xl);
  background: var(--glass-card);
  font-size: 14px;
  line-height: 16px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(50%) translateX(-6px);
  transition:
    opacity 180ms ease,
    transform 220ms var(--ease),
    bottom var(--motion) var(--ease);
}

.dock[data-open='true'] .tooltip {
  bottom: calc(var(--card-open-h) - var(--header-h) / 2);
}

.dock:has(.wanderers:hover) .tooltip,
.dock:has(.wanderers:focus-visible) .tooltip {
  opacity: 1;
  transform: translateY(50%) translateX(0);
}

/* Needs 80 + 420 + 16 + 355 of room to sit beside the card — and there is no
   hover to trigger it on touch anyway. */
@media (max-width: 940px), (hover: none) {
  .tooltip {
    display: none;
  }
}

/* --- body --------------------------------------------------------------- */

.card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--chat-gap);
  min-height: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 200ms ease;
}

.dock[data-open='true'] .card__body {
  opacity: 1;
  transition: opacity 300ms ease 200ms;
}

/* messages */

.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.messages::-webkit-scrollbar {
  display: none;
}

.messages > :first-child {
  margin-top: auto;
}

.bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: none;
  width: 100%;
  padding-right: 80px;
  animation: bubble-in 320ms var(--ease) both;
}

.bubble--own {
  align-items: flex-end;
  padding-right: 0;
  padding-left: 80px;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble__card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-2xl);
  background: var(--glass-bubble); /* fill only — the card behind already blurs */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.bubble--own .bubble__card {
  width: auto;
  max-width: 100%;
}

.bubble__author {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  line-height: 16px;
  color: var(--text-muted);
  white-space: nowrap;
}

.bubble--own .bubble__author {
  justify-content: flex-end;
}

.bubble__text {
  margin: 0;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--white);
  overflow-wrap: anywhere;
}

.bubble--own .bubble__text {
  width: auto;
}

/* composer */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: var(--composer-h);
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-2xl);
  background: var(--glass-card); /* fill only — the card behind already blurs */
  transition: border-color 200ms ease;
}

.composer:focus-within {
  border-color: rgba(255, 255, 255, 0.45);
}

.composer__input {
  flex: 1 0 0;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--white);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.composer__input::placeholder {
  color: var(--text-muted);
}

.composer__input:focus {
  outline: none;
}

.composer__send {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 30px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--glass-pill-light);
  cursor: pointer;
  transition: transform 160ms var(--ease), background 160ms ease;
}

.composer__send:hover {
  background: rgba(250, 250, 249, 0.45);
}

.composer__send:active {
  transform: scale(0.92);
}

.composer__send img {
  display: block;
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Focus states
   ========================================================================== */

:where(button, a, input):focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

/* ==========================================================================
   Mobile — Figma frame 375 × 812
   ========================================================================== */

@media (max-width: 767px) {
  :root {
    --edge-x: 16px;
    --dock-bottom: 64px;
    --card-px: 16px;
    --card-pb: 16px;
    --header-h: 58px;
    --title-size: 20px;
    --title-tracking: -0.2px;
    --chat-gap: 16px;
  }

  /* Portrait crops horizontally, not vertically, so only X matters here. */
  .backdrop {
    background-position: 63% top;
  }

  .backdrop__image {
    object-position: 63% top;
  }

  .topbar {
    top: 24px;
    right: 24px;
  }

  .wordmark {
    left: 50%;
    top: 96px;
    transform: translateX(-50%);
    font-size: 48px;
    letter-spacing: -0.48px;
  }

  .quote {
    left: 50%;
    right: auto;
    top: calc(50% - 16px);
    width: 258px;
    transform: translateX(-50%);
    font-size: 12px;
    line-height: 16px;
    text-align: center;
  }

  .credit {
    left: 50%;
    right: auto;
    bottom: 24px;
    transform: translateX(-50%);
    font-size: 12px;
    line-height: 16px;
  }

  .dock {
    left: var(--edge-x);
    right: var(--edge-x);
    width: auto;
  }

  .wanderers {
    background: rgba(0, 0, 0, 0.2);
  }

  .wanderers__text {
    font-size: 12px;
    font-weight: 500;
  }

  .bubble {
    padding-right: 80px;
  }

  .bubble--own {
    padding-right: 0;
    padding-left: 80px;
  }
}

/* short viewports: keep everything on screen without scrolling */
@media (max-height: 700px) {
  .dock[data-open='true'] .card {
    height: min(var(--card-open-h), calc(100dvh - var(--dock-bottom) - 120px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }

  .sound[aria-pressed='true'] .bar {
    animation: none;
  }

  .bubble {
    animation: none;
  }
}
