/**
 * Holos Discover - Fediverse Search Engine
 * Page-specific styles (uses MD3 base components)
 */

/* Software-specific colors */
:root {
  --software-mastodon: #6364ff;
  --software-pleroma: #fba457;
  --software-akkoma: #5a3dff;
  --software-misskey: #96d04a;
  --software-firefish: #ff6b2d;
  --software-gotosocial: #ff6200;
  --software-pixelfed: #f84b6a;
  --software-peertube: #f1680d;
  --software-lemmy: #00bc8c;
  --software-kbin: #7b5cff;
  --software-friendica: #0b4e8d;
  --software-bookwyrm: #002549;
  --software-funkwhale: #0062d3;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--md-sys-color-surface-1);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-2);
  transition: var(--theme-transition), transform 0.2s;
}

.theme-toggle:hover {
  transform: scale(1.05);
  background: var(--md-sys-color-surface-2);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle .material-icons {
  font-size: 22px;
}

/* Hide icons based on theme */
.theme-toggle .icon-light { display: none; }
.theme-toggle .icon-dark { display: block; }

[data-theme="dark"] .theme-toggle .icon-light { display: block; }
[data-theme="dark"] .theme-toggle .icon-dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: none; }
}

/* Filter divider */
.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--md-sys-color-outline-variant);
  margin: 0 4px;
}

/* Sensitive Content Filter - MD3 Style */
.sensitive-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
}

.sensitive-label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sensitive-label .material-icons {
  font-size: 18px;
}

.md3-select-inline {
  appearance: none;
  -webkit-appearance: none;
  background: var(--md-sys-color-surface-container-highest);
  border: none;
  border-radius: 8px;
  color: var(--md-sys-color-on-surface);
  font-size: 13px;
  font-family: 'Roboto', sans-serif;
  padding: 4px 24px 4px 8px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: background-color 0.2s;
}

.md3-select-inline:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.md3-select-inline:focus {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 1px;
}

/* Dark mode arrow */
[data-theme="dark"] .md3-select-inline {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23aaa' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .md3-select-inline {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23aaa' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  }
}

/* Hero Section */
.hero {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: linear-gradient(135deg, var(--md-sys-color-surface) 0%, var(--md-sys-color-surface-1) 100%);
  position: relative;
  overflow: hidden;
  transition: var(--theme-transition);
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(27, 95, 181, 0.08) 0%, transparent 70%);
  animation: pulse 15s ease-in-out infinite;
}

[data-theme="dark"] .hero::before {
  background: radial-gradient(circle, rgba(168, 199, 250, 0.08) 0%, transparent 70%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero::before {
    background: radial-gradient(circle, rgba(168, 199, 250, 0.08) 0%, transparent 70%);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.hero-content {
  max-width: 900px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-title {
  font-size: 48px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 8px;
}

.primary-text {
  color: var(--md-sys-color-primary);
}

.hero-subtitle {
  font-size: 18px;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 32px;
}

/* Search Box */
.search-container {
  max-width: 700px;
  margin: 0 auto;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--md-sys-color-surface-1);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 28px;
  padding: 8px 8px 8px 20px;
  transition: all 0.2s;
  box-shadow: var(--md-sys-elevation-1);
}

.search-box:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-2);
}

.search-icon {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 24px;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-size: 16px;
  font-family: 'Roboto', sans-serif;
  padding: 12px 0;
  outline: none;
}

.search-box input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

/* Filters */
.filters-container {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  min-width: 70px;
  text-align: right;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chips.centered {
  justify-content: center;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--md-sys-color-surface-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 20px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-chip .material-icons {
  font-size: 16px;
}

.filter-chip:hover {
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-surface);
}

.filter-chip.active {
  background: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

/* Extended Filters */
.extended-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  padding: 16px;
  background: var(--md-sys-color-surface-1);
  border-radius: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  animation: slideDown 0.2s ease-out;
}

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

.extended-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.extended-filter-group .filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  min-width: auto;
  text-align: right;
}

.md3-input {
  background: var(--md-sys-color-surface-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  padding: 8px 12px;
  width: 100px;
  transition: border-color 0.2s;
}

.md3-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
}

.md3-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  background: var(--md-sys-color-primary);
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-3);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.scroll-to-top:hover {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  transform: scale(1.05);
}

.scroll-to-top:active {
  transform: scale(0.95);
}

.scroll-to-top .material-icons {
  font-size: 28px;
}

