/*
Electrical Calculators — scoped, self-contained styling.

Marketing pages run Tailwind preflight (resets form-element defaults);
portal pages do not. Every element used inside .calc-* markup must be
fully styled here so the shared partials render identically under both
shells — do not rely on either surface's ambient styles or the browser
default stylesheet for anything under .calc-*.
*/

.calc-tile-grid, .calc-tile-section, .calc-engine, .calc-disclaimer, .calc-portal-header {
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}
.calc-tile-grid *, .calc-tile-section *, .calc-engine *, .calc-disclaimer * { box-sizing: border-box; }

/* ── Tile grid (index pages) ───────────────────────────────────────── */
.calc-tile-section { margin-bottom: 36px; }
.calc-tile-section:last-child { margin-bottom: 0; }
.calc-tile-section-title {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: #111111;
  margin: 0 0 16px;
}
/* Extra breathing room above every section after the first, on top of the
   36px .calc-tile-section gap - same amount as the title-to-tile-grid gap
   above, so the previous section's tiles don't crowd the next heading. */
.calc-tile-section + .calc-tile-section .calc-tile-section-title {
  margin-top: 16px;
}
.calc-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: stretch;
  gap: 16px;
}
.calc-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #E5E9EE;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.calc-tile:hover {
  border-color: #4DB7FF;
  box-shadow: 0 4px 20px rgba(15,23,42,0.08);
  transform: translateY(-1px);
}
.calc-tile-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #2A9BE6;
  background: rgba(77,183,255,0.14);
  padding: 3px 8px;
  border-radius: 999px;
}
/* Public-surface-only state for a portal_only calculator (see
   calculators/registry.py) - tile still links through, but to the locked
   landing page (calculators/public/_locked.html), never the real
   calculator. Portal tile grid never renders this - full access there. */
