/* Homepage: hero, preview card, calculator, guides, why-section */

.hero {
  padding: var(--space-7) 0 var(--space-6);
}

.hero__inner {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

/* Grid items must be allowed to shrink below their content's min width,
   otherwise wide children (chips, selects) blow out the mobile viewport. */
.hero__inner > *,
.calc > * {
  min-width: 0;
}

.hero__title {
  margin-bottom: var(--space-4);
}

.hero__title-accent {
  color: var(--color-primary);
}

.hero__subtitle {
  font-size: 1.0625rem;
  color: var(--color-text-muted);
  max-width: 30rem;
}

.hero__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hero__squiggle {
  width: 3.5rem;
  flex: none;
}

.hero__note {
  margin-top: var(--space-3);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.hero__preview {
  padding: var(--space-5);
}

.preview__chips {
  margin-bottom: var(--space-5);
}

.preview__heading {
  font-size: 1rem;
  margin-bottom: var(--space-3);
}

.preview__chart {
  display: grid;
  gap: var(--space-4);
  align-items: center;
}

.donut {
  width: 100%;
  max-width: 13rem;
  margin: 0 auto;
}

.donut__total {
  font-size: 26px;
  font-weight: 700;
  fill: var(--color-text);
}

.donut__label {
  font-size: 13px;
  fill: var(--color-text-muted);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
}

.legend__dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex: none;
}

.legend__label {
  flex: 1;
}

.legend__value {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

/* Sections */

.section {
  padding: var(--space-6) 0;
}

.section--alt {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-7) 0;
}

.section__block {
  margin-top: var(--space-5);
}

.section__title--center {
  text-align: center;
  margin-bottom: var(--space-6);
}

.section__lead {
  max-width: 40rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

/* Topic guide hub */

.topic-guides__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.topic-guides__header h2 {
  margin-bottom: var(--space-2);
}

.topic-guides__header .section__lead {
  margin-bottom: 0;
}

.topic-guides__all {
  flex: none;
  font-weight: 700;
}

.topic-guides__pillar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-block: 1px solid var(--color-border);
  color: var(--color-text);
  text-decoration: none;
}

.topic-guides__pillar strong,
.topic-guides__pillar small {
  display: block;
}

.topic-guides__pillar strong {
  margin-bottom: var(--space-1);
  font-size: 1.125rem;
}

.topic-guides__pillar small {
  max-width: 48rem;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.topic-guides__pillar:hover strong,
.topic-guides__pillar:focus-visible strong,
.topic-guides__list a:hover,
.topic-guides__list a:focus-visible {
  color: var(--color-primary-dark);
}

.topic-guides__list {
  display: grid;
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.topic-guides__list li {
  min-width: 0;
  border-bottom: 1px solid var(--color-border);
}

.topic-guides__list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 3.5rem;
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.topic-guides__arrow {
  flex: none;
  color: var(--color-primary);
  font-size: 1.25rem;
}

/* Calculator */

.calc {
  display: grid;
  gap: var(--space-4);
}

.calc__panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.calc__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.calc__title {
  margin: 0;
  font-size: 1.25rem;
}

.calc__rows {
  display: grid;
  gap: var(--space-2);
}

.calc__group-label {
  margin-top: var(--space-2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.calc__group-label:first-child {
  margin-top: 0;
}

.calc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--space-2);
}

.calc-row__icon {
  font-size: 1.125rem;
}

.calc-row:has(.calc-row__icon) {
  grid-template-columns: auto 1fr auto auto;
}

.calc-row__label {
  font-weight: 500;
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-row__hint {
  display: block;
  color: var(--color-text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.calc-row__form {
  margin: 0;
}

.calc-row__delete {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1);
}

.calc-row__delete:hover {
  color: var(--color-danger);
}

.amount-input {
  position: relative;
  display: block;
}

.amount-input__currency {
  position: absolute;
  inset-inline-start: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.amount-input .form__input {
  padding-inline-start: 1.75rem;
}

.amount-input--compact .form__input {
  width: 7.5rem;
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.calc-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: center;
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
}

.calc-add__provider {
  grid-column: 1 / -1;
}

.calc-add__button {
  grid-column: 1 / -1;
  border-style: dashed;
  justify-content: center;
}

.calc-add__button--pink {
  color: var(--color-expense);
  border-color: var(--color-expense);
}

.calc-add__button--pink:hover {
  background: var(--color-expense-soft);
}

.calc__providers-link {
  margin: 0;
  font-size: 0.875rem;
}

.calc__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-m);
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  margin-top: auto;
}

.calc__total--green {
  background: var(--color-primary-soft);
}

.calc__total--green strong {
  color: var(--color-primary-dark);
  font-size: 1.25rem;
}

.calc__total--pink {
  background: var(--color-expense-soft);
}

.calc__total--pink strong {
  color: var(--color-expense-dark);
  font-size: 1.25rem;
}

/* Why section */

.why {
  display: grid;
  gap: var(--space-6);
  text-align: center;
}

.why__item h3 {
  margin: var(--space-3) 0 var(--space-2);
  font-size: 1.0625rem;
}

.why__item p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

@media (min-width: 40rem) {
  .topic-guides__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-5);
  }

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

  .preview__chart {
    grid-template-columns: auto 1fr;
  }
}

@media (min-width: 64rem) {
  .hero__inner {
    grid-template-columns: 5fr 6fr;
  }

  .calc {
    grid-template-columns: 1fr 1fr;
  }

  .why {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 39.999rem) {
  .topic-guides__header {
    align-items: start;
    flex-direction: column;
  }
}

/* Legal pages (privacy & cookie policy) */

.legal h1 {
  margin-bottom: var(--space-2);
}

.legal h2 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: 1.25rem;
}

.legal p,
.legal li {
  color: var(--color-text-muted);
  line-height: 1.6;
}

.legal ul {
  padding-inline-start: 1.25rem;
  display: grid;
  gap: var(--space-2);
}

.legal__updated {
  font-size: 0.875rem;
  margin-bottom: var(--space-5);
}

.legal__table-wrap {
  overflow-x: auto;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  font-size: 0.875rem;
}

.legal-table th,
.legal-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  text-align: start;
  vertical-align: top;
}

.legal-table th {
  color: var(--color-text);
}

.legal-table tr:last-child td {
  border-bottom: none;
}