@media (max-width: 768px) {
  .scroll-to-top {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .scroll-to-top .material-icons {
    font-size: 24px;
  }

  .extended-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .extended-filter-group {
    justify-content: space-between;
  }

  .md3-input {
    flex: 1;
    width: auto;
  }
}

/* Instance Select */
.md3-select {
  background: var(--md-sys-color-surface-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  color: var(--md-sys-color-on-surface);
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  padding: 8px 12px;
  cursor: pointer;
  min-width: 180px;
}

.md3-select:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
}

/* Tabs */
.tabs-container {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 32px;
  padding: 4px;
  background: var(--md-sys-color-surface-1);
  border-radius: 24px;
  display: inline-flex;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: 20px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab .material-icons {
  font-size: 18px;
}

.tab:hover {
  background: var(--md-sys-color-surface-2);
  color: var(--md-sys-color-on-surface);
}

.tab.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

/* Results Wrapper */
.results-wrapper {
  background: var(--md-sys-color-background);
  padding: 48px 24px;
  min-height: 50vh;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Section Title */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 24px;
}

.section-title .material-icons {
  font-size: 24px;
  color: var(--md-sys-color-primary);
}

/* Trending Grid */
.trending-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Discover sections */
.discover-section {
  padding: 0 20px;
}

.discover-section:first-of-type {
  padding-top: 8px;
}

.discover-section:last-of-type {
  padding-bottom: 8px;
}

.md3-overline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  padding: 12px 0 8px;
}

.md3-overline .material-icons {
  font-size: 16px;
}

.trending-card {
  padding: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--md-sys-color-surface-2);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.card-header .material-icons {
  font-size: 20px;
  color: var(--md-sys-color-primary);
}

.card-header h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.trending-list {
  padding: 8px 0;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
}

/* Trending Items */
.trending-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.trending-item:hover {
  background: var(--md-sys-color-surface-2);
}

.trending-hashtag {
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.trending-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Sparkline */
.sparkline {
  flex-shrink: 0;
  color: var(--md-sys-color-primary);
  opacity: 0.7;
}

.trending-item:hover .sparkline {
  opacity: 1;
}

/* Trending Link Item */
.trending-link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.trending-link-item:hover {
  background: var(--md-sys-color-surface-2);
}

.trending-link-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trending-link-title {
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.trending-link-url {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Trending Post Item */
.trending-post-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.trending-post-item:hover {
  background: var(--md-sys-color-surface-2);
}

.trending-post-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--md-sys-color-surface-variant);
  object-fit: cover;
  flex-shrink: 0;
}

.trending-post-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.trending-post-author {
  font-size: 13px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-post-text {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-post-text .custom-emoji {
  height: 1em;
}

.trending-post-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.trending-post-stats span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.trending-post-stats .material-icons {
  font-size: 14px;
}

.trending-post-time {
  margin-left: auto;
}

/* Results Header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

#results-count {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Results List */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Post Card */
.post-card {
  background: var(--md-sys-color-surface-1);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--md-sys-elevation-1);
  transition: box-shadow 0.2s;
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.post-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--md-sys-color-surface-variant);
  object-fit: cover;
}

.post-author {
  flex: 1;
  min-width: 0;
}

.post-author-link {
  flex-shrink: 0;
}

.post-author-link:hover .post-avatar {
  opacity: 0.8;
}

.post-author-name-link {
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  display: block;
}

.post-author-name-link:hover {
  color: var(--md-sys-color-primary);
  text-decoration: underline;
}

.post-author-handle {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-software {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: capitalize;
  /* Default/fallback for unknown software */
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
}

.post-software.mastodon { background: var(--software-mastodon); color: #fff; }
.post-software.pleroma { background: var(--software-pleroma); color: #1a1a1d; }
.post-software.akkoma { background: var(--software-akkoma); color: #fff; }
.post-software.misskey { background: var(--software-misskey); color: #1a1a1d; }
.post-software.firefish, .post-software.calckey { background: var(--software-firefish); color: #fff; }
.post-software.gotosocial { background: var(--software-gotosocial); color: #fff; }
.post-software.pixelfed { background: var(--software-pixelfed); color: #fff; }
.post-software.peertube { background: var(--software-peertube); color: #fff; }
.post-software.lemmy { background: var(--software-lemmy); color: #fff; }
.post-software.kbin, .post-software.mbin { background: var(--software-kbin); color: #fff; }
.post-software.friendica { background: var(--software-friendica); color: #fff; }
.post-software.bookwyrm { background: var(--software-bookwyrm); color: #fff; }
.post-software.funkwhale { background: var(--software-funkwhale); color: #fff; }
.post-software.hubzilla { background: #3465a4; color: #fff; }
.post-software.writefreely { background: #5a5a5a; color: #fff; }
/* Mastodon forks - use Mastodon color */
.post-software.fedibird, .post-software.hometown, .post-software.glitch-soc, .post-software.ecko { background: var(--software-mastodon); color: #fff; }
/* Misskey forks */
.post-software.sharkey, .post-software.foundkey, .post-software.iceshrimp { background: var(--software-misskey); color: #1a1a1d; }
/* Other software */
.post-software.diaspora { background: #000; color: #fff; }
.post-software.threads { background: #000; color: #fff; }
.post-software.wordpress { background: #21759b; color: #fff; }
.post-software.unknown { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }

.post-time {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.post-content {
  color: var(--md-sys-color-on-surface);
  line-height: 1.6;
  word-wrap: break-word;
}

.post-content.collapsed {
  max-height: calc(1.6em * 20); /* 20 lines */
  overflow: hidden;
  position: relative;
}

.post-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3em;
  background: linear-gradient(transparent, var(--md-sys-color-surface));
  pointer-events: none;
}

.post-content.expanded {
  max-height: none;
}

.post-content.expanded::after {
  display: none;
}

.post-expand-btn {
  display: block;
  margin-top: 8px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 16px;
  color: var(--md-sys-color-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.post-expand-btn:hover {
  background: var(--md-sys-color-surface-container);
}

.post-content a {
  color: var(--md-sys-color-primary);
}

.post-content .hashtag {
  color: var(--md-sys-color-primary);
  cursor: pointer;
}

.post-content .hashtag:hover {
  text-decoration: underline;
}

/* Media Grid */
.post-media {
  margin-top: 12px;
  display: grid;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
  border-radius: 12px;
}

/* Grid layouts based on image count */
.post-media.media-count-1 {
  grid-template-columns: 1fr;
}

.post-media.media-count-2 {
  grid-template-columns: 1fr 1fr;
}

.post-media.media-count-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.post-media.media-count-3 .media-item:first-child {
  grid-row: span 2;
}

.post-media.media-count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.post-media img,
.post-media video {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--md-sys-color-surface-variant);
}

/* Media Item with ALT badge */
.media-item {
  position: relative;
  cursor: zoom-in;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  min-height: 120px;
  max-height: 300px;
}

.post-media.media-count-1 .media-item {
  max-height: 400px;
}

.post-media.media-count-3 .media-item:first-child {
  max-height: 100%;
  height: 100%;
}

.media-item img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.media-item:hover img {
  transform: scale(1.02);
}

/* Video in media grid */
.media-video {
  cursor: default;
}

.media-video video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 350px;
  object-fit: contain;
  background: #000;
  border-radius: 12px;
}

/* Video fallback placeholder */
.video-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 200px;
  background: var(--md-sys-color-surface-container);
  border-radius: 12px;
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: background 0.2s;
}

.video-fallback:hover {
  background: var(--md-sys-color-surface-container-high);
}

.video-fallback .material-icons {
  font-size: 48px;
}

.video-fallback-text {
  font-size: 14px;
  font-weight: 500;
}

/* ALT Badge */
.media-alt-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: help;
  transition: background 0.2s;
  z-index: 1;
}

.media-alt-badge:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* ==========================================================================
   Image Lightbox
   ========================================================================== */

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.95);
  justify-content: center;
  align-items: center;
  padding: 16px;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  z-index: 1;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
  cursor: default;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
}

.lightbox-alt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 600px;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
}

.lightbox-alt .material-icons {
  font-size: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.lightbox-alt-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

/* Sensitive Media */
.sensitive-media {
  position: relative;
  cursor: pointer;
}

.sensitive-media .sensitive-content {
  filter: blur(40px);
  transition: filter 0.3s ease;
}

.sensitive-media[data-revealed="true"] .sensitive-content {
  filter: none;
}

.sensitive-media .sensitive-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  color: white;
  font-size: 14px;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.sensitive-media .sensitive-overlay .material-icons {
  font-size: 32px;
}

.sensitive-media[data-revealed="true"] .sensitive-overlay {
  opacity: 0;
  pointer-events: none;
}

/* Content Warning */
.post-cw {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-radius: 8px;
  font-size: 14px;
}

.post-cw .material-icons {
  font-size: 18px;
}

/* Post Footer */
.post-footer {
  display: flex;
  gap: 24px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.post-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

.post-stat .material-icons {
  font-size: 18px;
}

.post-action {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.post-action:hover {
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-primary);
}

.post-action .material-icons {
  font-size: 20px;
}

/* Account Card */
.account-card {
  background: var(--md-sys-color-surface-1);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--md-sys-elevation-1);
  transition: box-shadow 0.2s;
}

.account-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--md-sys-color-surface-variant);
  object-fit: cover;
  flex-shrink: 0;
}

.account-info {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-weight: 500;
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
}

/* Custom emojis (inline in text) */
.custom-emoji {
  height: 1.2em;
  width: auto;
  vertical-align: middle;
  margin: 0 0.1em;
}

.account-handle {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
}

.account-bio {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.account-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.account-stat {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.account-stat strong {
  color: var(--md-sys-color-on-surface);
}

/* Hashtag Card */
.hashtag-card {
  background: var(--md-sys-color-surface-1);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: box-shadow 0.2s;
}

.hashtag-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.hashtag-name {
  font-size: 18px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.hashtag-stats {
  margin-left: auto;
  text-align: right;
}

.hashtag-posts {
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
}

.hashtag-users {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Load More */
#load-more-container {
  text-align: center;
  margin-top: 32px;
}

/* Submit Instance Card */
.submit-card {
  margin-top: 48px;
  padding: 0;
  overflow: hidden;
}

.submit-card .card-header {
  padding: 20px 24px;
}

.submit-description {
  padding: 12px 24px 8px;
  margin: 0;
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
}

.submit-form {
  padding: 20px 24px 24px;
}

.submit-input-group {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.submit-input-group input {
  flex: 1;
  background: var(--md-sys-color-surface-2);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  padding: 14px 20px;
  color: var(--md-sys-color-on-surface);
  font-size: 15px;
  font-family: 'Roboto', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.submit-input-group input:focus {
  border-color: var(--md-sys-color-primary);
}

.submit-input-group input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.submit-input-group .md3-button {
  padding: 14px 24px;
  white-space: nowrap;
}

.submit-result {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.submit-result.success {
  background: rgba(76, 175, 80, 0.15);
  color: #81c784;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.submit-result.error {
  background: rgba(244, 67, 54, 0.15);
  color: #e57373;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

.submit-result .material-icons {
  font-size: 20px;
  flex-shrink: 0;
}

.submit-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.submit-info .material-icons {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

@media (max-width: 600px) {
  .submit-input-group {
    flex-direction: column;
  }

  .submit-input-group .md3-button {
    width: 100%;
    justify-content: center;
  }
}

.footer-stats {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.post-card,
.account-card,
.hashtag-card {
  animation: fadeIn 0.3s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
  .hero {
    padding: 32px 16px;
  }

  .hero-title {
    font-size: 32px;
  }

  .filter-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-label {
    min-width: auto;
    text-align: left;
  }

  .trending-grid {
    grid-template-columns: 1fr;
  }

  .account-card {
    flex-direction: column;
    text-align: center;
  }

  .account-stats {
    justify-content: center;
  }

  .tabs-container {
    width: 100%;
  }

  .tab {
    flex: 1;
    justify-content: center;
  }

  /* Fix images overflow on mobile */
  .post-media {
    grid-template-columns: 1fr;
  }

  .post-media img,
  .post-media video,
  .media-item img {
    max-height: 300px;
  }

  .post-card {
    overflow: hidden;
  }

  .post-content {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* Lightbox mobile */
  .lightbox {
    padding: 8px;
  }

  .lightbox-image {
    max-height: calc(100vh - 160px);
  }

  .lightbox-alt {
    padding: 12px;
    font-size: 13px;
  }

  .lightbox-close {
    top: 8px;
    right: 8px;
  }
}

/* ==========================================================================
   Post Modal
   ========================================================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--md-sys-color-surface);
  border-radius: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--md-sys-elevation-5);
  animation: modal-enter 0.2s ease-out;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--md-sys-color-surface-variant);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  z-index: 1;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--md-sys-color-surface-3);
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.modal-content .post-card {
  cursor: default;
  box-shadow: none;
}

.modal-content .post-card:hover {
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   Hashtag Section View
   ========================================================================== */

.hashtag-section {
  max-width: 800px;
  margin: 0 auto;
  animation: fade-in 0.3s ease-out;
}

.hashtag-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 0 8px;
}

.hashtag-header h2 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  margin: 0;
}

.hashtag-count {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  margin-left: auto;
}

.back-button {
  background: var(--md-sys-color-surface-variant);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  transition: background 0.2s, transform 0.2s;
}

.back-button:hover {
  background: var(--md-sys-color-surface-3);
  transform: scale(1.05);
}

.hashtag-posts {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hashtag-loading {
  display: flex;
  justify-content: center;
  padding: 24px;
}

/* Scroll sentinel (invisible element for infinite scroll) */
#scroll-sentinel {
  height: 1px;
  margin-top: 16px;
}

/* Mobile adjustments for modal */
@media (max-width: 600px) {
  .modal-content {
    padding: 16px;
    border-radius: 16px;
    max-height: 95vh;
  }

  .hashtag-header h2 {
    font-size: 1.25rem;
  }
}
