/*
 * The "glance pad" — the Collection at a glance block on the dashboard and
 * on a public profile: a black pad with a red outline, cream panels on it,
 * red bars, black train icons. (ericstrains.com's Collection page wears the
 * same colours; its copy of these rules is in that site's style.css.)
 *
 * The pad keeps these colours whatever theme the page is in. The pages are
 * written in Tailwind slate utilities and the themes re-point those
 * utilities (see themes.css), so the rules below re-point the same
 * utilities once more for anything inside .glance-pad. The doubled
 * ".glance-pad.glance-pad" gives them the weight to beat both Tailwind's
 * own classes and a theme's ".themed .x" rules, wherever this file loads.
 *
 * To change a colour, change it here; nothing else names them.
 */
.glance-pad {
    --gp-red: #b3261e;        /* the outline, the bars, the money figures (ericstrains.com's red) */
    --gp-pad: #000000;        /* the pad itself */
    --gp-panel: #f9f1dd;      /* tiles and the chart panel */
    --gp-panel-hover: #f1e5c4;
    --gp-track: #e4d7b3;      /* the empty part of a bar; hairlines */
    --gp-ink: #1c1917;        /* figures and labels on a panel */
    --gp-ink-soft: #5f563f;   /* small labels on a panel */
    --gp-on-pad: #f9f1dd;     /* lettering straight on the black */
}
.glance-pad.glance-pad {
    background-color: var(--gp-pad);
    border: 2px solid var(--gp-red);
    border-radius: 1rem;
    padding: 0.5rem;
}
@media (min-width: 640px) {
    .glance-pad.glance-pad { padding: 1rem; }
}

/* A heading that sits on the pad itself rather than on a panel. */
.glance-pad.glance-pad .glance-pad-title.glance-pad-title { color: var(--gp-on-pad); }

/* "Powered by ITRAINDB", in white on the black. On a public profile it shares
   a row with the heading (.glance-pad-head); on the dashboard, where the
   heading is above the pad, it is the pad's last line (--foot). */
.glance-pad.glance-pad .glance-pad-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.glance-pad.glance-pad .glance-pad-credit,
.glance-pad.glance-pad .glance-pad-credit a {
    color: #ffffff;
}
.glance-pad.glance-pad .glance-pad-credit {
    margin: 0;
    font-weight: 700;
    font-size: 0.7rem;
    line-height: 1.2;
    text-align: right;
    white-space: nowrap;
}
.glance-pad.glance-pad .glance-pad-credit a { text-decoration: none; }
.glance-pad.glance-pad .glance-pad-credit a:hover,
.glance-pad.glance-pad .glance-pad-credit a:focus-visible { text-decoration: underline; }
.glance-pad.glance-pad .glance-pad-credit--foot { margin-top: 0.5rem; }
@media (min-width: 640px) {
    .glance-pad.glance-pad .glance-pad-credit--foot { margin-top: 0.75rem; }
}

/* Panels: every white card inside the pad. No drop shadow on black, and no
   Train-theme lining. */
.glance-pad.glance-pad .bg-white {
    background-color: var(--gp-panel);
    box-shadow: none;
    outline: none;
}
.glance-pad.glance-pad .bg-slate-50,
.glance-pad.glance-pad .hover\:bg-slate-50:hover { background-color: var(--gp-panel-hover); }

/* Bars: red on a darker-cream track. (The Trains by Year columns are bars too.) */
.glance-pad.glance-pad .bg-slate-200 { background-color: var(--gp-track); }
.glance-pad.glance-pad .bg-slate-800,
.glance-pad.glance-pad .bg-slate-900 { background-color: var(--gp-red); }

