/*
 * Age Gap Calculator, layout only. Colour and scale come from tokens.css.
 *
 * The tool is one centred card, the same card language the /statistics/ and
 * /calculators/ hubs use: white surface, soft indigo shadow, generous radius.
 * Inside it the reading order is control -> input -> result, top to bottom,
 * centre-aligned so the headline number lands on the page's optical centre.
 */

.ms-calc--age-gap {
  /* no width of its own: the row is the site's 1200 container, so the tool lines
     up with every other page instead of floating in a narrower column */
  width: 100%;
  margin: 0 0 32px;
}

.ms-calc__card {
  background: var(--ms-white);
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius-lg);
  box-shadow: var(--ms-shadow);
  padding: clamp(20px, 4vw, 34px);
}

/* ---------- mode switch ---------- */

.ms-calc__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 22px;
}

.ms-calc__modes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--ms-surface-1);
  border-radius: 999px;
}

.ms-calc__mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ms-primary-dark);
  border-radius: 999px;
  padding: 9px 16px;
  font-family: var(--ms-ui-font);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  /* white-on-dark type renders thinner than dark-on-light at the same size, so
     all three pills get the same smoothing and the active one stops looking
     a size smaller than its neighbours */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.ms-calc__mode:hover { background: var(--ms-surface-2); }

.ms-calc__mode.is-active {
  background: var(--ms-primary-dark);
  color: var(--ms-white);
  box-shadow: 0 1px 2px rgba(29, 15, 107, .2);
}

.ms-calc__reset {
  appearance: none;
  border: 0;
  background: none;
  font-family: var(--ms-ui-font);
  color: var(--ms-text-muted);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}

.ms-calc__reset:hover { color: var(--ms-primary-dark); }

/* one label per pill: the long one from 620px up, the short one below, because
   three full labels cannot fit a phone row and wrapping them reads as broken */
.ms-calc__mode-short { display: none; }

@media (max-width: 619px) {
  .ms-calc__controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .ms-calc__modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }
  .ms-calc__mode {
    padding: 10px 4px;
    font-size: .875rem;
    text-align: center;
  }
  .ms-calc__mode-long { display: none; }
  .ms-calc__mode-short { display: inline; }
  .ms-calc__reset { align-self: flex-end; padding: 2px 2px 0; }
}

.ms-calc__precision {
  margin: -10px 0 18px !important;
  font-size: .875rem;
  color: var(--ms-text-muted);
}

/* ---------- inputs ---------- */

.ms-calc__inputs {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 620px) {
  .ms-calc__inputs { grid-template-columns: 1fr 1fr; gap: 8px 28px; }
}

.ms-calc__field { min-width: 0; }

.ms-calc__label {
  font-family: var(--ms-ui-font);
  display: block;
  margin: 0 0 7px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}

/*
 * The theme styles input[type="text"] directly (12px, 3px padding) and that
 * outranks a single class, so a text field and a number field rendered at two
 * different sizes in the same control. Everything that decides the field's size
 * is therefore forced here, and the rule is written for any input type the
 * modes switch to.
 */
