/* Only what Bootstrap doesn't cover. */

:root {
  --tab-bar-height: 4rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  -webkit-tap-highlight-color: transparent;
}

/* --- Brand colours --- */

/* Bootstrap's success colour is the app's accent, set to the logo's lime green.
   Lime is too pale for text on a light page, so text and outlines use olive there. */
:root,
[data-bs-theme="light"] {
  --brand-lime: #adcb50;
  --brand-lime-dark: #9ab83f;
  --brand-ink: #1a0f1f;
  --brand-focus-ring: 0 0 0 0.25rem rgba(173, 203, 80, 0.4);
  --bs-focus-ring-color: rgba(173, 203, 80, 0.4);
  --bs-success: #5a7a16;
  --bs-success-rgb: 90, 122, 22;
  --bs-success-text-emphasis: #36490d;
  --bs-success-bg-subtle: #eef4dc;
  --bs-success-border-subtle: #d6e4a7;
}

[data-bs-theme="dark"] {
  --bs-success: #adcb50;
  --bs-success-rgb: 173, 203, 80;
  --bs-success-text-emphasis: #cee08f;
  --bs-success-bg-subtle: #232910;
  --bs-success-border-subtle: #4f5e22;
}

/* filled buttons are lime with the logo's dark ink, as white on lime is hard to read */
.btn-success {
  --bs-btn-color: var(--brand-ink);
  --bs-btn-bg: var(--brand-lime);
  --bs-btn-border-color: var(--brand-lime);
  --bs-btn-hover-color: var(--brand-ink);
  --bs-btn-hover-bg: var(--brand-lime-dark);
  --bs-btn-hover-border-color: var(--brand-lime-dark);
  --bs-btn-focus-shadow-rgb: 173, 203, 80;
  --bs-btn-active-color: var(--brand-ink);
  --bs-btn-active-bg: var(--brand-lime-dark);
  --bs-btn-active-border-color: var(--brand-lime-dark);
  --bs-btn-disabled-color: var(--brand-ink);
  --bs-btn-disabled-bg: var(--brand-lime);
  --bs-btn-disabled-border-color: var(--brand-lime);
}

/* the active state also covers checked btn-check toggles */
.btn-outline-success {
  --bs-btn-color: var(--bs-success);
  --bs-btn-border-color: var(--bs-success);
  --bs-btn-hover-color: var(--brand-ink);
  --bs-btn-hover-bg: var(--brand-lime);
  --bs-btn-hover-border-color: var(--brand-lime);
  --bs-btn-focus-shadow-rgb: 173, 203, 80;
  --bs-btn-active-color: var(--brand-ink);
  --bs-btn-active-bg: var(--brand-lime);
  --bs-btn-active-border-color: var(--brand-lime);
  --bs-btn-disabled-color: var(--bs-success);
  --bs-btn-disabled-border-color: var(--bs-success);
}

/* Bootstrap hard-codes a blue focus outline on these */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--brand-lime);
  box-shadow: var(--brand-focus-ring);
}

.btn-close {
  --bs-btn-close-focus-shadow: var(--brand-focus-ring);
}

/* the toast is dark in both themes */
.toast-action {
  --bs-btn-color: var(--brand-lime);
  --bs-btn-hover-color: var(--brand-lime);
  --bs-btn-active-color: var(--brand-lime);
}

.logo-large {
  width: 9rem;
  height: 9rem;
}

.logo-small {
  width: 5rem;
  height: 5rem;
}

/* --- Layout --- */

.app-container {
  max-width: 40rem;
}

.app-header {
  padding-top: env(safe-area-inset-top, 0px);
}

.app-main {
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 6rem);
}

.auth-container {
  max-width: 25rem;
  padding-top: calc(3rem + env(safe-area-inset-top, 0px));
  padding-bottom: 2.5rem;
}

.tab-bar {
  padding-bottom: var(--safe-bottom);
}

.tab-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  height: var(--tab-bar-height);
  border: 0;
  border-radius: 0;
  color: var(--bs-secondary-color);
  font-size: 0.7rem;
  font-weight: 600;
}

.tab-button .fa-solid {
  font-size: 1.25rem;
}

.tab-button[aria-current="page"] {
  color: var(--bs-success);
}

.add-button {
  position: fixed;
  z-index: 1020;
  right: max(1rem, calc(50% - 19rem));
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 1rem);
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.5rem;
}

