/* Part of the design system, loaded after app.css (see templates/base.html). Tokens live in app.css. Responsive refinements and print (sections 16, 17). Loaded after every component sheet above it. */

/* ---------------------------------------------------------------------------
   16. Responsive refinements
   --------------------------------------------------------------------------- */
/* collapsed navbar (phones, tablets): the bar keeps --app-nav-height, the open
   menu scrolls inside the viewport, the account menu opens inline at full width */
@media (max-width: 1199.98px) {
  .app-navbar { padding-block: 0; }
  .app-navbar-inner { flex-wrap: wrap; min-height: calc(var(--app-bar-height) - 1px); padding-block: 0.5rem; }
  .app-navbar .navbar-collapse { max-height: calc(100dvh - var(--app-nav-height)); overflow-y: auto; }
  .app-nav { flex-direction: column; align-items: stretch; gap: 0.25rem; padding: 0.5rem 0; }
  .app-nav .nav-link { padding: 0.65rem 0.8rem; font-size: 1rem; }
  .app-account { width: 100%; gap: 0.5rem; padding-bottom: 0.75rem; }
  .app-account-toggle { padding: 0.4rem 0.6rem 0.4rem 0.4rem; font-size: 0.95rem; }
  .app-account-avatar { width: 2rem; height: 2rem; font-size: 0.75rem; }
  .app-account .dropdown-menu[data-bs-popper] { position: static; width: 100%; margin-top: 0.25rem; }
  .app-account-tools { padding-inline: 0.4rem; }
  .app-lang, .app-theme { gap: 0.4rem; }
  .app-tool-btn { min-width: 2.75rem; height: 2.25rem; font-size: 0.8rem; }
}

/* phones */
@media (max-width: 767.98px) {
  .app-main { padding-block: 1rem 2rem; }
  .flash-area:not(:has(.alert)) { min-height: 0; margin-bottom: 0; }
  .page-title { font-size: 1.35rem; }
  .cal-toolbar .btn-icon { width: 2.5rem; height: 2.25rem; }
  .stat-card .card-body { padding: 0.85rem 0.9rem; }
  .stat-card .stat-label { font-size: 0.7rem; letter-spacing: 0.04em; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .stat-card .stat-icon { top: 0.75rem; right: 0.75rem; font-size: 1.25rem; }

  /* Touch: inputs at 16px (no iOS zoom on focus) and small buttons at least 36px high. */
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 1rem; }
  .btn-sm { min-height: 2.25rem; }
  .btn-sm.btn-icon { min-width: 2.25rem; }
}

/* ---------------------------------------------------------------------------
   17. Print
   --------------------------------------------------------------------------- */
@media print {
  .app-navbar, .app-manage-bar, .app-bottom-dock, .app-footer, .no-print { display: none !important; }
  body { background: #fff !important; }
  .app-main { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------------------------------------------------------------------------
   Data page (backup): stat tiles and row counters
   --------------------------------------------------------------------------- */
.data-stat {
  position: relative;
  height: 100%;
  padding: 1rem 1.15rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
}

.data-stat > .bi {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  font-size: 1.4rem;
  opacity: 0.25;
}

.data-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--app-text-muted);
}

.data-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.1rem;
}

.data-stat-note { font-size: 0.8rem; color: var(--app-text-muted); }

.data-count { font-variant-numeric: tabular-nums; font-weight: 650; }
.data-count-zero { opacity: 0.4; font-weight: 400; }

/* ---------------------------------------------------------------------------
   Health tiles (Settings -> Integrations): a {% card %} wrapped in
   .health-tile.health-<status>; the status colours the top stripe and summary.
   --------------------------------------------------------------------------- */
.health-tile { --health-color: var(--app-neutral); height: 100%; }
.health-tile.health-healthy { --health-color: var(--app-success); }
.health-tile.health-unhealthy { --health-color: var(--app-danger); }
.health-tile.health-checking { --health-color: var(--app-info); }

.health-tile > .card { border-top: 4px solid var(--health-color); }
.health-tile > .card > .card-body { display: flex; flex-direction: column; }

.health-description { font-size: 0.85rem; color: var(--app-text-muted); margin-bottom: 0.75rem; }

.health-summary {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--health-color);
  margin-bottom: 0.75rem;
}

.health-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.health-details > div { display: contents; }
.health-details dt { font-weight: 500; color: var(--app-text-muted); }
.health-details dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.health-items { margin: 0 0 0.75rem; border-top: 1px solid var(--app-border); }
.health-items .list-row-meta { font-size: 0.8rem; }
.health-item-note { color: var(--app-danger); overflow-wrap: anywhere; }
.health-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-left: auto;
}
.health-actions .btn { white-space: nowrap; }

