/* Lazy Pounds: brand tokens and base styles. */

:root {
  /* Colour */
  --lp-teal: #0E5A54;        /* primary */
  --lp-marigold: #E0A030;    /* decorative accent only: never text or controls */
  --lp-ink: #17191C;
  --lp-linen: #F4F2EC;       /* page background */
  --lp-stone: #9AA0A6;       /* decorative rules only: too light for text on linen */
  --lp-muted: #5B5F66;       /* secondary text */
  --lp-warn-bg: #FBEBDD;
  --lp-warn-text: #7A3206;
  --lp-white: #FFFFFF;

  /* Type */
  --lp-font-display: "Fraunces", Georgia, serif;
  --lp-font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --lp-font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Layout */
  --lp-touch-target: 44px;   /* WCAG 2.2 AA, and our own minimum */
  --lp-radius: 8px;
  --lp-space-1: 0.25rem;
  --lp-space-2: 0.5rem;
  --lp-space-3: 1rem;
  --lp-space-4: 1.5rem;
  --lp-space-5: 2.5rem;
  --lp-gutter: clamp(1rem, 3vw, 3rem);  /* pages use the full window width, less this */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--lp-linen);
  color: var(--lp-ink);
  font-family: var(--lp-font-ui);
  font-size: 1rem;
  line-height: 1.5;
}

main {
  flex: 1;
  padding-block: var(--lp-space-5);
}

main:focus {
  outline: none;
}

.container {
  width: 100%;
  padding-inline: var(--lp-gutter);
}

/* Typography */

h1, h2, h3, .display {
  font-family: var(--lp-font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 var(--lp-space-3);
}

.display {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
}

.lede {
  font-size: 1.125rem;
  max-width: 40rem;
}

.muted {
  color: var(--lp-muted);
}

/* Money and rates are always monospaced so columns line up. */
.money,
.rate {
  font-family: var(--lp-font-mono);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--lp-teal);
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

/* Controls: every interactive element is at least 44px tall. */

.button,
button,
input,
select,
textarea {
  font: inherit;
  min-height: var(--lp-touch-target);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--lp-touch-target);
  padding: var(--lp-space-2) var(--lp-space-4);
  border: 2px solid var(--lp-teal);
  border-radius: var(--lp-radius);
  background: var(--lp-teal);
  color: var(--lp-white);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button--secondary {
  background: transparent;
  color: var(--lp-teal);
}

input,
select,
textarea {
  max-width: 100%;  /* a long option mustn't widen the page on a phone */
  padding: var(--lp-space-2) var(--lp-space-3);
  border: 1px solid var(--lp-muted);
  border-radius: var(--lp-radius);
  background: var(--lp-white);
  color: var(--lp-ink);
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--lp-space-1);
}

/* Notices */

.notice {
  padding: var(--lp-space-3);
  border-left: 4px solid var(--lp-teal);
  border-radius: var(--lp-radius);
  background: var(--lp-white);
  max-width: 40rem;
}

.warning {
  padding: var(--lp-space-3);
  border-radius: var(--lp-radius);
  background: var(--lp-warn-bg);
  color: var(--lp-warn-text);
}

/* Header and footer */

.skip-link {
  position: absolute;
  left: var(--lp-space-3);
  top: -100px;
  padding: var(--lp-space-2) var(--lp-space-3);
  background: var(--lp-teal);
  color: var(--lp-white);
  z-index: 10;
}

.skip-link:focus {
  top: var(--lp-space-2);
}

.site-header {
  border-bottom: 1px solid var(--lp-stone);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--lp-space-3);
  min-height: 4.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--lp-touch-target);
}

.brand svg {
  display: block;
  width: 208px;
  height: auto;
}

.site-footer {
  border-top: 1px solid var(--lp-stone);
  padding-block: var(--lp-space-4);
  color: var(--lp-muted);
  font-size: 0.9375rem;
}

.site-footer p {
  margin: 0 0 var(--lp-space-2);
}

/* Home */

.hero {
  padding-block: var(--lp-space-4);
}

.hero .display {
  max-width: 20ch;
}

/* Navigation */

.site-nav {
  display: flex;
  gap: var(--lp-space-2);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--lp-touch-target);
  padding-inline: var(--lp-space-3);
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--lp-radius);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.site-nav__form {
  display: flex;
  margin: 0;
}

/* Sign out is a form button (it changes state) that looks like the other menu links. */
.site-nav__button {
  min-width: 0;
  padding-inline: var(--lp-space-3);
  border: 0;
  background: transparent;
  color: var(--lp-teal);
  font-weight: 500;
  text-underline-offset: 0.15em;
}

.site-nav__button:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Sign in */