.app-toasts {
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + 5.5rem);
  z-index: 1090;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.25rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.chore-card {
  overflow: hidden;
  transition: opacity 0.35s, transform 0.35s;
}

.chore-card.completing {
  opacity: 0;
  transform: translateX(2.5rem) scale(0.97);
}

.complete-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
}

.chore-title {
  min-width: 0;
  min-height: 3rem;
  overflow-wrap: anywhere;
}

/* fixed width so titles line up whichever icon is in front */
.chore-icon {
  display: inline-block;
  width: 1.5em;
  color: var(--bs-success);
  text-align: center;
  margin-right: 0.35rem;
}

.min-width-0 {
  min-width: 0;
}

.subtask-row {
  min-height: 3rem;
  cursor: pointer;
}

.subtask-check {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

/* Bootstrap's tick with the stroke changed from white to the brand ink */
.subtask-check:checked[type="checkbox"] {
  --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%231a0f1f' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
  background-color: var(--brand-lime);
  border-color: var(--brand-lime);
}

.notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Chart --- */

/* the week and day names stay in view while scrolling, under the page header */
.chart-header {
  position: sticky;
  top: var(--app-header-height, 0);
  z-index: 1010;
  padding: 0 calc(0.5rem + 1px) 0.4rem; /* lines the days up with the card rows */
  background-color: var(--bs-tertiary-bg);
}

.chart-week-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.chart-week-title {
  min-width: 9rem;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(7, 2rem);
  align-items: center;
  gap: 0.3rem;
}

.chart-section {
  padding: 0.6rem 0.5rem;
}

.chart-section + .chart-section {
  border-top: 1px solid var(--bs-border-color);
}

.chart-section .chart-row + .chart-row {
  margin-top: 0.3rem;
}

.chart-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.chart-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.85rem;
}

/* up to two lines, as the label column is narrow on a phone */
.chart-label-text {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  line-height: 1.15;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chart-label .chore-icon {
  flex: none;
  width: 1.25em;
  margin-right: 0;
}

.chart-day {
  font-size: 0.75rem;
  line-height: 1.15;
  text-align: center;
}

.chart-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  aspect-ratio: 1;
  border-radius: 0.45rem;
  background-color: var(--bs-secondary-bg);
}

.chart-dot {
  font-size: 0.45rem;
}

/* --- Avatars --- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid var(--bs-body-bg);
  border-radius: 50%;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.avatar-small {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.7rem;
}

.avatar-tiny {
  width: 1.4rem;
  height: 1.4rem;
  border-width: 1px;
  font-size: 0.55rem;
}

.avatar-group {
  display: flex;
  flex: none;
}

.avatar-group .avatar + .avatar {
  margin-left: -0.5rem;
}

.avatar-coral {
  background-color: #e07a5f;
}

.avatar-blue {
  background-color: #3d8bfd;
}

.avatar-purple {
  background-color: #9b5de5;
}

.avatar-orange {
  background-color: #f4a261;
}

.avatar-teal {
  background-color: #2a9d8f;
}

.avatar-pink {
  background-color: #e76f9a;
}

.avatar-green {
  background-color: #6a994e;
}

.avatar-slate {
  background-color: #577590;
}

/* someone who has been removed from the household */
.avatar-unknown {
  background-color: #8a8f88;
}

.color-swatch {
  width: 2rem; /* 8 fit on one line on a small phone */
  height: 2rem;
  border: 3px solid var(--bs-body-bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--bs-border-color);
  cursor: pointer;
}

.btn-check:checked + .color-swatch {
  box-shadow: 0 0 0 3px var(--bs-emphasis-color);
}

.btn-check:focus-visible + .color-swatch {
  outline: 2px solid var(--bs-success);
  outline-offset: 3px;
}

.invite-code {
  font-family: var(--bs-font-monospace);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

/* --- Editor --- */

.editor-sheet.offcanvas-bottom {
  height: auto;
  max-height: 92dvh;
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
}

.editor-sheet .offcanvas-body {
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.day-button {
  width: 2.75rem;
  padding-left: 0;
  padding-right: 0;
}

/* scrolls under the search box so it stays in view */
.icon-results {
  max-height: 18rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.icon-choice {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 1.15rem;
}

@media (min-width: 768px) {
  .editor-sheet.offcanvas-bottom {
    left: 50%;
    width: 36rem;
    margin-left: -18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chore-card {
    transition: none;
  }
}
