/**
 * Live Feed — Public spectator page styles
 *
 * Standalone page at live.html?runner=<id>
 * Uses semantic tokens from tokens.css
 *
 * v3 — Premium redesign: glassmorphism, edge-to-edge media,
 *       refined typography, animated transitions, multi-emoji reactions
 */

/* --- Page Reset --- */
html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  background: #060609;
  color: var(--text, #F8FAFC);
  font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* Subtle animated gradient background */
#live-feed-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(6, 182, 212, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, #060609 0%, #0C0C14 100%);
}

/* --- Header --- */
.lf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}
.lf-header__brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #06B6D4, #3B82F6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lf-header__runner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lf-header__runner-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #F8FAFC);
}
.lf-header__live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: lf-pulse 2s ease-in-out infinite;
}
.lf-header__live-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #22C55E;
}

@keyframes lf-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* --- Stats Banner --- */
.lf-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}
.lf-stats__item {
  text-align: center;
}
.lf-stats__value {
  font-size: 22px;
  font-weight: 700;
  color: #F8FAFC;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.lf-stats__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.7);
  margin-top: 3px;
}

/* --- Loading / Empty / Error --- */
.lf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 16px;
  color: rgba(148, 163, 184, 0.6);
  font-size: 14px;
}
.lf-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(148, 163, 184, 0.15);
  border-top-color: #06B6D4;
  border-radius: 50%;
  animation: lf-spin 0.8s linear infinite;
}
@keyframes lf-spin { to { transform: rotate(360deg); } }

/* Shimmer loading skeleton */
.lf-shimmer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.lf-shimmer__card {
  background: rgba(30, 41, 59, 0.4);
  border-radius: 16px;
  height: 120px;
  position: relative;
  overflow: hidden;
}
.lf-shimmer__card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.03), transparent);
  animation: lf-shimmer-sweep 1.5s ease-in-out infinite;
}
@keyframes lf-shimmer-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.lf-empty {
  text-align: center;
  padding: 100px 40px;
}
.lf-empty__icon {
  font-size: 56px;
  margin-bottom: 16px;
  filter: grayscale(0.3);
}
.lf-empty__text {
  font-size: 15px;
  color: rgba(148, 163, 184, 0.6);
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.lf-error {
  text-align: center;
  padding: 48px 20px;
  color: #EF4444;
  font-size: 14px;
}

/* --- Feed List --- */
.lf-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0 110px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Feed Card (glassmorphism) --- */
.lf-card {
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.45);
  border-top: 1px solid rgba(148, 163, 184, 0.04);
  border-bottom: 1px solid rgba(148, 163, 184, 0.04);
  /* Entry animation */
  animation: lf-card-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes lf-card-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Type accents — subtle left glow instead of hard border */
.lf-card--cheer {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.06) 0%, transparent 40%),
              rgba(15, 23, 42, 0.45);
}
.lf-card--photo {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
              rgba(15, 23, 42, 0.45);
}
.lf-card--post {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.05) 0%, transparent 40%),
              rgba(15, 23, 42, 0.45);
}
.lf-card--milestone {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
              rgba(15, 23, 42, 0.45);
}
.lf-card--system {
  background: rgba(15, 23, 42, 0.3);
}

/* Card inner content (text area gets padding, media goes edge-to-edge) */
.lf-card__inner {
  display: flex;
  gap: 12px;
  padding: 14px 20px 6px;
}
.lf-card__icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}
.lf-card__body {
  flex: 1;
  min-width: 0;
}
.lf-card__author {
  font-size: 12px;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.8);
  margin-bottom: 3px;
  letter-spacing: 0.01em;
}
.lf-card__text {
  font-size: 15px;
  color: #F1F5F9;
  line-height: 1.55;
  word-wrap: break-word;
  letter-spacing: 0.005em;
}
.lf-card__meta {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.5);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

/* --- Edge-to-Edge Media --- */
.lf-card__media-wrap {
  margin-top: 10px;
  /* No horizontal padding — media bleeds to card edges */
}
.lf-card__media {
  overflow: hidden;
}
.lf-card__img {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  display: block;
  background: #000;
}
.lf-card__video {
  width: 100%;
  max-height: 480px;
  display: block;
  background: #000;
}
.lf-card__audio {
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
  margin: 4px 0;
}

/* --- Multi-Emoji Reactions --- */
.lf-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 12px;
  gap: 8px;
}

.lf-reactions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.lf-emoji-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 20px;
  padding: 4px 8px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  line-height: 1;
}
.lf-emoji-btn__count {
  font-size: 11px;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.7);
  min-width: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Active/selected state */
.lf-emoji-btn--active {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.3);
}
.lf-emoji-btn--active .lf-emoji-btn__count {
  color: #06B6D4;
}