.auth {
  max-width: 32rem;
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: var(--lp-space-2);
  margin-bottom: var(--lp-space-4);
}

.auth__form label {
  margin: 0;
}

.auth__form button {
  align-self: flex-start;
}

.auth__code {
  max-width: 12rem;
  font-family: var(--lp-font-mono);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
}

.auth__again {
  margin-bottom: var(--lp-space-2);
}

/* Phones: a smaller logo and tighter menu, so the signed-in header fits on one line. */
@media (max-width: 30rem) {
  .brand svg {
    width: 140px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 0;
  }

  .site-nav a,
  .site-nav__button {
    padding-inline: var(--lp-space-2);
    white-space: nowrap;
  }
}

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

/* Rates */

.rates-intro {
  margin-bottom: var(--lp-space-5);
}

/* Wide screens: the explainer sits beside the introduction instead of below it. */
@media (min-width: 64rem) {
  .rates-intro {
    display: grid;
    grid-template-columns: minmax(0, 40rem) minmax(0, 32rem);
    column-gap: var(--lp-space-5);
    align-items: start;
  }

  .rates-intro h1 {
    grid-column: 1 / -1;
  }

  .rates-intro p {
    grid-column: 1;
  }

  .rates-intro .how-we-check {
    grid-column: 2;
    grid-row: 2 / span 2;
  }
}

.rates-intro .muted {
  max-width: 40rem;
}

.how-we-check {
  max-width: 40rem;
  padding: var(--lp-space-2) var(--lp-space-3);
  border-radius: var(--lp-radius);
  background: var(--lp-white);
}

.how-we-check summary {
  display: flex;
  align-items: center;
  min-height: var(--lp-touch-target);
  font-weight: 600;
  cursor: pointer;
}

.how-we-check dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--lp-space-2) var(--lp-space-3);
  margin: 0 0 var(--lp-space-3);
}

.how-we-check dd {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 0.125rem var(--lp-space-2);
  border: 1px solid var(--lp-muted);
  border-radius: 999px;
  color: var(--lp-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge--verified {
  border-color: var(--lp-teal);
  background: var(--lp-teal);
  color: var(--lp-white);
}

/* Filters */

.rate-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--lp-space-3) var(--lp-space-4);
  margin-bottom: var(--lp-space-3);
  padding: var(--lp-space-3);
  border-radius: var(--lp-radius);
  background: var(--lp-white);
}

.rate-filters__field {
  display: flex;
  flex-direction: column;
  min-width: 14rem;
}

.rate-filters__hint {
  color: var(--lp-muted);
  font-size: 0.8125rem;
  margin-top: var(--lp-space-1);
}

.rate-filters__check {
  flex-direction: row;
  align-items: center;
  gap: var(--lp-space-2);
  min-width: 0;
}

.rate-filters__check input {
  width: 1.5rem;
  height: 1.5rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--lp-teal);
}

.rate-filters__check label {
  display: flex;
  align-items: center;
  min-height: var(--lp-touch-target);
  margin: 0;
}

/* Line the checkbox and button up with the other controls, below their labels. */
.rate-filters__check,
.rate-filters__submit {
  margin-top: calc(1.5em + var(--lp-space-1));
}

.rates-untracked {
  margin-top: var(--lp-space-5);
  max-width: 44rem;
}

.rate-status {
  margin-bottom: var(--lp-space-4);
}

.rate-status p {
  margin: 0 0 var(--lp-space-2);
}

.rate-status__count {
  color: var(--lp-muted);
}

.rate-section {
  margin-bottom: var(--lp-space-5);
}

.rate-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--lp-white);
  border-radius: var(--lp-radius);
  overflow: hidden;
}

.rate-table th,
.rate-table td {
  padding: var(--lp-space-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--lp-linen);
}

/* Column shares, so extra width is spread across the row instead of one column. */
.rate-table thead th:nth-child(1) { width: 22%; }
.rate-table thead th:nth-child(2) { width: 9%; }
.rate-table thead th:nth-child(3) { width: 22%; }
.rate-table thead th:nth-child(4) { width: 27%; }
.rate-table thead th:nth-child(5) { width: 20%; }

.rate-table thead th {
  color: var(--lp-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid var(--lp-stone);
}

.rate-table__account {
  font-weight: 400;
}

.rate-table__provider {
  display: block;
  font-weight: 600;
}

.rate-table__product {
  display: block;
  margin-bottom: var(--lp-space-2);
}

.rate-table__aer .rate {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--lp-teal);
  white-space: nowrap;
}

.rate-table__protection,
.rate-table__source {
  font-size: 0.9375rem;
}

