/* ============================================
   OSRS Tracker — Chronicle Feed
   Adapted from feed-prototype.html
   ============================================ */

/* ============================================
   Feed Layout
   ============================================ */

.chronicle-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 0 0;
}

@media (min-width: 640px) {
  .chronicle-feed {
    gap: 12px;
    padding: 12px 0 0;
  }
}

/* ============================================
   Feed Card — content-first, zero chrome
   ============================================ */

.feed-card {
  --event-color: #6b7280;
  position: relative;
  background: var(--bg-elevated);
  border: none;
  overflow: hidden;
  margin-bottom: 8px;
}

@media (min-width: 640px) {
  .feed-card {
    margin-bottom: 12px;
  }
}

/* Subtle event-color tint across the whole card */
.feed-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--event-color);
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
}

/* Top accent edge — event-colored */
.feed-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--event-color);
  opacity: 0.35;
  z-index: 1;
}

/* Special cards get stronger accent + colored glow */
.feed-card--special::after {
  opacity: 0.85;
  height: 3px;
}

.feed-card--special {
  box-shadow: 0 0 40px -12px color-mix(in srgb, var(--event-color) 20%, transparent);
}

@media (min-width: 640px) {
  .feed-card {
    border-radius: 12px;
  }

  .feed-card--special {
    box-shadow: 0 0 50px -12px color-mix(in srgb, var(--event-color) 22%, transparent);
  }
}

/* ============================================
   Event Type Badge
   ============================================ */

.feed-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--event-color);
  background: color-mix(in srgb, var(--event-color) 12%, transparent);
  margin-left: auto;
  flex-shrink: 0;
}

.feed-card__badge .material-icons {
  font-size: 13px;
}

.feed-card__badge-label {
  display: none;
}

@media (min-width: 400px) {
  .feed-card__badge-label {
    display: inline;
  }
}

/* ============================================
   Card Header
   ============================================ */

.feed-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
  position: relative;
  z-index: 1;
}

.feed-card__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.feed-card__avatar-link {
  flex-shrink: 0;
  text-decoration: none;
}

.feed-card__avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.feed-card__meta {
  flex: 1;
  min-width: 0;
}

.feed-card__author {
  display: flex;
  align-items: center;
  gap: 6px;
}