/* Lettering on a panel. */
.glance-pad.glance-pad .text-slate-900,
.glance-pad.glance-pad .text-slate-800,
.glance-pad.glance-pad .text-slate-700,
.glance-pad.glance-pad .hover\:text-slate-900:hover { color: var(--gp-ink); }
.glance-pad.glance-pad .text-slate-600,
.glance-pad.glance-pad .text-slate-500,
.glance-pad.glance-pad .text-slate-400 { color: var(--gp-ink-soft); }
.glance-pad.glance-pad .text-red-700 { color: var(--gp-red); }
.glance-pad.glance-pad .text-blue-600 { color: #1d4ed8; }
.glance-pad.glance-pad .text-purple-600 { color: #7e22ce; }

/* Hairlines (a theme sets every border colour, so say it for all of them). */
.glance-pad.glance-pad *,
.glance-pad.glance-pad .border-slate-200 { border-color: var(--gp-track); }
.glance-pad.glance-pad .ring-slate-400 { --tw-ring-color: var(--gp-red); }

/* ---------------------------------------------------------------------------
   Bars / Pie switch (assets/js/glance-pie.js). In the pie view each breakdown
   chart gets a pie beside its list; the list stays as the legend, with a
   colour chip per row in place of the bar. The rows keep their height in
   both views, so switching never moves the panel about.

   Slice colours: slot 1 is the pad's red, then four hues chosen to stay
   apart from their neighbours (colour-blind checked against the cream
   panel). "Everything else" — what a top-5 list leaves out — is gold, and gets
   a legend row of its own in the pie view.
   Colours go to the largest slice first, in this fixed order.
   --------------------------------------------------------------------------- */
.glance-pad {
  --gp-pie-1: var(--gp-red, #b3261e);
  --gp-pie-2: #2f6f9f;
  --gp-pie-3: #2a8a4c;
  --gp-pie-4: #7b4f96;
  --gp-pie-5: #f2c200;      /* yellow */
  --gp-pie-rest: #b97f00;   /* gold: "Everything else" */
}

/* The switch: a small two-button control at the top right of the chart panel.
   Its row has a fixed height, so it holds its place before the script runs. */
.glance-pad.glance-pad .gp-toggle-row {
  display: flex;
  justify-content: flex-end;
  min-height: 1.5rem;
  margin-bottom: 0.5rem;
}
.glance-pad.glance-pad .gp-toggle {
  display: inline-flex;
  border: 1px solid var(--gp-ink-soft, #5f563f);
  border-radius: 999px;
  overflow: hidden;
}
.glance-pad.glance-pad .gp-toggle-btn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0.15rem 0.7rem;
  background: transparent;
  color: var(--gp-ink, #1c1917);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2rem;
  cursor: pointer;
}
.glance-pad.glance-pad .gp-toggle-btn[aria-pressed="true"] {
  background: var(--gp-red, #b3261e);
  color: #ffffff;
}
.glance-pad.glance-pad .gp-toggle-btn:focus-visible {
  outline: 2px solid var(--gp-ink, #1c1917);
  outline-offset: -2px;
}

/* Bars view (the default): the pie, the chips and the "Everything else"
   legend row are simply not there. */
.glance-pad.glance-pad .gp-pie,
.glance-pad.glance-pad .gp-chip,
.glance-pad.glance-pad:not(.gp-view-pie) .gp-rest-row { display: none; }

/* Pie view. */
.glance-pad.glance-pad.gp-view-pie .gp-chart {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.glance-pad.glance-pad.gp-view-pie .gp-chart > ul {
  flex: 1 1 0;
  min-width: 0;
}
.glance-pad.glance-pad.gp-view-pie .gp-pie {
  display: block;
  flex: 0 0 auto;
}
.glance-pad.glance-pad .gp-pie svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
/* A thin panel-coloured line between slices. */
.glance-pad.glance-pad .gp-slice {
  stroke: var(--gp-panel, #f9f1dd);
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.glance-pad.glance-pad .gp-slice--none { fill: var(--gp-track, #e4d7b3); }
.glance-pad.glance-pad .gp-pie a:hover .gp-slice,
.glance-pad.glance-pad .gp-pie a:focus-visible .gp-slice { opacity: 0.8; }
.glance-pad.glance-pad.gp-view-pie .gp-track { visibility: hidden; }
.glance-pad.glance-pad.gp-view-pie .gp-chip {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.3rem;
  border-radius: 2px;
  vertical-align: baseline;
}
/* Narrow charts (class set by the script): percentage only, so names fit. */
.glance-pad.glance-pad.gp-view-pie .gp-tight .gp-n { display: none; }
.glance-pad.glance-pad.gp-view-pie .gp-tight.gp-chart { gap: 0.4rem; }
@media (max-width: 639px) {
  .glance-pad.glance-pad.gp-view-pie .gp-chart { gap: 0.4rem; }
  .glance-pad.glance-pad.gp-view-pie .gp-chip { width: 0.45rem; height: 0.45rem; margin-right: 0.15rem; }
}
