/* FILE: /css/base.css
   Purpose: Global reset, CSS variables (design tokens), typography, and base elements.
   Notes:
   - No layout here (no sidebar/topbar positioning). That belongs in layout.css.
   - No component-specific styling (buttons, inputs, modals). That belongs in components.css.
*/

:root {
  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Base sizing */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.10);

  --border: 1px solid rgba(0, 0, 0, 0.10);

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  /* Colors (neutral-first, minimalist) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --surface-3: #f1f2f3;

  --text: #111111;
  --text-2: rgba(17, 17, 17, 0.78);
  --muted: rgba(17, 17, 17, 0.55);

  --line: rgba(17, 17, 17, 0.10);
  --line-strong: rgba(17, 17, 17, 0.16);

  --focus: rgba(17, 17, 17, 0.25);

  /* Accent (kept subtle by default) */
  --accent: #111111;
  --accent-contrast: #ffffff;

  /* System semantic colors */
  --danger: #b42318;
  --warning: #b54708;
  --ok: #027a48;

  /* App tokens */
  --page-max: 1280px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 120ms;
  --dur-2: 220ms;

  /* Form */
  --input-h: 42px;
}

/* A more comfortable base on large screens */
@media (min-width: 1200px) {
  :root {
    --input-h: 44px;
  }
}

/* Reset / Normalize (minimal) */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* ✅ Prevent “rubber band” scroll chaining on supporting browsers */
  overscroll-behavior: none;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

/* ✅ Modal open: lock background scroll */
body.is-modal-open {
  overflow: hidden;

  /* iOS/Safari: reduce scroll gestures bleeding to body */
  touch-action: none;
  overscroll-behavior: none;
}

/* Media */
img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Accessible focus (consistent, subtle) */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: rgba(17, 17, 17, 0.12);
}

/* Utility: visually hidden (for accessible labels) */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Utility: container (optional, used by pages if needed) */
.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--s-4);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}


/* ===== Modal scroll lock (driven by ui.js) ===== */
body.is-modal-open {
  overflow: hidden;
}

/* Optional: avoid layout shift when scrollbar disappears (supported browsers) */
@supports (scrollbar-gutter: stable) {
  html {
    scrollbar-gutter: stable;
  }
}



/* =========================
   Search Modal (v1) styles
   ========================= */

/* Search result container */
[data-bind="searchResults"] {
  margin-top: 10px;
}

/* Hint / empty states */
[data-bind="searchResults"] .hint {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.04);
  font-size: 13px;
  line-height: 1.4;
  color: rgba(0,0,0,0.65);
}

/* Summary line */
[data-bind="searchResults"] .search-summary {
  font-size: 12px;
  color: rgba(0,0,0,0.55);
  padding: 6px 4px 8px 4px;
}

/* List wrapper */
[data-bind="searchResults"] .search-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px; /* scrollbar breathing room */
}

/* Search item button */
[data-bind="searchResults"] .search-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.75);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Hover / active */
[data-bind="searchResults"] .search-item:hover {
  background: rgba(255,255,255,0.95);
  border-color: rgba(0,0,0,0.16);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

[data-bind="searchResults"] .search-item:active {
  transform: translateY(0px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
}

/* Keyboard focus */
[data-bind="searchResults"] .search-item:focus-visible {
  outline: none;
  border-color: rgba(0,0,0,0.30);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.10);
}

/* Title + meta */
[data-bind="searchResults"] .search-item__title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.1px;
  color: rgba(0,0,0,0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-bind="searchResults"] .search-item__meta {
  font-size: 12px;
  color: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Optional: show a small dot before time */
[data-bind="searchResults"] .search-item__meta::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.25);
  display: inline-block;
}

/* Nice scrollbar (webkit) */
[data-bind="searchResults"] .search-list::-webkit-scrollbar {
  width: 10px;
}
[data-bind="searchResults"] .search-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
[data-bind="searchResults"] .search-list::-webkit-scrollbar-track {
  background: transparent;
}

/* =========================
   Task row highlight (search)
   ========================= */
.is-search-hit {
  position: relative;
  border-radius: 14px;
  animation: searchHitPulse 1200ms ease-out 1;
}

@keyframes searchHitPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,0,0,0.18); transform: scale(1); }
  25%  { box-shadow: 0 0 0 8px rgba(0,0,0,0.10); transform: scale(1.01); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0.0); transform: scale(1); }
}

