/* Digest Page Styles */

/* Fluid Media Safety */
img,
video,
iframe,
embed {
  max-width: 100%;
  height: auto;
}

/* Main Container */
.digest-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.digest-feed {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 1rem;
}

/* Loading/Error/Empty States */
.digest-loading,
.digest-error,
.digest-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  min-height: 400px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(102, 126, 234, 0.1);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.digest-loading p,
.digest-error .error-message,
.digest-empty .empty-message {
  color: #6b7280;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  line-height: 1.6;
}

.error-icon,
.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.error-title,
.empty-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.5rem 0;
}

/* Digest Item Card */
.digest-item {
  background: white;
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.digest-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.digest-item:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07),
    0 8px 24px rgba(102, 126, 234, 0.15);
  transform: translateY(-4px);
}

.digest-item:hover::before {
  opacity: 1;
}

/* Digest Header */
.digest-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid #f3f4f6;
}

.digest-date {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.1) 100%
  );
  border-radius: 20px;
  color: #667eea;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.digest-date-icon {
  font-size: 1rem;
}

.digest-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* Digest Sections */
.digest-section {
  margin-bottom: 2rem;
}

.digest-section:last-child {
  margin-bottom: 0;
}

.digest-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.digest-section-content {
  padding-left: 0;
  margin-top: 1rem;
}

.digest-section-content p {
  margin: 0;
  line-height: 1.8;
  color: #374151;
  font-size: 1rem;
}

/* Collapsible Sections */
.digest-section.collapsible {
  background: #f9fafb;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
}

.digest-section.collapsible:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.digest-section.collapsible .digest-section-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease,
    margin-top 0.3s ease;
}

.digest-section.collapsible.expanded {
  background: white;
  border-color: rgba(102, 126, 234, 0.3);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
}

.digest-section.collapsible.expanded .digest-section-content {
  max-height: 3000px;
  opacity: 1;
  margin-top: 1rem;
}

.digest-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  transition: transform 0.2s ease;
}

.digest-section-toggle:hover {
  transform: translateX(2px);
}

.digest-section-toggle:active {
  transform: translateX(0);
}

.toggle-icon {
  color: #9ca3af;
  font-size: 0.875rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
  flex-shrink: 0;
  margin-left: 1rem;
}

.digest-section.collapsible:hover .toggle-icon {
  color: #667eea;
}

.digest-section.collapsible.expanded .toggle-icon {
  transform: rotate(180deg);
  color: #667eea;
}

/* Lists */
.digest-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.digest-list li {
  padding: 1rem 1.25rem;
  background: white;
  border-radius: 10px;
  border-left: 4px solid #667eea;
  color: #374151;
  font-size: 0.95rem;
  line-height: 1.7;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.digest-list li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.05) 0%,
    rgba(118, 75, 162, 0.05) 100%
  );
  transition: width 0.3s ease;
}

.digest-list li:hover {
  border-left-color: #4f46e5;
  transform: translateX(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.digest-list li:hover::before {
  width: 100%;
}

/* Button Styles */
.btn {
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: "Inter", -apple-system, sans-serif;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Non-collapsible sections styling */
.digest-section:not(.collapsible) {
  padding: 1.5rem;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.03) 0%,
    rgba(118, 75, 162, 0.03) 100%
  );
  border-radius: 12px;
  border: 1px solid rgba(102, 126, 234, 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .digest-container {
    padding: 0 1rem 1.5rem;
  }

  .digest-feed {
    gap: 1.5rem;
  }

  .digest-item {
    padding: 1.5rem;
    border-radius: 16px;
  }

  .digest-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .digest-title {
    font-size: 1.375rem;
  }

  .digest-date {
    font-size: 0.8125rem;
    padding: 0.375rem 0.875rem;
  }

  .digest-section-title {
    font-size: 1rem;
  }

  .digest-section {
    margin-bottom: 1.5rem;
  }

  .digest-section.collapsible {
    padding: 1rem;
  }

  .digest-section:not(.collapsible) {
    padding: 1rem;
  }

  .digest-section-content {
    margin-top: 0.75rem;
  }

  .digest-section-content p,
  .digest-list li {
    font-size: 0.9375rem;
  }

  .digest-list {
    gap: 0.625rem;
  }

  .digest-list li {
    padding: 0.875rem 1rem;
  }

  .digest-loading,
  .digest-error,
  .digest-empty {
    padding: 3rem 1.5rem;
    min-height: 300px;
  }

  .error-title,
  .empty-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .digest-container {
    padding: 0 0.75rem 1rem;
  }

  .digest-item {
    padding: 1.25rem;
    border-radius: 14px;
  }

  .digest-title {
    font-size: 1.25rem;
  }

  .digest-section-title {
    font-size: 0.9375rem;
  }

  .toggle-icon {
    font-size: 0.75rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .digest-item,
  .digest-loading,
  .digest-error,
  .digest-empty {
    background: #1f2937;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .digest-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  .digest-title,
  .digest-section-title,
  .error-title,
  .empty-title {
    color: #f9fafb;
  }

  .digest-section-content p {
    color: #d1d5db;
  }

  .digest-date {
    background: rgba(102, 126, 234, 0.15);
    color: #a5b4fc;
    border-color: rgba(102, 126, 234, 0.3);
  }

  .digest-section.collapsible {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .digest-section.collapsible:hover {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.15);
  }

  .digest-section.collapsible.expanded {
    background: #1f2937;
    border-color: rgba(102, 126, 234, 0.4);
  }

  .digest-section:not(.collapsible) {
    background: rgba(102, 126, 234, 0.08);
    border-color: rgba(102, 126, 234, 0.2);
  }

  .digest-list li {
    background: #111827;
    border-left-color: #818cf8;
    color: #d1d5db;
  }

  .digest-list li:hover {
    background: #0f172a;
    border-left-color: #a5b4fc;
  }

  .toggle-icon {
    color: #6b7280;
  }

  .digest-section.collapsible:hover .toggle-icon,
  .digest-section.collapsible.expanded .toggle-icon {
    color: #a5b4fc;
  }

  .digest-loading p,
  .digest-error .error-message,
  .digest-empty .empty-message {
    color: #9ca3af;
  }
}

/* Smooth scrolling for digest items */
.digest-item {
  scroll-margin-top: 2rem;
}

/* Print styles */
@media print {
  .digest-item {
    box-shadow: none;
    border: 1px solid #e5e7eb;
    page-break-inside: avoid;
    margin-bottom: 2rem;
  }

  .digest-section.collapsible .digest-section-content {
    max-height: none !important;
    opacity: 1 !important;
    margin-top: 1rem !important;
  }

  .toggle-icon {
    display: none;
  }
}