.health-checked { font-size: 0.8rem; color: var(--app-text-soft); }

/* Wide panel (the email queue): details become a row of stats. */
.health-tile-wide .health-details {
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.75rem 1.25rem;
}
.health-tile-wide .health-details > div { display: block; min-width: 0; }
.health-tile-wide .health-details dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.health-tile-wide .health-details dd { font-size: 1rem; font-weight: 600; }

/* ---------------------------------------------------------------------------
   Diagnosis steps (Settings -> Integrations -> Email): a headline and one
   compact .check-step per step; .check-<status> colours the stripe and icon.
   --------------------------------------------------------------------------- */
.check-step,
.email-checks-status { --check-color: var(--app-neutral); }
.check-healthy { --check-color: var(--app-success); }
.check-unhealthy { --check-color: var(--app-danger); }
.check-checking { --check-color: var(--app-info); }

.email-checks-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.email-checks-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; min-width: 0; }
.email-checks-summary { font-weight: 600; color: var(--check-color); }

.check-step {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  height: 100%;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--check-color);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow-sm);
}
.check-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  font-size: 0.9rem;
  font-weight: 650;
}
.check-step-head .bi { color: var(--check-color); }
.check-step-name { min-width: 0; overflow-wrap: anywhere; }
.check-step-head .badge { margin-left: auto; }
.check-step-question { font-size: 0.78rem; color: var(--app-text-muted); }
.check-step-detail { font-size: 0.82rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.check-step-error { font-size: 0.8rem; color: var(--app-danger); overflow-wrap: anywhere; }

.health-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
  font-size: 0.8rem;
  color: var(--app-text-soft);
}

/* ---------------------------------------------------------------------------
   Onboarding: sign-in page divider, join-link QR code
   --------------------------------------------------------------------------- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--bs-secondary-color);
  font-size: .8125rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1 1 auto;
  border-top: 1px solid var(--bs-border-color);
}
.join-qr {
  width: 168px;
  height: 168px;
  margin: 0 auto;
  padding: 0;
  background: var(--app-on-color);
  border-radius: .5rem;
}
.join-qr svg { width: 100%; height: 100%; display: block; }
/* Roster → Join link: a big QR to scan off the screen, the link, Share and Copy. */
.join-share {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 26rem;
  margin: 0 auto;
  padding: .5rem 0;
  text-align: center;
}
.join-share .join-qr {
  width: min(100%, 20rem);
  height: auto;
  aspect-ratio: 1;
  padding: .75rem;
  border-radius: .75rem;
  box-shadow: 0 0 0 1px var(--bs-border-color);
}
.join-share-hint { margin: 0; color: var(--bs-secondary-color); }
#join-link { font-size: 1rem; text-align: center; text-overflow: ellipsis; }
.join-share-actions { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
.join-share-actions .btn { flex: 1 1 10rem; min-height: 2.75rem; }
.join-request-actions { display: flex; align-items: center; gap: .5rem; }
.join-request-actions .btn { white-space: nowrap; }

/* colour picker inputs rendered by the field component */
input[type="color"].form-control { height: calc(1.5em + 0.75rem + 2px); padding: 0.25rem; cursor: pointer; }

/* ---------------------------------------------------------------------------
   Legal: cookie banner, "accept the documents" bar, document pages
   --------------------------------------------------------------------------- */
/* a small card in the bottom-left corner; never covers the page centre */
.cookie-banner {
  position: fixed;
  left: 1rem;
  bottom: calc(1rem + var(--app-bottom-nav-space));
  z-index: 1040;
  width: min(23rem, calc(100vw - 2rem));
  max-height: calc(100vh - var(--app-nav-height) - 2rem);
  overflow-y: auto;
  padding: 1rem 1.1rem;
  background: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-lg);
  font-size: 0.85rem;
  animation: cookie-banner-in 0.25s ease-out;
}
.cookie-banner[hidden] { display: none; }
@keyframes cookie-banner-in {
  from { opacity: 0; transform: translateY(0.75rem); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .cookie-banner { animation: none; } }
.cookie-banner-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}
.cookie-banner-head .bi { color: var(--app-primary); font-size: 1.15rem; }
.cookie-banner-text { color: var(--app-text-muted); margin-bottom: 0.75rem; }
.cookie-banner-text a { white-space: nowrap; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cookie-actions .btn { flex: 1 1 auto; }
.cookie-categories {
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--app-surface-2);
  border-radius: var(--app-radius-sm);
}
.cookie-categories[hidden] { display: none; }
.cookie-categories .form-check { margin-bottom: 0.35rem; }
.cookie-saved { margin-top: 0.5rem; color: var(--app-success); font-size: 0.85rem; }
@media (max-width: 575.98px) {
  .cookie-banner { left: 0.5rem; right: 0.5rem; bottom: calc(0.5rem + var(--app-bottom-nav-space)); width: auto; padding: 0.85rem 0.9rem; }
  .cookie-actions .btn { min-height: 2.25rem; }
}

