/*
 * Calculator pages and the hub. Loaded from document.tsx on those pages only. Tokens, the hero panel, the tiles and
 * the glow panel come from academy.css: 1. hero  2. calculator  3. text  4. sidebar  5. hub.
 */

/* 1. Hero: the home panel, lower, with room at the bottom for the calculator that sits on its edge. */
.academy-hero__panel.academy-tool__hero {
  gap: 1rem;
  padding: 2.5rem 1.25rem 5rem;
}
.academy-tools-hub .academy-hero__panel.academy-tool__hero {
  padding-bottom: 2.5rem;
}
.academy-tool__hero .academy-hero__title {
  max-width: 22ch;
  margin: 0;
  font-size: 2.125rem;
}
.academy-tool__hero .academy-hero__lead {
  max-width: 40rem;
  font-size: 1.0625rem;
}
.academy-tool__badge {
  margin: 0;
  padding-right: 0.875rem;
  background: var(--cs-color-widgets-background);
  box-shadow: var(--academy-shadow-soft);
}

/* 2. Calculator: a raised card with the fields on its surface and the answer on a glow panel set into it. */
.academy-calc-card,
.academy-tool__layout {
  max-width: 68rem;
  margin-inline: auto;
}
.academy-calc-card {
  position: relative;
  width: calc(100% - 1rem);
  margin-top: -3.5rem;
  padding: 0.375rem;
  border-radius: var(--academy-radius-xl);
  background: var(--cs-color-widgets-background);
  box-shadow: var(--academy-shadow-raised), 0 28px 48px -36px rgba(0, 0, 0, 0.35);
}
.academy-calc {
  display: grid;
  gap: 0.375rem;
}
.academy-calc [hidden] {
  display: none;
}
.academy-calc__inputs {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  padding: 1.125rem;
}
.academy-calc__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem 0.75rem;
}
.academy-calc__wide,
.academy-calc__rows,
.academy-calc__add,
.academy-calc__choice {
  grid-column: 1 / -1;
}
.academy-calc__field {
  display: grid;
  align-content: end;
  gap: 0.375rem;
  min-width: 0;
}
.academy-calc__field,
.academy-calc__choice legend,
.academy-calc__hint {
  color: var(--cs-color-post-meta);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
}
.academy-calc__field i {
  font-style: normal;
  font-weight: 400;
}
.academy-calc__input,
.academy-calc__segments {
  border-radius: 999px;
  background: var(--cs-color-site-background);
  box-shadow: inset 0 0 0 1px var(--academy-ring);
}
.academy-calc__input {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 1rem;
  font-size: 1rem;
  font-weight: 400;
  transition: box-shadow 0.2s;
}
.academy-calc__input:focus-within {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--academy-brand) 70%, var(--cs-color-primary)), 0 0 0 3px color-mix(in srgb, var(--academy-brand) 40%, transparent);
}
.academy-calc__input--money::before {
  content: '$';
}
.academy-calc__input--percent::after {
  content: '%';
}
.academy-calc .academy-calc__input input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--cs-color-primary);
  font: inherit;
  font-variant-numeric: tabular-nums;
  outline: 0;
}
/* The pill carries the focus ring, so the theme's ring on the input itself is off. */
.academy-calc .academy-calc__input input:focus {
  box-shadow: none;
}
.academy-calc__choice {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.academy-calc__choice legend {
  margin-bottom: 0.375rem;
  padding: 0;
}
/* Long or short: a switch. The radio is kept for the keyboard and hidden from the eye. */
.academy-calc__segments {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 0.25rem;
}
.academy-calc__segments label {
  position: relative;
  padding: 0.625rem 1rem;
  border-radius: 999px;
  color: var(--cs-color-post-meta);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.academy-calc__segments input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.academy-calc__segments label:has(:checked) {
  background: var(--cs-color-widgets-background);
  box-shadow: var(--academy-shadow-raised);
  color: var(--cs-color-primary);
}
.academy-calc__segments label:has(:focus-visible) {
  outline: 2px solid var(--academy-brand);
}
.academy-calc__rows {
  display: grid;
  gap: 0.75rem;
}
.academy-calc__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 0.5rem;
}
.academy-calc__row + .academy-calc__row {
  padding-top: 0.75rem;
  border-top: 1px solid var(--academy-line);
}
/* Quiet controls: the theme paints every button black, these are not the main action. */
.academy-calc__add,
.academy-calc__ghost,
.academy-calc__remove {
  border-radius: 999px;
  background: none;
  color: var(--cs-color-post-meta);
}
.academy-calc__add:hover,
.academy-calc__ghost:hover,
.academy-calc__remove:hover {
  background: var(--cs-color-site-background);
  color: var(--cs-color-primary);
}
.academy-calc__remove {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  box-shadow: inset 0 0 0 1px var(--academy-ring);
}
.academy-calc__add {
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px dashed color-mix(in srgb, var(--cs-color-primary) 22%, transparent);
  color: var(--cs-color-primary);
}
.academy-calc__hint {
  margin: 0;
  font-weight: 400;
  line-height: 1.5;
}
.academy-calc__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: auto -0.5rem 0;
}
.academy-calc__ghost {
  padding: 0.75rem 0.5rem;
}
.academy-calc__copy {
  margin: 0 0.5rem 0 auto;
  padding: 0.75rem 1rem;
}

