/* Spec-driven UI polish for AG Grid + Offcanvas */

.trend-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.trend-cell-value {
  flex: 1;
  min-width: 0;
}

.trend-icon {
  opacity: 0.55;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  transition: opacity 200ms ease, transform 200ms ease;
}

.trend-arrow {
  font-weight: 800;
  letter-spacing: 0.02em;
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
}

.trend-up {
  color: var(--success-color, #28a745);
}

.trend-down {
  color: var(--danger-color, #dc3545);
}

.trend-flat {
  color: var(--text-secondary, #b0bec5);
}

/* Fallback UX: if the inline renderer doesn't display, still show a hover affordance.
   Clicking the numeric cell opens the trend panel via cellClicked callback. */
.ag-theme-alpine-dark .ag-cell.trendable-cell {
  cursor: pointer;
}

/* Draggable trends modal header */
.pe-trends-modal-header {
  cursor: move;
  user-select: none;
}

/* If the React renderer is active, it renders a real .trend-icon element.
   Hide it by default and reveal on hover/focus for the spec-like affordance. */
.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon {
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  user-select: none;
}

.ag-theme-alpine-dark .ag-cell.trendable-cell:hover .trend-icon,
.ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon:focus {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Mobile: there is no hover, so keep the trend affordance visible. */
@media (max-width: 768px) {
  .ag-theme-alpine-dark .ag-cell.trendable-cell .trend-icon {
    opacity: 0.95;
    transform: none;
    padding: 2px 6px;
    margin-left: 2px;
  }
}

/* IMPORTANT: do not show the pseudo-element icon when the renderer is active,
   otherwise users see two 📈 icons (one from renderer, one from ::after).
   We keep the click-to-open fallback via cellClicked without showing an extra icon. */
.ag-theme-alpine-dark .ag-cell.trendable-cell::after,
.ag-theme-alpine-dark .ag-cell.trendable-cell .ag-cell-value::after {
  content: "";
}

.ag-row-hover .trend-icon,
.trend-cell:hover .trend-icon {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Plus metric semantics */
.plus-good {
  color: var(--success-color, #28a745);
  font-weight: 600;
}

.plus-bad {
  color: var(--danger-color, #dc3545);
  font-weight: 600;
}

/* Roto+ emphasis */
.roto-strong {
  font-weight: 700;
}

/* Offcanvas subtle transition (browser dependent) */
.offcanvas {
  transition: transform 280ms ease, opacity 280ms ease;
}

/* Blog / Posts: readable Markdown on dark theme */
.post-content {
  line-height: 1.75;
  color: var(--text-primary, #ffffff);
}

/* Anchor targets: add some offset for the sticky navbar */
.post-anchor {
  display: block;
  position: relative;
  top: -88px;
  visibility: hidden;
}

.post-content p {
  margin: 0.85rem 0;
  color: var(--text-secondary, #a1a1aa);
}

.post-content h1,
.post-content h2,
.post-content h3 {
  margin: 1.75rem 0 0.75rem 0;
  color: var(--text-primary, #ffffff);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.post-content h2 {
  font-size: 1.5rem;
}

.post-content h3 {
  font-size: 1.25rem;
}

.post-content a {
  color: var(--accent-color, #7f9dbb);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-content ul,
.post-content ol {
  margin: 0.75rem 0 0.75rem 1.25rem;
}

.post-content li {
  margin: 0.25rem 0;
  color: var(--text-secondary, #a1a1aa);
}

.post-content code {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.post-content pre {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.9rem;
  border-radius: 0.75rem;
  overflow-x: auto;
}

/* Subtle page transition */
@keyframes pageFadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-page-container.page-enter {
  animation: pageFadeInUp 180ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .app-page-container.page-enter {
    animation: none !important;
  }

  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* AG Grid zebra striping + hover (FanGraphs-like) */
.ag-theme-alpine-dark .ag-row-odd {
  background-color: rgba(255, 255, 255, 0.02);
}

.ag-theme-alpine-dark .ag-row-hover {
  background-color: var(--hover-bg, rgba(255, 255, 255, 0.06)) !important;
}

.ag-theme-alpine-dark .ag-header {
  font-weight: 600;
}