/* slim bar above the page content; the page stays usable */
.legal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--app-primary-soft);
  border: 1px solid var(--app-border);
  border-left: 3px solid var(--app-primary);
  border-radius: var(--app-radius-sm);
  font-size: 0.875rem;
}
.legal-bar-icon { color: var(--app-primary); font-size: 1.25rem; }
.legal-bar-text { flex: 1 1 14rem; min-width: 0; }
.legal-bar-title { font-weight: 600; }
.legal-bar-links a { color: var(--app-primary); }
.legal-bar-note { margin-top: 0.2rem; color: var(--app-text-muted); }

/* temporary "Set up the app" bar on Events (accounts/_setup_bar.html) and the setup page */
.setup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--app-primary-soft);
  border: 1px solid var(--app-border);
  border-left: 3px solid var(--app-primary);
  border-radius: var(--app-radius-sm);
  font-size: 0.875rem;
}
.setup-bar-icon { color: var(--app-primary); font-size: 1.25rem; }
.setup-bar-text { flex: 1 1 14rem; min-width: 0; }
.setup-bar-title { font-weight: 600; }
/* long banner text: three lines, then a "Show more" toggle added by collapsible_text.js */
.setup-bar-body.is-collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.collapsible-toggle {
  padding: 0;
  margin-top: 0.15rem;
  border: 0;
  background: none;
  color: var(--app-primary);
  font-weight: 600;
  font-size: inherit;
}
.collapsible-toggle:hover { text-decoration: underline; }
.collapsible-toggle .bi { transition: transform 0.15s; }
.collapsible-toggle[aria-expanded="true"] .bi { transform: rotate(180deg); }
.setup-facts { padding-left: 1.1rem; margin-bottom: 0; }
.setup-facts li { margin-bottom: 0.4rem; }
.setup-switch { font-size: 1rem; padding-left: 3.4em; }
.setup-switch .form-check-input { width: 2.6em; height: 1.4em; margin-top: 0.05em; margin-left: -3.4em; }
.setup-calendar-buttons { display: grid; gap: 0.5rem; max-width: 24rem; }
.setup-connect { margin-top: 0.4rem; }

/* document pages */
.legal-toc {
  position: sticky;
  top: calc(var(--app-nav-height) + 1rem);
  font-size: 0.85rem;
}
.legal-toc-title {
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  color: var(--app-text-soft);
  margin-bottom: 0.5rem;
}
.legal-toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--app-border); }
.legal-toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.75rem;
  color: var(--app-text-muted);
  text-decoration: none;
}
.legal-toc a:hover { color: var(--app-primary); }
.legal-doc { max-width: 48rem; line-height: 1.65; }
.legal-doc-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.35rem; }
.legal-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--app-text-soft);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.legal-doc h2 {
  font-size: 1.1rem;
  font-weight: 650;
  margin: 1.75rem 0 0.6rem;
  scroll-margin-top: calc(var(--app-nav-height) + 1rem);
}
.legal-doc h3 { font-size: 1rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.legal-doc ol, .legal-doc ul { padding-left: 1.4rem; }
.legal-doc li { margin-bottom: 0.35rem; }
.legal-anchor { scroll-margin-top: calc(var(--app-nav-height) + 1rem); }
.legal-placeholder {
  background: color-mix(in srgb, var(--app-warning) 35%, transparent);
  color: var(--app-text);
  border-radius: 0.25rem;
  padding: 0 0.25rem;
}
.legal-notice { font-size: 0.78rem; color: var(--app-text-soft); margin-bottom: 1rem; }
.legal-notice p { margin-bottom: 0; }
.legal-request-actions { padding: 0 0 0.75rem; border-bottom: 1px solid var(--app-border); margin-bottom: 0.5rem; }
.legal-request-actions .btn { white-space: nowrap; }

@media print {
  .cookie-banner, .legal-bar, .legal-toc { display: none !important; }
}
