/* RenoMath embeddable calculator — self-contained stylesheet.
   Loaded only by /embed/<slug>/ frames. Kept separate from styles.css so the
   iframe payload stays small (no header/footer/nav/ad rules) and so a host page
   can never inherit our page styles.
   Theme: follows the visitor's OS by default; ?theme=light|dark on the frame URL
   forces one, for hosts whose own site does not switch. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f4f2ed;
  --ink: #1a1a17;
  --ink-soft: #5d5c56;
  --ink-faint: #8b8981;
  --line: #e3e1da;
  --line-strong: #cdcac1;
  --accent: #1f5e4a;
  --accent-soft: #e7f0ec;
  --radius: 10px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1c1d17;
    --surface-alt: #22231c;
    --ink: #f2f1ec;
    --ink-soft: #a9a79e;
    --ink-faint: #7c7a72;
    --line: #303128;
    --line-strong: #45463a;
    --accent: #6cc4a2;
    --accent-soft: #1e2f27;
  }
}

/* Forced themes outrank the media query above on specificity (0,1,1 vs 0,1,0). */
html.theme-light {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f4f2ed;
  --ink: #1a1a17;
  --ink-soft: #5d5c56;
  --ink-faint: #8b8981;
  --line: #e3e1da;
  --line-strong: #cdcac1;
  --accent: #1f5e4a;
  --accent-soft: #e7f0ec;
}
html.theme-dark {
  --bg: #14150f;
  --surface: #1c1d17;
  --surface-alt: #22231c;
  --ink: #f2f1ec;
  --ink-soft: #a9a79e;
  --ink-faint: #7c7a72;
  --line: #303128;
  --line-strong: #45463a;
  --accent: #6cc4a2;
  --accent-soft: #1e2f27;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: transparent;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overflow: hidden; /* the parent sizes us; never show an inner scrollbar */
}

.reno-embed { padding: 2px; }

/* ---------------------------------------------------------------- form */

.calc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin: 0;
  overflow: hidden;
}

.calc-form { padding: 16px; }

.calc-fields {
  display: grid;
  /* 130px, not 148px: at a 320px host width the difference is one column of
     seven stacked fields (≈870px tall) versus two columns (≈560px). A long label
     wrapping to two lines is cheaper than tripling the frame height. */
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px 12px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.input-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-row input,
.input-row select {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  font-size: 15px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  appearance: none;
}
.input-row input::-webkit-outer-spin-button,
.input-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit {
  flex: none;
  padding: 8px 10px 8px 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.select-row { position: relative; }
.select-row select { cursor: pointer; padding-right: 24px; }
.select-row::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* -------------------------------------------------------------- result */

.calc-result {
  background: var(--accent-soft);
  border-top: 1px solid var(--line);
  padding: 16px;
}
.result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.result-primary {
  font-size: 32px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.result-unit { font-size: 14px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.result-rows { margin: 12px 0 0; border-top: 1px solid var(--accent); }
.result-rows dl { margin: 0; padding: 0; }
.result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.result-row:last-child { border-bottom: 0; padding-bottom: 0; }
.result-row dt { color: var(--ink-soft); margin: 0; }
.result-row dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.result-note {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* -------------------------------------------------------------- credit */

.reno-credit {
  display: flex;
  justify-content: flex-end;
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--ink-faint);
  text-decoration: none;
}
.reno-credit-by { white-space: nowrap; }
.reno-credit:hover .reno-credit-by { color: var(--accent); text-decoration: underline; }

@media (max-width: 460px) {
  .calc-form, .calc-result { padding: 14px; }
  .result-primary { font-size: 28px; }
}