.feed-card__username {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-card__info {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.feed-card__separator {
  opacity: 0.4;
}

.feed-card__group {
  color: var(--text-tertiary);
  text-decoration: none;
}

.feed-card__group:hover {
  color: var(--text-secondary);
  text-decoration: none;
}

/* ============================================
   Card Content & Message
   ============================================ */

.feed-card__content {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}

.feed-card__message {
  padding: 8px 16px 10px;
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
}

/* ============================================
   Media — edge-to-edge, content IS the card
   ============================================ */

.feed-card__media {
  position: relative;
  background: #000;
  overflow: hidden;
}

.feed-card__video,
.feed-card__image {
  width: 100%;
  display: block;
}

.feed-card__play-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.feed-card__media:hover .feed-card__play-hint {
  opacity: 1;
}

.feed-card__media:hover .feed-card__play-hint {
  transform: translate(-50%, -50%) scale(1.06);
}

.feed-card__media:has(.feed-card__video:not(:paused)) .feed-card__play-hint {
  opacity: 0;
}

.feed-card__play-hint .material-icons {
  font-size: 32px;
  color: white;
  margin-left: 3px;
}

/* ============================================
   Double-tap Heart Animation
   ============================================ */

.feed-card__heart-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
}

.feed-card__heart-burst .material-icons {
  font-size: 64px;
  color: var(--like-red, #ff3b5c);
  filter: drop-shadow(0 2px 8px rgba(255, 59, 92, 0.5));
}

.feed-card__heart-burst.animate {
  animation: heart-burst 0.5s ease-out;
}

@keyframes heart-burst {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  30%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  60%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ============================================
   Card Actions — Instagram layout
   Left: like, comment, share  |  Right: bookmark
   ============================================ */

.feed-card__actions {
  display: flex;
  align-items: center;
  padding: 2px 8px 8px;
  position: relative;
  z-index: 1;
}

.feed-card__actions-left {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.feed-card__actions-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.feed-card__action {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.feed-card__action:hover {
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
  color: var(--text-primary);
}

.feed-card__action:focus {
  outline: none;
  background: transparent;
}

.feed-card__action:active {
  transform: scale(0.93);
}

.feed-card__action .material-icons {
  font-size: 22px;
}

.feed-card__action-count {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-width: 1ch;
}

/* Like active */
.feed-card__action--like.liked {
  color: #ff3b5c;
}

.feed-card__action--like.liked .material-icons {
  animation: like-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes like-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}


/* Delete */
.feed-card__action--delete {
  color: var(--text-tertiary);
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
}

.feed-card__action--delete:hover {
  opacity: 1;
  color: #ef4444;
}

.feed-card__delete-wrapper {
  display: flex;
  align-items: center;
}

.feed-card__delete-confirm {
  align-items: center;
  gap: 6px;
}

.feed-card__delete-confirm-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.feed-card__delete-confirm-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.feed-card__delete-confirm-btn--yes {
  background: #ef4444;
  color: white;
}

.feed-card__delete-confirm-btn--no {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.feed-card__action-label {
  display: none;
}

@media (min-width: 360px) {
  .feed-card__action-label {
    display: inline;
  }
}

/* ============================================
   Share Drawer
   ============================================ */

.feed-card__share-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 18px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 20;
}

.feed-card__share-drawer.open {
  transform: translateY(0);
}

.feed-card__share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.feed-card__share-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  border-radius: 50%;
  transition: background 0.15s;
}

.feed-card__share-close:hover {
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.feed-card__share-close .material-icons {
  font-size: 1.25rem;
}

.feed-card__share-options {
  display: flex;
  justify-content: space-around;
}

.feed-card__share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s;
}

.feed-card__share-btn:hover {
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
}

.feed-card__share-btn:active { opacity: 0.6; }

.feed-card__share-btn svg,
.feed-card__share-btn .material-icons {
  width: 28px;
  height: 28px;
  font-size: 28px;
}

.feed-card__share-btn--discord { color: #5865F2; }
.feed-card__share-btn--reddit { color: #FF4500; }
.feed-card__share-btn--twitter { color: #1d9bf0; }
.feed-card__share-btn--copy { color: var(--text-secondary); }

/* ============================================
   Feed Header
   ============================================ */

.chronicle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  max-width: 640px;
  margin: 0 auto;
}

.chronicle-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   View Toggle (List/Reels)
   ============================================ */

.chronicle-toggle {
  display: flex;
  gap: 4px;
}

.chronicle-toggle__btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
}

.chronicle-toggle__btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.chronicle-toggle__btn .material-icons {
  font-size: 1rem;
}

.chronicle-toggle__label {
  display: none;
}

@media (min-width: 360px) {
  .chronicle-toggle__label {
    display: inline;
  }
}

/* ============================================
   Empty State
   ============================================ */

.chronicle-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-tertiary);
}

.chronicle-empty__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-tertiary);
  opacity: 0.4;
}

.chronicle-empty__icon .material-icons {
  font-size: 48px;
}

.chronicle-empty__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.chronicle-empty__text {
  color: var(--text-tertiary);
  font-size: 13px;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ============================================
   Quick Actions Bar
   ============================================ */

.chronicle-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0 16px;
  max-width: 640px;
  margin: 0 auto;
  justify-content: center;
}

.chronicle-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
}

.chronicle-action:hover {
  background: var(--bg-tertiary);
  text-decoration: none;
}

.chronicle-action .material-icons { font-size: 1rem; }

