/*------------------------------------------------
 * Fonts are linked from the page head (base.html), not @imported here,
 * so they load in parallel with the stylesheets.
 *
 * Breakpoints (media queries can't read custom properties, so use these
 * literal values everywhere):
 *   sm  30rem  (480px)  phones
 *   md  48rem  (768px)  tablets / narrow windows
 *   lg  62rem  (992px)  small laptops
 * Write mobile overrides as @media (max-width: 48rem) { ... }.
 * ------------------------------------------------*/

/*------------------------------------------------
 * Global reset
 * ------------------------------------------------*/

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

/* Exclude table cells from border-box to preserve column widths */
td, th {
  box-sizing: content-box;
}


/*------------------------------------------------
 * body, layout
 * ------------------------------------------------*/

html {
  height: 100%;
}

body {
  background: var(--background-body);
  color: var(--color-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--line-height);
  min-height: 100%;
  margin: 0;
  padding: 0;
}

/* Dev environment banner */
.dev-banner {
  background-color: var(--warning);
  color: var(--white);
  letter-spacing: 0.25rem;
  text-align: center;
  padding: 0.25rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
}

/* Push content down when banner is present */
.env-dev {
  padding-top: 1.5rem;
}

.container {
  margin: 0 auto;
  padding: 0 2rem;
}

/* flow-root keeps the last card's bottom margin inside the content, so
   the page ends a card's margin below the last card */
#content {
  display: flow-root;
  padding-top: 1.5rem;
}

.page-vertical-centered {
  overflow: hidden;
  position: absolute;
  width: 100%;
  align-items: center;
  display: flex;
  height: 80%;
  justify-content: center;
}

.page-horizontal-centered {
  margin: 1rem auto;
  max-width: calc(100% - 2rem);
  width: 31.25rem;
}

@media (max-width: 48rem) {
  .container {
    padding: 0 1rem;
  }
}



/*------------------------------------------------
 * icons (Lucide font icons)
 * ------------------------------------------------*/

[class^="icon-"],
[class*=" icon-"] {
  font-size: 1.125rem;
  display: inline-block;
  vertical-align: middle;
}


/*------------------------------------------------
 * links
 * ------------------------------------------------*/

a,
a:hover {
  color: var(--link);
  text-decoration: none;
}


/*------------------------------------------------
 * keyboard focus
 * ------------------------------------------------*/

:focus-visible {
  outline: 0.125rem solid var(--focus-ring);
  outline-offset: 0.125rem;
}

/* Skip link: hidden until focused by keyboard */
.skip-link {
  background: var(--background-light);
  border: 1px solid var(--focus-ring);
  border-radius: var(--radius-md);
  color: var(--link);
  left: 1rem;
  padding: 0.5rem 1rem;
  position: fixed;
  top: -4rem;
  z-index: 10001;
}

.skip-link:focus {
  top: 1rem;
}

/* The skip link's target takes focus only programmatically */
main:focus {
  outline: none;
}


/*------------------------------------------------
 * cards
 * ------------------------------------------------*/

/* The one card: lighter than the page, rounded, no rule round it. Every
   page's content sits in cards. The atmospheric themes (atmosphere.css)
   let it through to the wash. A table in a card runs out to its edges
   (tables.css). */
.card {
  background: var(--background-section);
  border: none;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  padding: 1rem;
  padding-bottom: 1.5rem;
}

/* A card's title row: the title (an h1 or h2, or the row itself), and
   any buttons for the card at its right. One style for every card. */
.card-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 1.2rem;
  font-weight: normal;
  gap: 1rem;
  justify-content: space-between;
  line-height: var(--line-height);
  margin: 0 0 1rem;
}

.card-title > h1,
.card-title > h2 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

.card-title > :last-child:not(:first-child) {
  align-items: center;
  display: flex;
  gap: 1rem;
}

.card-text {
  margin: 0 0 1rem;
}

/* Cards side by side: a main column and a narrower one beside it (a
   report's tables and its charts), stacked on narrow screens */
.card-columns {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
}