/* The answer: the one dark surface, lit from above by the brand colour, the same in both schemes. */
.academy-calc__result {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.5rem 1.25rem 1.25rem;
  border-radius: calc(var(--academy-radius-xl) - 0.375rem);
  background: radial-gradient(75% 60% at 50% 0, color-mix(in srgb, var(--academy-brand) 34%, transparent), transparent 72%), #141614;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #fff;
}
.academy-calc__line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.75rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9375rem;
}
.academy-calc__line output,
.academy-calc__table b {
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}
.academy-calc__line--detail,
.academy-calc__line--detail output {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
}
/* The answer: label above, number at title size. It holds the top of the panel, the breakdown sits at the bottom. */
.academy-calc__line--lead {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.375rem;
  margin-bottom: auto;
  padding: 0 0 1.25rem;
  border: 0;
}
.academy-calc__line--lead output {
  font-size: 2.75rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1;
  text-align: left;
  overflow-wrap: anywhere;
}
/* On the dark panel a gain is the brand colour and a loss a soft red, in both schemes. */
.academy-calc__line--up output,
.academy-calc__table .academy-calc__line--up {
  color: var(--academy-brand);
}
.academy-calc__line--down output,
.academy-calc__table .academy-calc__line--down,
.academy-calc__error {
  color: #ff9d8f;
}
.academy-calc__error {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.5;
}
.academy-calc__table {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.academy-calc__caption {
  margin: 0 0 0.625rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8125rem;
}
.academy-calc__table ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.25rem, 1fr));
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.academy-calc__table li {
  display: grid;
  gap: 0.25rem;
  padding: 0.625rem 0.25rem;
  border-radius: var(--academy-radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  line-height: 1.2;
  text-align: center;
}
.academy-calc__table b {
  font-size: 0.9375rem;
  text-align: center;
}

/* 3. Text: one readable column, headings as light as the section headings of the home. */
.academy-tool__layout {
  display: grid;
  gap: 3rem;
  margin-top: 3.5rem;
}
.academy-tool__main {
  min-width: 0;
}
.academy-tool .academy-tool__copy > h2 {
  margin: 3rem 0 0;
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.academy-tool .academy-tool__copy > h2:first-child {
  margin-top: 0;
}
.academy-tool .academy-tool__copy p {
  margin: 1rem 0 0;
  font-size: 1.0625rem;
  line-height: 1.65;
}
.academy-tool__example,
.academy-tool__faq,
.academy-tool__more {
  border-radius: var(--academy-radius-lg);
  background: var(--cs-color-widgets-background);
}
.academy-tool__example {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--academy-brand) 16%, var(--cs-color-widgets-background));
}
.academy-tool__faq {
  margin-top: 1.5rem;
  padding: 0 1.25rem;
}
.academy-tool__qa {
  padding: 1.25rem 0;
}
.academy-tool__qa + .academy-tool__qa {
  border-top: 1px solid var(--academy-line);
}
.academy-tool .academy-tool__copy h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.academy-tool .academy-tool__copy :is(.academy-tool__example, .academy-tool__qa) p {
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.6;
}
.academy-tool__related,
.academy-tool__copy .academy-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.academy-tool__note,
.academy-tool__side-title {
  color: var(--cs-color-post-meta);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.academy-tool__note {
  margin: 3rem 0 0;
}

/* A tool as a row: icon, then name over blurb. The sidebar list and "Related Tools". */
.academy-tool__rows .academy-topic {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.125rem 0.875rem;
  padding: 0.875rem;
}
.academy-tool__rows .academy-icon {
  grid-row: span 2;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
}
.academy-tool__rows .academy-icon svg {
  width: 1.375rem;
  height: 1.375rem;
}
.academy-tool__rows .academy-topic__name {
  align-self: end;
  font-size: 1rem;
}
.academy-tool__rows .academy-topic__blurb {
  align-self: start;
  font-size: 0.8125rem;
  line-height: 1.35;
}

/* Newsletter on the tool pages: the brand glow of the hero, a lime icon and a lime button. */
.academy-tool .academy-tool__cta {
  background: radial-gradient(130% 75% at 50% 0, color-mix(in srgb, var(--academy-brand) 30%, var(--cs-color-widgets-background)), var(--cs-color-widgets-background) 80%);
}
.academy-tool__cta > .academy-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1.25rem;
}
.academy-tool__cta .cs-site-subscribe__title {
  text-wrap: balance;
}
.academy-tool__cta .pk-subscribe-submit,
.academy-tool__cta .pk-subscribe-submit:hover {
  background: var(--academy-brand);
  color: #141614;
}

