/* The public landing page at /. The layout, type, buttons and sections come from the site kit in
   /assets/site (system.css and its parts); this file only holds what sits inside the page's visuals:
   the hero's window, the cash book app frame with its live posting demo, and the plan cards. */

/* The nav's links scroll to their section instead of jumping, unless the visitor asks for less motion */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

/* The hero's line is text people read, so it is in the ink */
.hero--centred .hero__lead {
  color: var(--ink);
}

/* The name stays on one line beside the four words at 1024 */
.nav__logo {
  white-space: nowrap;
}

/* The hero's window: the cash book, its open lines posting one after another. Its painted ground
   when WebGL is not there: a pale sky over two purple hills */
.hero__window {
  background:
    radial-gradient(120% 60% at 70% 118%, #7e3af2 0 40%, transparent 41%),
    radial-gradient(90% 50% at 10% 108%, #6c2bd9 0 42%, transparent 43%),
    radial-gradient(80% 40% at 60% 92%, #cabffd 0 40%, transparent 41%),
    linear-gradient(#bfb3f5, #e4e0fb 70%, #f4f5f7);
}

html.theme-dark .hero__window {
  background:
    radial-gradient(120% 60% at 70% 118%, #4c1d95 0 40%, transparent 41%),
    radial-gradient(90% 50% at 10% 108%, #3b1676 0 42%, transparent 43%),
    radial-gradient(80% 40% at 60% 92%, #5521b5 0 40%, transparent 41%),
    linear-gradient(#121317, #1a1c23 70%, #24262d);
}

.hero__window .ui-win {
  width: 100%;
}

.hero__window .ui-win__body {
  min-height: 420px;
}

/* The amount takes the column the kit gives to a short age, so it gets the room a rand amount needs */
.hero__window :is(.ui-win__cols, .ui-win__row) {
  grid-template-columns: 24px 128px minmax(0, 1fr) 84px 92px;
}

.ui-win__age {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The cash book app frame (sections-library app-frame): the list of lines beside the open one */

.books-head {
  row-gap: var(--s-4);
}

/* The frame is as tall as the open line and its postings, not the screen: the section grows past one
   screen when they need more room, and never stretches the frame to fill two on a phone */
main > #books {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

.app.ui {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin-top: var(--s-7);
  background: var(--u-bg);
  border: 1px solid var(--u-border);
  border-radius: var(--u-r);
  box-shadow: var(--u-shadow);
}

.app > .app__pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.app > .app__pane + .app__pane {
  border-left: 1px solid var(--u-line);
}

/* The list pane has no sidebar, so its rows take the whole body */
.app .ui-win__body {
  grid-template-columns: minmax(0, 1fr);
}

/* Beside the open line the list takes its height and fades out at the foot, so the open pane alone
   sets how tall the frame is */
@media (min-width: 1024px) {
  .app > .app__pane--list > .ui-panel {
    position: absolute;
    inset: 0;
  }
}

.app > .app__pane > .ui-panel {
  width: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.app > .app__pane--list::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 64px;
  background: linear-gradient(transparent, var(--u-bg));
  pointer-events: none;
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .app.ui {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  }
}

@media (max-width: 1023px) {
  .app.ui {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app > .app__pane--list {
    max-height: 252px;
  }

  .app > .app__pane--list::after {
    display: none;
  }

  .app .ui-win__side {
    display: none;
  }

  .app .ui-win__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .app > .app__pane + .app__pane {
    border-left: 0;
    border-top: 1px solid var(--u-line);
  }
}

/* The open line: a cash book entry you can change, and the postings it makes */

.ledger {
  display: grid;
  align-content: start;
  gap: var(--s-6);
  height: 100%;
  padding: var(--s-6);
  color: var(--u-ink);
  font: 400 15px/1.45 var(--font-text);
}

.entry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4) var(--s-5);
}

.entry__field {
  display: grid;
  gap: var(--s-1);
  min-width: 0;
}

.entry__field--wide,
.entry__check {
  grid-column: 1 / -1;
}

.entry__field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.entry__field input,
.entry__field select {
  width: 100%;
  height: 44px;
  padding: 0 var(--s-3);
  border: 1px solid var(--u-line-2);
  border-radius: var(--r-sm);
  background: var(--u-bg);
  color: var(--u-ink);
  font: inherit;
  font-size: 16px;
}

.entry__field input:hover,
.entry__field select:hover {
  border-color: var(--u-ink);
}

.entry__check {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  cursor: pointer;
}

.entry__check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--action);
}

.postings table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.postings th,
.postings td {
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--u-line);
  text-align: left;
  font-weight: 400;
}

.postings thead th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.postings .num {
  width: 8.5rem;
  padding-left: var(--s-3);
  text-align: right;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 14px;
}

.postings .narration td {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.postings tfoot th,
.postings tfoot td {
  border-bottom: 0;
  font-weight: 500;
}

/* Totals carry a single rule over them and a double rule under them, as in a ledger */
.postings .total {
  border-top: 1px solid var(--u-ink);
}

.postings .total:not(:empty) {
  border-bottom: 3px double var(--u-ink);
}

.postings__note {
  min-height: 3em;
  margin-top: var(--s-4);
  font-weight: 500;
}

@media (max-width: 639px) {
  .ledger {
    padding: var(--s-4);
    gap: var(--s-5);
  }

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

  .postings .num {
    width: 1%;
  }
}

/* The reports: the path a cash book line takes, then a card per report */

.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
  margin: 0 0 var(--s-6);
  padding: 0;
  list-style: none;
  counter-reset: flow;
}

.flow__step {
  display: grid;
  align-content: start;
  gap: var(--s-1);
  padding-top: var(--s-4);
  border-top: 2px solid var(--line, currentColor);
  counter-increment: flow;
}

.flow__step b::before {
  content: counter(flow) "  ";
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 400;
  white-space: pre;
}

.flow__step span {
  color: var(--muted);
}

/* The flow and four reports need more than a screen, so the section grows to hold them, as #books does */
main > #reports {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

#reports .group + .grid {
  margin-top: var(--s-7);
}

/* The trial balance needs the most room, up to its agreeing totals; the second row needs less */
#reports .panel {
  --p-h: 420px;
}

#reports .group + .grid .panel {
  --p-h: 320px;
}

.report {
  overflow: hidden;
  color: var(--u-ink);
  font-size: 13px;
  line-height: 1.4;
}

.report__account {
  margin: 0;
  padding: var(--s-3) var(--s-4) 0;
  font-weight: 500;
}

.report table {
  width: 100%;
  margin-bottom: var(--s-2);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.report th,
.report td {
  padding: 6px var(--s-4);
  border-bottom: 1px solid var(--u-line);
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.report td + td,
.report th + th {
  padding-left: 0;
}

.report thead th {
  color: var(--u-muted);
  font-weight: 500;
}

.report .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}

.report tfoot th,
.report tfoot td {
  border-bottom: 0;
  font-weight: 500;
}

/* Totals carry a single rule over them and a double rule under them, as in a ledger */
.report .total {
  border-top: 1px solid var(--u-ink);
  border-bottom: 3px double var(--u-ink);
}

.report .ui-head .ui-btn + .ui-btn {
  margin-left: 6px;
}

.exports {
  display: grid;
  padding: var(--s-2) 0;
}

.exports li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-2) var(--s-4);
}

.exports li > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exports__type {
  flex: none;
  width: 44px;
  padding: 2px 0;
  border-radius: 4px;
  background: var(--u-fill-3);
  color: var(--u-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

@media (max-width: 1023px) {
  .flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: var(--s-5);
  }
}

@media (max-width: 639px) {
  .flow {
    grid-template-columns: 1fr;
  }

  #reports .panel {
    --p-h: 470px;
  }

  #reports .group + .grid .panel {
    --p-h: 260px;
  }

  .report th,
  .report td {
    padding-inline: var(--s-3);
  }

  /* Names wrap, so the amounts keep the width a phone has */
  .report :is(td, th):not(.num) {
    white-space: normal;
  }

  .report .ui-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Debtors: invoices, receipts, the age analysis and the dashboard, laid out like #reports */
main > #debtors {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

#debtors .group + .grid {
  margin-top: var(--s-7);
}

