/*
 * Telema 2 v2 — App-specific CSS
 * Telema-only overrides and classes not in base.css.
 * base.css provides: CSS variables, .m-dot, .m-badge, .bar-track, .bar-fill,
 *                    .status-dot, .card-edges, .transitioning
 */

/* ===== Overrides on base.css components ===== */

/* bar-fill animation (not in base.css) */
.bar-fill { transition: width 0.3s ease; }

/* status-dot: Telema uses flex gap, no margin needed */
.status-dot { margin-right: 0; }

/* Font custom props referenced in .notes-panel */
:root {
  --f-serif: 'Newsreader', Georgia, serif;
  --f-mono: 'Inter', system-ui, sans-serif; /* unified — no 3rd font */
}

/* Widget fade-in — content appears without "Loading..." text */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.widget-ready { animation: fadeIn 0.15s ease both; }

/* ===== Telema-specific components ===== */

.status-dd { position: absolute; z-index: 30; top: 100%; left: 0; margin-top: 4px; min-width: 140px; }
.task-card:hover { background: var(--c-highlight); }
.screen-tabs { scrollbar-width: none; }
.screen-tabs::-webkit-scrollbar { display: none; }

/* Nav search expand/collapse */
.nav-icon-block { position: relative; }
.nav-icon-block::before {
  content: ''; position: absolute; right: calc(100% + 1px); top: 0; bottom: 0;
  width: 8vw; pointer-events: none;
  background: linear-gradient(to right, transparent, var(--c-page)); z-index: 1;
}
.nav-icon-block .nav-hideable { transition: opacity 0.2s ease, flex 0.25s ease; }

#nav-search-input {
  flex: 0 0 0; width: 0; min-width: 0; opacity: 0;
  padding: 0; border: none; border-bottom: 1px solid transparent;
  background: transparent; color: var(--c-ink); font-size: 0.85rem; outline: none; overflow: hidden;
  transition: flex 0.25s ease, opacity 0.2s ease, border-color 0.25s ease, padding 0.25s ease;
}
#nav-search-input.open { flex: 1 1 auto; opacity: 1; padding: 4px 8px; border-bottom-color: var(--c-subtle); }

/* Watch sidebar */
.watch-sidebar-item:hover { background: var(--c-highlight); }
.watch-sidebar-active { background: var(--c-highlight); border-left: 2px solid var(--c-teal, #0d9488); padding-left: 6px; }

/* Screen tabs */
.screen-tab { transition: border-color 0.15s ease; }
.screen-tab:hover { border-color: var(--c-muted); }
.screen-tab.active { border-color: var(--m-elegance); color: var(--m-elegance); }

/* Drawer */
.drawer-open { transform: translateX(0) !important; }

/* Inline form inputs */
.inline-input {
  background: transparent; border: none; border-bottom: 1px solid var(--c-subtle);
  outline: none; color: var(--c-ink); font-size: 0.8rem; width: 100%; padding: 4px 0;
}
.inline-input:focus { border-bottom-color: var(--m-elegance); }
.inline-input::placeholder { color: var(--c-faint); font-size: 0.75rem; }

/* Task creation advanced fields */
.task-creation-advanced select, .task-creation-advanced input[type="date"] { font-size: 0.7rem; padding: 2px 4px; }

/* VERA small bar */
.vera-bar-sm { height: 4px; border-radius: 2px; }

/* Capacity bar (S/O/E) */
.capacity-bar { height: 6px; border-radius: 3px; display: flex; overflow: hidden; gap: 1px; }

/* Hamburger menu — mobile only */
.hamburger-menu { display: none; }
@media (max-width: 768px) {
  .hamburger-menu { display: block; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--c-card); border-bottom: 1px solid var(--c-subtle);
    padding: 12px 24px; gap: 4px; z-index: 40;
  }
  .nav-links.open a { width: 100%; justify-content: flex-start; gap: 8px; padding: 6px 8px; }
  .nav-links.open .nav-label { display: inline; }
  .screen-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Small badge */
.badge-sm {
  font-size: 0.65rem; padding: 1px 6px; border-radius: 999px;
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em;
}

/* Collapsible triggers */
.collapsible-trigger::after {
  content: '\25B6'; display: inline-block; margin-left: 6px;
  font-size: 0.6rem; transition: transform 0.15s;
}
.collapsible-trigger.open::after { transform: rotate(90deg); }

/* Tree indent */
.tree-indent { padding-left: 20px; }

/* Unified screen grid — tasks, goals, metrics all snap to same column track.
   max(280px, 33.4% - 8px) caps at 3 columns: the 33.4% floor prevents a 4th
   from fitting, while 280px sets the min before wrapping down to 2 or 1. */
.screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(280px, calc(33% - 8px)), 1fr));
  gap: 12px;
}

/* Goal card hover */
.goal-card { transition: outline-color 0.15s ease; }
.goal-card:hover { outline: 1px solid var(--c-muted); outline-offset: -1px; }

/* Avatar circle */
.avatar-circle {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 600; flex-shrink: 0;
}

/* Task card states */
.task-card.expanded { background: var(--c-highlight); }
.task-card.expanded .task-title { overflow: visible; text-overflow: unset; white-space: normal; word-break: break-word; }
.task-card[draggable="true"] { cursor: grab; }
.task-card[draggable="true"]:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.4; }

/* Task column drag state */
.task-col.drag-over { outline: 2px dashed var(--m-elegance); outline-offset: -2px; }

/* Task list scrollable area */
.task-list {
  max-height: calc(42vh - 40px); overflow-y: auto; position: relative;
  scrollbar-width: thin; scrollbar-color: var(--c-subtle) transparent;
}
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-thumb { background: var(--c-subtle); border-radius: 2px; }