/* Hover */
.lf-emoji-btn:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.9);
  transform: scale(1.05);
}
.lf-emoji-btn:active:not(:disabled) {
  transform: scale(0.92);
}
.lf-emoji-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Pop animation on react */
@keyframes lf-reaction-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.lf-emoji-btn--pop {
  animation: lf-reaction-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Add-reaction trigger (the "+" or smiley button) */
.lf-add-reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px dashed rgba(148, 163, 184, 0.12);
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: rgba(148, 163, 184, 0.4);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.lf-add-reaction:hover {
  border-color: rgba(148, 163, 184, 0.25);
  color: rgba(148, 163, 184, 0.7);
  background: rgba(30, 41, 59, 0.4);
}

/* Emoji picker popover */
.lf-emoji-picker {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 24px;
  padding: 6px 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: lf-picker-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes lf-picker-in {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.lf-emoji-picker__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.lf-emoji-picker__btn:hover {
  background: rgba(148, 163, 184, 0.1);
  transform: scale(1.15);
}
.lf-emoji-picker__btn:active {
  transform: scale(0.9);
}

/* Attribution text */
.lf-reaction-text {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  letter-spacing: 0.01em;
}

/* --- Load More --- */
.lf-load-more {
  margin: 8px 20px;
  padding: 14px;
  background: transparent;
  border: 1px dashed rgba(148, 163, 184, 0.1);
  border-radius: 12px;
  color: rgba(148, 163, 184, 0.5);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.lf-load-more:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(148, 163, 184, 0.15);
}
.lf-load-more:disabled { opacity: 0.4; }

/* --- Cheer Bar (fixed bottom, glassmorphism) --- */
.lf-cheer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(148, 163, 184, 0.06);
  max-width: 500px;
  margin: 0 auto;
  box-sizing: border-box;
}
.lf-cheer-bar__name {
  flex: 1;
  padding: 10px 14px;
  background: rgba(6, 9, 15, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 22px;
  color: #F8FAFC;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.lf-cheer-bar__name::placeholder { color: rgba(148, 163, 184, 0.4); }
.lf-cheer-bar__name:focus {
  outline: none;
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.08);
}
.lf-cheer-bar__btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #06B6D4, #0891B2);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(6, 182, 212, 0.2);
}
.lf-cheer-bar__btn:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
  transform: translateY(-1px);
}
.lf-cheer-bar__btn:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(6, 182, 212, 0.15);
}
.lf-cheer-bar__btn.sending {
  background: linear-gradient(135deg, #22C55E, #16A34A);
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.2);
}
.lf-cheer-bar__btn:disabled { cursor: default; }

/* --- Comment toggle trigger --- */
.lf-card__comment-toggle {
  padding: 0 20px 10px;
}
.lf-comment-trigger {
  background: none;
  border: none;
  color: rgba(148, 163, 184, 0.45);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}
.lf-comment-trigger:hover {
  color: rgba(148, 163, 184, 0.7);
}

/* --- Comments Thread --- */
.lf-comments {
  padding: 0 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lf-comments__expand {
  background: none;
  border: none;
  color: rgba(6, 182, 212, 0.7);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: color 0.15s ease;
}
.lf-comments__expand:hover {
  color: rgba(6, 182, 212, 1);
}

.lf-comment {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  animation: lf-comment-in 0.25s ease both;
}
@keyframes lf-comment-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.lf-comment__author {
  font-size: 12px;
  font-weight: 700;
  color: rgba(248, 250, 252, 0.85);
  flex-shrink: 0;
}
.lf-comment__body {
  font-size: 13px;
  color: rgba(248, 250, 252, 0.7);
  line-height: 1.4;
  word-break: break-word;
}
.lf-comment__time {
  font-size: 10px;
  color: rgba(148, 163, 184, 0.35);
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Comment Input --- */
.lf-comment-input {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.lf-comment-input__field {
  flex: 1;
  padding: 7px 12px;
  background: rgba(6, 9, 15, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 18px;
  color: #F8FAFC;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.lf-comment-input__field::placeholder {
  color: rgba(148, 163, 184, 0.35);
}
.lf-comment-input__field:focus {
  outline: none;
  border-color: rgba(6, 182, 212, 0.3);
}
.lf-comment-input__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(6, 182, 212, 0.15);
  border: none;
  border-radius: 50%;
  color: #06B6D4;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.lf-comment-input__send:hover:not(:disabled) {
  background: rgba(6, 182, 212, 0.25);
}
.lf-comment-input__send:disabled {
  opacity: 0.3;
  cursor: default;
}

/* --- New entry highlight flash --- */
@keyframes lf-new-flash {
  0% { background-color: rgba(6, 182, 212, 0.1); }
  100% { background-color: transparent; }
}
.lf-card--new {
  animation: lf-card-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both,
             lf-new-flash 2s ease-out 0.4s both;
}
