/* OpenMV Battery Life Estimator -- standalone, iframe-friendly. */

:root {
  --bl-bg: #f6f7f9;
  --bl-card: #ffffff;
  --bl-text: #1c1f24;
  --bl-muted: #5b6470;
  --bl-border: #d8dde5;
  --bl-accent: #00a37a;
  --bl-accent-dark: #007a5b;
  --bl-warn: #c64a2a;
  --bl-result-bg: #eaf7f1;
  --bl-radius: 8px;
  --bl-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Dark-mode palette. Applied either when the user's OS prefers dark
   (standalone access) OR when the parent docs page has html.dark
   (Shibuya theme manual toggle, detected by app.js at runtime). */
@media (prefers-color-scheme: dark) {
  :root {
    --bl-bg: #14171c;
    --bl-card: #1f242c;
    --bl-text: #e6e8eb;
    --bl-muted: #9aa3b0;
    --bl-border: #2c333d;
    --bl-accent: #2bd0a3;
    --bl-accent-dark: #4ee0b8;
    --bl-warn: #f08a6a;
    --bl-result-bg: #1a2b25;
  }
}

html.bl-dark {
  --bl-bg: #14171c;
  --bl-card: #1f242c;
  --bl-text: #e6e8eb;
  --bl-muted: #9aa3b0;
  --bl-border: #2c333d;
  --bl-accent: #2bd0a3;
  --bl-accent-dark: #4ee0b8;
  --bl-warn: #f08a6a;
  --bl-result-bg: #1a2b25;
}

html.bl-light {
  --bl-bg: #f6f7f9;
  --bl-card: #ffffff;
  --bl-text: #1c1f24;
  --bl-muted: #5b6470;
  --bl-border: #d8dde5;
  --bl-accent: #00a37a;
  --bl-accent-dark: #007a5b;
  --bl-warn: #c64a2a;
  --bl-result-bg: #eaf7f1;
}

* { box-sizing: border-box; }

/* Make the HTML `hidden` attribute authoritative even when a class on
   the same element sets `display: grid` or `display: flex`. */
[hidden] { display: none !important; }

html {
  /* color-scheme tells the browser to use the matching system colors
     for unstyled UI (scrollbars, form-control chrome, etc.). app.js
     toggles `bl-dark` / `bl-light` on <html> based on the parent docs
     page's theme; we mirror that into color-scheme via the rules
     below. */
  color-scheme: light;
}

html.bl-dark { color-scheme: dark; }

html, body {
  margin: 0;
  padding: 0;
  /* Transparent so the calculator inherits the embedding page's
     background -- the step cards (and info cards) still keep their
     own white/dark fill so the structure remains legible. */
  background: transparent;
  color: var(--bl-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  html:not(.bl-light) { color-scheme: dark; }
}

.bl-app {
  max-width: 720px;
  margin: 0 auto;
  /* Standalone: 20px breathing room on every side.
     Embedded (html.bl-embedded, set by app.js when in an iframe):
     no padding -- the parent docs page provides its own margins. */
  padding: 20px 16px;
}

html.bl-embedded .bl-app { padding: 0; }

/* Strip the trailing margin off the last card so the visible gap above
   the first card matches the gap below the last card. */
.bl-app > :last-child { margin-bottom: 0; }

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

.bl-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  font-weight: 600;
}

.bl-sub {
  margin: 0;
  color: var(--bl-muted);
}

.bl-step {
  background: var(--bl-card);
  border: 1px solid var(--bl-border);
  border-radius: var(--bl-radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.bl-step h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bl-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bl-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.bl-opt {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--bl-muted);
}

.bl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
}

.bl-field > span {
  font-size: 0.85rem;
  color: var(--bl-muted);
}

.bl-field select,
.bl-field input[type="number"] {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--bl-border);
  background: var(--bl-bg);
  color: var(--bl-text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}

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

.bl-field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--bl-muted) 50%),
                    linear-gradient(135deg, var(--bl-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.bl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.bl-num-unit {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 6px;
}

.bl-num-unit input,
.bl-num-unit select {
  width: 100%;
}

.bl-hint {
  margin: 6px 0 0;
  color: var(--bl-muted);
  font-size: 0.85rem;
}

.bl-custom {
  margin-top: 10px;
  grid-template-columns: 1fr 1fr 1fr;
}

@media (max-width: 600px) {
  .bl-custom { grid-template-columns: 1fr; }
}

.bl-result {
  background: var(--bl-result-bg);
  border-color: var(--bl-accent);
}

.bl-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .bl-stats { grid-template-columns: 1fr; }
}

.bl-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bl-card);
  border-radius: 6px;
  border: 1px solid var(--bl-border);
}

.bl-stat .bl-label {
  font-size: 0.8rem;
  color: var(--bl-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bl-stat .bl-value {
  font-family: var(--bl-mono);
  font-size: 1.1rem;
  font-weight: 600;
}

.bl-stat-emph .bl-value {
  font-size: 1.2rem;
}

.bl-stat-result {
  grid-column: 1 / -1;
  background: var(--bl-accent);
  border-color: var(--bl-accent-dark);
}

.bl-stat-result .bl-label {
  color: rgba(255, 255, 255, 0.85);
}

.bl-stat-result .bl-value {
  color: #fff;
  font-size: 1.5rem;
}

.bl-disclaimer {
  margin: 12px 0 0;
  color: var(--bl-warn);
  font-size: 0.85rem;
  display: none;
}

.bl-disclaimer.show { display: block; }

/* Share link button at the bottom of the result panel. */
.bl-share {
  margin: 12px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bl-share button {
  background: transparent;
  color: var(--bl-text);
  border: 1px solid var(--bl-border);
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.bl-share button:hover {
  background: var(--bl-card);
}

.bl-share-msg {
  color: var(--bl-accent-dark);
  font-size: 0.85rem;
}

.bl-info {
  background: var(--bl-card);
  border: 1px solid var(--bl-border);
  border-radius: var(--bl-radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  color: var(--bl-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.bl-info h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--bl-text);
}

.bl-info p { margin: 6px 0; }

.bl-info ul {
  margin: 6px 0 6px 0;
  padding-left: 20px;
}

.bl-info li { margin: 4px 0; }

.bl-info strong { color: var(--bl-text); }

.bl-eq {
  font-family: var(--bl-mono);
  background: var(--bl-bg);
  border: 1px solid var(--bl-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.95rem;
  color: var(--bl-text);
  overflow-x: auto;
}