#debtors .panel {
  --p-h: 340px;
}

/* Six columns of amounts need tighter cells than the other reports */
.report--compact th,
.report--compact td {
  padding-inline: 10px;
}

.report--compact td + td,
.report--compact th + th {
  padding-left: 0;
}

.debt-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--u-tint);
  color: var(--u-accent-text);
  font-size: 11px;
  font-weight: 500;
}

.debt-tag.is-paid {
  background: var(--u-fill-3);
  color: var(--u-muted);
}

.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
}

.dash-stats div {
  display: grid;
  gap: 2px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--u-line);
  border-radius: 6px;
}

.dash-stats span {
  color: var(--u-muted);
  font-size: 11px;
}

.dash-stats b {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

/* Each month stacks its unpaid revenue on its paid revenue, as the app's chart does */
.dash-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: var(--s-2) var(--s-4) 0;
}

.dash-bars span {
  display: flex;
  flex: 1;
  flex-direction: column-reverse;
  height: 100%;
}

.dash-bars i {
  display: block;
  border-radius: 3px 3px 0 0;
}

.dash-bars i:first-child {
  height: var(--paid);
  background: var(--u-accent);
}

.dash-bars i:last-child {
  height: var(--unpaid);
  background: var(--u-tint-2);
}

.dash-legend {
  display: flex;
  gap: var(--s-4);
  margin: 0;
  padding: var(--s-3) var(--s-4);
  list-style: none;
  color: var(--u-muted);
  font-size: 12px;
}

.dash-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dash-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--u-tint-2);
}

.dash-legend i.is-paid {
  background: var(--u-accent);
}

@media (max-width: 639px) {
  #debtors .panel {
    --p-h: 320px;
  }

  .dash-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report--compact th,
  .report--compact td {
    padding-inline: 6px;
  }
}

/* Plans: as many across as there are, up to three; one column on a phone */

.plans {
  margin-top: var(--s-7);
}

.plans > .card--plan {
  grid-column: auto / span 4;
}

