/*
 * wiki-calculators.css — Poly-Sim Calculator Pages (all languages)
 * Complements wiki-translated.css; provides calculator-specific components.
 * ─────────────────────────────────────────────────────────────────────────
 * Scope: .calc-card, .calc-field, .calc-btn, .calc-result, .calc-formula,
 *        .calc-explainer-grid, range inputs, result states
 * ─────────────────────────────────────────────────────────────────────────
 */

/* ─── CWV: font-display swap (calculator pages share wiki-translated.css;   */
/*     this declaration is a safety fallback if calc pages load only this    */
/*     file without wiki-translated.css)                                     */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: local('Inter');
}

/* ─── CALCULATOR CARD ───────────────────────────────────────────────────── */
.calc-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 24px 22px;
  margin-bottom: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.calc-card-title {
  font-size: 17px; font-weight: 800; color: #0f172a;
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

/* ─── FIELDS ────────────────────────────────────────────────────────────── */
.calc-field {
  margin-bottom: 20px;
}
.calc-label {
  display: block;
  font-size: 13px; font-weight: 700; color: #1e293b;
  margin-bottom: 4px;
}
.calc-hint {
  display: block;
  font-size: 11px; color: #94a3b8;
  margin-bottom: 8px;
}

/* Text / Number inputs */
.calc-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 15px; color: #0f172a;
  background: #f8fafc;
  font-family: inherit;
  transition: border-color .15s, background .15s;
  min-height: 44px;
  outline: none;
}
.calc-input:focus { border-color: #0284c7; background: #fff; box-shadow: 0 0 0 2px rgba(2,132,199,.12); }

/* Select */
.calc-select {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 14px; color: #0f172a;
  background: #f8fafc; font-family: inherit;
  min-height: 44px; cursor: pointer; outline: none;
  transition: border-color .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}
[dir="rtl"] .calc-select {
  background-position: right 12px center;
  padding-left: 14px; padding-right: 32px;
}
.calc-select:focus { border-color: #0284c7; }

/* Range inputs */
.calc-range-wrap { display: flex; align-items: center; gap: 12px; }
.calc-range {
  flex: 1; height: 5px; border-radius: 99px;
  accent-color: #0284c7; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: linear-gradient(to right, #0284c7 0%, #0284c7 60%, #e2e8f0 60%);
  outline: none;
}
.calc-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: #0284c7;
  border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15);
  cursor: pointer;
}
.calc-range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #0284c7; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.15); cursor: pointer;
}
.calc-range-val {
  font-size: 14px; font-weight: 800; color: #0284c7;
  min-width: 40px; text-align: center;
}
.calc-range-labels {
  display: flex; justify-content: space-between;
  font-size: 10px; color: #94a3b8; margin-top: 4px;
}

/* ─── CALCULATE BUTTON ──────────────────────────────────────────────────── */
.calc-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 20px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff; font-size: 16px; font-weight: 800;
  border: none; border-radius: 10px; cursor: pointer;
  min-height: 52px; margin-top: 4px;
  font-family: inherit; letter-spacing: .01em;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  box-shadow: 0 4px 16px rgba(2,132,199,.35);
}
.calc-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(2,132,199,.45); }
.calc-btn:active { transform: translateY(0); opacity: .9; }