/* 4. Sidebar: the newsletter panel at card size, then the other calculators. */
.academy-tool__side {
  display: grid;
  align-content: start;
  gap: 1rem;
}
.academy-tool__side .academy-icon {
  margin-inline: 0;
}
.academy-tool__side .cs-entry__subscribe {
  margin: 0;
  padding: 1.5rem;
  border-radius: var(--academy-radius-lg);
  text-align: left;
}
.academy-tool__side .cs-site-subscribe__title {
  font-size: 1.375rem;
}
.academy-tool__side .cs-site-subscribe__excerpt {
  font-size: 0.9375rem;
}
.academy-tool__side .cs-site-subscribe__form {
  gap: 1rem;
}
.academy-tool__more {
  padding: 1.25rem 0.75rem 1rem;
}
.academy-tool__side-title,
.academy-tool__more .academy-more {
  margin: 0 0.5rem 0.5rem;
}
.academy-tool__more .academy-more {
  margin-top: 0.5rem;
}
.academy-tool__more .academy-topic {
  padding: 0.5rem;
  border-radius: var(--academy-radius-sm);
  background: none;
}
.academy-tool__more .academy-topic:hover {
  background: var(--cs-color-site-background);
  box-shadow: none;
  transform: none;
}

/* 5. Hub: two wide cards, then three. */
.academy-tool-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}
.academy-tool-tile--card {
  gap: 0.625rem;
  padding: 1.5rem;
  border-radius: var(--academy-radius-lg);
}
.academy-tool-tile--card .academy-topic__name {
  margin-top: 0.5rem;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.academy-tool-tile__example {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--academy-radius-sm);
  background: var(--cs-color-site-background);
  color: var(--cs-color-post-meta);
  font-size: 0.8125rem;
}
.academy-tool-tile__example b {
  color: var(--cs-color-primary);
  font-size: 1rem;
  font-weight: 600;
}
.academy-tool-tile__go {
  font-size: var(--cs-font-primary-size);
  font-weight: 500;
}

@media (min-width: 560px) {
  .academy-calc__row {
    grid-template-columns: 1fr 1fr 1fr auto;
  }
  .academy-calc__row + .academy-calc__row {
    padding-top: 0;
    border-top: 0;
  }
  /* One line per purchase: the first row carries the column names, the rest keep them for screen readers only. */
  .academy-calc__row + .academy-calc__row .academy-calc__field > span:first-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .academy-tool__related,
  .academy-tool__copy .academy-list {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 720px) {
  .academy-hero__panel.academy-tool__hero {
    padding: 3.5rem 3rem 6.5rem;
  }
  .academy-tools-hub .academy-hero__panel.academy-tool__hero {
    padding-bottom: 3.5rem;
  }
  .academy-tool__hero .academy-hero__title {
    max-width: none;
    font-size: 3rem;
  }
  .academy-calc-card {
    width: calc(100% - 4rem);
    margin-top: -4.5rem;
    padding: 0.5rem;
  }
  .academy-calc {
    gap: 0.5rem;
  }
  .academy-calc__inputs {
    padding: 1.5rem;
  }
  .academy-calc__result {
    padding: 2rem 1.75rem 1.75rem;
    border-radius: calc(var(--academy-radius-xl) - 0.5rem);
  }
  .academy-calc__line--lead output {
    font-size: 3.5rem;
  }
  .academy-tool .academy-tool__copy > h2 {
    font-size: 2.25rem;
  }
  .academy-tool__example {
    padding: 1.5rem;
  }
  .academy-tool__faq {
    padding: 0 1.5rem;
  }
  .academy-tool-tile--card {
    padding: 2rem;
  }
}
@media (min-width: 720px) and (max-width: 1019px) {
  .academy-tool-grid,
  .academy-tool__side {
    grid-template-columns: 1fr 1fr;
  }
  .academy-tool-grid > :last-child {
    grid-column: 1 / -1;
  }
}
@media (min-width: 900px) {
  .academy-calc {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
@media (min-width: 1020px) {
  /* The trail sits on the axis of the centred hero, as it does above a post. */
  .academy-tool > .cs-breadcrumbs {
    text-align: center;
  }
  .academy-tool__layout {
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 4rem;
    margin-top: 5rem;
  }
  .academy-tool-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  .academy-tool-grid > * {
    grid-column: span 2;
  }
  .academy-tool-grid > :nth-child(-n + 2) {
    grid-column: span 3;
  }
}
@media (min-width: 1020px) and (min-height: 820px) {
  .academy-tool__side {
    position: sticky;
    top: 6rem;
    align-self: start;
  }
}
