/*
  Cribz Market Pulse
  - Theme-aware (light + dark)
  - Button styling for 12w/26w/52w controls
  - Mobile-friendly scroll + canvas sizing
*/

:root {
  --mp-card-bg: rgba(0, 0, 0, 0.04);
  --mp-card-border: rgba(0, 0, 0, 0.08);
  --mp-text: rgba(0, 0, 0, 0.92);
  --mp-muted: rgba(0, 0, 0, 0.62);

  --mp-ctrl-bg: rgba(0, 0, 0, 0.06);
  --mp-ctrl-border: rgba(0, 0, 0, 0.12);
  --mp-ctrl-text: rgba(0, 0, 0, 0.76);

  --mp-ctrl-active-bg: rgba(255, 69, 0, 0.14);
  --mp-ctrl-active-border: rgba(255, 69, 0, 0.30);
  --mp-ctrl-active-text: #ff4500;

  --mp-scroll-track: rgba(0, 0, 0, 0.06);
  --mp-scroll-thumb: rgba(0, 0, 0, 0.16);
  --mp-mini-canvas-h: 375px;
  --mp-full-canvas-h: 650px;
}


:root {
  --mp-chip-bg: rgba(0, 0, 0, 0.03);
  --mp-chip-border: rgba(0, 0, 0, 0.06);
}

/* Your app uses this attribute in places — support it */
:root[data-theme='dark'] {
  --mp-card-bg: rgba(255, 255, 255, 0.04);
  --mp-card-border: rgba(255, 255, 255, 0.06);
  --mp-text: rgba(255, 255, 255, 0.92);
  --mp-muted: rgba(255, 255, 255, 0.62);

  --mp-ctrl-bg: rgba(255, 255, 255, 0.07);
  --mp-ctrl-border: rgba(255, 255, 255, 0.12);
  --mp-ctrl-text: rgba(255, 255, 255, 0.80);

  --mp-ctrl-active-bg: rgba(255, 69, 0, 0.16);
  --mp-ctrl-active-border: rgba(255, 69, 0, 0.34);
  --mp-ctrl-active-text: #ff4500;

  --mp-scroll-track: rgba(255, 255, 255, 0.06);
  --mp-scroll-thumb: rgba(255, 255, 255, 0.16);
  --mp-mini-canvas-h: 375px;
  --mp-full-canvas-h: 650px;
}

:root[data-theme='dark'] {
  --mp-chip-bg: rgba(255, 255, 255, 0.03);
  --mp-chip-border: rgba(255, 255, 255, 0.10);
}

.cribz-mp {
  border-radius: 14px;
  padding: none /*12px*/;
  /*background: var(--mp-card-bg);*/
  /*border: 1px solid var(--mp-card-border); */
  color: var(--mp-text);
  margin-bottom: 30px;
}

.cribz-mp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: nowrap;
}

.cribz-mp-title {
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.2;
  margin-right: auto;
}

/* Mini mode toggles: Price / Speed / Rate */
.cribz-mp-mini-modes {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: auto;
}

/* Buttons inside mini mode group */
.cribz-mp-mini-modes button {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 14px;
  border: 1px solid var(--mp-ctrl-border);
  background: var(--mp-ctrl-bg);
  color: var(--mp-ctrl-text);
  padding: 6px 14px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  min-width: 80px;
  text-align: center;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 100ms ease,
    box-shadow 140ms ease;
}

.cribz-mp-mini-modes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cribz-mp-mini-modes button i {
  font-size: 0.9rem;
}

.cribz-mp-mode-label {
  display: inline-block;
}

/* Hover / focus */
.cribz-mp-mini-modes button:hover {
  border-color: rgba(255, 69, 0, 0.32);
  box-shadow: 0 0 0 1px rgba(255, 69, 0, 0.08);
}

.cribz-mp-mini-modes button:focus-visible {
  outline: 2px solid rgba(255, 69, 0, 0.55);
  outline-offset: 2px;
}

/* Active mode (matches other active controls) */
.cribz-mp-mini-modes button.is-active {
  background: var(--mp-ctrl-active-bg);
  border-color: var(--mp-ctrl-active-border);
  color: var(--mp-ctrl-active-text);
  box-shadow:
    inset 0 0 0 1px rgba(255, 69, 0, 0.18),
    0 0 18px rgba(255, 69, 0, 0.18);
}

/* Tap feedback */
.cribz-mp-mini-modes button:active {
  transform: translateY(1px) scale(0.98);
}