.calc-tile--locked { background: #FAFAFA; }
.calc-tile--locked:hover { border-color: #E5E9EE; box-shadow: none; transform: none; }
.calc-tile--locked .calc-tile-icon { background: rgba(91,100,112,0.10); color: #5B6470; }
.calc-tile--locked .calc-tile-name,
.calc-tile--locked .calc-tile-description { color: #98A2B3; }
.calc-tile-badge--locked {
  color: #92702A;
  background: rgba(234,179,8,0.14);
  display: inline-flex;
  align-items: center;
}
.calc-tile-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(77,183,255,0.12);
  color: #2A9BE6;
  flex-shrink: 0;
}
.calc-tile-icon svg { width: 22px; height: 22px; }
.calc-tile-name {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  color: #111111;
  /* Reserve 2 lines' worth of height even for a one-line title, and clamp
     longer titles to 2 lines, so every tile in a row is the same height
     regardless of name length (e.g. "Healthy Homes Heating Assessment"
     next to "Heat Pump Size Calculator"). */
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.calc-tile-description {
  font-size: 13px;
  line-height: 1.5;
  color: #5B6470;
  /* Same reasoning as .calc-tile-name - reserve/clamp to 2 lines so
     description length doesn't change the tile's overall height. */
  min-height: 3em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Disclaimer box ───────────────────────────────────────────────── */
.calc-disclaimer {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: #92400E;
  margin-top: 28px;
}
.calc-disclaimer p { margin: 0; }
.calc-disclaimer--compact { padding: 12px 14px; font-size: 12.5px; }

/* ── Calculator engine shell (Phase 2 builds real content here) ──────── */
.calc-engine { color: #111111; font-size: 14px; }
.calc-placeholder-note { color: #5B6470; font-style: italic; margin: 0; padding: 24px 0; text-align: center; }

/* ── Form controls (ready for Phase 2) ───────────────────────────────── */
.calc-field { margin-bottom: 16px; }
.calc-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #111111;
  margin-bottom: 6px;
}
.calc-input, .calc-select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  color: #111111;
  background: #ffffff;
  border: 1px solid #D1D5DB;
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  line-height: 1.4;
}
.calc-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6470' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}
.calc-input:focus, .calc-select:focus {
  outline: none;
  border-color: #4DB7FF;
  box-shadow: 0 0 0 3px rgba(77,183,255,0.25);
}
.calc-help-text { font-size: 12px; color: #5B6470; margin-top: 4px; }
.calc-input--readonly { background: #F7F9FB; color: #5B6470; cursor: default; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.calc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: #ffffff;
  background: #4DB7FF;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.calc-btn:hover { background: #2A9BE6; }
.calc-btn--secondary {
  color: #111111;
  background: #F7F9FB;
  border: 1px solid #E5E9EE;
}
.calc-btn--secondary:hover { background: #EEF2F6; }

/* ── Result / pass-fail badges ────────────────────────────────────── */
.calc-result { margin-top: 20px; padding-top: 16px; border-top: 1px solid #E5E9EE; }
.calc-result-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.calc-result-col {
  flex: 1 1 200px;
  min-width: 200px;
}
.calc-result-col-heading {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5B6470;
}
.calc-cable-option {
  border: 1px solid #E5E9EE;
  border-radius: 12px;
  padding: 16px;
}
.calc-cable-option + .calc-cable-option { margin-top: 12px; }
.calc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}
.calc-badge--pass { color: #067647; background: rgba(6,118,71,0.12); }
.calc-badge--fail { color: #B42318; background: rgba(180,35,24,0.12); }
.calc-working {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  color: #5B6470;
  background: #F7F9FB;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  white-space: pre-wrap;
}

/* ── Mode toggle (segmented buttons) ─────────────────────────────────
   Heat Pump Size Calculator's mode switch - two mutually exclusive
   states, styled distinctly from a plain <select> since it's a primary,
   always-visible control rather than a form field. */
.calc-toggle-group {
  display: flex;
  border: 1px solid #E5E9EE;
  border-radius: 12px;
  padding: 4px;
  background: #F7F9FB;
  gap: 4px;
  margin-bottom: 20px;
}
.calc-toggle-btn {
  flex: 1 1 0;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  color: #5B6470;
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.calc-toggle-btn:hover { color: #111111; }
.calc-toggle-btn--active {
  background: #ffffff;
  color: #111111;
  box-shadow: 0 1px 4px rgba(15,23,42,0.12);
}
.calc-toggle-btn:focus-visible {
  outline: 2px solid #4DB7FF;
  outline-offset: 2px;
}

/* ── Selectable cards (insulation level) ─────────────────────────────── */
.calc-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.calc-card {
  text-align: left;
  padding: 14px 16px;
  background: #ffffff;
  border: 1.5px solid #D1D5DB;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.calc-card:hover { border-color: #4DB7FF; }
.calc-card:focus-visible { outline: 2px solid #4DB7FF; outline-offset: 2px; }
.calc-card--selected {
  border-color: #4DB7FF;
  box-shadow: 0 0 0 3px rgba(77,183,255,0.18);
}
.calc-card-title { font-weight: 700; font-size: 13.5px; color: #111111; margin: 0 0 4px; }
.calc-card-desc { font-size: 12.5px; color: #5B6470; margin: 0; line-height: 1.45; }
.calc-insulation-group--error .calc-card { border-color: #B42318; }

/* ── Checkbox fields ──────────────────────────────────────────────── */
.calc-checkbox-field { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.calc-checkbox { width: 18px; height: 18px; min-width: 18px; margin-top: 2px; accent-color: #4DB7FF; cursor: pointer; }
.calc-checkbox-label { font-size: 13.5px; color: #111111; cursor: pointer; line-height: 1.4; }

/* ── Inline field validation ─────────────────────────────────────────── */
.calc-input--error, select.calc-input--error, .calc-select.calc-input--error { border-color: #B42318 !important; }
.calc-field-error { font-size: 12px; color: #B42318; margin-top: 4px; display: none; }

/* ── Submit button disabled state ────────────────────────────────────── */
.calc-btn:disabled { background: #D1D5DB; color: #ffffff; cursor: not-allowed; }
.calc-btn:disabled:hover { background: #D1D5DB; }

/* ── Collapsible breakdown (native <details>, styled to match
   .calc-working's look but genuinely collapsible) ────────────────────── */
.calc-details { border-top: 1px solid #E5E9EE; padding-top: 12px; }
.calc-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #2A9BE6;
  list-style: none;
}
.calc-details summary::-webkit-details-marker { display: none; }
.calc-details summary:before { content: "▸ "; }
.calc-details[open] summary:before { content: "▾ "; }
.calc-breakdown { margin-top: 10px; }
.calc-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
}
.calc-breakdown-row span:first-child { color: #5B6470; }
.calc-breakdown-row span:last-child { color: #111111; font-weight: 600; }

@media (max-width: 640px) {
  .calc-tile-grid { grid-template-columns: 1fr; }
  .calc-toggle-group { flex-direction: column; }
}
