﻿/* TerraTrend - panel.css (redesigned) */

/* ── Panel shell ─────────────────────────────────────────── */
.info-panel {
  position: absolute;
  top: calc(var(--appbar-h) + 14px);
  right: 16px;
  width: min(460px, 94%);
  background: rgba(4, 5, 16, 0.98);
  border: 1px solid rgba(140, 150, 255, 0.18);
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(139, 124, 255, 0.07) inset,
    0 0 60px -20px rgba(139, 124, 255, 0.35);
  transform: translateX(24px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 36;
  max-height: calc(100vh - var(--appbar-h) - 28px);
  display: flex;
  flex-direction: column;
}
.info-panel.visible { opacity: 1; transform: none; pointer-events: auto; }
.info-panel.hidden  { display: none; }

/* ── Scrollable body ─────────────────────────────────────── */
.panel-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 124, 255, 0.22) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 3px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(139, 124, 255, 0.25); border-radius: 999px; }

.panel-body {
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Cinematic banner ────────────────────────────────────── */
.panel-banner {
  position: relative;
  height: 160px;
  min-height: 86px;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(150deg, rgba(12, 8, 40, 1) 0%, rgba(6, 12, 35, 1) 100%);
  transition: height 0.25s ease;
}
.info-panel.no-photo .panel-banner { height: 86px; }
.panel-banner-photo {
  position: absolute;
  inset: 0;
}
.panel-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.52;
}
.panel-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(4, 5, 16, 0.4)  0%,
    rgba(4, 5, 16, 0.05) 35%,
    rgba(4, 5, 16, 0.7)  68%,
    rgba(4, 5, 16, 0.98) 100%
  );
}
.panel-banner-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 13px 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-banner-title {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0 18px 15px;
}

/* ── Banner typography ───────────────────────────────────── */
.panel-kicker {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(34, 224, 238, 0.5);
}
.info-panel h3 {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 5px;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9);
}
.panel-tagline {
  font-size: 0.77rem;
  color: rgba(195, 205, 235, 0.88);
  line-height: 1.4;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

/* ── Panel head elements ─────────────────────────────────── */
.panel-head-left  { display: flex; flex-direction: column; gap: 2px; }
.panel-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.panel-close {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.75);
  font-size: 1rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  backdrop-filter: blur(6px);
}
.panel-close:hover {
  color: #fff;
  background: rgba(139, 124, 255, 0.35);
  border-color: rgba(139, 124, 255, 0.55);
}