/* ─── RESULT BOX ────────────────────────────────────────────────────────── */
.calc-result {
  display: none; margin-top: 20px;
  border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 20px 18px; background: #f8fafc;
}
.calc-result.visible { display: block; }
.calc-result h3 { font-size: 14px; font-weight: 700; color: #64748b; margin-bottom: 14px; }
.result-primary {
  font-size: 2rem; font-weight: 900; color: #0f172a;
  letter-spacing: -.02em; margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}
.result-breakdown {
  list-style: none; padding: 0; margin: 0;
  border-top: 1px solid #e2e8f0; padding-top: 12px;
}
.result-breakdown li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid #f1f5f9;
  font-size: 13px; color: #475569;
}
.result-breakdown li:last-child { border-bottom: none; }
.result-breakdown strong { color: #0f172a; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Result state modifiers */
.calc-positive { border-color: rgba(22,163,74,.25); background: rgba(22,163,74,.04); }
.calc-positive .result-primary { color: #16a34a; }
.calc-negative { border-color: rgba(220,38,38,.25); background: rgba(220,38,38,.04); }
.calc-negative .result-primary { color: #dc2626; }

/* ─── INTERPRETATION ────────────────────────────────────────────────────── */
.calc-interpretation {
  display: none; margin-top: 14px;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; line-height: 1.6; font-weight: 500;
  background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0;
}
.calc-interpretation.visible { display: block; }

/* ─── FORMULA BOX ───────────────────────────────────────────────────────── */
.calc-formula {
  background: #0f172a; border-radius: 10px;
  padding: 16px 20px; margin: 20px 0;
  font-family: 'JetBrains Mono','Courier New',monospace;
  color: #e2e8f0; font-size: 14px; line-height: 1.8;
}
.calc-formula code {
  display: block; color: #4ade80; font-size: 16px;
  font-weight: 700; letter-spacing: .02em; margin-bottom: 4px;
  background: none; border: none; padding: 0;
}
.calc-formula-title {
  font-size: 10px; font-weight: 700; color: #475569;
  text-transform: uppercase; letter-spacing: .1em;
  display: block; margin-bottom: 10px;
}

/* ─── EXPLAINER GRID (3-col feature cards) ──────────────────────────────── */
.calc-explainer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin: 20px 0;
}
.calc-explainer-item {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 16px 14px; text-align: center;
}
.calc-explainer-icon { font-size: 24px; margin-bottom: 8px; }
.calc-explainer-item h4 { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
.calc-explainer-item p { font-size: 12px; color: #64748b; line-height: 1.55; margin: 0; }

/* ─── CALC TABLE (inside explainer section) ─────────────────────────────── */
.calc-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 16px 0; border-radius: 10px; border: 1px solid #e2e8f0; }
.calc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.calc-table th { background: #f1f5f9; color: #0f172a; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.calc-table td { padding: 9px 12px; color: #374151; border-bottom: 1px solid #f1f5f9; }
.calc-table tr:last-child td { border-bottom: none; }

/* ─── LONG-FORM CONTENT BLOCKS ───────────────────────────────────────────
   Calculator pages in every locale carry a real article-style body under the
   tool (explainer / worked example / FAQ), not just a formula line. These
   blocks style that prose so the page reads as a genuine answer to a query.
   .calc-info   — white card wrapping one content section
   .formula-box — readable formula callout (monospace for the maths only)
   ──────────────────────────────────────────────────────────────────────── */
.calc-info {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 20px;
  margin-bottom: 22px;
}
.calc-info h2 {
  font-size: 18px; font-weight: 800; color: #0f172a;
  margin: 0 0 12px; line-height: 1.35;
}
.calc-info h3 {
  font-size: 14.5px; font-weight: 700; color: #1e293b;
  margin: 20px 0 6px;
}
.calc-info p {
  font-size: 14px; line-height: 1.75; color: #334155;
  margin: 0 0 12px;
}
.calc-info p:last-child { margin-bottom: 0; }
.calc-info ul, .calc-info ol { margin: 0 0 12px; padding-left: 22px; }
.calc-info li { font-size: 14px; line-height: 1.7; color: #334155; margin-bottom: 7px; }
.calc-info li:last-child { margin-bottom: 0; }
.calc-info strong { color: #0f172a; font-weight: 700; }

/* Scoped to .calc-info deliberately. Several existing es/fr calculator pages
   nest an UNSTYLED .formula-box inside .calc-formula (a dark navy monospace
   panel); a global rule here would drop a light-blue box inside that dark
   panel and restyle pages unrelated to this work. Only these content blocks
   get the callout treatment. */
.calc-info .formula-box {
  background: #f0f9ff;
  border-left: 4px solid #0284c7;
  border-radius: 8px;
  padding: 13px 16px;
  margin: 14px 0;
  font-family: 'JetBrains Mono','Courier New',monospace;
  font-size: 13px; line-height: 1.7; color: #0c4a6e;
  overflow-x: auto;
}
.calc-info .formula-box code {
  display: block; color: #0369a1; font-weight: 700;
  background: none; border: none; padding: 0;
}
.calc-info .formula-box code + code { margin-top: 6px; }

/* ─── RTL ADJUSTMENTS ───────────────────────────────────────────────────── */
[dir="rtl"] .calc-info .formula-box { border-left: none; border-right: 4px solid #0284c7; }
[dir="rtl"] .calc-info ul, [dir="rtl"] .calc-info ol { padding-left: 0; padding-right: 22px; }
[dir="rtl"] .calc-table th,
[dir="rtl"] .calc-table td { text-align: right; }
[dir="rtl"] .result-breakdown li { flex-direction: row-reverse; }

/* ─── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .calc-card { padding: 18px 14px; border-radius: 10px; }
  .calc-btn { font-size: 15px; padding: 13px 16px; min-height: 50px; }
  .result-primary { font-size: 1.6rem; }
  .calc-explainer-grid { grid-template-columns: 1fr; }
  .calc-formula { padding: 13px 14px; font-size: 13px; }
  .calc-formula code { font-size: 14px; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .calc-explainer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 769px) {
  .calc-card { padding: 28px 26px; }
  .result-primary { font-size: 2.2rem; }
}

/* ─── RELATED CALCULATORS (internal funnel links) ───────────────────────────
   Used by 37 locale calculator pages but previously had NO style rule, so the
   blocks rendered as raw unstyled lists. Mirrors .t-related in
   wiki-translated.css so calculators and wiki pages look consistent. */
.calc-related {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
  margin: 26px auto 0;
  max-width: 860px;
  width: 100%;
}
.calc-related h2, .calc-related h3 {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: .08em;
  margin: 0 0 12px; padding: 0; border: none;
}
.calc-related ul { list-style: none; margin: 0; padding: 0; }
.calc-related li { border-bottom: 1px solid #e2e8f0; }
.calc-related li:last-child { border-bottom: none; }
.calc-related a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; font-size: 14px; font-weight: 600;
  color: #0f172a; min-height: 40px; text-decoration: none;
  transition: color .12s;
}
.calc-related a:hover { color: #0284c7; text-decoration: none; }
.calc-related a::before {
  content: '→'; color: #0284c7; font-size: 12px; flex-shrink: 0;
}
[dir="rtl"] .calc-related a { flex-direction: row-reverse; justify-content: flex-end; }
[dir="rtl"] .calc-related a::before { content: '←'; }

@media (max-width: 480px) {
  .calc-related { padding: 14px 14px; margin-top: 20px; }
  .calc-related a { font-size: 13.5px; }
}
