/* 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;
}

/* --------------------------------------------------------------------------- */
/* Global footer                                                                 */
/* --------------------------------------------------------------------------- */

/* Keep the footer pinned to the bottom on short pages. */
.app-shell {
  display: flex;
  flex-direction: column;
}

.app-shell > .app-page-container {
  flex: 1 0 auto;
}

.app-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border-color, #232830);
  background: rgba(255, 255, 255, 0.02);
  animation: app-footer-fade 0.35s ease;
}

/* Don't flash the footer at the top of the viewport while the page body is
   still routing/loading — keep it hidden until Dash renders page content. */
.app-shell:has(#_pages_content:empty) .app-footer {
  display: none;
}

@keyframes app-footer-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.app-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 28px;
  text-align: left;
}

/* "Powered By" label sits inline with the logo strip on one line. */
.app-footer-powered {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.app-footer-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary, #9aa3af);
  white-space: nowrap;
}

.app-footer-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.app-footer-logo {
  display: inline-flex;
  align-items: center;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.app-footer-logo:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.app-footer-logo-img {
  height: 22px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}

.app-footer-support-btn {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-color, #232830);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #e8eaed);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.app-footer-support-btn:hover {
  background: rgba(var(--accent-rgb, 96, 165, 250), 0.12);
  border-color: rgba(var(--accent-rgb, 96, 165, 250), 0.45);
  color: var(--text-primary, #e8eaed);
}

.app-footer-copyright {
  font-size: 0.76rem;
  color: var(--text-secondary, #9aa3af);
  white-space: nowrap;
}

/* Phone-sized screens: fall back to the stacked, centered arrangement. */
@media (max-width: 640px) {
  .app-footer-inner {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 20px 12px 16px;
    gap: 14px;
  }

  .app-footer-powered {
    flex-direction: column;
    gap: 10px;
  }

  .app-footer-logos {
    justify-content: center;
    gap: 14px 18px;
  }

  .app-footer-logo-img {
    height: 20px;
    max-width: 110px;
  }

  .app-footer-copyright {
    white-space: normal;
  }
}
