/*
 * Calculator-specific styles extending ../assets/site.css for
 * /telescope-calculator/ so it shares the Hybrid C Wayfinder Bento palette,
 * auto light/dark tokens, and Low-Vision Mode (?view=accessible).
 */

:root {
  --calc-single: light-dark(#2c5c8f, #7ec4f8);
  --calc-array: light-dark(#c45506, #f7a048);
  --calc-bad: light-dark(#b02a22, #ff8f87);
  --calc-bad-bg: light-dark(#fdeceb, #3a1c1a);
  --calc-input-bg: light-dark(#ffffff, #1d1b18);

  --chart-bg: light-dark(#f6f1e7, #1c1b18);
  --chart-grid: light-dark(#dfd6c6, #322f29);
  --chart-label: light-dark(#4e483e, #bdb5a7);
  --chart-ref: light-dark(#6c6458, #9c9488);
}

.page-shell.calc-shell {
  max-width: 1180px;
}

.brand-link {
  text-decoration: none;
}

.brand-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.calc-header {
  margin-bottom: 20px;
}

.calc-title {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 29px);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.calc-title .thin {
  color: var(--muted);
  font-weight: 400;
}

.calc-sub {
  color: var(--muted);
  max-width: 74ch;
  margin: 0;
  font-size: 14.5px;
}

.mono-inline {
  font-family: var(--mono);
  color: var(--ink);
}

.refs {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12.5px;
}

.refs a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.calc-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

.sticky {
  position: sticky;
  top: 18px;
}

@media (max-width: 900px) {
  .sticky {
    position: static;
  }
}

.win + .win {
  margin-top: 16px;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.labrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.row {
  display: flex;
  gap: 8px;
}

.row > input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
}

select,
input[type="number"] {
  background: var(--calc-input-bg);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 14px;
  font-family: var(--mono);
}

select {
  cursor: pointer;
  font-size: 12.5px;
  flex: 0 0 auto;
  padding-right: 6px;
}

.select-full {
  width: 100%;
}

.select-compact {
  padding: 2px 6px;
  font-size: 11.5px;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select:focus,
input[type="number"]:focus {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  background: var(--tint);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-family: var(--mono);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.chip:hover {
  border-color: var(--tab-apricot-bg);
  background: var(--paper);
}

.chip-static {
  cursor: default;
  color: var(--muted);
}

.chip-static:hover {
  border-color: var(--line);
  background: var(--tint);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--tint);
  margin-bottom: 14px;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sw {
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  flex: 0 0 auto;
  transition: background 0.16s ease;
}

.sw::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--edge);
  transition: transform 0.16s ease;
}

.toggle input:checked + .sw {
  background: var(--tab-sage-bg);
}

.toggle input:checked + .sw::after {
  transform: translateX(15px);
}

.toggle .tl {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.toggle input:focus-visible + .sw {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Skip target is focused programmatically on skip-link click. */
#results:focus {
  outline: none;
}

.big {
  background: var(--paper);
  border: 1.5px solid var(--edge);
  border-left: 5px solid var(--calc-single);
  box-shadow: 3px 3px 0 var(--shadow);
  padding: 15px 18px;
  margin-bottom: 14px;
}

.big.array {
  border-left-color: var(--calc-array);
}

.big[hidden] {
  display: none;
}

.big .k {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  font-weight: 700;
}

.big .k .tag {
  font-family: var(--mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.val {
  font-family: var(--mono);
  font-size: clamp(28px, 4.5vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  word-break: break-word;
}

.val .u {
  font-size: 0.44em;
  color: var(--muted);
  margin-left: 0.28em;
  letter-spacing: 0;
}

.subv {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
  word-break: break-word;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.card {
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.card .ck {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.card .cv {
  font-family: var(--mono);
  font-size: 16.5px;
  color: var(--ink);
  word-break: break-word;
}

.card .cv .u {
  font-size: 0.66em;
  color: var(--muted);
  margin-left: 0.2em;
}

.note {
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.note b {
  color: var(--ink);
  font-weight: 650;
}

/* Off-screen live region for debounced screen-reader announcements. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.err {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--calc-bad-bg);
  border: 1.5px solid var(--calc-bad);
  border-radius: 6px;
  color: var(--calc-bad);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.err[hidden] {
  display: none;
}

input[type="number"][aria-invalid="true"] {
  border-color: var(--calc-bad);
  outline: 2px solid var(--calc-bad);
  outline-offset: 1px;
}

/* SVG Log-Log Chart styled via CSS tokens so Auto/Light/Dark switches update live */
svg#chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-bg {
  fill: var(--chart-bg);
  stroke: var(--line);
  stroke-width: 1.2;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-label {
  fill: var(--chart-label);
  font-family: var(--mono);
  font-size: 11px;
}

.chart-axis {
  fill: var(--muted);
  font-size: 12px;
}

.chart-empty {
  fill: var(--muted);
  font-size: 13px;
}

.chart-ref-line {
  stroke: var(--chart-ref);
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
}

.chart-ref-label {
  fill: var(--chart-label);
  font-family: var(--mono);
  font-size: 11px;
}

.chart-curve-single {
  fill: none;
  stroke: var(--calc-single);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-curve-array {
  fill: none;
  stroke: var(--calc-array);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-item[hidden] {
  display: none;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.swatch-single { background: var(--calc-single); }
.swatch-array { background: var(--calc-array); }
.swatch-ref { background: var(--chart-ref); }

.eq {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
}

.eq em {
  color: var(--calc-single);
  font-style: normal;
  font-weight: 700;
}

.eq .c {
  color: var(--calc-array);
}

.prose {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 82ch;
  margin: 0;
}

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.physics-list {
  padding-left: 18px;
  margin: 0;
}

.physics-list li {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13.5px;
}

.physics-list li b {
  color: var(--ink);
  font-weight: 650;
}

/* Low-Vision & Screen-Reader Mode (?view=accessible) */
:root[data-a11y-mode="accessible"] {
  --calc-single: light-dark(#0b4a8c, #8cc4ff);
  --calc-array: light-dark(#9e3a00, #ffd35c);
}

:root[data-a11y-mode="accessible"] .page-shell.calc-shell {
  max-width: 68ch;
}

:root[data-a11y-mode="accessible"] .calc-grid {
  grid-template-columns: 1fr;
}

:root[data-a11y-mode="accessible"] .sticky {
  position: static;
}

:root[data-a11y-mode="accessible"] .big,
:root[data-a11y-mode="accessible"] .card,
:root[data-a11y-mode="accessible"] .eq,
:root[data-a11y-mode="accessible"] .chip,
:root[data-a11y-mode="accessible"] select,
:root[data-a11y-mode="accessible"] input[type="number"] {
  background: transparent;
  color: inherit;
  border: 1.5px solid currentColor;
  box-shadow: none;
}

:root[data-a11y-mode="accessible"] .calc-sub,
:root[data-a11y-mode="accessible"] .hint,
:root[data-a11y-mode="accessible"] .subv,
:root[data-a11y-mode="accessible"] .note,
:root[data-a11y-mode="accessible"] .prose,
:root[data-a11y-mode="accessible"] .physics-list li,
:root[data-a11y-mode="accessible"] .legend {
  color: inherit;
  font-size: 1rem;
}

:root[data-a11y-mode="accessible"] .chart-curve-single,
:root[data-a11y-mode="accessible"] .chart-curve-array {
  stroke-width: 3px;
}

:root[data-a11y-mode="accessible"] .chart-label,
:root[data-a11y-mode="accessible"] .chart-ref-label {
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .chip,
  .sw,
  .sw::after {
    transition: none;
  }
}

@media (forced-colors: active) {
  .big,
  .card,
  .chip,
  .toggle,
  .eq,
  select,
  input[type="number"] {
    border: 1px solid CanvasText;
    box-shadow: none;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
}
