/**
 * Matthuset Calculator — frontend styles
 */

.mh-calc {
  font-family: inherit;
  color: #1a1a1a;
}

.mh-calc__notice {
  padding: 1rem;
  background: #fff3e0;
  color: #6b3200;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* ---------- Sections & labels ---------- */
.mh-calc__section {
  margin-bottom: 1.25rem;
}

.mh-calc__section:last-child {
  margin-bottom: 0;
}

.mh-calc__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
  margin: 0 0 0.55rem;
  line-height: 1.35;
}

.mh-calc__hint {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.5;
  margin: 0.6rem 0 0;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
}

/* ---------- Card grid (radio alternatives / widths) ---------- */
.mh-calc__cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.mh-calc__cards--2col {
  grid-template-columns: repeat(2, 1fr);
}

.mh-calc__cards--list {
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.mh-calc__cards--list .mh-calc__card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  gap: 0.75rem;
}

.mh-calc__cards--list .mh-calc__card-sub {
  flex-shrink: 0;
  text-align: right;
}

@media (min-width: 480px) {
  .mh-calc__cards:not(.mh-calc__cards--list) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mh-calc__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 58px;
  padding: 0.65rem 0.85rem;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.mh-calc__card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mh-calc__card:hover {
  border-color: #1a1a1a;
  background: #faf7f2;
}

.mh-calc__card:has(input[type="radio"]:checked) {
  border-color: #1a1a1a;
  background: #1a1a1a;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mh-calc__card-label {
  font-size: 0.85rem;
  line-height: 1.25;
}

.mh-calc__card-sub {
  font-size: 0.68rem;
  font-weight: 400;
  color: #888;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.mh-calc__card:has(input[type="radio"]:checked) .mh-calc__card-sub {
  color: rgba(255, 255, 255, 0.72);
}

/* ---------- Inputs ---------- */
.mh-calc__input-wrap {
  position: relative;
}

.mh-calc__input-wrap input[type="number"] {
  width: 100%;
  padding: 0.85rem 3rem 0.85rem 1rem;
  font-size: 0.95rem;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mh-calc__input-wrap input[type="number"]:hover {
  border-color: #c4c4c4;
}

.mh-calc__input-wrap input[type="number"]:focus {
  outline: none;
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.mh-calc__input-wrap input[type="number"]::placeholder {
  color: #bbb;
  font-weight: 400;
}

.mh-calc__input-wrap--cm::after,
.mh-calc__input-wrap--m2::after {
  content: "cm";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  color: #999;
  pointer-events: none;
  font-weight: 500;
}

.mh-calc__input-wrap--m2::after {
  content: "m²";
}

/* ---------- Readout row (area / linear-m computed info) ---------- */
.mh-calc__readout {
  margin: 0.5rem 0 1.25rem;
  padding: 0.75rem 0.95rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  font-size: 0.85rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  transition: opacity 0.2s ease;
}

.mh-calc__readout[hidden] {
  display: none;
}

.mh-calc__readout-value {
  font-weight: 600;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
}

.mh-calc__readout-sep {
  color: #ccc;
}

.mh-calc__readout-meta {
  color: #888;
}

/* ---------- Chips (pkg model: pkg count + m² readback) ---------- */
.mh-calc__chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mh-calc__chip {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mh-calc__chip-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  font-weight: 600;
}

.mh-calc__chip-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.mh-calc__chip-meta {
  font-size: 0.68rem;
  color: #888;
  margin-top: 0.1rem;
}

/* ---------- Hero total ---------- */
.mh-calc__total {
  margin: 1.5rem 0 1rem;
  padding: 1.5rem 0 0;
  border-top: 1px solid #e8e8e8;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.mh-calc__total-label {
  font-size: 0.72rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  flex-shrink: 0;
}

.mh-calc__total-value {
  font-size: 2.15rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: color 0.18s ease;
}

.mh-calc__total-value.is-empty {
  color: #bbb;
  font-weight: 500;
}

/* ---------- Preset chips (common-size quick-fill) ---------- */
.mh-calc__presets {
  margin-bottom: 0.75rem;
}

.mh-calc__preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mh-calc__preset {
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #333;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.1s ease;
  font-family: inherit;
  line-height: 1;
}

.mh-calc__preset:hover {
  border-color: #1a1a1a;
  background: #faf7f2;
}

.mh-calc__preset:active {
  transform: scale(0.97);
}

.mh-calc__preset.is-active {
  background: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
}

.mh-calc__preset--custom {
  background: transparent;
  color: #666;
  border-style: dashed;
}

.mh-calc__preset--custom:hover {
  color: #1a1a1a;
}

/* ---------- Proportional SVG visual (heltack / los_matta / rund) ---------- */
.mh-calc__visual {
  margin: 1rem 0;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.mh-calc__visual[hidden],
.mh-calc__visual[style*="display: none"] {
  display: none;
}

.mh-calc__visual-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.mh-calc__visual-svg {
  width: 100%;
  max-width: 260px;
  height: auto;
  overflow: visible;
}

.mh-calc__visual-rect,
.mh-calc__visual-circle {
  fill: #1a1a1a;
  fill-opacity: 0.06;
  stroke: #1a1a1a;
  stroke-width: 1.5;
  stroke-opacity: 0.45;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              x 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              y 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              r 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              cx 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              cy 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.mh-calc__visual-dim-w,
.mh-calc__visual-dim-l {
  fill: #666;
  font-size: 9px;
  font-family: inherit;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.2s ease;
}

/* ---------- Linear-m strip visual ---------- */
.mh-calc__visual[data-mh-visual="linear_m"] {
  padding: 1rem;
}

.mh-calc__visual-strip {
  height: 34px;
  background: #1a1a1a;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 19px,
    rgba(255, 255, 255, 0.15) 19px,
    rgba(255, 255, 255, 0.15) 20px
  );
  border-radius: 4px;
  width: 0;
  max-width: 100%;
  position: relative;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.mh-calc__visual-strip[data-mh-strip-empty="1"] {
  background: rgba(0, 0, 0, 0.06);
  color: #888;
  width: 100%;
}

.mh-calc__visual-dim {
  padding: 0 0.6rem;
  white-space: nowrap;
}

/* ---------- Package grid visual (pkg model) ---------- */
.mh-calc__visual[data-mh-visual="pkg"] {
  padding: 1.1rem 1rem;
}

.mh-calc__pkg-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 32px;
  align-items: flex-start;
  justify-content: flex-start;
}

.mh-calc__pkg-box {
  width: 26px;
  height: 34px;
  background: #1a1a1a;
  border-radius: 2px 2px 4px 4px;
  position: relative;
  animation: mh-pkg-pop 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom center;
  background-image: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 40%),
                    repeating-linear-gradient(45deg, transparent 0, transparent 4px, rgba(255,255,255,0.06) 4px, rgba(255,255,255,0.06) 5px);
  flex-shrink: 0;
}

.mh-calc__pkg-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 3px;
  right: 3px;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 1px;
}

.mh-calc__pkg-box--empty {
  background: transparent;
  background-image: none;
  border: 1.5px dashed rgba(0, 0, 0, 0.15);
  animation: none;
}

@keyframes mh-pkg-pop {
  from { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Breakdown line (math transparency) ---------- */
.mh-calc__breakdown {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: #666;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  transition: opacity 0.22s ease;
}

.mh-calc__breakdown[hidden] {
  display: none;
}

.mh-calc__breakdown-eq {
  color: #1a1a1a;
  font-weight: 500;
}

.mh-calc__breakdown-op {
  color: #bbb;
  margin: 0 0.25em;
}

/* ---------- Empty-state hint (under TOTAL when value is 0) ---------- */
.mh-calc__empty-hint {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: #999;
  text-align: right;
  font-style: italic;
  transition: opacity 0.2s ease;
}

.mh-calc:not(.is-empty) .mh-calc__empty-hint {
  opacity: 0;
  height: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---------- Count-up total: tabular-nums already applied; add subtle bounce on update ---------- */
.mh-calc__total-value.is-updating {
  animation: mh-total-pulse 0.4s ease-out;
}

@keyframes mh-total-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .mh-calc__card,
  .mh-calc__readout,
  .mh-calc__total-value,
  .mh-calc__visual-rect,
  .mh-calc__visual-circle,
  .mh-calc__visual-strip,
  .mh-calc__breakdown,
  .mh-calc__preset {
    transition: none;
  }
  .mh-calc__pkg-box,
  .mh-calc__total-value.is-updating {
    animation: none;
  }
}