/* Task column overflow fade */
.task-col { position: relative; }
.task-col::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 28px;
  background: linear-gradient(transparent, var(--c-card));
  pointer-events: none; border-radius: 0 0 5px 5px; opacity: 0; transition: opacity 0.15s;
}
.task-col.has-overflow::after { opacity: 1; }
.task-col-pool::after { background: linear-gradient(transparent, color-mix(in srgb, var(--c-card) 92%, var(--c-subtle))); }

/* Animations */
.task-creation-advanced { animation: slideDown 0.15s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes metricPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.2; transform: scale(0.97); }
}
.metric-loading { animation: metricPulse 1.6s ease-in-out infinite; pointer-events: none; }

/* Notes panel markdown styling */
.notes-panel a { color: var(--m-elegance); text-decoration: underline; }
.notes-panel h1 { font-family: var(--f-serif); font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.25rem; }
.notes-panel h2 { font-family: var(--f-serif); font-size: 0.9rem; font-weight: 600; margin: 0.6rem 0 0.25rem; }
.notes-panel h3 { font-size: 0.85rem; font-weight: 600; margin: 0.5rem 0 0.2rem; }
.notes-panel h4 { font-size: 0.8rem; font-weight: 500; margin: 0.4rem 0 0.2rem; color: var(--c-muted); }
.notes-panel p { margin: 0.3rem 0; }
.notes-panel ul { list-style: disc; padding-left: 1.2rem; margin: 0.25rem 0; }
.notes-panel ol { list-style: decimal; padding-left: 1.2rem; margin: 0.25rem 0; }
.notes-panel li { margin: 0.15rem 0; }
.notes-panel li > ul, .notes-panel li > ol { margin: 0.1rem 0; }
.notes-panel code { background: var(--c-subtle); padding: 1px 4px; border-radius: 3px; font-size: 0.75rem; }
.notes-panel pre { background: var(--c-subtle); border-radius: 6px; padding: 8px 10px; margin: 0.4rem 0; overflow-x: auto; }
.notes-panel pre code { background: none; padding: 0; font-size: 0.75rem; }
.notes-panel blockquote { border-left: 2px solid var(--m-elegance); padding-left: 10px; margin: 0.4rem 0; color: var(--c-muted); font-style: italic; }
.notes-panel table { width: 100%; border-collapse: collapse; margin: 0.4rem 0; font-size: 0.8rem; }
.notes-panel th, .notes-panel td { border: 1px solid var(--c-subtle); padding: 3px 6px; text-align: left; }
.notes-panel th { background: var(--c-subtle); font-weight: 600; }
.notes-panel hr { border: none; border-top: 1px solid var(--c-subtle); margin: 0.5rem 0; }
.notes-panel img { max-width: 100%; border-radius: 4px; }
.notes-panel input[type="checkbox"] { margin-right: 4px; }

/* ===== Universal Search ===== */
.search-results-container {
  position: absolute;
  top: 100%;
  right: 0;
  width: 420px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  z-index: 60;
  transition: max-height 0.2s ease, opacity 0.15s ease;
  pointer-events: none;
}
.search-results-container.open {
  max-height: 480px;
  opacity: 1;
  pointer-events: auto;
  overflow-y: auto;
}
.search-dropdown {
  background: var(--c-card);
  border: 1px solid var(--c-subtle);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px 0;
}
.search-group { padding: 2px 0; }
.search-group + .search-group { border-top: 1px solid var(--c-subtle); }
.search-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-faint);
}
.search-group-icon { display: flex; align-items: center; }
.search-group-count {
  margin-left: auto;
  background: var(--c-subtle);
  border-radius: 8px;
  padding: 0 5px;
  font-size: 9px;
}
.search-item {
  display: block;
  padding: 7px 14px 7px 32px;
  text-decoration: none;
  color: var(--c-ink);
  transition: background 0.1s;
  cursor: pointer;
}
.search-item:hover, .search-item-active {
  background: color-mix(in srgb, var(--m-awareness) 18%, var(--c-card));
}
.search-item-active {
  background: color-mix(in srgb, var(--m-awareness) 25%, var(--c-card));
  box-shadow: inset 3px 0 0 var(--m-awareness);
}
.search-item-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-sub {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--c-faint);
}
.search-highlight {
  background: rgba(212, 184, 106, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.page-highlight {
  background: rgba(212, 184, 106, 0.4);
  color: inherit;
  border-radius: 2px;
  padding: 1px 2px;
  animation: highlightPulse 1.5s ease-in-out 2;
}
@keyframes highlightPulse {
  0%, 100% { background: rgba(212, 184, 106, 0.4); }
  50% { background: rgba(212, 184, 106, 0.7); }
}
/* Mobile: full-width dropdown */
@media (max-width: 768px) {
  .search-results-container { width: 100vw; right: -16px; }
}

/* Screen tabs */
.screen-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--c-muted);
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.screen-tab:hover { color: var(--c-ink); }
.screen-tab.active {
  color: var(--c-ink);
  font-weight: 500;
  border-bottom-color: var(--c-teal, #0d9488);
}

/* Mobile responsive — 375px+ */
@media (max-width: 768px) {
  .screen-grid { grid-template-columns: 1fr; }
  .drawer { width: 100% !important; max-width: 100% !important; }
  .task-creation-advanced select,
  .task-creation-advanced input[type="date"] { width: 100%; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .task-list { max-height: none; }
  #app { padding: 0.5rem; }
  .capacity-bar { height: 8px; }
}
