/* =========================================================================
   NurseCraft – Apple Design System Layer (WWDC Fluid Interfaces & Craft)
   Aktiviert über Klasse `html.nc-apple-design` (jederzeit umschaltbar)
   ========================================================================= */

/* 1. Typografie: Optische Skalierung, größenabhängiges Tracking & Leading (§15) */
html.nc-apple-design {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
}

html.nc-apple-design body {
  letter-spacing: 0;
  line-height: 1.52;
}

html.nc-apple-design h1,
html.nc-apple-design .hero-claim-title {
  letter-spacing: -0.025em;
  line-height: 1.12;
  font-weight: 800;
}

html.nc-apple-design h2,
html.nc-apple-design .panel-head h2,
html.nc-apple-design .bedside-brand-text h1 {
  letter-spacing: -0.018em;
  line-height: 1.2;
}

html.nc-apple-design h3,
html.nc-apple-design .modal-title {
  letter-spacing: -0.012em;
  line-height: 1.28;
}

html.nc-apple-design .dropdown-section-label,
html.nc-apple-design .bedside-brand-sub,
html.nc-apple-design .modal-form-label,
html.nc-apple-design .section-headline-bar h2 {
  letter-spacing: 0.015em;
}

/* 2. Sofortiges taktiles Feedback auf Pointer-Down (§1: Kill Latency) */
html.nc-apple-design button,
html.nc-apple-design .btn,
html.nc-apple-design .btn-bedside,
html.nc-apple-design .pillar-tab,
html.nc-apple-design .subnav-btn,
html.nc-apple-design .dropdown-menu-item,
html.nc-apple-design .nav-tab-btn,
html.nc-apple-design .quick-action-btn,
html.nc-apple-design .btn-header-icon,
html.nc-apple-design .sync-pill {
  touch-action: manipulation;
  transition:
    transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background-color 160ms ease,
    box-shadow 180ms ease,
    border-color 160ms ease,
    opacity 150ms ease;
}

html.nc-apple-design button:active,
html.nc-apple-design .btn:active,
html.nc-apple-design .btn-bedside:active,
html.nc-apple-design .pillar-tab:active,
html.nc-apple-design .subnav-btn:active,
html.nc-apple-design .dropdown-menu-item:active,
html.nc-apple-design .nav-tab-btn:active,
html.nc-apple-design .quick-action-btn:active,
html.nc-apple-design .btn-header-icon:active,
html.nc-apple-design .sync-pill:active,
html.nc-apple-design .nc-pressed {
  transform: scale(0.968) !important;
  transition-duration: 75ms !important;
  transition-timing-function: ease-out !important;
}

html.nc-apple-design .mcard,
html.nc-apple-design .plan-card,
html.nc-apple-design .bedside-task-card,
html.nc-apple-design .template-card {
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 180ms ease;
}

html.nc-apple-design .mcard:hover,
html.nc-apple-design .plan-card:hover,
html.nc-apple-design .template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.09), 0 1px 3px rgba(15, 23, 42, 0.05);
}

html.nc-apple-design .mcard.nc-pressed,
html.nc-apple-design .plan-card.nc-pressed,
html.nc-apple-design .bedside-task-card.nc-pressed {
  transform: scale(0.985) !important;
}

/* 3. Materials & Depth: Transluzente Chrome-Ebenen & Lichtkanten (§12) */
html.nc-apple-design .btn-hero-menu {
  background: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  box-shadow:
    0 4px 16px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

html.nc-apple-design[data-theme="dark"] .btn-hero-menu {
  background: rgba(23, 33, 48, 0.72) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html.nc-apple-design .hero-dropdown-menu {
  background: rgba(255, 255, 255, 0.84) !important;
  backdrop-filter: blur(26px) saturate(190%);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.65) !important;
  border-radius: 18px !important;
  box-shadow:
    0 24px 64px rgba(15, 23, 42, 0.22),
    0 4px 16px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.85) !important;
}