.card-columns > :first-child {
  flex: 1 1 36rem;
  max-width: 60rem;
  min-width: 0;
}

.card-columns > :nth-child(2) {
  flex: 1 1 24rem;
  min-width: 0;
}


/*------------------------------------------------
 * typography
 * ------------------------------------------------*/

.page-vertical-centered h1 {
  color: var(--link);
  font-size: 1.5rem;
}

.page-vertical-centered h1,
.page-vertical-centered p {
  text-align: center;
}

h1,
h2 {
  font-size: 1.2rem;
  font-weight: normal;
  margin: 0 0 1rem;
}

strong {
  font-weight: 600;
}

.strong {
  font-weight: 600;
}

.soon {
  color: var(--error);
}


/*------------------------------------------------
 * lists
 * ------------------------------------------------*/

li {
  list-style-type: none;
}


/*------------------------------------------------
 * utilities
 * ------------------------------------------------*/

.flx-t {
  align-items: start;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.flx-fc {
  align-items: center;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.bottom-right {
  margin-top: 1rem;
  text-align: right;
}

/*------------------------------------------------
 * toolbar: a card's row of controls (a filter, an add button, a period
 * stepper), above its table. .filter is the older name, kept by every
 * page's filter partial.
 * ------------------------------------------------*/

.toolbar,
.filter {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 0 1rem;
}

.toolbar-left,
.toolbar-right,
.filter-left,
.filter-right {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Text links in a toolbar (View Transactions, Export CSV) */
.toolbar-link {
  white-space: nowrap;
}


/*------------------------------------------------
 * Bootstrap replacement utilities
 * ------------------------------------------------*/

/* Display */
.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }

/* Flexbox */
.flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.items-center { align-items: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* Spacing - Margin */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.ms-1 { margin-left: 0.25rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-3 { margin-left: 1rem; }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 1rem; }

/* Spacing - Padding */
.pt-1 { padding-top: 0.25rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-3 { padding-top: 1rem; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-3 { padding-bottom: 1rem; }
.ps-1 { padding-left: 0.25rem; }
.ps-2 { padding-left: 0.5rem; }
.pe-0 { padding-right: 0; }
.pe-1 { padding-right: 0.25rem; }
.pe-2 { padding-right: 0.5rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Text */
.fw-bold, .font-bold { font-weight: 600; }
.float-end, .float-right { float: right; }
.text-center { text-align: center; }

/* Borders */
.border-top { border-top: 1px solid var(--border-light); }
.border-bottom { border-bottom: 1px solid var(--border-light); }

/* Width */
.w-100 { width: 100%; }

/* Grid replacement - simple row/col with flexbox */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.5rem;
}
.col-md { flex: 1; padding: 0 0.5rem; }

/* Alerts: a message in the alert tokens' colours */
.alert {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}

.alert-success {
  background: var(--alert-success-bg);
  border-color: var(--alert-success-border);
  color: var(--alert-success-color);
}

.alert-danger {
  background: var(--alert-danger-bg);
  border-color: var(--alert-danger-border);
  color: var(--alert-danger-color);
}

.alert-info {
  background: var(--background-light);
  border-color: var(--border-medium);
  color: var(--color-strong);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 0.125rem solid var(--background-control);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/*------------------------------------------------
 * Reduced motion
 * ------------------------------------------------*/

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


/*------------------------------------------------
 * Utility classes: highlights, text, money
 * ------------------------------------------------*/

.hl-blue { background: var(--hl-blue) !important; }
.hl-gray { background: var(--hl-gray) !important; }
.hl-green { background: var(--hl-green) !important; }
.hl-orange { background: var(--hl-orange) !important; }
.hl-violet { background: var(--hl-violet) !important; }
.hl-purple { background: var(--hl-purple) !important; }
.hl-red { background: var(--hl-red) !important; }
.hl-yellow { background: var(--hl-yellow) !important; }

.text-muted {
  color: var(--color-muted) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--error) !important;
}

.credit {
  color: var(--credit) !important;
}

.text-negative {
  color: var(--error) !important;
}
