/* EngineeringStuffs Construction Calcs — shared styles
   Matches the typography/palette used across the EPE/SPE sag-tension
   calculators and blog series (navy/amber, IBM Plex Sans body,
   JetBrains Mono for numeric fields). Scoped under .escc-wrap. */

.escc-wrap {
  --escc-navy:   #1F3864;
  --escc-amber:  #C9A21A;
  --escc-amber-hover: #B8931A;
  --escc-blue:   #2563EB;
  --escc-lblue:  #EFF6FF;
  --escc-border: #E2E8F0;
  --escc-bg:     #F8FAFC;
  --escc-grey:   #F1F5F9;
  --escc-text:   #1E293B;
  --escc-text2:  #475569;
  --escc-text3:  #94A3B8;
  --escc-red:    #DC2626;
  --escc-radius: 8px;
  --escc-font:   'IBM Plex Sans', Arial, sans-serif;
  --escc-mono:   'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  box-sizing: border-box;
  font-family: var(--escc-font);
  color: var(--escc-text);
  background: var(--escc-bg);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--escc-border);
  font-size: 0.95rem;
  line-height: 1.6;
}
.escc-wrap *, .escc-wrap *::before, .escc-wrap *::after { box-sizing: border-box; }

.escc-title { text-align: center; font-weight: 700; color: var(--escc-navy); font-size: 1.5rem; margin: 0 0 4px; }
.escc-subtitle { text-align: center; color: var(--escc-text2); margin: 0 0 18px; font-size: 0.85rem; }

/* --- Toolbar ---
   Floating icon buttons, bottom-right by default, so controls stay
   reachable on a long single-column form. If your page layout has a
   right-hand sidebar, override the position per-instance via the
   shortcode's toolbar_right / toolbar_bottom attributes, e.g.
   [concrete_estimate toolbar_right="33%"] — no CSS editing needed. */
