/* 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;
}

/* Tapping quickly through days or weeks shouldn't zoom in, and pinch to zoom still works.
   Set on what's tapped too, as inside a scrolling box like the editor the page's doesn't count. */
body,
a,
button,
input,
label,
select,
textarea {
  touch-action: manipulation;
}

/* --- 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);
}

/* checkboxes and switches are lime when on, with the tick and knob in the brand ink */
.form-check-input:checked {
  background-color: var(--brand-lime);
  border-color: var(--brand-lime);
}

.form-check-input: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");
}

.form-switch .form-check-input:focus {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%239ab83f'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%231a0f1f'/%3e%3c/svg%3e");
}

/* the toast is the logo's dark ink with a lime edge in both themes, so it stands out on either */
.app-toast {
  --bs-toast-bg: var(--brand-ink);
  --bs-toast-color: #fff;
  --bs-toast-border-color: var(--brand-lime);
  border-left-width: 0.375rem;
}

.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;
}

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

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

.flex-none {
  flex: none;
}

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

/* --- Posters --- */

.poster-thumb {
  flex: none;
  width: 2.75rem;
  height: 4.125rem;
  border-radius: 0.35rem;
  object-fit: cover;
}

/* the 2:3 shape of a film poster */
.ratio-poster {
  --bs-aspect-ratio: 150%;
}

.poster-image {
  object-fit: cover;
}

/* stands in for a missing poster or photo, at the size of whatever it replaces */
.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bs-secondary-bg);
  color: var(--bs-secondary-color);
}

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

.title-poster {
  flex: none;
  width: 6.5rem;
  height: 9.75rem;
  object-fit: cover;
}

.title-backdrop {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* --- Title page --- */

.score-tile {
  background-color: var(--bs-tertiary-bg);
}

/* a thin lime bar for how many episodes have been watched */
.episode-progress {
  display: block;
  width: 100%;
  height: 0.4rem;
  margin-top: 0.25rem;
  border: 0;
  border-radius: 1rem;
  background-color: var(--bs-secondary-bg);
  accent-color: var(--brand-lime);
  -webkit-appearance: none;
  appearance: none;
}

.episode-progress::-webkit-progress-bar {
  border-radius: 1rem;
  background-color: var(--bs-secondary-bg);
}

.episode-progress::-webkit-progress-value {
  border-radius: 1rem;
  background-color: var(--brand-lime);
}

.episode-progress::-moz-progress-bar {
  border-radius: 1rem;
  background-color: var(--brand-lime);
}

/* scrolls sideways, so a long cast doesn't push everything else down */
.cast-list {
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.cast-member {
  width: 6rem;
  scroll-snap-align: start;
}

.cast-photo {
  width: 6rem;
  height: 9rem;
  object-fit: cover;
}

details > summary {
  cursor: pointer;
}

/* --- Audit log --- */

.audit-icon {
  flex: none;
  width: 1.25rem;
  text-align: center;
}

/* titles and usernames can be long with no spaces to break at */
.audit-summary {
  overflow-wrap: anywhere;
}

/* --- 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;
}

/* --- Search sheet --- */

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

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

/* the same width as the close button, so the heading stays in the middle */
.search-sheet-spacer {
  width: 1.5rem;
}

.search-overview {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

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