/* The price chart on a stock's card (chart.js).
 *
 * One series, so there is no legend: the title says what is drawn. The line is COL blue and the
 * newest day carries the warm accent (the main page calls that colour --signal-mark; the name is the
 * page's own and has nothing to do with a trading signal). Text never takes the line's colour; it uses the page's own
 * ink and muted tones. Each page maps the six --pchart colours to its own tokens; the fallbacks
 * here are the light theme of the main page.
 */
.pchart {
  --pchart-line: var(--primary, #004482);
  --pchart-dot: var(--signal-mark, #c8660a);
  --pchart-grid: var(--rule, #e4e1da);
  --pchart-ink: var(--ink, #0b2545);
  --pchart-muted: var(--muted, #52627a);
  --pchart-surface: var(--surface, #ffffff);
  --pchart-axis: calc(var(--pchart-digits, 6) * 1ch + 10px);   /* room for "₱1,234.50" beside the plot */
  margin: 0;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--pchart-grid);
  color: var(--pchart-ink);
  font-size: var(--fs-label, 0.8125rem);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
/* Parts are switched on and off with the hidden attribute. A display rule further down would win
   over the browser's own, so this says it outright (the classic page has no page-wide rule for it). */
.pchart [hidden] { display: none !important; }
.pchart__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 10px;
}
.pchart__title { color: var(--pchart-muted); font-weight: var(--w-label, 600); }
.pchart__range { color: var(--pchart-muted); }

.pchart__body {
  display: grid;
  grid-template-columns: var(--pchart-axis) minmax(0, 1fr) var(--pchart-axis);
  height: 132px;
}
.pchart__axis, .pchart__end { position: relative; min-width: 0; color: var(--pchart-muted); }
.pchart__tick, .pchart__end-label {
  position: absolute;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}
.pchart__tick { padding-right: 8px; text-align: right; }
.pchart__end-label { padding-left: 10px; color: var(--pchart-ink); font-weight: var(--w-label, 600); }

.pchart__plot {
  position: relative;
  min-width: 0;
  cursor: crosshair;
  touch-action: pan-y pinch-zoom;   /* a sideways drag reads the days; scrolling and zooming the page still work */
  border-radius: 2px;
  outline-offset: 6px;
}
.pchart__plot:focus-visible { outline: 2px solid var(--focus, var(--pchart-line)); }
.pchart__plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.pchart__grid { stroke: var(--pchart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.pchart__line {
  fill: none;
  stroke: var(--pchart-line);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* The newest day, and the day under the pointer: 8px, with a ring in the card's own colour so the
   mark stays clear where it sits on the line. */
.pchart__dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--pchart-dot);
  box-shadow: 0 0 0 2px var(--pchart-surface);
  pointer-events: none;
}
.pchart__dot--hover { background: var(--pchart-line); }
.pchart__cross {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: var(--pchart-muted);
  opacity: 0.55;
  pointer-events: none;
}
/* The value leads and the date follows. It sits inside the plot, on whichever side has room. */
.pchart__tip {
  position: absolute;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 8px;
  border-radius: var(--r-control, 6px);
  background: var(--pchart-ink);
  color: var(--pchart-surface);
  white-space: nowrap;
  pointer-events: none;
}
.pchart__tip--low { top: auto; bottom: 0; }
.pchart__tip-value { font-size: var(--fs-small, 0.875rem); font-weight: var(--w-label, 600); }
.pchart__tip-date { opacity: 0.8; }

.pchart__foot {
  display: flex;
  justify-content: space-between;
  margin: 6px var(--pchart-axis) 0;
  color: var(--pchart-muted);
}
.pchart__note { margin: 10px 0 0; color: var(--pchart-muted); }
.pchart__live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The same prices as a table, for anyone who would rather read them than point at them. */
.pchart__table { margin-top: 8px; }
.pchart__table > summary {
  display: inline-block;
  min-height: 28px;
  padding: 4px 0;
  color: var(--link, var(--pchart-line));
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.pchart__table > summary::-webkit-details-marker { display: none; }
.pchart__table > summary:focus-visible { outline: 2px solid var(--focus, var(--pchart-line)); outline-offset: 2px; }
.pchart__scroll {
  max-height: 228px;
  margin-top: 6px;
  overflow-y: auto;
  border: 1px solid var(--pchart-grid);
  border-radius: var(--r-control, 6px);
}
.pchart__scroll table { width: 100%; border-collapse: collapse; }
.pchart__scroll th, .pchart__scroll td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--pchart-grid);
  text-align: left;
  white-space: nowrap;
}
.pchart__scroll th {
  position: sticky;
  top: 0;
  background: var(--pchart-surface);
  color: var(--pchart-muted);
  font-weight: var(--w-label, 600);
}
.pchart__scroll :is(th, td):last-child { text-align: right; }
.pchart__scroll tr:last-child td { border-bottom: 0; }

@media (min-width: 720px) {
  .pchart__body { height: 148px; }
}
/* Windows high-contrast mode: the system's own colours, so the line is never lost. */
@media (forced-colors: active) {
  .pchart__line { stroke: CanvasText; }
  .pchart__grid { stroke: GrayText; }
  .pchart__dot { background: Highlight; box-shadow: 0 0 0 2px Canvas; }
  .pchart__cross { background: CanvasText; opacity: 1; }
  .pchart__tip { border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
}
