/* ============================================
   Global typography
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Exact iOS system colors (Color.blue, .purple, ...) -- matches
     SystemColors.kt on Android and Color.blue/.purple/etc. in the
     SwiftUI source, so the site's palette is the app's palette. */
  --ios-blue: #007AFF;
  --ios-purple: #AF52DE;
  --ios-red: #FF3B30;
  --ios-orange: #FF9500;
  --ios-yellow: #FFCC00;
  --ios-green: #34C759;
  --ios-indigo: #5856D6;
  --ios-teal: #30B0C7;
  --ios-cyan: #32ADE6;
  --ios-pink: #FF2D55;
  --ios-mint: #00C7BE;
  --ios-gray: #8E8E93;
  --ios-card-radius: 20px;
  --ios-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

body {
  font-family: var(--font-sans);
  font-size: 17.5px;
  line-height: 1.65;
  color: #1c1c1e;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Quarto already generates a breadcrumb trail (Section > Page) on
   every page, but Bootstrap's d-none/d-lg-block utility classes hide
   it below desktop width -- exactly the screens where the site can
   feel most "app-like" and a way back is least obvious. Force it
   visible at every size so there's always a clickable path back up
   the hierarchy, not just the sidebar or browser back button. */
.quarto-page-breadcrumbs {
  display: flex !important;
  margin-bottom: 0.5em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  color: #1c1c1e;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font-size: 2.15rem;
  font-weight: 800;
  margin-bottom: 0.5em;
}

/* StandardPageHeader match: icon (as an emoji prefixed onto the title
   itself) + bold title + gray subtitle, mirroring StandardPageHeader.swift
   (title in plain primary text, no accent color -- only the icon carries
   color, which emoji already do on their own). */
.quarto-title .subtitle.lead {
  font-size: 1rem;
  font-weight: 400;
  font-style: normal;
  color: #6b7280;
  margin-top: -0.3em;
  margin-bottom: 0.8em;
}

h2 {
  font-size: 1.5rem;
  margin-top: 2em;
  margin-bottom: 0.6em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid #e9edf2;
}

h3 {
  font-size: 1.2rem;
  margin-top: 1.6em;
  margin-bottom: 0.5em;
}

p {
  margin-bottom: 1em;
}

a {
  color: var(--ios-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================
   Home screen -- mirrors HomeView.swift exactly:
   diagonal blue->purple gradient banner, gradient
   "New Here?" heading, and a StartHereRow list
   (circular gradient icon badge + light tinted row).
   ============================================ */

.home-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-radius: var(--ios-card-radius);
  background: linear-gradient(135deg, var(--ios-blue), var(--ios-purple));
  color: white;
  margin-bottom: 4px;
}

.home-header-icon {
  font-size: 28px;
  line-height: 1;
}

.home-header-title {
  font-weight: 800;
  font-size: 1.2rem;
}

.home-header-subtitle {
  opacity: 0.9;
  font-size: 0.85rem;
}

.new-here-heading .anchorjs-link {
  display: none !important;
}

.new-here-heading {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--ios-blue), var(--ios-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0;
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-top: 1.4em !important;
}

.new-here-subtitle {
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ============================================
   Home page layout: fixed compact width,
   left-aligned instead of centered in the full
   page-layout-full width.
   ============================================ */

.home-wrap {
  max-width: 1020px;
  margin: 0;
}

.new-here-heading {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--ios-blue), var(--ios-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 16px 0 4px !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.start-here-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px 12px;
  margin: 10px 0 20px;
}

.start-here-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 16px;
  text-decoration: none !important;
  color: inherit;
  background: linear-gradient(135deg, color-mix(in srgb, var(--row-color) 16%, white), color-mix(in srgb, var(--row-color) 5%, white));
  transition: transform 0.1s ease;
}

.start-here-row:hover {
  transform: translateX(2px);
}

.start-here-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: white;
  background: linear-gradient(135deg, var(--row-color), color-mix(in srgb, var(--row-color) 60%, white));
}

.start-here-text {
  flex: 1;
  min-width: 0;
}

.start-here-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1c1c1e;
}

.start-here-subtitle {
  font-size: 0.78rem;
  color: #6b7280;
}

.start-here-chevron {
  flex: 0 0 auto;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* ============================================
   CategoryTile -- mirrors CategoryTile.swift: a
   bold color-gradient tile with white icon/title/
   subtitle, used for hub-style navigation grids.
   ============================================ */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin: 14px 0 24px;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  min-height: 150px;
  padding: 18px;
  border-radius: 24px;
  text-decoration: none !important;
  background: linear-gradient(135deg, var(--tile-color), color-mix(in srgb, var(--tile-color) 75%, white));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--tile-color) 25%, transparent);
}