/* Button-style “View full” */
.cribz-mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 14px;
  text-decoration: none;
  background: rgba(255, 69, 0, 0.14);
  color: #ff4500;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid rgba(255, 69, 0, 0.25);
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.cribz-mp-btn:hover {
  background: rgba(255, 69, 0, 0.20);
  border-color: rgba(255, 69, 0, 0.40);
  text-decoration: none;
}

.cribz-mp-btn:active {
  transform: translateY(1px);
}

.cribz-mp-btn:focus-visible {
  outline: 2px solid rgba(255, 69, 0, 0.55);
  outline-offset: 2px;
}

.cribz-mp-btn i {
  font-size: 0.95em;
}

.cribz-mp-btn-text {
  font-weight: 700;
}

.cribz-mp-panel {
  margin-top: 14px;
}

.cribz-mp-mini-snapshot {
  margin-top: 5px;
  margin-bottom: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--mp-muted);
}

.cribz-mp-mini-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--mp-chip-bg);
  border: 1px solid var(--mp-chip-border);
  white-space: nowrap;
}

.cribz-mp-mini-chip strong {
  font-weight: 700;
  color: var(--mp-ctrl-active-text);
}

/* Slightly tighter chips on very narrow screens */
@media (max-width: 700px) {
  .cribz-mp-mini-snapshot {
    font-size: 0.8rem;
    gap: 4px 6px;
    justify-content: center;
  }

  .cribz-mp-mini-chip {
    padding: 3px 8px;
    max-width: 100%;
    white-space: normal;
  }
}

/* 12w / 26w / 52w controls */
.cribz-mp-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cribz-mp-controls button {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--mp-ctrl-border);
  background: var(--mp-ctrl-bg);
  color: var(--mp-ctrl-text);
  margin: 0;
  padding: 7px 12px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, color 160ms ease;
}

.cribz-mp-controls button:hover {
  border-color: rgba(255, 69, 0, 0.28);
}

.cribz-mp-controls button:active {
  transform: translateY(1px);
}

.cribz-mp-controls button:focus-visible {
  outline: 2px solid rgba(255, 69, 0, 0.35);
  outline-offset: 2px;
}

.cribz-mp-controls button.is-active {
  background: var(--mp-ctrl-active-bg);
  border-color: var(--mp-ctrl-active-border);
  color: var(--mp-ctrl-active-text);
  box-shadow: inset 0 0 0 1px rgba(255, 69, 0, 0.10);
}

/* Full view footer: chart mode buttons + caption under the chart */
.cribz-mp-full-footer {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cribz-mp-full-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cribz-mp-full-modes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.cribz-mp-full-caption {
  margin-top: 15px;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--mp-muted);
}

/* Horizontal scroll wrapper (mobile-friendly) */
.cribz-mp-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px; /* iOS swipe target */
}

.cribz-mp-full .cribz-mp-header {
    margin-bottom: 2rem;
}

/* Give the full Market Pulse block extra room before the site footer */
.cribz-mp-full {
  margin-bottom: 60px;
}

/* Tighter full-view spacing on phones */
@media (max-width: 700px) {
  .cribz-mp-full .cribz-mp-header {
    margin-bottom: 14px;
  }

  .cribz-mp-full .cribz-mp-controls {
    margin-bottom: 10px;
    justify-content: center;
  }

  /* Full view chart a bit taller on phones too */
  .cribz-mp-full .cribz-mp-scroll {
    height: 460px;
  }
}
/* Full view: keep chart fully in-frame so axes never get clipped */
.cribz-mp-full .cribz-mp-scroll {
  overflow-x: hidden;
}

.cribz-mp-full .cribz-mp-scroll-inner {
  min-width: 100%;
}

/* Inner wrapper we size (or min-size) to create horizontal scroll */
.cribz-mp-scroll-inner {
  height: 100%;
  min-width: 100%;
}

/* Canvas should follow the inner wrapper’s box (Chart.js will manage its internal drawing size) */
.cribz-mp-scroll-inner canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Make canvases behave nicely inside a scroller */

.cribz-mp-scroll canvas {
  display: block;
  max-width: none;
}

.cribz-mp-full .cribz-mp-scroll canvas {
  /* In full view, keep the canvas locked to the card so both Y axes stay visible */
  max-width: 100%;
}

/* Give the charts a consistent vertical footprint */
.cribz-mp-mini .cribz-mp-scroll {
  height: var(--mp-mini-canvas-h);
}

.cribz-mp-mini .cribz-mp-scroll canvas {
  height: 100%;
}

.cribz-mp-full .cribz-mp-scroll {
  height: var(--mp-full-canvas-h);
}