.plan__features {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plan__features li {
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--line);
}

.plans-empty {
  max-width: 52ch;
  margin-top: var(--s-7);
  font-size: var(--t-lead);
}

@media (max-width: 1023px) {
  .plans > .card--plan {
    grid-column: 1 / -1;
  }
}

/* Pricing and the questions are as tall as what they hold: a section grows past a screen when it needs
   to, so a card is never squeezed, and the four questions are not stretched over a whole screen */
main > #pricing {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}

main > #questions {
  height: auto;
  min-height: 0;
}

/* The questions two by two beside each other on a wide screen, each pair's rules on one line */
@media (min-width: 1024px) {
  #questions .faq {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--gutter);
  }

  /* the shorter of a pair keeps its answer under its question, not pushed down to the taller one's height */
  #questions .faq > .faq__item {
    align-content: start;
  }

  #questions .faq > .faq__item:nth-child(2) {
    padding-top: 0;
  }
}

/* The footer: the close and the links. On a phone and a tablet they stack as the kit's closing footer
   did (the close, its button, the name set large, then the links); on a wide screen the close sits on
   the left and the links with the button on the right, as tall as they are and no more */
.site-footer > .site-footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "pitch" "cta" "word" "brand" "cols" "legal";
  row-gap: var(--s-7);
}

.site-footer__pitch {
  grid-area: pitch;
  display: grid;
  gap: var(--s-4);
}

.site-footer__pitch h2 {
  max-width: 20ch;
}

.site-footer__cta {
  grid-area: cta;
  margin-top: calc(var(--s-6) - var(--s-7));
}

.site-footer__word {
  grid-area: word;
  margin-top: var(--s-8);
  overflow: visible;
  line-height: 1;
  font-size: clamp(56px, 12.4vw, 180px);
}

.site-footer__brand {
  grid-area: brand;
}

.site-footer__brand .footer__lede {
  max-width: 30ch;
  font-size: var(--t-lead);
}

.site-footer__cols {
  grid-area: cols;
}

.site-footer__cols h3 {
  margin-bottom: var(--s-4);
}

.site-footer__legal {
  grid-area: legal;
  margin-top: 0;
}

/* The name has 13 letters, so it is set smaller than the kit's 8-letter size to fit a phone's line */
@media (max-width: 639px) {
  .site-footer {
    padding-top: var(--padt);
  }

  .site-footer__cta .btn {
    width: 100%;
  }

  .site-footer > .site-footer__grid {
    row-gap: var(--s-6);
  }

  .site-footer__cta {
    margin-top: calc(var(--s-5) - var(--s-6));
  }

  .site-footer__word {
    margin-top: var(--s-9);
    font-size: 12.4vw;
  }

  .site-footer .site-footer__cols {
    row-gap: var(--s-5);
  }
}

@media (min-width: 1024px) {
  .site-footer {
    padding-block: var(--s-9) var(--s-6);
  }

  .site-footer > .site-footer__grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-areas: none;
    column-gap: var(--gutter);
    row-gap: var(--s-6);
  }

  .site-footer__pitch {
    grid-column: 1 / span 5;
    grid-row: 1 / span 2;
    align-content: start;
  }

  .site-footer__pitch .t-lead {
    max-width: 40ch;
  }

  .site-footer__cols {
    grid-column: 7 / -1;
    grid-row: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--gutter);
  }

  .site-footer .site-footer__cols > .footer__col {
    grid-column: auto;
  }

  .site-footer__cta {
    grid-column: 7 / -1;
    grid-row: 2;
    margin-top: 0;
  }

  /* the name set large and the company block are the phone's; the bar above already carries the name */
  .site-footer__word,
  .site-footer__brand {
    display: none;
  }

  .site-footer__legal {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: var(--s-5);
  }
}

/* A phone has no room for the name and the button side by side: the button waits in the menu
   sheet, and the hero shows it on the first screen */
@media (max-width: 639px) {
  .nav:not(.is-open) .nav__actions {
    display: none;
  }

  .nav:not(.is-open) .nav__actions + .nav__toggle {
    margin-left: auto;
  }
}

/* The light and dark switch, the app's moon and sun. One sits with the actions on a wide screen,
   the other beside the menu button when the actions fold into the menu */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}

.theme-toggle:hover {
  background: color-mix(in oklab, var(--ink) 6%, transparent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.theme-toggle__sun,
html.theme-dark .theme-toggle__moon {
  display: none;
}

html.theme-dark .theme-toggle__sun {
  display: block;
}

.theme-toggle--bar {
  display: none;
}

@media (max-width: 1199px) {
  .theme-toggle--bar {
    display: inline-grid;
    margin-left: auto;
  }

  .theme-toggle--bar + .nav__toggle {
    margin-left: var(--s-2);
  }

  /* in the open menu's bottom bar the switch would take a full row */
  .nav__actions .theme-toggle {
    display: none;
  }
}

/* While the main button stays in the bar it already takes the free space, so the switch sits beside it */
@media (min-width: 640px) and (max-width: 1199px) {
  .nav:not(.is-open) .nav__actions + .theme-toggle--bar {
    margin-left: var(--s-2);
  }
}
