/* ==========================================================================
   mamiundpapi-uf - Rechner ([mup_rechner], build spec section 5, agent M3)

   Loaded only on pages with a calculator (inc/rechner.php). Colours come from the
   brand tokens of spec section 6, each with its literal fallback, mapped once to
   local --mr-* names so the rest of the file reads cleanly.

   Specificity: inner rules are scoped as ".mup-rechner .mup-rechner__x" (0,2,0).
   Article prose rules (":where(...) p", "... h2", "... ol li") therefore never reach
   into the card, whatever order the stylesheets print in. No !important.

   Contrast (WCAG AA, measured with the fallback values):
     #103840 ink on #F7F3FA       12,9:1   headings, values
     #5E6B73 muted on #F7F3FA      5,0:1   help texts, meta
     #7A45A8 primary on #FFF       6,5:1   labels, links; white on it 6,5:1 (button)
     #63358C button hover          8,7:1   white text
     #C2345F accent on #FFF        5,3:1   "heute fruchtbar" badge, hint border
     #857A92 field border          3,7:1 on #F7F3FA, 4,0:1 on #FFF (non-text, >= 3:1)
   Error texts use the ink colour; the warn colour only marks the field and icon.
   ========================================================================== */

.mup-rechner{
  --mr-ink: var(--mup-ink, #103840);
  --mr-text: var(--mup-text, #2E3B44);
  --mr-muted: var(--mup-muted, #5E6B73);
  --mr-bg: var(--mup-bg, #FFFFFF);
  --mr-soft: var(--mup-bg-soft, #F7F3FA);
  --mr-line: var(--mup-line, #E6DFEA);
  --mr-primary: var(--mup-primary, #7A45A8);
  --mr-primary-soft: var(--mup-primary-soft, #EFE6F7);
  --mr-accent: var(--mup-accent, #C2345F);
  --mr-warn: var(--mup-warn, #B5532F);
  --mr-radius: var(--mup-radius, 14px);
  --mr-hover: #63358C;     /* button hover, primary darkened */
  --mr-rand: #857A92;      /* field border */
  --mr-fruchtbar: #A57BCB; /* fertile days in the cycle strip */
  --mr-leer: #E9E2EE;      /* other days in the cycle strip */

  position: relative;
  margin: 2.25rem 0;
  padding: clamp(1.125rem, 4vw, 2rem);
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(122, 69, 168, .08) 0, rgba(122, 69, 168, 0) 60%),
    var(--mr-soft);
  border: 1px solid var(--mr-line);
  border-radius: calc(var(--mr-radius) + 6px);
  color: var(--mr-text);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

/* ---------- head ---------- */

.mup-rechner .mup-rechner__kopf{
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin: 0 0 1.5rem;
}
.mup-rechner .mup-rechner__symbol{
  flex: none;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 16px;
  background: var(--mr-bg);
  color: var(--mr-primary);
  box-shadow: 0 0 0 1px var(--mr-line), 0 4px 12px -6px rgba(16, 56, 64, .25);
}
.mup-rechner .mup-rechner__symbol svg{
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mup-rechner .mup-rechner__kopftext{ min-width: 0; }
.mup-rechner .mup-rechner__titel{
  margin: .1rem 0 .35rem;
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.625rem);
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__intro{
  margin: 0;
  color: var(--mr-muted);
  font-size: .975rem;
  line-height: 1.5;
}

/* ---------- mode switch (radio chips) ---------- */

.mup-rechner .mup-rechner__form{ margin: 0; }
.mup-rechner .mup-rechner__modus{
  min-width: 0;
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}
.mup-rechner .mup-rechner__legende-modus{
  margin: 0 0 .6rem;
  padding: 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__optionen{
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.mup-rechner .mup-rechner__option{
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  margin: 0;
  padding: .5rem 1rem .5rem .8rem;
  background: var(--mr-bg);
  border: 1px solid var(--mr-rand);
  border-radius: 12px;
  color: var(--mr-ink);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.mup-rechner .mup-rechner__option:hover{ border-color: var(--mr-primary); }
.mup-rechner .mup-rechner__option:has(input:checked){
  border-color: var(--mr-primary);
  background: var(--mr-primary-soft);
  box-shadow: inset 0 0 0 1px var(--mr-primary);
}
.mup-rechner .mup-rechner__option input{
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  min-width: 0;
  min-height: 0;
  margin: 0;
  accent-color: var(--mr-primary);
}
@media (max-width: 519px){
  .mup-rechner .mup-rechner__option{ flex: 1 1 100%; }
}

/* ---------- fields ---------- */

.mup-rechner .mup-rechner__felder{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1.1rem 1.25rem;
}
.mup-rechner .mup-rechner__feld{ min-width: 0; }
.mup-rechner .mup-rechner__beschriftung{
  display: block;
  margin: 0 0 .4rem;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__eingabe{
  position: relative;
  display: block;
}
.mup-rechner .mup-rechner__eingabe input{
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  margin: 0;
  padding: .65rem .9rem;
  background: var(--mr-bg);
  border: 1px solid var(--mr-rand);
  border-radius: 12px;
  color: var(--mr-ink);
  font-size: 1.0625rem;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}
.mup-rechner .mup-rechner__eingabe input[type="number"]{ -moz-appearance: textfield; appearance: textfield; }
.mup-rechner .mup-rechner__eingabe input::-webkit-inner-spin-button,
.mup-rechner .mup-rechner__eingabe input::-webkit-outer-spin-button{ -webkit-appearance: none; margin: 0; }
/* iOS centres the value of an empty-looking date field; keep it left like the others. */
.mup-rechner .mup-rechner__eingabe input::-webkit-date-and-time-value{ text-align: left; margin: 0; }
.mup-rechner .mup-rechner__eingabe input:hover{ border-color: var(--mr-primary); }
.mup-rechner .mup-rechner__eingabe input:focus-visible{
  border-color: var(--mr-primary);
  outline: 2px solid var(--mr-primary);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px rgba(122, 69, 168, .14);
}
.mup-rechner .mup-rechner__eingabe input[aria-invalid="true"]{
  border-color: var(--mr-warn);
  box-shadow: inset 0 0 0 1px var(--mr-warn);
}
.mup-rechner .mup-rechner__eingabe--einheit input{ padding-right: 4.75rem; }
.mup-rechner .mup-rechner__einheit{
  position: absolute;
  top: 0;
  right: .9rem;
  bottom: 0;
  display: flex;
  align-items: center;
  color: var(--mr-muted);
  font-size: .95rem;
  pointer-events: none;
}
.mup-rechner .mup-rechner__hilfe{
  margin: .4rem 0 0;
  font-size: .85rem;
  line-height: 1.45;
  color: var(--mr-muted);
}
.mup-rechner .mup-rechner__fehler{
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  margin: .5rem 0 0;
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__fehler::before{
  content: "!";
  flex: none;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: .05rem;
  border-radius: 50%;
  background: var(--mr-warn);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  line-height: 1;
}

/* ---------- button ---------- */

.mup-rechner .mup-rechner__aktion{ margin-top: 1.5rem; }
.mup-rechner .mup-rechner__knopf{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: .75rem 1.75rem;
  border: 0;
  border-radius: 999px;
  background: var(--mr-primary);
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 8px 18px -10px rgba(122, 69, 168, .8);
  transition: background-color .15s ease, transform .15s ease;
}
.mup-rechner .mup-rechner__knopf:hover{ background: var(--mr-hover); }
.mup-rechner .mup-rechner__knopf:active{ transform: translateY(1px); }
.mup-rechner .mup-rechner__knopf:focus-visible{
  outline: 3px solid var(--mr-primary);
  outline-offset: 3px;
}
.mup-rechner .mup-rechner__knopf[disabled]{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}
@media (min-width: 600px){
  .mup-rechner .mup-rechner__knopf{ width: auto; min-width: 15rem; }
}

/* ---------- result ---------- */

.mup-rechner .mup-rechner__resultat{
  margin-top: 1.5rem;
  padding: 1.1rem 1.25rem;
  background: rgba(255, 255, 255, .55);
  border: 1px dashed #CDBFD8;
  border-radius: var(--mr-radius);
}
.mup-rechner .mup-rechner__resultat--da{
  padding: 1.35rem clamp(1rem, 3.5vw, 1.6rem) 1.5rem;
  background: var(--mr-bg);
  border: 1px solid var(--mr-line);
  border-top: 4px solid var(--mr-primary);
  box-shadow: 0 14px 32px -20px rgba(16, 56, 64, .45);
}
.mup-rechner .mup-rechner__resultat--fehler{
  background: #FFF8F4;
  border-style: solid;
  border-color: #E8C9BC;
}
.mup-rechner .mup-rechner__ergebnis{ display: block; }
.mup-rechner .mup-rechner__ergebnis > span,
.mup-rechner .mup-rechner__ergebnis > strong{ display: block; }
.mup-rechner .mup-rechner__platzhalter{
  color: var(--mr-muted);
  font-size: .95rem;
}
.mup-rechner .mup-rechner__label{
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mr-primary);
}
.mup-rechner .mup-rechner__wert{
  margin: .3rem 0 .6rem;
  font-size: clamp(1.55rem, 1.2rem + 2.2vw, 2.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--mr-ink);
  font-variant-numeric: tabular-nums;
}
.mup-rechner .mup-rechner__zeile{
  margin-top: .2rem;
  color: var(--mr-text);
}
.mup-rechner .mup-rechner__resultat--fehler .mup-rechner__zeile{
  margin: 0;
  font-weight: 600;
  color: var(--mr-ink);
}

.mup-rechner .mup-rechner__details{
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--mr-line);
}
.mup-rechner .mup-rechner__fakten{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: .6rem;
  margin: 0;
}
.mup-rechner .mup-rechner__fakten > div{
  min-width: 0;
  padding: .75rem .9rem;
  background: var(--mr-soft);
  border-radius: 12px;
}
.mup-rechner .mup-rechner__fakten dt,
.mup-rechner .mup-rechner__zyklus-daten dt{
  margin: 0;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--mr-muted);
}
.mup-rechner .mup-rechner__fakten dd,
.mup-rechner .mup-rechner__zyklus-daten dd{
  margin: .15rem 0 0;
  font-weight: 700;
  line-height: 1.35;
  color: var(--mr-ink);
  font-variant-numeric: tabular-nums;
}
.mup-rechner .mup-rechner__zwischentitel{
  margin: 0;
  font-weight: 700;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__basis{
  margin: 0;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--mr-muted);
}

/* Progress bar 0+0 to 40+0, trimester marks at 14+0 (35 %) and 28+0 (70 %). */
.mup-rechner .mup-rechner__balken{
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--mr-primary-soft);
  overflow: hidden;
}
.mup-rechner .mup-rechner__balken::before,
.mup-rechner .mup-rechner__balken::after{
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 2px;
  background: var(--mr-bg);
}
.mup-rechner .mup-rechner__balken::before{ left: 35%; }
.mup-rechner .mup-rechner__balken::after{ left: 70%; }
.mup-rechner .mup-rechner__balken-fuellung{
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mr-fruchtbar), var(--mr-primary));
}
.mup-rechner .mup-rechner__skala{
  display: flex;
  margin-top: .4rem;
  font-size: .75rem;
  line-height: 1.3;
  color: var(--mr-muted);
}
.mup-rechner .mup-rechner__skala > span{ flex: 0 0 35%; padding-right: .25rem; }
.mup-rechner .mup-rechner__skala > span:last-child{ flex-basis: 30%; padding-right: 0; text-align: right; }

/* Cycle preview */
.mup-rechner .mup-rechner__zyklen{
  display: grid;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.mup-rechner .mup-rechner__zyklus{
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--mr-bg);
  border: 1px solid var(--mr-line);
  border-radius: 14px;
}
.mup-rechner .mup-rechner__zyklus::before{ content: none; }
.mup-rechner .mup-rechner__zyklus::marker{ content: none; }
.mup-rechner .mup-rechner__zyklus--aktuell{
  border-color: #C9B0DF;
  box-shadow: 0 0 0 3px var(--mr-primary-soft);
}
.mup-rechner .mup-rechner__zyklus--vorbei{
  background: transparent;
  border-style: dashed;
}
.mup-rechner .mup-rechner__zyklus-titel{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  font-weight: 700;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__marke{
  display: inline-block;
  padding: .1rem .6rem;
  border-radius: 999px;
  background: var(--mr-primary-soft);
  color: var(--mr-primary);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.5;
}
.mup-rechner .mup-rechner__marke--heute{
  background: var(--mr-bg);
  color: var(--mr-accent);
  box-shadow: inset 0 0 0 1px var(--mr-accent);
}
.mup-rechner .mup-rechner__leiste{
  display: flex;
  gap: 1px;
  margin: .75rem 0 .85rem;
  padding: 4px 0;
}
@media (min-width: 480px){
  .mup-rechner .mup-rechner__leiste{ gap: 2px; }
}
.mup-rechner .mup-rechner__tag{
  display: block;
  flex: 1 1 0;
  min-width: 0;
  height: 12px;
  border-radius: 3px;
  background: var(--mr-leer);
}
.mup-rechner .mup-rechner__tag--periode{ background: var(--mr-ink); }
.mup-rechner .mup-rechner__tag--fruchtbar{ background: var(--mr-fruchtbar); }
.mup-rechner .mup-rechner__tag--eisprung{ background: var(--mr-accent); }
.mup-rechner .mup-rechner__tag--heute{
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 2px var(--mr-bg), 0 0 0 3.5px var(--mr-ink);
}
.mup-rechner .mup-rechner__zyklus--vorbei .mup-rechner__tag--fruchtbar{ background: #D3C2E2; }
.mup-rechner .mup-rechner__zyklus--vorbei .mup-rechner__tag--eisprung{ background: #E3A9BB; }
/* Phones: one line per date (label left, value right); from 600px three columns. */
.mup-rechner .mup-rechner__zyklus-daten{
  display: grid;
  gap: .3rem;
  margin: 0;
}
.mup-rechner .mup-rechner__zyklus-daten > div{
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0 .75rem;
}
.mup-rechner .mup-rechner__zyklus-daten dd{ margin: 0; text-align: right; }
@media (min-width: 600px){
  .mup-rechner .mup-rechner__zyklus-daten{ grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem 1rem; }
  .mup-rechner .mup-rechner__zyklus-daten > div{ display: block; }
  .mup-rechner .mup-rechner__zyklus-daten dd{ margin: .1rem 0 0; text-align: left; }
}

/* Legend: static markup from PHP, shown once there is a result. */
.mup-rechner .mup-rechner__legende{
  display: none;
  flex-wrap: wrap;
  gap: .4rem 1.1rem;
  margin: 1rem 0 0;
  font-size: .8rem;
  color: var(--mr-muted);
}
.mup-rechner .mup-rechner__resultat--da .mup-rechner__legende{ display: flex; }
.mup-rechner .mup-rechner__legende-eintrag{
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}
.mup-rechner .mup-rechner__legende .mup-rechner__tag{
  flex: none;
  width: 12px;
  height: 12px;
}

/* ---------- explanation ---------- */

.mup-rechner .mup-rechner__nojs{
  margin: 1rem 0 0;
  padding: .75rem 1rem;
  background: var(--mr-bg);
  border: 1px solid var(--mr-line);
  border-radius: 12px;
  font-size: .9rem;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__erklaerung{
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--mr-line);
  font-size: .95rem;
  line-height: 1.6;
}
.mup-rechner .mup-rechner__erklaerung-titel{
  margin: 0 0 .6rem;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--mr-ink);
}
.mup-rechner .mup-rechner__erklaerung p{ margin: 0 0 .75rem; }
.mup-rechner .mup-rechner__hinweis{
  margin: 1rem 0 .85rem;
  padding: .85rem 1rem;
  background: var(--mr-bg);
  border-left: 4px solid var(--mr-accent);
  border-radius: 0 12px 12px 0;
}
.mup-rechner .mup-rechner__hinweis strong{ color: var(--mr-ink); }
.mup-rechner .mup-rechner__erklaerung .mup-rechner__quelle{
  margin: 0;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--mr-muted);
}
.mup-rechner .mup-rechner__quelle a{ color: var(--mr-primary); }

@media (prefers-reduced-motion: reduce){
  .mup-rechner .mup-rechner__knopf{ transition: none; }
}

/* Last on purpose: beats the display values above at equal specificity, so `hidden`
   also works where basis.css (with its [hidden] rule) is not loaded. */
.mup-rechner [hidden]{ display: none; }
