/* pdf-calcs.css */

/* ─── HLTT: on-image orange result badges ───────────────────────────────────── */

.hltt-on-image-result {
   position: absolute;
   display: inline-flex;
   flex-direction: column;
   align-items: stretch;
   transform: translate(-50%, -50%);
   border: 1px solid #f59e0b;
   border-radius: 0.375rem;
   overflow: hidden;
   box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
   z-index: 2;
}

.hltt-result__label {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   padding: 0.2rem 0.75rem 0;
   background: #fffbeb;
   color: #92400e;
   font-size: 0.8rem;
   font-weight: 600;
   line-height: 1;
   white-space: nowrap;
}

/* HLTT result field in diagram-fields rows — same structure as inputs, amber result styling */
.diagram-field-col .form-control.hltt-result-control,
.hltt-mobile-max-load .form-control.hltt-result-control {
   background-color: #fffbeb;
   border: 1px solid #f59e0b;
   border-left: 3px solid #f59e0b;
   color: #78350f;
   font-weight: 700;
   text-align: center;
   pointer-events: none;
   transition: none;
}

.hltt-result__value {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   min-width: 100%;
   padding: 0.3rem 0.75rem;
   background: #fffbeb;
   color: #4a3800;
   font-size: 1rem;
   font-weight: 700;
   line-height: 1;
}

.hltt-result__value.hltt-result--invalid {
   color: #999;
   background-color: #f5f5f5;
}

/* Mobile Max Load field: hidden on desktop, shown in stacked layout */
.hltt-mobile-max-load {
   display: none;
}

/* Inline variant: same orange badge visual but positioned in flow (not on-image) */
.hltt-inline-result {
   position: relative;
   transform: none;
   display: flex;
}

/* ─── D-Rating: annotated diagram renderer ─────────────────────────────────── */

.dr-diagram-stage {
   position: relative;
   width: min(100%, 1100px);
   margin: 0 auto;
}

.dr-diagram-bg {
   display: block;
   width: 100%;
   height: auto;
}

.dr-fields-overlay {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   pointer-events: none;
}

.dr-field,
.dr-result {
   position: absolute;
   transform: translate(-50%, -50%);
   text-align: center;
   pointer-events: auto;
   width: clamp(5rem, 8vw, 7.5rem);
}

.dr-field-label,
.dr-result-label {
   display: block;
   font-size: 0.72rem;
   line-height: 1.2;
   margin-bottom: 0.2rem;
   white-space: nowrap;
}

.dr-field-input-wrap {
   display: flex;
   align-items: center;
   gap: 0.15rem;
}

.dr-field-input {
   width: 100%;
   text-align: center;
   font-size: 0.8rem;
   padding: 0.2rem 0.25rem;
}

.dr-field-unit,
.dr-result-unit {
   font-size: 0.72rem;
   color: #666;
   white-space: nowrap;
}

.dr-result-value {
   display: inline-block;
   min-width: 3rem;
   padding: 0.25rem 0.5rem;
   font-size: 1rem;
   font-weight: 700;
   color: #b91c1c;
   background-color: #fff5f5;
   border: 1px solid #fca5a5;
   border-radius: 0.375rem;
   line-height: 1.4;
}

.dr-result-invalid {
   color: #999;
   background-color: #f5f5f5;
   border-color: #ddd;
}

/* Connectors overlay */
.dr-connectors {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   pointer-events: none;
   overflow: visible;
}

.dr-connectors line {
   stroke: #999;
   stroke-width: 1.5;
   stroke-dasharray: 4 3;
}

/* Remove number input spinners */
.dr-field-input[type='number']::-webkit-inner-spin-button,
.dr-field-input[type='number']::-webkit-outer-spin-button {
   -webkit-appearance: none;
   margin: 0;
}

.dr-field-input[type='number'] {
   -moz-appearance: textfield;
   appearance: textfield;
}

/* D-Rating mobile collapse */
@media (max-width: 768px) {
   .dr-fields-overlay {
      position: static;
   }

   .dr-field,
   .dr-result {
      position: static;
      transform: none;
      width: 100%;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.5rem;
   }

   .dr-connectors {
      display: none;
   }
}

/* ─── Tabs ──────────────────────────────────────────────────────────────────── */

#atm-variant-tabs .nav-link:hover {
   text-decoration: underline;
}

/* ─── Shared diagram scaffolding ───────────────────────────────────────────── */

.diagram-wrap {
   width: min(100%, 1100px);
   margin: 0 auto;
}

.dr-toolbar {
   display: flex;
   justify-content: flex-end;
   align-items: center;
}

/* Diagram area */
.diagram-stage {
   position: relative;
   width: 100%;
}

.diagram-bg {
   display: block;
   width: 100%;
   height: auto;
}

.diagram-fields {
   width: 100%;
}

.diagram-field-row {
   position: relative;
   width: 100%;
   min-height: 6.75rem;
   margin-bottom: 0.4rem;
}

.diagram-field-col {
   position: absolute;
   width: clamp(4.5rem, 6vw, 6rem);
   transform: translateX(-50%);
}

/* Use for unusually long 3-line labels so they do not wrap to a 4th line. */
.diagram-field-col--wide-label {
   width: clamp(6.8rem, 10vw, 8.8rem);
}