.tile-icon {
  font-size: 30px;
  color: white;
}

.tile-title {
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
}

.tile-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.82rem;
}

/* ============================================
   Soft-tint card -- mirrors SectionCard.swift: a
   rounded card with the whole background tinted
   ~12% of the accent color, not just a header bar.
   ============================================ */

.ios-card {
  background: color-mix(in srgb, var(--card-color, var(--ios-blue)) 12%, white);
  border-radius: var(--ios-card-radius);
  padding: 16px 18px;
  box-shadow: var(--ios-shadow);
  margin: 14px 0;
}

/* ============================================
   App shell -- when installed to the home screen
   (display-mode: standalone), the site sheds every
   bit of "website" chrome (sidebar, docs header,
   footer stats) and becomes a bottom-tab app shell
   matching MainTabView.swift's 4 tabs exactly, so
   the installed experience is indistinguishable
   from the native app.
   ============================================ */

.app-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: rgba(249, 249, 249, 0.94);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
}

.app-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #8E8E93;
  text-decoration: none !important;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
}

.app-tab-item.active {
  color: var(--ios-blue);
}

.app-tab-icon {
  font-size: 22px;
  line-height: 1;
}

/* Collaborator map on About: an embedded iframe in the regular browser,
   falling back to a plain link-out card in standalone/installed mode,
   where cross-origin iframes are unreliable in WebKit's PWA container. */
.map-link-fallback {
  display: none;
}

@media (display-mode: standalone) {
  .app-tab-bar {
    display: flex;
  }

  #quarto-header,
  #quarto-sidebar,
  #quarto-margin-sidebar,
  .quarto-secondary-nav,
  .page-footer,
  #title-block-header nav.quarto-page-breadcrumbs {
    display: none !important;
  }

  #quarto-content.page-columns {
    display: block !important;
  }

  main.content {
    margin: 0 !important;
    max-width: 100% !important;
    padding: 16px 16px calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }

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

  .map-embed-only {
    display: none !important;
  }

  .map-link-fallback {
    display: flex !important;
  }
}

/* sidebar polish */
.sidebar-title {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.sidebar-title,
.sidebar-title a {
  color: #ffffff !important;
}

.sidebar-title a:hover {
  color: #ffffff !important;
  opacity: 0.85;
}

#quarto-sidebar .sidebar-item-text {
  font-size: 15.5px;
  font-weight: 500;
}

#quarto-sidebar .sidebar-section .sidebar-item-text {
  font-weight: 400;
}

/* table polish */
table {
  border-collapse: collapse;
  width: 100%;
}

table th {
  background: #f7f9fc;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
}

table td {
  padding: 10px 14px;
  border-top: 1px solid #eef1f5;
}

.mark-do {
  color: var(--ios-green);
  font-weight: 800;
}

.mark-dont {
  color: var(--ios-red);
  font-weight: 800;
}

.callout-pearl {
  background: color-mix(in srgb, var(--ios-blue) 12%, white);
  padding: 14px 16px;
  border-radius: var(--ios-card-radius);
  margin: 10px 0;
  box-shadow: var(--ios-shadow);
}

/* ============================================
   Firestore-backed card/grid/filter system
   Shared visual language for systems.qmd,
   video.qmd, catheter-types.qmd, references.qmd
   ============================================ */

.fs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin: 8px 0 24px;
}

.fs-card {
  background: white;
  border-radius: var(--ios-card-radius);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}

.fs-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.fs-card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #f1f3f5;
  display: block;
  cursor: zoom-in;
}

/* Once fsClassifyImage() (lightbox-include.html) reads the image's
   real naturalWidth/naturalHeight on load, give portrait photos a
   taller box instead of cropping them into the default landscape
   frame above. .is-landscape keeps the default 160px height. */
.fs-card-image.is-portrait {
  height: 320px;
}

/* ============================================
   Click-to-enlarge overlay for Firestore/OJS-
   injected images (fs-card-image and friends),
   which the native Quarto lightbox can't reach
   since they're inserted client-side at runtime.
   ============================================ */

#fs-lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.9);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 32px;
  cursor: zoom-out;
}

#fs-lightbox-overlay.open {
  display: flex;
}

#fs-lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.fs-card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.fs-card-title {
  font-size: 17px;
  font-weight: 700;
  color: #1c1c1e;
  margin: 0;
  line-height: 1.3;
}

.fs-card-desc {
  font-size: 14.5px;
  color: #555;
  margin: 0;
  line-height: 1.5;
}

.fs-card-meta {
  font-size: 13px;
  color: #999;
  margin: 2px 0 0;
}