.ms-calc input.ms-calc__input,
.ms-calc__input {
  font-family: var(--ms-ui-font) !important;
  width: 100% !important;
  max-width: 360px !important;
  padding: 14px 16px !important;
  font-size: 1.125rem !important;
  line-height: 1.3 !important;
  height: auto !important;
  font-variant-numeric: tabular-nums;
  color: var(--ms-text) !important;
  background: var(--ms-white) !important;
  border: 1.5px solid var(--ms-border) !important;
  border-radius: var(--ms-radius) !important;
  box-shadow: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* a spinner on a birth year earns nothing */
.ms-calc__input::-webkit-outer-spin-button,
.ms-calc__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ms-calc__input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.ms-calc__input::placeholder { color: #a9a4c9; }

.ms-calc input.ms-calc__input:hover { border-color: #b7b0f7 !important; }

.ms-calc input.ms-calc__input:focus,
.ms-calc__input:focus {
  outline: none;
  border-color: var(--ms-accent) !important;
  box-shadow: var(--ms-focus);
}

.ms-calc__hint,
.ms-calc__error {
  margin: 7px 0 0 !important;   /* the theme sets p { margin-bottom: 26px } */
  font-size: .875rem;
}

.ms-calc__hint { min-height: 1.25em; color: var(--ms-text-muted); font-weight: 600; }
.ms-calc__error { min-height: 0; color: #a3231b; }
.ms-calc__error:empty { margin: 0 !important; }

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

.ms-calc__result {
  margin: 22px 0 0;
  padding: clamp(20px, 3.5vw, 28px);
  background: var(--ms-surface-2);
  border-radius: var(--ms-radius);
  min-height: 176px;              /* reserved from first paint, so CLS stays 0 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.ms-calc__empty-line {
  font-family: var(--ms-ui-font);
  margin: 0 !important;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ms-ink);
}

.ms-calc__empty-sub {
  margin: 6px auto 0 !important;
  max-width: 34ch;
  font-size: .9375rem;
  color: var(--ms-text-muted);
}

.ms-calc__kicker {
  font-family: var(--ms-ui-font);
  margin: 0 0 4px !important;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ms-primary);
}

.ms-calc__gap {
  font-family: var(--ms-ui-font);
  margin: 0 !important;
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.01em;
  color: var(--ms-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- stat tiles ---------- */

.ms-calc__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin: 22px auto 0;
  max-width: 620px;      /* the tiles read as a group, not as a stretched row */
}

.ms-calc__tile {
  background: var(--ms-white);
  border-radius: var(--ms-radius);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ms-calc__tile-value {
  font-family: var(--ms-ui-font);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ms-ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.ms-calc__tile-label {
  font-family: var(--ms-ui-font);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
  line-height: 1.3;
}

/* ---------- distribution ---------- */

.ms-calc__compare { margin: 22px 0 0; }

.ms-calc__bar-wrap { max-width: 620px; margin: 0 auto 14px; }

.ms-calc__bar {
  position: relative;
  height: 10px;
  background: var(--ms-white);
  border-radius: 999px;
}

.ms-calc__bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ms-accent), var(--ms-primary-dark));
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}

.ms-calc__bar-marker {
  position: absolute;
  top: -4px;
  left: 0;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: var(--ms-white);
  border: 3px solid var(--ms-ink);
  box-shadow: 0 1px 3px rgba(29, 15, 107, .25);
  transition: left .3s cubic-bezier(.4, 0, .2, 1);
}

.ms-calc__bar-scale {
  font-family: var(--ms-ui-font);
  display: flex;
  justify-content: space-between;
  margin: 10px 0 0;
  font-size: .6875rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--ms-text-muted);
}

.ms-calc__percentile {
  font-family: var(--ms-ui-font);
  margin: 0 auto !important;
  max-width: 46ch;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ms-ink);
}

.ms-calc__rule { margin: 12px 0 0 !important; }

.ms-calc__chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ms-white);
  border: 1px solid var(--ms-border);
  font-size: .8125rem;
  color: var(--ms-text-muted);
}

/* ---------- notice, actions ---------- */

.ms-calc__notice {
  margin: 18px 0 0;
  padding: 14px 16px;
  background: var(--ms-notice-bg);
  border: 1px solid var(--ms-notice-border);
  border-radius: var(--ms-radius);
  color: var(--ms-notice-text);
  font-size: .9375rem;
  text-align: left;
}

.ms-calc__notice a { color: var(--ms-notice-text); }

.ms-calc__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 0;
}

.ms-calc__btn { padding: 11px 20px; }

.ms-calc__copied { font-size: .875rem; color: var(--ms-text-muted); }

/* ---------- footer ---------- */

.ms-calc__source {
  margin: 16px auto 0 !important;
  max-width: 62ch;
  font-size: .8125rem;
  line-height: 1.55;
  text-align: center;
  color: var(--ms-text-muted);
}

.ms-calc__embed-box {
  margin: 14px 0 0;
  font-size: .875rem;
  color: var(--ms-text-muted);
  text-align: center;
}

.ms-calc__embed-box summary {
  cursor: pointer;
  color: var(--ms-primary-dark);
  font-weight: 600;
  display: inline-block;
}

.ms-calc__embed-note { margin: 10px 0 8px !important; }

.ms-calc__embed-code {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--ms-border);
  border-radius: var(--ms-radius);
  background: var(--ms-surface-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8125rem;
  text-align: left;
  resize: vertical;
}

/* ---------- embedded on another site ---------- */

.ms-calc--embed { max-width: none; margin: 0; }

.ms-calc--embed .ms-calc__card {
  border: 0;
  box-shadow: none;
  padding: 0;
}