html.nc-apple-design[data-theme="dark"] .hero-dropdown-menu {
  background: rgba(19, 27, 38, 0.84) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html.nc-apple-design .dropdown-menu-item {
  border-radius: 11px !important;
}

html.nc-apple-design .dropdown-menu-item:hover {
  background: rgba(169, 85, 58, 0.11) !important;
}

/* Sticky Sub-Navigation & Pillar-Tabs mit Transluzenz & Scroll-Edge statt harter Kante */
html.nc-apple-design .pillar-tabs,
html.nc-apple-design .subnav-bar {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-color: rgba(15, 23, 42, 0.06);
  box-shadow:
    0 6px 24px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

html.nc-apple-design[data-theme="dark"] .pillar-tabs,
html.nc-apple-design[data-theme="dark"] .subnav-bar {
  background: rgba(19, 27, 38, 0.78);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* Karten & Panels: Weiche Radien, subtile Haarränder, Tiefe */
html.nc-apple-design .panel,
html.nc-apple-design .card,
html.nc-apple-design .mcard,
html.nc-apple-design .plan-card,
html.nc-apple-design .cockpit-card,
html.nc-apple-design .template-card {
  border-radius: 16px;
  border-color: rgba(15, 23, 42, 0.08);
}

html.nc-apple-design[data-theme="dark"] .panel,
html.nc-apple-design[data-theme="dark"] .card,
html.nc-apple-design[data-theme="dark"] .mcard,
html.nc-apple-design[data-theme="dark"] .plan-card,
html.nc-apple-design[data-theme="dark"] .cockpit-card,
html.nc-apple-design[data-theme="dark"] .template-card {
  border-color: rgba(255, 255, 255, 0.09);
}

/* 4. Desktop Modals / Dialoge: Materialisierung, Scrim & Context-Aware Shadow (§12) */
html.nc-apple-design dialog {
  border-radius: 20px !important;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  box-shadow:
    0 32px 80px rgba(15, 23, 42, 0.26),
    0 8px 24px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.65) !important;
  will-change: transform, opacity;
}

html.nc-apple-design[data-theme="dark"] dialog {
  border-color: rgba(255, 255, 255, 0.12) !important;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html.nc-apple-design dialog::backdrop {
  background: rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity 220ms ease, backdrop-filter 220ms ease;
}

/* 5. Bedside Companion (Mobil): Floating Translucent Chrome & Bottom-Sheet-Grabber */
html.nc-apple-design .bedside-header {
  background: rgba(255, 255, 255, 0.68) !important;
  backdrop-filter: blur(24px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(190%) !important;
  border-bottom: none !important;
  box-shadow:
    0 8px 28px rgba(15, 23, 42, 0.07),
    inset 0 -0.5px 0 rgba(15, 23, 42, 0.08) !important;
}

html.nc-apple-design .bedside-bottom-nav {
  background: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(26px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(26px) saturate(200%) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.72) !important;
  box-shadow:
    0 -8px 32px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.85) !important;
}

html.nc-apple-design .bedside-modal-backdrop {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

html.nc-apple-design .bedside-modal-sheet {
  background: rgba(255, 255, 255, 0.88) !important;
  backdrop-filter: blur(30px) saturate(190%) !important;
  -webkit-backdrop-filter: blur(30px) saturate(190%) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.9) !important;
  border-radius: 26px 26px 0 0 !important;
  box-shadow:
    0 -16px 48px rgba(15, 23, 42, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
  will-change: transform;
  touch-action: pan-x;
}

.nc-sheet-handle {
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
  margin: -6px auto 14px auto;
  cursor: grab;
  flex-shrink: 0;
  transition: background-color 150ms ease, width 150ms ease;
}

.nc-sheet-handle:active {
  cursor: grabbing;
  background: rgba(15, 23, 42, 0.34);
  width: 46px;
}

/* 6. Live Design-Umschalter Pill (A/B-Vergleich im Browser) */
.nc-design-switcher {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  font-family: -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
  user-select: none;
  transition: transform 140ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 180ms ease, background-color 180ms ease;
}

.nc-design-switcher:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
}

.nc-design-switcher:active {
  transform: scale(0.95);
}

.nc-design-switcher .nc-ds-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a9553a;
  box-shadow: 0 0 0 2px rgba(169, 85, 58, 0.22);
}

html:not(.nc-apple-design) .nc-design-switcher .nc-ds-dot {
  background: #64748b;
  box-shadow: none;
}

/* In der Bedside-App über der Bottom-Nav schweben, damit nichts überdeckt wird */
body.light-mode .nc-design-switcher {
  bottom: calc(var(--nav-height, 64px) + env(safe-area-inset-bottom, 0px) + 12px);
  right: 12px;
}

html.nc-apple-design[data-theme="dark"] .nc-design-switcher {
  color: #f1f5f9;
  background: rgba(19, 27, 38, 0.78);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* 7. Barrierefreiheit: Reduced Motion, Reduced Transparency & High Contrast (§14) */
@media (prefers-reduced-motion: reduce) {
  html.nc-apple-design *,
  html.nc-apple-design *::before,
  html.nc-apple-design *::after {
    transition-duration: 160ms !important;
    animation-duration: 1ms !important;
  }
  html.nc-apple-design button:active,
  html.nc-apple-design .nc-pressed,
  html.nc-apple-design .mcard:hover {
    transform: none !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  html.nc-apple-design .btn-hero-menu,
  html.nc-apple-design .hero-dropdown-menu,
  html.nc-apple-design .pillar-tabs,
  html.nc-apple-design .subnav-bar,
  html.nc-apple-design .bedside-header,
  html.nc-apple-design .bedside-bottom-nav,
  html.nc-apple-design .bedside-modal-sheet,
  html.nc-apple-design .nc-design-switcher {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--pa, #ffffff) !important;
  }
}

@media (prefers-contrast: more) {
  html.nc-apple-design .panel,
  html.nc-apple-design .card,
  html.nc-apple-design .mcard,
  html.nc-apple-design dialog,
  html.nc-apple-design .hero-dropdown-menu {
    border-width: 1.5px !important;
    border-color: var(--ink, #0f172a) !important;
  }
}

@media print {
  .nc-design-switcher {
    display: none !important;
  }
}
