/* Rhizome / Skein design tokens — WCAG 2.2 AA oriented */
:root {
  --rh-color-fg: #1a1a1a;
  --rh-color-fg-muted: #4a5568;
  --rh-color-bg: #ffffff;
  --rh-color-surface: #f8f9fa;
  --rh-color-header-start: #2c3e50;
  --rh-color-header-end: #34495e;
  --rh-color-header-fg: #ffffff;
  --rh-color-accent: #4338ca; /* indigo-700, ~7.9:1 on white */
  --rh-color-accent-fg: #ffffff;
  --rh-color-stat-bg: #5b1a3a; /* dark rose, white text >=4.5:1 */
  --rh-color-stat-bg-end: #7a1f2e;
  --rh-color-stat-fg: #ffffff;
  --rh-focus-ring: #4338ca;
  --rh-focus-ring-offset: #ffffff;
  --rh-target-min: 44px;
  --rh-safe-top: env(safe-area-inset-top, 0px);
  --rh-safe-right: env(safe-area-inset-right, 0px);
  --rh-safe-bottom: env(safe-area-inset-bottom, 0px);
  --rh-safe-left: env(safe-area-inset-left, 0px);
}

[data-bs-theme="dark"] {
  --rh-color-fg: #ecf0f1;
  --rh-color-fg-muted: #b0bec5;
  --rh-color-bg: #1a252f;
  --rh-color-surface: #2c3e50;
  --rh-focus-ring: #a5b4fc;
  --rh-focus-ring-offset: #1a252f;
}

/* Focus visibility (WCAG 2.4.7) */
:focus-visible {
  outline: 3px solid var(--rh-focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: 0.75rem 1rem;
  background: var(--rh-color-accent);
  color: var(--rh-color-accent-fg);
  text-decoration: none;
  border-radius: 0 0 4px 0;
}
.skip-link:focus {
  left: var(--rh-safe-left);
  top: var(--rh-safe-top);
}

body {
  padding-left: var(--rh-safe-left);
  padding-right: var(--rh-safe-right);
}

.rhizome-header {
  /* Solid fill (not gradient) so contrast checkers sample correctly */
  background-color: var(--rh-color-header-start);
  background-image: linear-gradient(135deg, var(--rh-color-header-start) 0%, var(--rh-color-header-end) 100%);
  color: var(--rh-color-header-fg);
  padding: calc(1.25rem + var(--rh-safe-top)) 0 1.25rem;
}
.rhizome-header .btn-outline-light {
  color: #fff;
  border-color: #fff;
  background-color: transparent;
}
.rhizome-header .btn-outline-light:hover,
.rhizome-header .btn-outline-light:focus {
  color: var(--rh-color-header-start);
  background-color: #fff;
  border-color: #fff;
}
.rhizome-header .badge.bg-success {
  background-color: #0f5132 !important; /* darker for white text */
  color: #fff;
}
.rhizome-header .badge.bg-danger {
  background-color: #842029 !important;
  color: #fff;
}

.theme-toggle {
  background: none;
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: var(--rh-color-header-fg);
  border-radius: 50%;
  width: var(--rh-target-min);
  height: var(--rh-target-min);
  min-width: var(--rh-target-min);
  min-height: var(--rh-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.7);
}

.content-card {
  background: var(--rh-color-bg);
  color: var(--rh-color-fg);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  margin: 2rem 0;
  padding: 2rem;
}
[data-bs-theme="dark"] .content-card,
[data-bs-theme="dark"] .post-card {
  background: var(--rh-color-surface);
  color: var(--rh-color-fg);
  border: 1px solid #34495e;
}
[data-bs-theme="dark"] .link-preview {
  background: #34495e;
  color: var(--rh-color-fg);
  border: 1px solid #4a5f7a;
}

.post-card {
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.post-card .card-body {
  overflow: visible;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
}
/* Wrap long URLs in prose links; never pre-wrap .btn (Read More etc.) */
.post-card .card-body a:not(.btn) {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.post-card .card-body pre,
.post-card .card-body code {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}
/* Keep link-preview images sized; don't let global img height:auto collapse them oddly */
.post-card .link-preview img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}
.post-card img { max-width: 100% !important; height: auto; }

/* Keep long titles/URLs inside the yellow RSS border on narrow viewports */
.post-card.border-warning,
.content-card {
  max-width: 100%;
}
@media (max-width: 576px) {
  .post-card .card-body { padding: 0.75rem; }
  .post-card .badge { white-space: normal; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.stat-card {
  background: linear-gradient(135deg, var(--rh-color-stat-bg) 0%, var(--rh-color-stat-bg-end) 100%);
  color: var(--rh-color-stat-fg);
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
}
.stat-number {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.dropdown-menu { z-index: 2000; }

/* Feed toolbar: wrap on small screens */
.feed-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}
.feed-toolbar-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

/* Action hit targets */
.feed-actions .btn-link {
  min-height: var(--rh-target-min);
  min-width: var(--rh-target-min);
  padding: 0.5rem 0.75rem !important;
  display: inline-flex;
  align-items: center;
}

footer.app-footer {
  padding-bottom: calc(1.5rem + var(--rh-safe-bottom));
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
