/* ============================================================================
   Prometheus Cardinality & Storage Estimator — tool layer.

   base.css is loaded immediately before this file and owns everything
   structural: reset, body, links, focus rings, headings, forms, .panel,
   .btn, .chip, tables, details, header, footer, .wrap, .badge, .stat.

   This file sets the tool's accent and styles only what is specific to this
   calculator: the global-inputs grid, the repeating metric/label rows, the
   "working" receipt and the danger callout tiers.

   Accent — violet. Measured with a WCAG relative-luminance script against
   the shared palette in base.css (see /scratchpad, not committed):
     dark   #c084fc on --bg        7.16:1   on --surface    6.60:1
                     on --bg-sunk  7.41:1
     light  #7e22ce on --bg        6.69:1   on --surface    6.98:1
   Both comfortably clear 4.5:1 (WCAG AA, normal text) in both themes.

   Distinctness from existing accents (HSL hue, dark-mode swatches):
     cron indigo 230°, aspect teal 172°, epoch amber 43°, days rose 351°,
     contrast green 142°, json sky 198°, regex fuchsia 292°.
   This violet sits at 270° — 40° from indigo, 22° from fuchsia, the two
   nearest neighbours — a distinct hue band from every sibling tool.
   ========================================================================= */

:root {
  --accent:     #c084fc;
  --accent-dim: rgba(192, 132, 252, 0.14);
}

@media (prefers-color-scheme: light) {
  :root {
    --accent:     #7e22ce;
    --accent-dim: rgba(126, 34, 206, 0.10);
  }
}

/* --------------------------------------------------------------- utility -- */

[hidden] { display: none !important; }

main ul, main ol { padding-left: 1.25em; margin: 0 0 1.1em; }
main li { margin-bottom: 0.4em; }

.content p, .content ul, .content ol { max-width: 68ch; }
.content .card-links { max-width: none; }
.content h2:first-child { margin-top: 0; }

/* -------------------------------------------------------- the instrument -- */
/* .tool carries .panel */

.tool { margin-bottom: 2rem; }

/* --------------------------------------------------------- global inputs -- */

.global-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
  gap: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

/* .field is `display: grid` in base.css, and .global-inputs stretches every
   field to the tallest row. The two unit fields are the only ones with no
   .field-hint, so they were short and their auto rows absorbed all the
   leftover height — the controls measured 93px against the other fields'
   43px. Pinning the rows to their natural size lines all five up. */
.global-inputs .field { align-content: start; }

/* Value + unit is one control, so it gets one box: the number input and the
   unit select sit inside a single border as segments. This keeps these two
   fields presenting exactly like the plain full-width ones beside them,
   rather than as two loose controls of differing widths. The border, hover
   and focus ring move to the wrapper; the segments go transparent. */
.input-group {
  display: flex;
  align-items: stretch;
  background: var(--bg-sunk);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input-group:hover { border-color: var(--text-faint); }
.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-group > input {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: transparent;
}
.input-group > select {
  flex: 0 0 auto;
  width: auto;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  /* background-COLOR only — base.css carries the chevron in background-image,
     and the shorthand would erase it. */
  background-color: transparent;
}

/* The wrapper draws the focus ring for the whole group, so neither segment
   may draw its own, and neither may repaint the divider on hover. */
.input-group > input:hover,
.input-group > input:focus-visible,
.input-group > select:hover,
.input-group > select:focus-visible {
  border-color: var(--line);
  box-shadow: none;
  outline: none;
}

.field-hint {
  margin: 0.3rem 0 0;
  font-size: 0.78125rem;
  color: var(--text-faint);
  line-height: 1.45;
}
.field-hint a { color: var(--text-faint); text-decoration-color: var(--line-strong); }
.field-hint a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.example-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

/* ------------------------------------------------------------ metric rows -- */

.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* .metric-row carries .panel-sunk */
.metric-row { position: relative; }

.metric-row-head {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.6rem;
  align-items: end;
  margin-bottom: 0.9rem;
}

.metric-series-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin: 0.7rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
}
.metric-series-readout .stat-value { font-size: 1.1rem; color: var(--accent); }

.labels-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.label-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.label-row .field-label {
  display: none;   /* shown once per metric-row via .labels-head instead */
}

.labels-head {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.labels-head span { visibility: hidden; }   /* spacer under the remove col */

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.icon-btn:hover { color: var(--err); border-color: var(--err); background: var(--err-bg); }

.remove-metric-btn {
  align-self: start;
}

.no-metrics {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9375rem;
}

/* ---------------------------------------------------------------- badges -- */

.tier-ok    { color: var(--ok);   background: var(--ok-bg); }
.tier-warn  { color: var(--warn); background: var(--warn-bg); }
.tier-danger,
.tier-danger.badge { color: var(--err); background: var(--err-bg); }

/* ----------------------------------------------------------------- receipt -- */
/* The working, shown as an ordered list of steps rather than a bare answer.
   Each step names its inputs so the arithmetic can be checked by hand. */

.receipt {
  margin: 0 0 1.4rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.receipt li {
  counter-increment: step;
  position: relative;
  padding: 0.6rem 0 0.6rem 2.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
}
.receipt li:last-child { border-bottom: 0; }
.receipt li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0.55rem;
  width: 1.6rem; height: 1.6rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 50%;
}
.receipt .step-label { color: var(--text-dim); }
.receipt .step-value {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 1.0625rem;
  font-weight: 640;
  color: var(--text);
}
.receipt .step-value strong { color: var(--accent); font-weight: 640; }

.results-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.1rem;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------------------------------------------------------- danger callout -- */

.danger-callout {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1.1rem;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  font-size: 0.9375rem;
  color: var(--text-dim);
}
.danger-callout > :last-child { margin-bottom: 0; }
.danger-callout strong { color: var(--text); }
.danger-callout.is-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.danger-callout.is-danger { border-left-color: var(--err); background: var(--err-bg); }
.danger-callout a { color: inherit; text-decoration-color: var(--line-strong); }
.danger-callout a:hover { text-decoration-color: currentColor; }

/* -------------------------------------------------------- privacy callout -- */

.callout {
  margin: 1.4em 0;
  padding: 0.9rem 1.1rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-dim);
  font-size: 0.9375rem;
  color: var(--text-dim);
}
.callout > :last-child { margin-bottom: 0; }
.callout strong { color: var(--text); }

/* ------------------------------------------------------------- worked ex. -- */

.example { margin-bottom: 1rem; }
.example h3 { margin-top: 0; }
.example > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------ card links -- */

.card-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
  gap: 0.75rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}
.card-links li { margin: 0; }
.card-links a {
  display: block;
  height: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.card-links a:hover { border-color: var(--accent); background: var(--surface-2); }
.card-links strong { display: block; font-size: 0.9375rem; }
.card-links span {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8125rem;
  color: var(--text-dim);
}
.card-links a:hover span { color: var(--accent); }

.sources { font-size: 0.9375rem; }
.sources li { margin-bottom: 0.6em; }
.source-note { color: var(--text-dim); }

/* --------------------------------------------------------------- table --- */

.table-scroll { overflow-x: auto; margin-inline: calc(var(--gut) * -1); padding-inline: var(--gut); }

/* ------------------------------------------------------------- responsive -- */

@media (max-width: 30rem) {
  .metric-row-head { grid-template-columns: 1fr; }
  .label-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .labels-head { display: none; }
  .label-row .field-label { display: block; visibility: visible; }
}