.fs-source {
  display: inline-block;
  margin: 4px 0 0;
  padding: 4px 11px;
  border-radius: 8px;
  background: #FFF4CC;
  color: #7a5b00;
  font-weight: 700;
  font-size: 12.5px;
}

.fs-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 20px;
  align-self: flex-start;
  margin-top: 8px;
  color: white;
}

.fs-card-link {
  display: inline-block;
  margin-top: 10px;
  background: var(--ios-blue);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  align-self: flex-start;
}

.fs-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 22px;
}

.fs-filter-pill {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid #dbe4ee;
  background: white;
  color: #444;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fs-filter-pill:hover {
  border-color: var(--ios-blue);
  color: var(--ios-blue);
}

.fs-filter-pill.active {
  background: var(--ios-blue);
  border-color: var(--ios-blue);
  color: white;
}

.fs-empty {
  padding: 40px 20px;
  text-align: center;
  color: #999;
  font-size: 15px;
  background: #f7f9fc;
  border-radius: 14px;
  grid-column: 1 / -1;
}

/* ============================================
   Accordion (collapsible-by-category groups)
   Used by references.qmd
   ============================================ */

.fs-accordion {
  background: white;
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.fs-accordion-summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16.5px;
  color: white;
  transition: filter 0.15s ease;
}

.fs-accordion-summary:hover {
  filter: brightness(1.08);
}

.fs-accordion-summary::-webkit-details-marker {
  display: none;
}

.fs-accordion-summary::marker {
  content: "";
}

.fs-accordion-summary::after {
  content: "⌄";
  font-size: 20px;
  color: white;
  transition: transform 0.2s ease;
  margin-left: auto;
}

.fs-accordion[open] .fs-accordion-summary::after {
  transform: rotate(180deg);
}

.fs-accordion-name {
  flex: 1;
}

.fs-accordion-count {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 12px;
}

.fs-accordion-body {
  padding: 4px 20px 12px;
  border-top: 1px solid #eef1f5;
}

.fs-ref-entry {
  padding: 14px 0;
  border-bottom: 1px solid #f4f6f9;
}

.fs-ref-entry:last-child {
  border-bottom: none;
}

.fs-ref-title {
  font-weight: 600;
  font-size: 16px;
  color: #1c1c1e;
  margin: 0 0 4px;
  line-height: 1.45;
}

.fs-ref-authors {
  font-size: 14.5px;
  color: #555;
  margin: 0 0 3px;
}

.fs-ref-journal {
  font-size: 13.5px;
  color: #888;
  margin: 0 0 6px;
  font-style: italic;
}

.fs-ref-link {
  font-size: 14px;
  color: var(--ios-blue);
  font-weight: 500;
  text-decoration: none;
}

.fs-ref-link:hover {
  text-decoration: underline;
}

/* ============================================
   Clinical checklist UI (checklist.qmd and any
   future checklist-style page) -- a real
   bedside-form look: bordered rows with large
   custom checkboxes, a page-wide progress bar,
   and a readiness status banner, all driven by
   fsChecklistToggle() in lightbox-include.html.
   ============================================ */

.checklist-progress {
  margin: 4px 0 28px;
}

.checklist-progress-bar {
  height: 12px;
  background: #eef1f5;
  border-radius: 999px;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ios-blue), var(--ios-green));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.checklist-progress-label {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  text-align: right;
}

.checklist-section {
  margin-bottom: 30px;
}

.checklist-section-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #12375c;
  margin-bottom: 14px;
}

.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1.5px solid #e4e9f0;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.checklist-row:hover {
  border-color: var(--ios-blue);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.checklist-row.checked {
  background: #eefaf1;
  border-color: var(--ios-green);
}

.checklist-checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 2.5px solid #c7ccd4;
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.checklist-checkbox:checked {
  background: var(--ios-green);
  border-color: var(--ios-green);
}

.checklist-checkbox:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 17px;
  font-weight: 800;
}

.checklist-row-text {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: #1c1c1e;
}

.checklist-row.checked .checklist-row-text {
  color: #6b7280;
  text-decoration: line-through;
  text-decoration-color: #9ca3af;
}

.checklist-status-banner {
  padding: 18px;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

.checklist-status-banner.ready {
  background: #e8f5e9;
  color: #1e7e45;
  border: 1.5px solid #7ac79b;
}

.checklist-status-banner.pending {
  background: #fdecea;
  color: #b03a2e;
  border: 1.5px solid #e3948a;
}

/* ============================================
   Sidebar brand tint: a deep navy echoing the
   home header's blue -> purple gradient, instead
   of Quarto/Bootstrap's generic dark-theme gray.
   ============================================ */

#quarto-sidebar,
#quarto-sidebar .sidebar-menu-container,
#quarto-sidebar .sidebar-search {
  background-color: #0d1b3a !important;
}
