/* ============================================
   Ovulation calculator (/ovulation-calculator/)
   template/ovulation-calculator.html. Tokens come from style.css.
   ============================================ */

.calc {
  padding-top: 32px;
}

/* Several blocks below set a display value, which would beat the hidden
   attribute. The form, the inactive mode and the empty result rely on it. */
.calc [hidden] {
  display: none !important;
}

.calc__container {
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.calc__panel {
  padding: 28px;
}

.calc__noscript {
  font-size: 16px;
  line-height: 1.6;
  color: var(--slate);
}

.calc__form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

html:not(.js) .calc__form {
  display: none;
}

/* Mode switch: two native radios drawn as one two-part control. */
.calc__modes {
  border: none;
  min-width: 0;
}

.calc__modes-legend {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 10px;
}

.calc__modes-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.calc__mode-option {
  position: relative;
  display: flex;
}

.calc__mode-option input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.calc__mode-option span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.calc__mode-option input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(36, 64, 79, 0.16);
}

.calc__mode-option input:focus-visible + span {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.calc__mode {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.calc__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc__label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.calc__input {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  min-height: 48px;
  width: 100%;
  max-width: 260px;
}

.calc__input--number {
  max-width: 140px;
}

.calc__input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.calc__input[aria-invalid="true"] {
  border-color: #B42318;
}

.calc__help {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.calc__error {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: #B42318;
}

.calc__periods {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calc__period {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc__period-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calc__remove {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.calc__remove:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.calc__add,
.calc__unsure {
  align-self: flex-start;
  font-size: 14px;
  font-weight: 700;
  color: var(--teal);
  padding: 10px 0;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.calc__note {
  font-size: 14px;
  line-height: 1.6;
  color: var(--slate);
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
}

.calc__submit {
  align-self: flex-start;
  background: var(--button);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 32px;
  min-height: 48px;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.calc__submit:hover {
  background: var(--slate);
}

.calc__submit:focus-visible,
.calc__add:focus-visible,
.calc__remove:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.calc__privacy {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

/* Result */
.calc-result {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calc-result__title {
  font-size: 22px;
  font-weight: var(--font-weight-heavy);
  color: var(--ink);
  letter-spacing: -0.3px;
}

.calc-result__title:focus {
  outline: none;
}

.calc-result__title:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
}

.calc-result__lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-result__line {
  font-size: 15px;
  line-height: 1.6;
  color: var(--slate);
}

.calc-result__key {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}

/* Same fill and edge as the calendar's fertile band, so the text answer and
   the days it names read as one thing. */
.calc-result__key-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--teal-soft);
  border: 1.5px solid var(--teal);
  border-radius: 16px;
}

.calc-result__key-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--slate);
}

.calc-result__key-value {
  margin: 0;
  font-size: 22px;
  font-weight: var(--font-weight-heavy);
  line-height: 1.3;
  color: var(--ink);
}

/* The period box spans the row, in the calendar's period hue, so the
   fertile days and the period read as two groups. */
.calc-result__key-item--period {
  grid-column: 1 / -1;
  background: #FDEBEF;
  border-color: #F00F44;
}

.calc-result__key-note {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--slate);
}

.calc-result__line--state {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

.calc-result__subtitle {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 8px;
  margin-bottom: 6px;
}

.calc-result__cycles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-result__cycle {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--slate);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
}

.calc-result__cycle-length {
  font-weight: 600;
}

.calc-result__source,
.calc-result__medical {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

/* How this works: one closed card, opened by the heading. */
.calc-how__details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 0 24px;
}

.calc-how__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0;
  cursor: pointer;
  list-style: none;
}

.calc-how__summary::-webkit-details-marker {
  display: none;
}

.calc-how__summary::after {
  content: '';
  flex: none;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  border-right: 2px solid var(--slate);
  border-bottom: 2px solid var(--slate);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.2s ease;
}

.calc-how__details[open] .calc-how__summary::after {
  transform: rotate(-135deg) translateY(-3px);
}

.calc-how__summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.calc-how__summary-title {
  font-size: 20px;
  font-weight: var(--font-weight-heavy);
  line-height: 1.3;
  color: var(--ink);
}

.calc-how__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 24px;
}

.calc-how__body .calc-how__subtitle:first-child {
  margin-top: 0;
}

/* FAQ */
.calc-how__title {
  text-align: left;
  margin-bottom: 4px;
}

.calc-how__subtitle {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 12px;
}

.calc-how__text {
  font-size: 16px;
  line-height: 1.75;
  color: var(--muted);
}

.calc-how__refs-title {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate);
}

.calc-how__refs {
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.calc-how__refs li + li {
  margin-top: 6px;
}

.calc-how__refs a {
  color: inherit;
  text-decoration: underline;
}

/* Pulled up against the hero's 16px gap, so it reads as part of the title. */
.page-hero__updated {
  margin-top: -8px;
  font-size: 14px;
  color: var(--muted);
}

.calc-faq {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calc-faq__item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0 20px;
}

.calc-faq__q {
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding: 16px 0;
  line-height: 1.4;
}

.calc-faq__q:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.calc-faq__a {
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
  padding-bottom: 18px;
}

/* What Intimassy is, above the calculator's title. */
.calc-app-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  align-self: center;
  max-width: 100%;
  padding: 10px 10px 10px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-align: left;
}

.calc-app-strip__icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.calc-app-strip__text {
  flex: 1 1 220px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

/* Download buttons: to the home page with ?from=, never to a store. */
.calc-cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--button);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 28px;
  min-height: 48px;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.calc-cta:hover {
  background: var(--slate);
}

.calc-cta:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

/* Month calendar. The period hue is the app's
   light-theme cycle colour (intimassy-re lib/theme/tokens.dart). */
.calc-result__calendar {
  --cycle-hue: #F00F44;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

.calc-cal__months {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.calc-cal {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calc-cal__caption {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  padding-bottom: 8px;
}

.calc-cal th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 4px;
}

.calc-cal td {
  text-align: center;
  padding: 2px 0;
}

.calc-cal__day {
  position: relative;
  height: 40px;
}

.calc-cal__num {
  position: relative;
  font-size: 14px;
  line-height: 1;
  color: var(--ink);
}

.calc-cal__day--today .calc-cal__num {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The fertile window: one band behind the days, with rounded ends where the
   window, a week row or a month starts and stops. The edge colour carries
   the 3:1 contrast the pale fill does not. */
.calc-cal__day--band::before,
.calc-legend__swatch[data-mark="fertile"]::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 34px;
  transform: translateY(-50%);
  background: var(--teal-soft);
  border-top: 1.5px solid var(--teal);
  border-bottom: 1.5px solid var(--teal);
}

.calc-cal__day--band-start::before {
  left: 3px;
  border-left: 1.5px solid var(--teal);
  border-top-left-radius: 999px;
  border-bottom-left-radius: 999px;
}

.calc-cal__day--band-end::before {
  right: 3px;
  border-right: 1.5px solid var(--teal);
  border-top-right-radius: 999px;
  border-bottom-right-radius: 999px;
}

.calc-cal__day--ovulation .calc-mark,
.calc-legend__swatch[data-mark="ovulation"] .calc-mark {
  color: var(--teal);
}

.calc-cal__day--ovulation .calc-cal__num {
  color: #fff;
  font-weight: 800;
}

.calc-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(36px, 100%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: var(--cycle-hue);
  overflow: visible;
  pointer-events: none;
}

.calc-legend__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-legend__item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--slate);
}

.calc-legend__swatch {
  --cycle-hue: #F00F44;
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
}

.calc-legend__swatch .calc-mark {
  width: 100%;
}

.calc-legend__swatch[data-mark="fertile"]::before {
  height: 18px;
  border: 1.5px solid var(--teal);
  border-radius: 999px;
}

.calc-legend__today {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The app block stacks and centres its text below 768px (style.css). */
@media (max-width: 768px) {
  .patterns .calc-cta {
    align-self: center;
  }
}

@media (max-width: 560px) {
  .calc-app-strip {
    border-radius: 20px;
    padding: 14px;
  }

  .calc-app-strip__text {
    flex-basis: calc(100% - 46px);
    font-size: 14px;
  }

  .calc__panel,
  .calc-result {
    padding: 20px;
  }

  .calc__modes-options,
  .calc-result__key {
    grid-template-columns: 1fr;
  }

  .calc__submit {
    align-self: stretch;
  }
}
