/**
 * TaskCore responsive shell — corporate, touch-friendly, mobile-first.
 * Works with the built React app (no bundle changes). Paired with responsive-shell.js.
 */

:root {
  --tc-nav-drawer-width: min(17.5rem, 88vw);
  --tc-nav-backdrop: rgba(15, 23, 42, 0.5);
  --tc-nav-z-backdrop: 10025;
  --tc-nav-z-drawer: 10035;
  --tc-nav-z-toggle: 10020;
}

/* Prevent horizontal bleed; single vertical scroll inside the app (not body + main). */
html {
  height: 100%;
  overflow-x: hidden;
}
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
#root {
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Let the bundled shell fill the viewport so only its inner .overflow-y-auto scrolls */
#root > div:first-child {
  flex: 1 1 auto;
  min-height: 0;
}

/* System-style scrollbars on the main scroll region (no custom thin/colored track) */
#root .overflow-y-auto {
  scrollbar-width: auto;
  scrollbar-color: auto;
}

/* —— Mobile / tablet: sidebar as off-canvas drawer (activated by .tc-shell-aside + html.tc-nav-open) —— */
@media (max-width: 1023.98px) {
  .tc-shell-aside {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--tc-nav-z-drawer);
    width: var(--tc-nav-drawer-width) !important;
    max-width: var(--tc-nav-drawer-width) !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    transform: translate3d(-102%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.35);
    border-right-width: 1px !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  html.tc-nav-open .tc-shell-aside {
    transform: translate3d(0, 0, 0);
  }

  html.tc-nav-open {
    overflow: hidden;
  }

  .tc-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--tc-nav-z-backdrop);
    background: var(--tc-nav-backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    -webkit-tap-highlight-color: transparent;
  }

  html.tc-nav-open .tc-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Main column uses full width when sidebar is off-canvas */
  #root > div.flex > aside.tc-shell-aside ~ * {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tc-shell-aside {
    transition-duration: 0.01ms !important;
  }
  .tc-nav-backdrop {
    transition-duration: 0.01ms !important;
  }
}

/* Desktop: restore normal flow; hide drawer chrome */
@media (min-width: 1024px) {
  .tc-shell-aside {
    position: relative !important;
    transform: none !important;
    height: auto !important;
    min-height: 0 !important;
    width: auto !important;
    max-width: none !important;
    box-shadow: none !important;
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
  }

  .tc-nav-backdrop {
    display: none !important;
  }

  #tc-nav-toggle {
    display: none !important;
  }
}

/* —— Hamburger (injected next to title) —— */
#tc-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin-right: 0.5rem;
  padding: 0;
  border-radius: 0.65rem;
  border: 1px solid var(--header-ui-border, var(--border));
  background: color-mix(in srgb, var(--header-ui-bg, var(--bg-card)) 92%, transparent);
  color: var(--header-fg, var(--text));
  cursor: pointer;
  position: relative;
  z-index: var(--tc-nav-z-toggle);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#tc-nav-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

#tc-nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#tc-nav-toggle svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

/* —— Header: stack-friendly tools on small screens —— */
@media (max-width: 767.98px) {
  [data-taskcore-header] {
    flex-wrap: wrap !important;
    row-gap: 0.35rem !important;
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px)) !important;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px)) !important;
  }

  [data-taskcore-header] > div:first-child {
    max-width: none !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  [data-taskcore-header] > div.justify-end {
    flex: 1 1 100% !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 0.4rem 0.5rem !important;
  }

  /* Search lives in .tc-header-search-wrap — size the shell, not the raw input */
  [data-taskcore-header] .tc-header-search-wrap {
    max-width: min(68vw, 18rem) !important;
    flex: 1 1 12rem !important;
  }

  [data-taskcore-header] .tc-header-search-wrap input[type='search'],
  [data-taskcore-header] .tc-header-search-wrap input[placeholder*='Search' i],
  [data-taskcore-header] .tc-header-search-wrap input[placeholder*='search' i] {
    max-width: 100% !important;
    min-height: 2.75rem;
  }

  /* Optional middle strip (e.g. due today): don’t dominate */
  [data-taskcore-header] > div:not(.justify-end):not(:first-child) {
    order: 3;
    flex: 1 1 100% !important;
    max-width: none !important;
  }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
  [data-taskcore-header] > div.justify-end {
    flex-wrap: wrap !important;
  }
}

/* —— Main content: breathing room —— */
@media (max-width: 1023.98px) {
  #root main {
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px)) !important;
  }
}

/* —— Cards & sections —— */
@media (max-width: 767.98px) {
  #root main .rounded-2xl.shadow-card,
  #root main [class*='rounded-2xl'][class*='shadow'] {
    border-radius: 1rem !important;
  }

  #root main .grid {
    gap: 0.75rem;
  }
}

/* —— Tables —— */
.table-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-width: 767.98px) {
  .table-scroll {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

/* —— Touch targets (coarse pointers): minimum tap size —— */
@media (pointer: coarse) and (max-width: 1023.98px) {
  #root main button:not(.lumi-avatar):not([class*='h-1']):not([class*='px-0']):not(.tc-nav-toggle-ignore),
  #root main a[role='button'],
  #root main [type='button'] {
    min-height: 44px;
  }
}

/* —— Fundraising / progress-style rows (flex toolbars with progress) —— */
@media (max-width: 767.98px) {
  #root main .tc-fundraising-row,
  #root main [data-tc-fundraising='true'] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  #root main .tc-fundraising-row .h-2,
  #root main .tc-fundraising-row [class*='h-1'],
  #root main [data-tc-fundraising='true'] .grow {
    width: 100% !important;
  }

  #root main .tc-fundraising-row .flex.gap-2,
  #root main [data-tc-fundraising='true'] .flex.gap-2 {
    width: 100%;
    flex-direction: column;
  }

  #root main .tc-fundraising-row button,
  #root main [data-tc-fundraising='true'] button {
    width: 100%;
    justify-content: center;
  }
}

/* —— Typography scale (app chrome) —— */
@media (max-width: 639.98px) {
  #root main h1 {
    font-size: clamp(1.125rem, 4vw, 1.5rem);
  }
  #root main h2 {
    font-size: clamp(1rem, 3.5vw, 1.25rem);
  }
}

/* —— No hover-only affordances on touch devices —— */
@media (hover: none) {
  .shadow-card:hover,
  [class*='shadow-card']:hover {
    transform: none !important;
  }
}