.escc-toolbar {
  display: flex; flex-direction: column; gap: 10px;
  position: fixed;
  bottom: var(--escc-toolbar-bottom, 20px);
  right: var(--escc-toolbar-right, 20px);
  z-index: 40;
  margin: 0; padding: 0; background: none; border: none;
}
.escc-btn {
  width: 48px; height: 48px; padding: 0; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: var(--escc-amber); color: var(--escc-text);
  box-shadow: 0 4px 14px rgba(15,23,42,.2);
  transition: background .15s, transform .1s;
  position: relative;
}
.escc-btn:hover { background: var(--escc-amber-hover); transform: scale(1.06); }
.escc-btn.escc-gray { background: #fff; color: var(--escc-text2); border: 1px solid var(--escc-border); }
.escc-btn.escc-gray:hover { background: var(--escc-grey); }
.escc-btn.escc-red { background: #fff; color: var(--escc-red); border: 1px solid #FCA5A5; }
.escc-btn.escc-red:hover { background: #FEF2F2; }
.escc-btn.escc-steps { background: #16A34A; color: #fff; }
.escc-btn.escc-steps:hover { background: #15803D; }
.escc-btn.escc-steps.escc-active { background: #14532D; }

.escc-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.escc-btn-label {
  position: absolute; right: 58px; top: 50%; transform: translateY(-50%) translateX(4px);
  background: var(--escc-navy); color: #fff; font-family: var(--escc-font);
  font-size: 0.75rem; font-weight: 600; padding: 6px 11px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.escc-btn-label::after {
  content: ''; position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-left-color: var(--escc-navy);
}
.escc-btn:hover .escc-btn-label,
.escc-btn:focus-visible .escc-btn-label { opacity: 1; transform: translateY(-50%) translateX(0); }

@media (max-width: 640px) {
  .escc-toolbar { bottom: var(--escc-toolbar-bottom, 12px); right: var(--escc-toolbar-right, 12px); gap: 8px; }
  .escc-btn { width: 44px; height: 44px; }
}

/* --- Center content / section blocks --- */
.escc-sheet { background: #fff; border: 1px solid var(--escc-border); border-radius: var(--escc-radius); padding: 1.1rem 1.2rem; }
.escc-section { margin-bottom: 1.1rem; scroll-margin-top: 20px; }
.escc-section:last-child { margin-bottom: 0; }
.escc-section-head {
  font-size: 1.05rem; font-weight: 700; color: var(--escc-navy);
  margin: 0 0 0.5rem; padding-bottom: 0.3rem; border-bottom: 3px solid var(--escc-amber);
}
.escc-section-head.escc-section-toggle {
  cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  user-select: none;
}
.escc-section-head.escc-section-toggle:hover { color: var(--escc-amber-hover); }
.escc-section-toggle-chevron {
  flex-shrink: 0; width: 18px; height: 18px; color: var(--escc-text3);
  transition: transform .18s ease;
}
.escc-section.escc-collapsed .escc-section-toggle-chevron { transform: rotate(-90deg); }
.escc-section-body { overflow: hidden; }
.escc-section.escc-collapsed .escc-section-body { display: none; }
.escc-section-note { font-size: 0.8rem; color: var(--escc-text2); margin-bottom: 0.5rem; }
.escc-thin { height: 1px; background: var(--escc-border); margin: 1.2rem 0; }

/* --- Collapsible logic box (matches .stb-callout--amber) --- */
.escc-wrap details.escc-logic {
  background: #FFFBEB; border-left: 4px solid var(--escc-amber);
  border-radius: 0 var(--escc-radius) var(--escc-radius) 0;
  padding: 0.6rem 0.9rem; margin: 0.6rem 0 0.9rem; font-size: 0.82rem; color: #78350F;
}
.escc-wrap details.escc-logic summary { cursor: pointer; font-weight: 700; color: var(--escc-navy); }
.escc-logic-content { margin-top: 0.5rem; line-height: 1.6; }

/* --- Fields (label-above-input, matches the floating sag calculator's
       .stbc-field pattern exactly) --- */
.escc-row { display: flex; gap: 0.7rem; }
.escc-row .escc-field { flex: 1; min-width: 0; }

.escc-field { margin-bottom: 0.65rem; }
.escc-field label {
  display: block; font-size: 0.78rem; font-weight: 600; color: var(--escc-text2); margin-bottom: 0.2rem;
}
.escc-field .escc-unit-tag { font-size: 0.72rem; color: var(--escc-text3); font-weight: 400; }

.escc-wrap .escc-field input[type="text"],
.escc-wrap .escc-field input[type="number"],
.escc-wrap .escc-field select {
  width: 100%; box-sizing: border-box; padding: 0.4rem 0.55rem; border: 1px solid #CBD5E1;
  border-radius: 6px; font-size: 0.88rem; font-family: var(--escc-mono);
  background: #fff; color: var(--escc-text); text-align: left;
}
.escc-wrap .escc-field select {
  font-family: var(--escc-font);
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-color: var(--escc-lblue);
  border-color: #BFDBFE;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%232563EB' stroke-width='2'%3E%3Cpath d='M5 8l5 5 5-5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 16px;
  padding-right: 2.1rem;
  cursor: pointer;
}
.escc-wrap .escc-field select:hover { background-color: #E0EDFF; }
.escc-wrap .escc-field input:focus, .escc-wrap .escc-field select:focus {
  outline: none; border-color: var(--escc-blue); box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.escc-wrap .escc-field input.escc-ro-field {
  background: var(--escc-grey); font-weight: 700; color: var(--escc-navy); border-color: transparent;
}

/* --- Results list (matches .stbc-results exactly: dashed rows, mono values) --- */
.escc-results {
  margin-top: 0.7rem; background: var(--escc-bg); border-radius: 8px;
  padding: 0.7rem 0.85rem; font-family: var(--escc-mono); font-size: 0.85rem;
}
.escc-results-title { font-family: var(--escc-font); font-weight: 700; font-size: 0.72rem; color: var(--escc-navy); text-transform: uppercase; letter-spacing: .02em; margin-bottom: 0.4rem; }
.escc-result-row { display: flex; justify-content: space-between; padding: 0.22rem 0; border-bottom: 1px dashed var(--escc-border); }
.escc-result-row:last-child { border-bottom: none; }
.escc-result-row span:first-child { font-family: var(--escc-font); color: var(--escc-text2); }
.escc-result-row span:last-child { color: var(--escc-navy); font-weight: 700; }
.escc-result-row.escc-total { border-top: 2px solid var(--escc-navy); margin-top: 0.3rem; padding-top: 0.45rem; }
.escc-result-row.escc-total span:last-child { font-size: 1.1rem; }

/* --- Figure placeholder: clearly marked spot to drop in a hand-annotated
       diagram later, instead of a guessed/broken image URL --- */
.escc-figure-placeholder {
  margin-top: 0.8rem; border: 2px dashed var(--escc-border); border-radius: 8px;
  padding: 1.6rem 1rem; text-align: center; color: var(--escc-text3);
  font-size: 0.78rem; background: #fff;
}
.escc-figure-placeholder strong { display: block; color: var(--escc-text2); font-size: 0.82rem; margin-bottom: 0.3rem; }
.escc-figure-placeholder .escc-figure-icon { font-size: 1.4rem; display: block; margin-bottom: 0.4rem; opacity: .5; }

/* --- Actual embedded figure (extracted from the source workbook) --- */
.escc-figure {
  margin-top: 0.8rem; border: 1px solid var(--escc-border); border-radius: 8px;
  overflow: hidden; background: #fff;
}
.escc-figure img { 
    display: block;
    margin: 0 auto;
    max-width: 100%;
    width: auto; 
    height: auto; 
    max-height: 340px; 
    object-fit: contain; 
    background: #fff; }
.escc-figure-caption {
  padding: 0.5rem 0.7rem; font-size: 0.75rem; color: var(--escc-text3);
  font-style: italic; text-align: center; border-top: 1px solid var(--escc-border);
}

/* --- Itemized cost table: Material | Quantity | Unit Cost | Total Cost --- */
.escc-cost-table { margin-top: 0.6rem; }
.escc-cost-row {
  display: grid; grid-template-columns: 2.1fr 1fr 1fr 1fr; gap: 0.5rem; align-items: center;
  padding: 0.4rem 0; border-bottom: 1px dashed var(--escc-border); font-size: 0.78rem;
}
.escc-cost-row.escc-cost-head {
  font-weight: 700; color: var(--escc-navy); font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: .02em; border-bottom: 2px solid var(--escc-navy);
}
.escc-cost-row .escc-cost-material { color: var(--escc-text); line-height: 1.3; }
.escc-cost-row .escc-cost-qty, .escc-cost-row .escc-cost-total {
  text-align: right; font-family: var(--escc-mono); font-variant-numeric: tabular-nums;
}
.escc-cost-row .escc-cost-total { font-weight: 700; color: var(--escc-navy); }
.escc-cost-row input[type="number"] {
  width: 100%; text-align: right; padding: 0.3rem 0.4rem; font-size: 0.78rem;
  border: 1px solid #CBD5E1; border-radius: 5px; font-family: var(--escc-mono);
}
@media (max-width: 480px) {
  .escc-cost-row { grid-template-columns: 1fr 1fr; row-gap: 0.15rem; }
  .escc-cost-row .escc-cost-material { grid-column: 1 / -1; font-weight: 600; }
}
.escc-final-summary { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 3px solid var(--escc-amber); }

/* --- Pre-download confirmation modal (PDF report gate) --- */
.escc-modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px;
}
.escc-modal {
  background: #fff; border-radius: 10px; max-width: 380px; width: 100%;
  padding: 20px; box-shadow: 0 20px 40px rgba(0,0,0,.2); font-family: var(--escc-font);
}
.escc-modal-title { font-weight: 700; font-size: 1.05rem; color: var(--escc-navy); margin-bottom: 8px; }
.escc-modal-body { font-size: 0.85rem; color: var(--escc-text2); line-height: 1.5; margin-bottom: 16px; }
.escc-modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* Modal buttons reuse .escc-btn's circle/icon styling but the tooltip
   needs to appear above the button, not to the left — these sit in a
   horizontal row, not the toolbar's vertical stack. */
.escc-modal-btn { position: relative; }
.escc-modal-btn .escc-btn-label {
  right: auto; left: 50%; top: auto; bottom: 58px;
  transform: translateX(-50%) translateY(4px);
}
.escc-modal-btn .escc-btn-label::after {
  left: 50%; top: 100%; transform: translateX(-50%);
  border-left-color: transparent; border-top-color: var(--escc-navy);
}
.escc-modal-btn:hover .escc-btn-label,
.escc-modal-btn:focus-visible .escc-btn-label { transform: translateX(-50%) translateY(0); }

/* --- Footer / disclaimer --- */
.escc-footer { padding: 0.6rem 0.2rem 0; color: var(--escc-text2); font-size: 0.78rem; text-align: center; }
.escc-disclaimer {
  margin-top: 0.9rem; padding-top: 0.6rem; border-top: 1px solid var(--escc-border);
  font-size: 0.7rem; color: var(--escc-text3); font-style: italic; line-height: 1.5;
}

/* --- SEO / usage content --- */
.escc-seo { margin-top: 2rem; padding-top: 1.1rem; border-top: 1px solid var(--escc-border); color: var(--escc-text); font-size: 0.9rem; line-height: 1.65; }
.escc-seo h2 { font-size: 1.15rem; color: var(--escc-navy); border-bottom: 3px solid var(--escc-amber); padding-bottom: 0.3rem; display: inline-block; }
.escc-seo h3, .escc-seo h4 { font-size: 0.95rem; font-weight: 700; color: var(--escc-navy); margin-top: 0.9rem; }

/* --- Loading indicator --- */
/* --- Loading indicator ---
   Height is always reserved (visibility, not display) so toggling it
   during auto-recalculation never shifts the page content up/down. */
.escc-loading { visibility: hidden; min-height: 1.15rem; font-size: 0.72rem; color: var(--escc-text3); text-align: center; padding: 0.2rem 0 0.6rem; }
.escc-wrap.escc-busy .escc-loading { visibility: visible; }

/* --- Numeric result stability: prevents digit-count changes from
       reflowing the layout during live recalculation --- */
.escc-result-row span:last-child {
  font-variant-numeric: tabular-nums;
  display: inline-block; min-width: 80px; text-align: right;
}
.escc-wrap input.escc-ro, .escc-wrap .escc-field input.escc-ro-field {
  font-variant-numeric: tabular-nums;
}

/* --- Step-by-step computation (shown/hidden via toolbar toggle,
       intended as the future premium-gated feature) --- */
.escc-steps-panel {
  display: none; margin-top: 0.6rem; background: #F0FDF4; border-left: 4px solid #22C55E;
  border-radius: 0 8px 8px 0; padding: 0.65rem 0.9rem;
}
.escc-wrap.escc-show-steps .escc-steps-panel { display: block; }
.escc-steps-title { font-family: var(--escc-font); font-weight: 700; font-size: 0.72rem; color: #166534; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 0.4rem; }
.escc-steps-list { margin: 0; padding-left: 1.1rem; }
.escc-steps-list li { margin-bottom: 0.4rem; font-family: var(--escc-mono); font-size: 0.78rem; color: var(--escc-text); line-height: 1.5; }
.escc-steps-list li:last-child { margin-bottom: 0; font-weight: 700; color: #166534; }

/* --- Print (report popup) --- */
@media print {
  body.escc-print-body { background: #fff !important; color: #000; font-size: 11pt; font-family: Arial, sans-serif; }
  .escc-print-body input { border: none !important; background: transparent !important; font-weight: bold; color: #000 !important; text-align: right; }
  .escc-print-body input[type="text"] { text-align: left; }
  .escc-print-body .escc-disclaimer { display: block; margin-top: 16px; border-top: 1px solid #000; padding-top: 6px; text-align: center; }

  /* Reference/background info is for on-page reading only — never printed
     or included in the PDF report (the popup report builder already skips
     it since it only reads .escc-field/.escc-results, but this covers a
     direct browser Ctrl+P on the page itself too). */
  .escc-wrap .escc-seo,
  .escc-wrap .escc-toolbar,
  .escc-wrap .escc-loading { display: none !important; }
}