.rate-table__source p {
  margin: 0 0 var(--lp-space-2);
}

.rate-table__source a {
  display: inline-flex;
  align-items: center;
  min-height: var(--lp-touch-target);
}

.terms {
  margin: 0;
  padding-left: 1.1rem;
}

.affiliate-label {
  font-size: 0.8125rem;
  color: var(--lp-warn-text);
  background: var(--lp-warn-bg);
  padding: 0.125rem var(--lp-space-2);
  border-radius: var(--lp-radius);
}

/* On narrow screens each row becomes a card: cells stack, labelled by their column. */
@media (max-width: 48rem) {
  .rate-filters__field {
    min-width: 100%;
  }

  .rate-filters__check,
  .rate-filters__submit {
    margin-top: 0;
  }

  .rate-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .rate-table,
  .rate-table tbody,
  .rate-table tr,
  .rate-table th,
  .rate-table td {
    display: block;
  }

  .rate-table {
    background: transparent;
  }

  .rate-table tr {
    margin-bottom: var(--lp-space-3);
    padding-block: var(--lp-space-2);
    background: var(--lp-white);
    border-radius: var(--lp-radius);
  }

  .rate-table th,
  .rate-table td {
    padding-block: var(--lp-space-2);
    border-bottom: 0;
  }

  .rate-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--lp-muted);
    font-size: 0.8125rem;
    font-weight: 500;
  }
}

/* Cards (dashboard) */

.card {
  margin-bottom: var(--lp-space-4);
  padding: var(--lp-space-4);
  border: 1px solid var(--lp-stone);
  border-radius: calc(var(--lp-radius) * 2);
  background: var(--lp-white);
}

.card h1,
.card h2 {
  margin: 0;
}

.card h1 {
  font-size: 1.75rem;
}

.card h2 {
  font-size: 1.375rem;
  margin-bottom: var(--lp-space-3);
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--lp-space-2) var(--lp-space-3);
  margin-bottom: var(--lp-space-3);
}

.card__header h2 {
  margin-bottom: 0;
}

.card__meta {
  margin: 0;
  color: var(--lp-muted);
}

.card__foot {
  margin: var(--lp-space-3) 0 0;
  color: var(--lp-muted);
  font-size: 0.875rem;
}

/* Dashboard: your savings on the left, rates and protection on the right. */

@media (min-width: 64rem) {
  .dashboard {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(20rem, 1fr);
    gap: var(--lp-space-4);
    align-items: start;
  }
}

.savings-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--lp-space-3);
}

.savings-table th,
.savings-table td {
  padding: var(--lp-space-3) var(--lp-space-2);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--lp-linen);
}

.savings-table thead th {
  color: var(--lp-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid var(--lp-stone);
}

.savings-table tbody th {
  font-weight: 400;
}

.savings-table__name {
  display: block;
  font-weight: 600;
}

.savings-table__detail {
  display: block;
  color: var(--lp-muted);
  font-size: 0.875rem;
}

.savings-table__gain {
  color: var(--lp-teal);
  font-weight: 500;
}

.savings-table__edit a {
  display: inline-flex;
  align-items: center;
  min-height: var(--lp-touch-target);
}

.savings-summary {
  padding: var(--lp-space-3);
  border-radius: var(--lp-radius);
  background: var(--lp-linen);
}

.best-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.best-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--lp-space-3);
  padding-block: var(--lp-space-2);
  border-bottom: 1px solid var(--lp-linen);
}

.best-list__name {
  font-weight: 500;
}

.best-list__detail {
  display: block;
  color: var(--lp-muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

.best-list .rate {
  font-size: 1.125rem;
  color: var(--lp-teal);
  white-space: nowrap;
}

.fscs-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.fscs-list li {
  padding-block: var(--lp-space-2);
  border-bottom: 1px solid var(--lp-linen);
}

.fscs-list__row {
  display: flex;
  justify-content: space-between;
  gap: var(--lp-space-3);
  font-weight: 500;
}

.fscs-list__note {
  display: block;
  color: var(--lp-muted);
  font-size: 0.875rem;
}

.fscs-list__note--over {
  display: inline-block;
  margin-top: var(--lp-space-1);
  padding: 0.125rem var(--lp-space-2);
  border-radius: var(--lp-radius);
  background: var(--lp-warn-bg);
  color: var(--lp-warn-text);
}

/* A native <meter>, styled: no inline styles, so a strict CSP can come later. */
.fscs-meter {
  display: block;
  width: 100%;
  height: 0.5rem;
  margin-top: var(--lp-space-1);
  border: 0;
  border-radius: 999px;
  background: var(--lp-linen);
  appearance: none;
}

.fscs-meter::-webkit-meter-bar {
  height: 0.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--lp-linen);
}

.fscs-meter::-webkit-meter-optimum-value,
.fscs-meter::-webkit-meter-suboptimum-value,
.fscs-meter::-webkit-meter-even-less-good-value {
  border-radius: 999px;
  background: var(--lp-teal);
}

.fscs-meter::-moz-meter-bar {
  border-radius: 999px;
  background: var(--lp-teal);
}

.fscs-meter--over::-webkit-meter-optimum-value,
.fscs-meter--over::-webkit-meter-suboptimum-value,
.fscs-meter--over::-webkit-meter-even-less-good-value {
  background: var(--lp-warn-text);
}

.fscs-meter--over::-moz-meter-bar {
  background: var(--lp-warn-text);
}

/* Home */

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

/* Admin */

.admin-section {
  margin-bottom: var(--lp-space-5);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--lp-space-3);
  margin: 0 0 var(--lp-space-3);
  padding: 0;
  list-style: none;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: var(--lp-space-1);
  padding: var(--lp-space-3);
  border: 1px solid var(--lp-stone);
  border-radius: var(--lp-radius);
  background: var(--lp-white);
}

