/* ===== Design Tokens ===== */
:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e4e6eb;
  --text-primary: #1c1e21;
  --text-secondary: #65676b;
  --text-tertiary: #8a8d91;
  --border-color: #dadde1;
  --azure-blue: #0078D4;
  --azure-blue-light: #50E6FF;
  --azure-blue-dark: #005A9E;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #18191a;
  --bg-secondary: #242526;
  --bg-tertiary: #3a3b3c;
  --text-primary: #e4e6eb;
  --text-secondary: #b0b3b8;
  --text-tertiary: #6c757d;
  --border-color: #3a3b3c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition), color var(--transition);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #0078D4 0%, #004E8C 100%);
  color: white;
  padding: 1.25rem 2rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.header-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.logo .subtitle {
  font-size: 0.78rem;
  opacity: 0.85;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-box {
  position: relative;
}

.search-box .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  pointer-events: none;
}

.search-box input {
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  border: none;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.88rem;
  width: 280px;
  outline: none;
  transition: background var(--transition), width var(--transition);
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-box input:focus {
  background: rgba(255, 255, 255, 0.3);
  width: 340px;
}

#bookmarks-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition);
  white-space: nowrap;
}

#bookmarks-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

#bookmarks-toggle.active {
  background: #f59e0b;
  border-color: #f59e0b;
}

#theme-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

#theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.stats-bar {
  max-width: 1440px;
  margin: 0.5rem auto 0;
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ===== Filters ===== */
.filters {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.6rem 2rem;
  position: sticky;
  top: 88px;
  z-index: 90;
  transition: background var(--transition), border-color var(--transition);
}

.filter-scroll {
  max-width: 1440px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-bottom: 0.15rem;
}

.pill {
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: inherit;
}

.pill:hover {
  border-color: var(--azure-blue);
  color: var(--azure-blue);
}

.pill.active {
  background: var(--azure-blue);
  color: white;
  border-color: var(--azure-blue);
}

.pill .count {
  display: inline-block;
  background: rgba(0, 0, 0, 0.1);
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  font-size: 0.72rem;
  margin-left: 0.3rem;
}

.pill.active .count {
  background: rgba(255, 255, 255, 0.25);
}

/* ===== Main Content ===== */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 2rem 2rem;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.controls-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#showing-count {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

#other-blogs-toggle {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}

#other-blogs-toggle:hover {
  border-color: var(--azure-blue);
  color: var(--azure-blue);
}

#other-blogs-toggle.active {
  background: var(--azure-blue);
  border-color: var(--azure-blue);
  color: white;
}

#date-filter,
#sort-by {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition);
}

#date-filter:focus,
#sort-by:focus {
  border-color: var(--azure-blue);
  outline: none;
}

/* ===== Date Group Headers ===== */
.date-group-header {
  grid-column: 1 / -1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.5rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--azure-blue);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-group-header:first-child {
  margin-top: 0;
}

/* ===== Articles Grid ===== */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* ===== Article Card ===== */
.article-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
}

.article-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}

.blog-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--azure-blue) 12%, transparent);
  color: var(--azure-blue);
  border: 1px solid color-mix(in srgb, var(--azure-blue) 24%, transparent);
}

.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 0.1rem;
  opacity: 0.35;
  transition: opacity var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.bookmark-btn:hover {
  opacity: 0.8;
  transform: scale(1.15);
}

.bookmark-btn.bookmarked {
  opacity: 1;
}

.article-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.article-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition);
}

.article-title a:hover {
  color: var(--azure-blue);
}

.article-meta {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-bottom: 0.6rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.article-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
  margin-bottom: 0.85rem;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: auto;
}

/* ===== Buttons ===== */
.btn {
  padding: 0.38rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--azure-blue);
  color: white;
}

.btn-primary:hover {
  background: var(--azure-blue-dark);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--border-color);
}

/* ===== Loading & Empty States ===== */
.loading,
.no-results {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
  font-size: 1rem;
  display: none;
}

.loading.visible,
.no-results.visible {
  display: block;
}

.is-hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

.empty-state-full {
  grid-column: 1 / -1;
}

.empty-state-title {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.loading-spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--azure-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 2rem;
  color: var(--text-tertiary);
  font-size: 0.82rem;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
  transition: border-color var(--transition);
}

footer a {
  color: var(--azure-blue);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  header {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .logo {
    justify-content: center;
  }

  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .search-box input {
    width: 100%;
  }

  .search-box input:focus {
    width: 100%;
  }

  .stats-bar {
    justify-content: center;
    font-size: 0.75rem;
  }

  .filters {
    padding: 0.5rem 1rem;
    top: 145px;
  }

  .filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  main {
    padding: 1rem;
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .controls-right {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 1.2rem;
  }

  .header-actions {
    gap: 0.5rem;
  }

  #bookmarks-toggle {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  height: 5px;
  width: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== NEW Badge ===== */
.new-badge {
  display: inline-block;
  background: #E81123;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.4rem;
  vertical-align: middle;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== Category Groups ===== */
.category-bar {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.category-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: inherit;
}

.category-pill:hover {
  border-color: var(--azure-blue);
  color: var(--azure-blue);
}

.category-pill.active {
  background: var(--azure-blue-dark);
  color: white;
  border-color: var(--azure-blue-dark);
}

.blog-pills-row {
  max-width: 1440px;
  margin: 0 auto;
}

/* ===== Share Buttons ===== */
.share-buttons {
  display: flex;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.share-btn {
  background: var(--bg-tertiary);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  opacity: 0.6;
}

.share-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}



/* ===== AI Summary ===== */
.ai-summary {
  background: linear-gradient(135deg, #0078D410 0%, #50E6FF10 100%);
  border: 1px solid var(--azure-blue);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.ai-summary h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--azure-blue);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-summary.is-unavailable {
  border-color: var(--border-color);
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-secondary) 100%);
}

.ai-summary-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ai-summary p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.ai-summary p:last-child {
  margin-bottom: 0;
}

.ai-summary-note {
  opacity: 0.7;
}

.ai-section {
  margin-bottom: 0.75rem;
}

.ai-section:last-child {
  margin-bottom: 0;
}

.ai-section h3 {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--azure-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.3rem 0;
}

.ai-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ai-section ul li {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding: 0.15rem 0 0.15rem 1.1rem;
  position: relative;
}

.ai-section ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--azure-blue);
  font-size: 0.75rem;
  top: 0.22rem;
}

.ai-section .ai-link {
  color: var(--azure-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-section .ai-link:hover {
  color: #0072c6;
}

/* ===== John Savill Video Card ===== */
#savill-video {
  margin-bottom: 1.5rem;
}

.savill-card {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 3px solid #FF0000;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
}

.savill-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.savill-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #FF0000;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.savill-body {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.savill-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 120px;
  height: 68px;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.savill-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.savill-thumb-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  font-size: 1.5rem;
}

.savill-thumb-wrap.thumb-fallback .savill-thumb {
  display: none;
}

.savill-thumb-wrap.thumb-fallback .savill-thumb-placeholder {
  display: flex;
}

.savill-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.3rem;
  opacity: 0;
  transition: opacity var(--transition);
}

.savill-card:hover .savill-play {
  opacity: 1;
}

.savill-info {
  min-width: 0;
}

.savill-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.savill-date {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