.cribz-mp-full .cribz-mp-scroll canvas {
  height: 100%;
}

/* Subtle, compact scrollbar styling */
.cribz-mp-scroll::-webkit-scrollbar {
  height: 8px;
}

.cribz-mp-scroll::-webkit-scrollbar-track {
  background: var(--mp-scroll-track);
  border-radius: 999px;
}

.cribz-mp-scroll::-webkit-scrollbar-thumb {
  background: var(--mp-scroll-thumb);
  border-radius: 999px;
}

.cribz-mp-scroll {
  scrollbar-color: var(--mp-scroll-thumb) var(--mp-scroll-track);
  scrollbar-width: thin;
}

/*
  Mobile behavior
  - mini chart should feel like a compact TradingView “glance”
  - full view canbe wider and scrollable
*/
@media (max-width: 700px) {

  .cribz-mp { 
    margin-bottom: 0px;
  }


  /* Stack title, mode buttons, and "View Full" vertically */
  .cribz-mp-header {
    align-items: stretch;
    gap: 8px;
  }

  .cribz-mp-title {
    font-size: 0.9rem;
  }

  .cribz-mp-mini-modes {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .cribz-mp-mini-modes button {
    flex: 1 1 0;
    padding: 8px 0;
    min-width: 0;
    border-radius: 999px;
    font-size: 0.85rem;
  }

  /* Icon-only on mobile to keep things tight */
  .cribz-mp-mini-modes .cribz-mp-mode-label {
    display: none;
  }

  /* Keep "View Full" compact on mobile */
  .cribz-mp-btn-text {
    display: none;
  }

  .cribz-mp-btn {
    align-self: flex-end;
    padding: 8px 12px;
  }

  /* Full view: keep chart locked to card width so both Y-axes stay visible */
  .cribz-mp-full .cribz-mp-scroll-inner {
    min-width: 100%;
  }

  /* Mini view (home): still a “glance”, but wide enough for readable bars/labels */
  .cribz-mp-mini .cribz-mp-scroll-inner {
    min-width: max(100%, 980px);
  }

  .cribz-mp-controls button {
    padding: 6px 10px;
    border-radius: 11px;
  }

  .cribz-mp-mini {
    padding: 0px;
  }

  .cribz-mp-mini .cribz-mp-header {
    gap: 8px;
  }

  /* Give the scroller a bit more usable swipe area */
  .cribz-mp-mini .cribz-mp-scroll {
    padding-bottom: 10px;
    height: 260px;
  }

  .cribz-mp-full .cribz-mp-scroll {
    height: 420px;
  }

  .cribz-mp-full-caption {
  font-size: .8rem;
}
}



/* --- Full Market Pulse layout tweaks --------------------------- */

/* Desktop / large screens: keep the footer pushed down */
@media (min-width: 901px) {
  .cribz-mp-full {
    min-height: 65vh;
    padding-bottom: 2.5rem;
  }

  .cribz-mp-full .cribz-mp-scroll {
    height: 460px;          /* nice tall chart on desktop */
  }
}

/* Mobile / small screens: tighter layout, smaller chart */
@media (max-width: 900px) {
  .cribz-mp-full {
    min-height: auto;       /* undo the 65vh */
    /*padding: 1rem 1rem 1rem;*/
    margin-bottom: 0px;
  }



  /* Stack title + mode buttons more tightly */
  .cribz-mp-full .cribz-mp-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .cribz-mp-full-footer {
    margin-top: 1rem;
  }

  .cribz-mp-full .cribz-mp-title {
    font-size: 0.95rem;
  }

  .cribz-mp-full .cribz-mp-full-modes {
    width: 100%;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .cribz-mp-full .cribz-mp-full-modes button {
    flex: 1 1 0;
    padding: 0.5rem 0;
    min-width: 0;
    font-size: 0.85rem;
  }

  /* Range buttons row */
  .cribz-mp-full .cribz-mp-controls {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }

  /* Chart height on mobile */
  .cribz-mp-full .cribz-mp-scroll {
    height: 320px;          /* shorter so it fits nicely */
  }

  .cribz-mp-full .cribz-mp-scroll-inner,
  .cribz-mp-full .cribz-mp-scroll canvas {
    height: 100% !important;
  }
}


/* Hidden by default (desktop) */
.cribz-mp-mode-heading {
  display: none;
}

/* Mobile-only chart name under the week buttons */
@media (max-width: 768px) {
  .cribz-mp-mode-heading {
    display: block;
    margin: 8px 0 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
  }

  .cribz-mp-mode-heading-label {
    letter-spacing: 0.01em;
  }
}