/* TCM display: alone in its row, no peer fields to align with — wider column, no min-height. */
.diagram-field-col--tcm {
   width: clamp(8rem, 12vw, 10rem);
}

.diagram-field-col--tcm .form-label {
   min-height: 0;
}

.diagram-field-col .form-control {
   width: 100%;
   background-color: #f2f9ff;
   border-left: 3px solid #cce5ff;
   transition: background-color 0.3s ease;
}

.diagram-field-col .form-control:focus {
   background-color: #fff8e1;
}

.diagram-field-col .form-label,
.hltt-mobile-max-load .form-label {
   display: flex;
   align-items: flex-end;
   justify-content: center;
   min-height: 4.8em;
   font-size: 0.8rem;
   margin-bottom: 0.25rem;
   line-height: 1.2;
   white-space: normal;
   text-align: center;
}

/* Remove spinners — maximise usable input width */
.diagram-field-col input[type='number']::-webkit-inner-spin-button,
.diagram-field-col input[type='number']::-webkit-outer-spin-button {
   -webkit-appearance: none;
   margin: 0;
}

.diagram-field-col input[type='number'] {
   -moz-appearance: textfield;
   appearance: textfield;
}

.diagram-connectors {
   display: block;
   width: 100%;
   height: 36px;
   margin-top: -24px;
   overflow: visible;
}

.diagram-connectors line,
.diagram-connectors polyline {
   stroke: #999;
   stroke-width: 2;
   stroke-dasharray: 4 3;
   fill: none;
   stroke-linejoin: round;
}

/* Output/result row */
.diagram-field-row--results {
   margin-top: 0rem;
   min-height: 5.5rem;
}
.diagram-field-row--results .form-label {
   min-height: 3.6em;
}

.diagram-result-box {
   display: block;
   width: 100%;
   padding: 0.375rem 0.5rem;
   font-size: 0.875rem;
   font-weight: 700;
   color: #4a3800; /* dark amber text */
   background-color: #fffbeb; /* warm cream background */
   border: 1px solid #fcd34d; /* soft amber border */
   border-radius: 0.375rem;
   line-height: 1.5;
   text-align: center;
}

.diagram-result-box.info-only {
   display: block;
   font-weight: 500;
   color: #6b7280;
   background-color: #f9fafb;
   border: 1px solid #e5e7eb;
}

.diagram-field-col .form-control {
   width: 100%;
   margin: 0 auto;
   text-align: center;
}

/* On-image D-rating display for Prime Mover variants */
.dr-on-image-result {
   position: absolute;
   display: inline-flex;
   flex-direction: column;
   align-items: stretch;
   transform: translate(-50%, -50%);
   border: 1px solid #1f7a3f;
   border-radius: 0.375rem;
   overflow: hidden;
   box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
   z-index: 2;
}

.dr-on-image-result__label {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   padding: 0.22rem 0.5rem;
   background: #1f7a3f;
   color: #fff;
   font-size: 0.7rem;
   font-weight: 700;
   line-height: 1;
   white-space: nowrap;
}

.dr-on-image-result__value {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   min-width: 100%;
   padding: 0.24rem 0.45rem;
   background: #f8fbf9;
   color: #1f7a3f;
   font-size: 0.8rem;
   font-weight: 700;
   line-height: 1;
}

/* ─── Variant-specific collapse breakpoints ─────────────────────────────────
   Each variant collapses to stacked layout at the viewport width where its
   proportional field layout would start to overlap. Add one @media block per
   dense variant, scoped to its pane ID.
   ─────────────────────────────────────────────────────────────────────────── */

/* Road Train: 7 axle columns, tightest gap ~8.8% — collapse at 1020px.
   Scoped to #atm-road-train so other variants are unaffected.
   This also covers .diagram-field-col inside the results row, so result
   boxes stack correctly at this breakpoint without extra rules. */
@media (max-width: 1020px) {
   #atm-road-train .diagram-field-row {
      position: static;
      min-height: 0;
      margin-bottom: 0;
   }

   #atm-road-train .diagram-fields {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
   }

   #atm-road-train .diagram-field-col {
      position: static;
      width: 100%;
      transform: none;
   }

   #atm-road-train .diagram-connectors {
      display: none;
   }
}

/* Default mobile collapse — all variants */
@media (max-width: 768px) {
   .dr-on-image-result {
      /* Keep per-variant inline left:% positioning while placing below image */
      position: relative;
      top: 0;
      transform: translateX(-50%);
      margin: 0.5rem 0 0;
   }

   .diagram-field-row--results {
      padding-top: 0.5rem;
      margin-top: 0.25rem;
   }

   .diagram-field-row {
      position: static;
      min-height: 0;
      margin-bottom: 0;
   }

   .diagram-fields {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
   }

   .diagram-field-col {
      position: static;
      width: min(18rem, 100%);
      margin: 0 auto;
      transform: none;
   }

   .diagram-connectors {
      display: none;
   }

   .hltt-on-image-result {
      display: none;
   }

   .hltt-mobile-max-load {
      display: block;
      width: min(18rem, 100%);
      margin: 0 auto;
   }

   .diagram-field-col .form-label,
   .hltt-mobile-max-load .form-label {
      min-height: 0;
   }
}