.tile--attention {
  border-color: var(--lp-warn-text);
  background: var(--lp-warn-bg);
}

.tile__value {
  font-family: var(--lp-font-mono);
  font-size: 1.75rem;
  color: var(--lp-teal);
}

.tile--attention .tile__value {
  color: var(--lp-warn-text);
}

.tile__of {
  font-size: 1rem;
  color: var(--lp-muted);
}

.tile__label {
  color: var(--lp-muted);
  font-size: 0.875rem;
}

.review-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-item p {
  margin: 0 0 var(--lp-space-2);
}

.review-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--lp-space-2);
}

.review-item__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--lp-space-1) var(--lp-space-3);
  margin: 0 0 var(--lp-space-3);
  font-size: 0.9375rem;
}

.review-item__facts dt {
  color: var(--lp-muted);
}

.review-item__facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.review-item__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--lp-space-3);
}

.review-item__actions form {
  margin: 0;
}

.review-item__reclassify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--lp-space-2);
}

.review-item__reclassify label {
  margin: 0;
}

.source-table thead th:nth-child(n) {
  width: auto;  /* not the rate table's column shares */
}

.source-table td,
.source-table th {
  overflow-wrap: anywhere;
}

.source-table__failing {
  background: var(--lp-warn-bg);
}

/* Forms */

.account-form {
  max-width: 40rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--lp-space-4);
}

.form-field label {
  margin-bottom: var(--lp-space-1);
}

.form-hint {
  color: var(--lp-muted);
  font-size: 0.875rem;
  margin-bottom: var(--lp-space-1);
}

.field-error {
  margin: 0 0 var(--lp-space-1);
  color: var(--lp-warn-text);
  font-weight: 600;
}

.form-field [aria-invalid="true"] {
  border: 2px solid var(--lp-warn-text);
}

.form-input--short {
  max-width: 14rem;
}

.form-group {
  min-width: 0;  /* fieldsets otherwise refuse to shrink below their content */
  margin: 0 0 var(--lp-space-4);
  padding: var(--lp-space-3) var(--lp-space-3) 0;
  border: 1px solid var(--lp-stone);
  border-radius: var(--lp-radius);
}

.form-group legend {
  padding-inline: var(--lp-space-2);
  font-weight: 600;
}

.error-summary {
  margin-bottom: var(--lp-space-4);
  padding: var(--lp-space-3);
  border-left: 4px solid var(--lp-warn-text);
  border-radius: var(--lp-radius);
  background: var(--lp-warn-bg);
  color: var(--lp-warn-text);
}

.error-summary h2 {
  font-size: 1.125rem;
  margin-bottom: var(--lp-space-2);
}

.error-summary ul {
  margin: 0;
  padding-left: 1.1rem;
}

.error-summary a {
  color: var(--lp-warn-text);
}

.account-form__remove {
  margin-top: var(--lp-space-5);
  padding-top: var(--lp-space-4);
  border-top: 1px solid var(--lp-stone);
}

@media (max-width: 48rem) {
  .savings-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .savings-table,
  .savings-table tbody,
  .savings-table tr,
  .savings-table th,
  .savings-table td {
    display: block;
  }

  .savings-table tr {
    padding-block: var(--lp-space-2);
    border-bottom: 1px solid var(--lp-stone);
  }

  .savings-table th,
  .savings-table td {
    padding-block: var(--lp-space-1);
    border-bottom: 0;
  }

  .savings-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--lp-muted);
    font-size: 0.8125rem;
    font-weight: 500;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
