/* SolarCalc — light "sunlit paper" theme.
   Warm off-white surfaces, amber sun primary and deep-sky accent: a rooftop-at-
   noon palette, deliberately the opposite of sibling EVCharge's dark dashboard
   on the same domain. All colors flow through base vars. */

:root {
  --bg: #fdfaf2;
  --surface: #faf4e6;
  --surface-2: #f2ead7;
  --text: #2a2117;
  --text-dim: #6d6350;
  --border: #e6d9bd;
  --sc-dim: #6d6350;
  --sc-glow: rgba(217, 119, 6, 0.07);
  --sc-panel: #17365d;
}
html {
  color-scheme: light;
}

/* ---------- calculator shell ---------- */
.sc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 1.4rem 0 1.8rem;
  box-shadow: 0 16px 44px -34px rgba(120, 84, 20, 0.55);
  overflow: hidden;
}
@media (min-width: 54rem) {
  .prose .sc {
    width: min(62rem, calc(100vw - 2.5rem));
  }
}

/* ---------- input grid ---------- */
.sc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.6rem, 1fr));
  gap: 0.7rem 0.8rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(90deg, transparent 0 2.4rem, var(--sc-glow) 2.4rem calc(2.4rem + 1px)),
    var(--surface-2);
}
.sc-sec {
  grid-column: 1 / -1;
  margin: 0.35rem 0 -0.1rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
}
.sc-sec:first-child {
  margin-top: 0;
}
.sc-f {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}
.sc-f-wide {
  grid-column: span 2;
}
.sc-f > span,
.sc-mode > span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sc-f small {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
}
.sc input[type="text"],
.sc select {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.38rem 0.5rem;
  box-sizing: border-box;
  width: 100%;
  min-height: 2.75rem; /* 44px tap target */
}
.sc select {
  font-family: var(--font);
  font-size: 0.86rem;
}
.sc input:focus,
.sc select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

/* sizing-mode segmented control */
.sc-mode {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.sc-mode-opts {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  min-height: 2.875rem;
}
.sc-mode-opts label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg);
  cursor: pointer;
}
.sc-mode-opts label + label {
  border-inline-start: 1px solid var(--border);
}
.sc-mode-opts input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.sc-mode-opts label:has(input:checked) {
  background: color-mix(in srgb, var(--primary) 14%, var(--bg));
  color: var(--primary);
}
.sc-mode-opts label:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* checkbox row (itemize losses) */
.sc-chk {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  align-self: end;
  min-height: 2.75rem;
  cursor: pointer;
}
.sc-chk input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
  flex: none;
}
.sc-chk span {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text);
}

/* itemized losses subgrid — hidden attr respected (P015) */
.sc-lossgrid {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  background: var(--bg);
}
.sc-lossgrid:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.6rem 0.7rem;
}
.sc-lossreadout {
  margin: 0;
  align-self: end;
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 0.55rem;
}
.sc-tiltfactor:not([hidden]) {
  display: flex;
}

/* ---------- hero ---------- */
.sc-hero {
  display: block;
  padding: 1.1rem 1rem 0.9rem;
  font-size: 1.02rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sc-hero strong {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.sc-herosub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.sc-hint {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---------- result cards ---------- */
.sc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.55rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.55rem 0.7rem;
}
.sc-card.is-key {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}
.sc-card .k {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sc-card strong {
  display: block;
  font-size: 1.12rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  margin: 0.1rem 0;
}
.sc-card.is-key strong {
  color: var(--primary);
}
.sc-card small {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}

/* ---------- chart ---------- */
.sc-chartwrap {
  padding: 0.9rem 1rem 0.4rem;
  border-bottom: 1px solid var(--border);
}
.sc-chart {
  width: 100%;
  display: block;
}
.sc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.76rem;
  color: var(--text-dim);
  padding: 0.3rem 0 0.5rem;
}
.sc-legend i {
  display: inline-block;
  width: 0.9rem;
  height: 0.22rem;
  border-radius: 2px;
  margin-inline-end: 0.35rem;
  vertical-align: middle;
}
.sc-legend i.dash {
  background: none !important;
  border-top: 2px dashed;
  height: 0;
}
.sc-export {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  margin: 0 0 0.6rem;
  min-height: 2.75rem;
}
.sc-export:hover {
  border-color: var(--accent);
}

/* ---------- projection table ---------- */
.sc-tblwrap {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sc-tblwrap:not([hidden]) {
  display: block;
}
.sc-tbltitle {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.55rem;
}
.sc-years {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.sc-years th {
  text-align: start;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding: 0.3rem 0.4rem;
}
.sc-years td {
  border-bottom: 1px dashed var(--border);
  padding: 0.32rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.sc-years tr:last-child td {
  border-bottom: none;
}
.sc-years td:first-child {
  font-family: var(--font);
  font-weight: 650;
}

/* ---------- notes ---------- */
.sc-notes {
  margin: 0;
  padding: 0.8rem 1rem 1rem 1.9rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.sc-notes li {
  margin: 0.28rem 0;
  line-height: 1.45;
}
.sc-notes li::marker {
  color: var(--accent);
}

/* ---------- article polish ---------- */
.prose table {
  font-variant-numeric: tabular-nums;
}
.prose table code {
  white-space: nowrap;
}
.formula {
  display: block;
  font-family: var(--mono);
  font-size: 0.92rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin: 0.8rem 0;
  overflow-x: auto;
}

/* ---------- mobile ---------- */
@media (max-width: 40rem) {
  .sc-f-wide {
    grid-column: 1 / -1;
  }
  .sc-hero strong {
    font-size: 1.28rem;
  }
}
@media (max-width: 53.99rem) {
  .prose .sc {
    display: flex;
    flex-direction: column;
  }
  .sc-hero {
    order: -2;
    border-top: 1px solid var(--border);
  }
  .sc-cards {
    order: -1;
    border-bottom: 0;
  }
}