/* ── Data source badge ───────────────────────────────────── */
.data-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
  backdrop-filter: blur(6px);
}
.data-badge.live     { background: rgba(34, 224, 100, 0.15); border-color: rgba(34, 224, 100, 0.4);  color: #34e064; }
.data-badge.archived { background: rgba(255, 180, 60, 0.12); border-color: rgba(255, 180, 60, 0.35); color: #ffb43c; }
.data-badge.loading  { background: rgba(139, 124, 255, 0.12); border-color: rgba(139, 124, 255, 0.3); color: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.data-badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.data-badge.live     .data-badge-dot { box-shadow: 0 0 6px #34e064; }
.data-badge.archived .data-badge-dot { box-shadow: 0 0 6px #ffb43c; }

/* ── Metadata row (coords · rate) ────────────────────────── */
.panel-meta {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(140, 150, 255, 0.1);
}
.panel-meta-item {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  line-height: 1.55;
}
.panel-meta-sep { color: rgba(140, 150, 255, 0.3); font-size: 0.62rem; }

/* ── Key finding callout ─────────────────────────────────── */
.panel-finding {
  background: rgba(139, 124, 255, 0.07);
  border: 1px solid rgba(139, 124, 255, 0.16);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text);
}
.panel-finding strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 7px;
}

/* ── Trend chart ─────────────────────────────────────────── */
.panel-chart-wrap { position: relative; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.panel-chart-title {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--text-tertiary);
}
#panel-chart {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: pan-y;
  border-radius: 6px;
}
.chart-delta {
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-top: 7px;
  padding-left: 44px;
}
.chart-tip {
  position: absolute;
  top: 26px;
  left: 0;
  transform: translateX(-50%);
  background: var(--panel-solid);
  border: 1px solid var(--line-bright);
  color: var(--text);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  padding: 5px 9px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 18px -6px rgba(139, 124, 255, 0.5);
}
.chart-tip .tip-val { color: var(--accent-2); font-weight: 500; }

/* ── Mann-Kendall block ──────────────────────────────────── */
.mk-block {
  padding: 13px 15px;
  border: 1px solid rgba(140, 150, 255, 0.15);
  border-left: 3px solid var(--mk-col, var(--accent));
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}
.mk-label {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  margin-bottom: 9px;
}
.mk-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mk-direction {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.mk-badge {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.mk-badge.sig-yes { background: rgba(34, 224, 100, 0.12); color: #34e064; border: 1px solid rgba(34, 224, 100, 0.3); }
.mk-badge.sig-no  { background: rgba(255, 138, 92, 0.1);  color: var(--signal-warm); border: 1px solid rgba(255, 138, 92, 0.3); }
.mk-stats-line { font-size: 0.64rem; letter-spacing: 0.04em; color: var(--text-secondary); line-height: 1.65; }
.mk-plain {
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(140, 150, 255, 0.08);
}

.sig-yes   { color: #34e064 !important; text-shadow: 0 0 10px rgba(52, 224, 100, 0.4); }
.sig-mixed { color: var(--signal-warm) !important; }

/* ── Why it matters ──────────────────────────────────────── */
.why-matters {
  background: rgba(34, 224, 238, 0.05);
  border: 1px solid rgba(34, 224, 238, 0.12);
  border-left: 3px solid var(--accent-2);
  border-radius: 10px;
  padding: 13px 15px;
  font-size: 0.81rem;
  line-height: 1.68;
  color: var(--text-secondary);
}
.why-matters strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--accent-2);
  margin-bottom: 7px;
}

/* ── Description · source · mission ─────────────────────── */
.panel-desc   { font-size: 0.81rem; color: var(--text-secondary); line-height: 1.68; }
.panel-source { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.08em; color: var(--accent); word-break: break-word; line-height: 1.6; }
.panel-source a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid rgba(34, 224, 238, 0.35);
  padding-bottom: 1px;
  transition: color 0.2s, border-color 0.2s;
}
.panel-source a:hover { color: #fff; border-color: var(--accent-2); }
.mission-tag  { font-size: 0.64rem; letter-spacing: 0.06em; color: var(--text-secondary); line-height: 1.55; }

/* ── Navigation bar (pinned to bottom) ───────────────────── */
.panel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 14px;
  border-top: 1px solid rgba(140, 150, 255, 0.1);
  flex-shrink: 0;
  background: rgba(4, 5, 16, 0.98);
}
.panel-nav-btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  width: 34px;
  height: 30px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.panel-nav-btn:hover {
  color: #fff;
  border-color: var(--line-bright);
  background: var(--accent-soft);
  box-shadow: 0 0 18px -4px rgba(139, 124, 255, 0.55);
}
.panel-share-btn { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; font-size: 0.75rem; }
.panel-share-btn[data-copied="yes"] { color: #34e064; border-color: rgba(34, 224, 100, 0.4); }
.panel-nav-count { font-size: 0.62rem; letter-spacing: 0.16em; color: var(--muted); }

/* ── Panel body stagger reveal ───────────────────────────── */
@keyframes panelItemIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel-body.entering > * {
  animation: panelItemIn 0.38s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.panel-body.entering > *:nth-child(1) { animation-delay: 0ms; }
.panel-body.entering > *:nth-child(2) { animation-delay: 55ms; }
.panel-body.entering > *:nth-child(3) { animation-delay: 110ms; }
.panel-body.entering > *:nth-child(4) { animation-delay: 165ms; }
.panel-body.entering > *:nth-child(5) { animation-delay: 220ms; }
.panel-body.entering > *:nth-child(6) { animation-delay: 275ms; }
.panel-body.entering > *:nth-child(7) { animation-delay: 330ms; }
.panel-body.entering > *:nth-child(8) { animation-delay: 385ms; }

/* ── Loading spinner ─────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wheel {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(139, 124, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.chart-spinner {
  position: absolute;
  top: 24px; /* clears the chart-header title */
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 14, 0.55);
  border-radius: 6px;
  z-index: 2;
}
.mk-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid rgba(140, 150, 255, 0.12);
  border-left: 3px solid rgba(139, 124, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--text-tertiary);
}

/* ── Rate loading skeleton ───────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.panel-meta-item.loading {
  color: transparent !important;
  background: linear-gradient(
    90deg,
    rgba(140, 150, 255, 0.05) 25%,
    rgba(140, 150, 255, 0.14) 50%,
    rgba(140, 150, 255, 0.05) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  min-width: 130px;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 1400px) {
  .info-panel { width: 520px; }
}
@media (max-width: 1024px) {
  .info-panel {
    top: auto;
    bottom: 24px;
    right: 50%;
    transform: translate(50%, 24px) scale(0.97);
    width: min(420px, 94%);
  }
  .info-panel.visible { transform: translate(50%, 0) scale(1); }
  .chatbot-wrap.panel-open { opacity: 0; pointer-events: none; }
}
@media (max-width: 900px) {
  /* Floating card above the dock so the variable pills stay reachable */
  .info-panel {
    right: 0;
    left: 0;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    border-radius: 18px;
    max-height: 60dvh;
    max-height: 60vh;
    transform: translateY(24px) scale(0.99);
  }
  .info-panel.visible { transform: none; }

  /* No photo or dark overlay on mobile: too noisy on a small sheet */
  .panel-banner-photo,
  .panel-banner-overlay { display: none; }

  /* Flat header: remove the absolute-overlay stacking, let kicker and
     title stack naturally so there's real breathing room between them */
  .panel-banner {
    height: auto;
    min-height: 0;
    padding: 16px 14px 0;
    background: transparent;
  }
  .panel-banner-head {
    position: static;
    padding: 0;
    margin-bottom: 10px;
  }
  .panel-banner-title {
    position: static;
    padding: 0 0 14px;
  }
  /* Text-shadows were for legibility over images, not needed without them */
  .info-panel h3 { font-size: 1.1rem; text-shadow: none; }
  .panel-tagline  { text-shadow: none; font-size: 0.8rem; }

  /* Colored top accent strip keyed to the active variable */
  .info-panel {
    border-top: 2px solid color-mix(in srgb, var(--spot-col, var(--accent)) 80%, transparent);
  }
  .panel-banner {
    background: linear-gradient(
      to bottom,
      color-mix(in srgb, var(--spot-col, var(--accent)) 10%, rgba(4, 5, 16, 0)),
      transparent 100%
    );
    padding-bottom: 8px;
  }
  .panel-kicker {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
  }

  .panel-body { padding: 12px 14px 16px; gap: 12px; }
  .panel-close { width: 36px; height: 36px; }
  .panel-nav-btn { width: 40px; height: 38px; }

  /* Rate in the meta row is covered by the MK block below; hide the
     skeleton so it doesn't show as a mystery rectangle while loading */
  #panel-rate,
  .panel-meta-sep { display: none; }
}
