/*
 * Terraformer Calculator - Bootstrap 5 Styles
 * Migrated from jQuery UI to Bootstrap 5.3.8
 * Shared pieces (.main-header, .subheader, .ui-input-margin, tooltip skin)
 * follow the same conventions as the graviton / queue / flight calculators.
 */

#terraformer {
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  overflow-x: auto;
}

/* The settings panel's intrinsic width would otherwise inflate #terraformer's
   max-content size; width:0 removes its contribution and min-width stretches
   it back to the resolved, content-driven width. The m-1 utility adds 0.25rem
   margin per side, so subtract 0.5rem to keep the outer box within the parent. */
#general-settings-panel {
  width: 0;
  min-width: calc(100% - 0.5rem);
  box-sizing: border-box;
}

.main-header {
  width: auto;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 4px;
  margin: 2px;
}

.subheader {
  text-align: center;
  font-weight: 600;
  margin: 0 0 6px 0;
  padding: 2px 6px;
}

#reset {
  cursor: pointer;
  z-index: 10;
  width: 30px;
  height: 30px;
  border: 1px solid #dc3545;
  border-radius: 8px;
  margin-right: 0.2rem;
}

/* Layout tables: tighten the default cell padding and align vertically. */
#terraformer table td {
  padding: 2px 4px;
  vertical-align: middle;
}

/* Inputs */
.level-input {
  width: 44px;
  text-align: center;
}

/* Fits a three-digit negative temperature (e.g. -140). */
#max-planet-temp {
  width: 56px;
}

.energy-input {
  width: 54px;
  text-align: center;
}

/* Computed result fields: rendered as form-control divs, so they can carry
   neither `readonly´ nor `disabled´. They wear the `ui-state-disabled´ marker
   instead — the same marker the flight and trade calculators use — which paints
   the Bootstrap disabled-field fill and is excluded from the light-theme
   "lift editable controls" rule in common.css. Note `.resource-show´ is
   shared with the two editable resources-on-hand inputs, which deliberately do
   not carry the marker. */
.ui-state-disabled {
  background-color: var(--bs-secondary-bg);
  cursor: default;
}

/* Each class names its width in --readout-width, read by the field rule below. */
.energy-show {
  --readout-width: 64px;
  width: var(--readout-width);
  text-align: center;
}

.resource-show {
  --readout-width: 100px;
  width: var(--readout-width);
  text-align: center;
}

.time-show {
  --readout-width: 150px;
  width: var(--readout-width);
  text-align: center;
}

.transport-show {
  --readout-width: 170px;
  width: var(--readout-width);
  text-align: center;
}

/* A readout's width is a minimum, not a size: the numbers have no upper bound
   (a terraformer at level 25 needs 16.777.216.000 energy and 1.677.721.550.000
   crystal), and a fixed width let them run out of the box and past the panel.
   The box grows with its number instead, up to its cell; past that a
   duration ("3994573нд 3д 8ч") wraps at its spaces, while a number, having
   none, stays whole. Only the divs: the editable inputs sharing
   .resource-show keep their fixed width. */
div.ui-state-disabled {
  width: auto;
  min-width: var(--readout-width, 0);
  max-width: 100%;
}

/* Warning banner (shared look with the graviton / queue calculators) */
#warning {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 20px;
  text-align: center;
  background-color: var(--bs-warning-bg-subtle);
  border: 1px solid var(--bs-warning-border-subtle);
  border-radius: var(--bs-border-radius);
  color: var(--bs-body-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 300px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in-out;
}

#warning.visible {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

/* Result sub-titles inside the expenses panel (Terraformer / Satellites / Total) */
.result-subtitle {
  font-weight: 600;
}

/* Responsive */
/* The terraformer level label with its single-level checkbox stays on one line
   (it was the text-nowrap utility, which a phone rule could not undo). */
.tf-level-label {
  white-space: nowrap;
}

@media (max-width: 992px) {
  #terraformer {
    max-width: 100%;
    padding: 0 10px;
  }
}

/* Phone layout (docs/patterns.md): the level label wraps once it has a line
   of its own; at a phone's 16px field text a five-digit satellite count needs
   more than 54px, a large energy requirement more than 64px, and the 170px
   transport readout runs past the panel. */
@media (max-width: 575.98px) {
  .tf-level-label {
    white-space: normal;
  }

  .energy-input {
    width: 72px;
  }

  .transport-show {
    --readout-width: 150px;
  }
}