.chronicle-action--groups .material-icons { color: var(--accent-primary); }
.chronicle-action--quests .material-icons { color: #f59e0b; }
.chronicle-action--stats .material-icons { color: #22c55e; }

/* ============================================
   Toast Notifications
   ============================================ */

.feed-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #1d1d1f;
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.feed-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.feed-toast .material-icons {
  font-size: 1.125rem;
  color: #22c55e;
}

/* ============================================
   Infinite Scroll Loader
   ============================================ */

.feed-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.feed-loader__spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--text-tertiary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.feed-loader:not(.loading) { opacity: 0; }
.feed-loader.loading { opacity: 1; }

/* ============================================
   Feed Tabs — TikTok style
   ============================================ */

.feed-tabs {
  max-width: 640px;
  margin: 0 auto;
}

.feed-tabs__bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-secondary);
  padding-top: 6px;
}

.feed-tabs__track {
  display: flex;
  justify-content: center;
  position: relative;
}

.feed-tabs__tab {
  padding: 10px 20px 14px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.feed-tabs__tab--active {
  color: var(--text-primary);
  font-weight: 700;
}

.feed-tabs__indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  background: var(--text-primary);
  border-radius: 3px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.feed-tabs__indicator {
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.feed-tabs__divider {
  height: 1px;
  background: var(--border-color);
  opacity: 0.5;
}

.feed-tabs__panels {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.feed-tabs__panel {
  display: none;
}

.feed-tabs__panel--active {
  display: block;
}

.feed-tabs__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  color: var(--text-tertiary);
  gap: 12px;
}

.feed-tabs__loading .feed-loader__spinner {
  width: 24px;
  height: 24px;
}

/* ============================================
   Inline Comments — bubble conversation
   ============================================ */

.feed-card__comments {
  border-top: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
}

.feed-card__comments-drawer {
  padding: 0 12px 12px;
}

.feed-card__comments-sort {
  display: flex;
  gap: 0;
  padding: 10px 4px 6px;
  margin-bottom: 4px;
}

.feed-card__comments-sort-btn {
  background: none;
  border: none;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 20px;
  transition: color 0.15s, background 0.15s;
}

.feed-card__comments-sort-btn:hover {
  background: color-mix(in srgb, var(--text-primary) 5%, transparent);
}

.feed-card__comments-sort-btn.active {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}

.feed-card__comments-list {
  max-height: 320px;
  overflow-y: auto;
}

/* Individual comment — soft bubble */
.feed-card__comments-list .comment {
  display: flex;
  gap: 8px;
  padding: 8px;
  margin: 4px 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-primary) 3%, transparent);
  border: none;
}

.comment__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.comment__avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.comment__body {
  flex: 1;
  min-width: 0;
}

.comment__header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.comment__name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

.comment__time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.comment__text {
  margin: 2px 0 4px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-primary);
  word-break: break-word;
}

.comment__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comment__like-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.comment__like-btn:hover { color: var(--text-secondary); }
.comment__like-btn .material-icons { font-size: 14px; }

.comment__delete-btn {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.comment:hover .comment__delete-btn { opacity: 1; }
.comment__delete-btn:hover { color: #ef4444; }
.comment__delete-btn .material-icons { font-size: 14px; }

/* Always show on touch devices */
@media (hover: none) {
  .comment__delete-btn { opacity: 0.6; }
}

/* Comment form */
.feed-card__comments-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 0;
  margin-top: 4px;
}

.feed-card__comments-input {
  flex: 1;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.feed-card__comments-input::placeholder { color: var(--text-tertiary); }
.feed-card__comments-input:focus { border-color: var(--accent-primary); }

.feed-card__comments-submit {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--accent-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.feed-card__comments-submit:hover {
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

.feed-card__comments-submit .material-icons { font-size: 20px; }

.feed-card__action--comment { color: var(--text-secondary); }

.feed-card__comments-form-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.feed-card__comments-toggle {
  display: block;
  width: 100%;
  padding: 10px 16px 12px;
  background: none;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.feed-card__comments-toggle:hover { color: var(--text-secondary); }

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .feed-card__heart-burst,
  .feed-card__share-drawer,
  .feed-toast,
  .feed-loader__spinner,
  .feed-tabs__indicator {
    transition: none;
    animation: none;
  }
}
