/* Base, layout and shared components. Screen-specific styles live in screens.css. */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font-body);
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; }
video { display: block; }
.num { font-variant-numeric: tabular-nums; }

/* ---- layout ---------------------------------------------------------------------------------- */

.app {
  padding: calc(env(safe-area-inset-top) + 12px) var(--pad)
    calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
  max-width: 560px;
  margin: 0 auto;
}

.screen { display: grid; gap: 20px; }
.screen.is-entering { animation: screen-in 360ms var(--ease-out) both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}

.section-title {
  margin: 4px 2px -8px;
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.surface {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

/* ---- tabs ------------------------------------------------------------------------------------ */

.tabs {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-2);
  z-index: 20;
}

.tabs[hidden] { display: none; }

.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition-property: background-color, color, transform;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
}

.tab svg { width: 19px; height: 19px; }
.tab:active { transform: scale(0.96); }
.tab[aria-current="page"] { background: var(--text); color: var(--bg); }

/* ---- buttons --------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  transition-property: transform, background-color, box-shadow, opacity;
  transition-duration: 150ms;
  transition-timing-function: var(--ease-out);
}

.btn svg { width: 19px; height: 19px; flex: none; }
.btn:active { transform: scale(0.96); background: var(--bg-press); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.btn--primary { background: var(--lime); color: var(--lime-ink); }
.btn--primary:active { background: var(--lime); filter: brightness(0.94); }
.btn--violet { background: var(--violet); color: #fff; }
.btn--violet:active { background: var(--violet); filter: brightness(0.92); }
.btn--ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--danger { color: var(--danger); }
.btn--block { width: 100%; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  transition-property: transform, background-color;
  transition-duration: 150ms;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.92); background: var(--bg-press); }

/* ---- avatars & chips ------------------------------------------------------------------------- */

.avatar {
  --size: 32px;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--c, var(--m3));
  color: var(--m-ink);
  font: 700 calc(var(--size) * 0.4) / 1 var(--font-display);
  letter-spacing: -0.02em;
  user-select: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.chip--coral { background: var(--coral-soft); color: var(--coral); box-shadow: none; }
.chip--lime { background: var(--lime-soft); color: var(--text); box-shadow: none; }
.chip--quiet { background: var(--bg-elev-2); color: var(--text-2); box-shadow: none; }

/* ---- media ----------------------------------------------------------------------------------- */

.media {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  aspect-ratio: 9 / 16;
}

.media::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--media-outline);
  pointer-events: none;
}

.media video { width: 100%; height: 100%; object-fit: cover; }

.play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: none;
}

.play-badge span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgb(16 13 23 / 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
}

.play-badge svg { width: 22px; height: 22px; margin-left: 3px; } /* optical centering of the triangle */

/* ---- sheet (full-screen player) -------------------------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--pad) calc(env(safe-area-inset-bottom) + 16px);
  background: rgb(8 6 12 / 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: fade-in 220ms var(--ease-out) both;
}

.sheet.is-leaving { animation: fade-out 150ms ease-in both; }

.sheet__video {
  justify-self: center;
  align-self: center;
  height: 100%;
  max-height: calc(100dvh - 160px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: var(--r-md);
  background: #000;
  object-fit: contain;
  animation: rise-in 320ms var(--ease-out) both;
}

.sheet__close { position: absolute; top: calc(env(safe-area-inset-top) + 14px); right: var(--pad); z-index: 1; }
.sheet__close.icon-btn { background: rgb(255 255 255 / 0.12); color: #fff; }
.sheet .btn { background: rgb(255 255 255 / 0.1); color: #fff; }
.sheet .btn--primary { background: var(--lime); color: var(--lime-ink); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* ---- feedback -------------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabs-h) + 28px);
  z-index: 50;
  padding: 11px 16px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition-property: opacity, transform;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.skeleton {
  border-radius: var(--r-lg);
  background:
    linear-gradient(100deg, transparent 30%, var(--line) 50%, transparent 70%) 0 0 / 200% 100%,
    var(--bg-elev);
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.state {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 48px 20px;
  text-align: center;
}

.state__art { font-size: 44px; line-height: 1; }
.state h2 { margin: 0; font: 600 20px/1.25 var(--font-display); text-wrap: balance; }
.state p { margin: 0; max-width: 30ch; color: var(--text-2); text-wrap: pretty; }

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

.demo-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(env(safe-area-inset-top) + 8px) var(--pad) 8px;
  background: var(--violet);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}
