/*
 * IWonnaP — Pages
 * Page-specific styles in priority order (most-used first).
 * Replaces: calendar.css, dashboard.css, statistics.css, quick_marks.css,
 *           edit.css, projects.css, psych_tests.css, vault.css,
 *           wishlist.css, login.css, pagination.css
 */

/* ═══════════════════════════════════════════════════════
   CALENDAR
   ══════════════════════════════════════════════════════ */

.calendar-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
}

.date-navigate {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
}
.date-navigate a {
  align-items: center;
  border-radius: var(--r-sm);
  color: var(--text);
  display: inline-flex;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  text-decoration: none;
  transition: background var(--t-fast);
}
.date-navigate a:hover { background: var(--surface-soft); }
.date-navigate a:nth-child(2) { font-size: var(--text-md); font-weight: 600; }

.day-summary {
  color: var(--muted);
  display: grid;
  font-size: var(--text-sm);
  gap: var(--sp-2);
}
.day-summary p { margin: 0; }

.weekdays {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.weekday {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 5px 2px;
  text-align: center;
  text-transform: uppercase;
}

.calendar-main { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.calendar-grid {
  display: grid;
  gap: 4px;
  grid-auto-rows: minmax(90px, auto);
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  min-height: 90px;
  overflow-wrap: anywhere;
  padding: 7px 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.day:hover { background: color-mix(in srgb, var(--surface-soft) 86%, var(--accent) 14%); }
.day.today {
  border: 2px solid var(--success);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 18%, transparent);
}
.day.selected {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}
.day.selected .calendar-day-metric,
.day.selected .calendar-day-number { color: #fff; }
.day.selected.today { outline: 3px solid var(--success); outline-offset: 2px; }
.empty-day { background: transparent; min-height: 90px; }

.calendar-day-number {
  align-items: center;
  border-radius: var(--r-sm);
  display: inline-flex;
  font-size: var(--text-sm);
  font-weight: 700;
  justify-content: center;
  margin-bottom: 3px;
  min-height: 24px;
  min-width: 24px;
}
.calendar-day-metric {
  color: inherit;
  font-size: var(--text-xs);
  line-height: 1.3;
  opacity: .85;
}

.emoji-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}
.emoji-icon {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.2rem;
  gap: 5px;
  min-height: 40px;
  padding: 6px var(--sp-2);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.emoji-icon:hover { background: var(--accent-muted); border-color: var(--accent); }
.emoji-icon.started {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  border-color: var(--success);
}

.info-day {
  display: grid;
  gap: var(--sp-3);
  /* Was: repeat(3, minmax(0, 1fr)) — forced 3-in-row, overflowed at narrow widths.
     auto-fit + minmax keeps 3 columns when there's room, drops to 2 or 1 automatically. */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  min-width: 0;
}
.task-list-calendar,
.event-list-calendar,
.mindstate-list-calendar,
.task-log-calendar,
.event-log-calendar,
.mindstate-log-calendar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
  overflow-wrap: anywhere;
  padding: var(--sp-3);
}
.task-list-calendar > *,
.event-list-calendar > *,
.mindstate-list-calendar > *,
.task-log-calendar > *,
.event-log-calendar > *,
.mindstate-log-calendar > * {
  min-width: 0;
}

/* Day event timeline */
.day-event-timeline {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}
.timeline-header {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr);
}
.timeline-header h3 { margin: 0; }
.timeline-header p { color: var(--muted); font-size: var(--text-sm); margin: 3px 0 0; }
.timeline-summary { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }
.timeline-summary span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  padding: 5px var(--sp-2);
}
.timeline-scale {
  color: var(--muted);
  display: grid;
  font-size: var(--text-xs);
  grid-template-columns: repeat(5, 1fr);
}
.timeline-scale span { border-left: 1px solid var(--line); padding-left: 5px; }
.timeline-track {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-2);
}
.timeline-segment {
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: 80px minmax(0, 1fr);
  min-height: 40px;
  padding: 7px var(--sp-2) 7px 14px;
  position: relative;
}
.timeline-segment::before {
  border-radius: var(--r-full);
  bottom: 7px;
  content: "";
  left: 5px;
  position: absolute;
  top: 7px;
  width: 4px;
}
.timeline-segment-gap {
  background: color-mix(in srgb, var(--surface) 72%, var(--line) 28%);
  border-style: dashed;
  min-height: 28px;
  opacity: .75;
}
.timeline-segment-gap::before { background: var(--line); }
.timeline-segment-event {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.timeline-segment-event::before { background: var(--accent); }
.timeline-segment-active {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 55%, var(--line));
}
.timeline-segment-active::before { background: var(--success); }
.timeline-segment-marker {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 55%, var(--line));
}
.timeline-segment-marker::before { background: var(--warning); }
.timeline-time { color: var(--muted); font-size: var(--text-xs); font-weight: 700; }
.timeline-body { display: grid; gap: 2px; min-width: 0; }
.timeline-body strong,
.timeline-body span { overflow-wrap: anywhere; }
.timeline-comment { color: var(--muted); font-size: var(--text-sm); }
.timeline-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }

/* ═══════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════ */

.dashboard {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
  width: 100%;
}
.dashboard-header { grid-column: 1 / -1; }
.dashboard-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 var(--sp-2); }

.dashboard-card {
  max-height: 360px;
  overflow: auto;
}
.dashboard-card h2 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--sp-2);
}
.dashboard-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: 7px 0;
}
.dashboard-row:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════════════════
   STATISTICS
   Chart.js mobile fix — explicit canvas height.
   IMPORTANT: also set maintainAspectRatio: false in
   statistics.js for this to take full effect.
   ══════════════════════════════════════════════════════ */

.statistics { display: grid; gap: var(--sp-4); padding: 0; }
.statistics-header {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}
.statistics-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 3px; }
.statistics-header p  { color: var(--muted); font-size: var(--text-sm); margin: 0; }

.statistics-period { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.statistics-period a {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--text-sm);
  padding: 7px var(--sp-3);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.statistics-period a:hover { background: var(--surface-soft); }
.statistics-period a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.statistics-cards {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat-card h2 { color: var(--muted); font-size: var(--text-sm); font-weight: 500; margin: 0 0 var(--sp-2); }
.stat-big { font-size: 2rem; font-weight: 700; line-height: 1; margin: 0; }

.statistics-charts {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
.chart-wrapper { display: flex; flex-direction: column; }
.chart-wrapper h2 { font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--sp-3); }
.chart-wrapper canvas {
  flex: 1;
  height: 260px !important;
  max-height: 320px;
  min-height: 220px;
  width: 100% !important;
}

/* ═══════════════════════════════════════════════════════
   QUICK MARKS
   Font-scale metaphor preserved.
   ══════════════════════════════════════════════════════ */

.quick-marks { padding: var(--sp-4); width: 100%; }
.quick-marks-header { margin-bottom: var(--sp-4); }
.quick-marks-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 4px; }
.quick-marks-header p  { color: var(--muted); font-size: var(--text-sm); margin: 0; }

.quick-marks-cloud { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.quick-mark-bubble {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: inline-flex;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 8px var(--sp-3);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.quick-mark-bubble small { color: var(--muted); font-size: .75em; }
.quick-mark-bubble:hover { background: var(--accent-muted); border-color: var(--accent); color: var(--text); }
.quick-mark-event { border-left: 3px solid var(--accent); }
.quick-mark-state { border-left: 3px solid var(--success); }
.quick-mark-task  { border-left: 3px solid var(--warning); }

/* ═══════════════════════════════════════════════════════
   PROJECTS
   ══════════════════════════════════════════════════════ */

.projects-page { display: grid; gap: var(--sp-4); padding: 0; }
.project-card { display: grid; gap: var(--sp-2); }
.project-summary { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.project-actions { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.project-badge {
  background: var(--accent-muted);
  border-radius: var(--r-sm);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
}

/* ═══════════════════════════════════════════════════════
   VAULT
   ══════════════════════════════════════════════════════ */

.vault-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.vault-password {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-3);
  word-break: break-all;
}
.vault-reveal-countdown { color: var(--muted); font-size: var(--text-xs); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════
   WISHLIST
   ══════════════════════════════════════════════════════ */

.wishlist-card, .wishlist-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.wishlist-form { display: grid; gap: var(--sp-3); }
.wishlist-item-priority-1 { border-left: 3px solid var(--muted); }
.wishlist-item-priority-2 { border-left: 3px solid var(--warning); }
.wishlist-item-priority-3 { border-left: 3px solid var(--danger); }
.wishlist-public { margin: var(--sp-5) auto; max-width: 640px; padding: 0 var(--sp-4); }
.wishlist-public h1 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--sp-4); }

/* ═══════════════════════════════════════════════════════
   PSYCH TESTS
   ══════════════════════════════════════════════════════ */

.psych-test-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.psych-question {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}
.psych-scale { align-items: center; display: flex; gap: var(--sp-2); }
.psych-scale input[type="range"] { accent-color: var(--accent); flex: 1; min-height: 40px; }

/* ═══════════════════════════════════════════════════════
   FAMILY TREE — minimal nav only, leave D3 alone
   ══════════════════════════════════════════════════════ */

.family-container,
.family-tree-view,
.family-tree-settings { display: grid; gap: var(--sp-3); padding: 0; }
.family-tree-view svg { max-width: 100%; overflow: visible; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE PAGES
   ══════════════════════════════════════════════════════ */

@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }
  .info-day   { grid-template-columns: 1fr; }

  .calendar-grid {
    gap: 3px;
    grid-auto-rows: minmax(72px, auto);
  }
  .day {
    font-size: var(--text-xs);
    min-height: 72px;
    padding: 5px 4px;
  }
  .calendar-day-number { font-size: var(--text-xs); min-height: 22px; min-width: 22px; }
  .calendar-day-metric { font-size: 0.68rem; }

  .date-navigate > * { flex: 1 1 100%; text-align: center; }

  .statistics-charts { grid-template-columns: 1fr; }
  .chart-wrapper canvas { height: 220px !important; }

  .timeline-header { grid-template-columns: 1fr; }
  .timeline-summary { justify-content: stretch; }
  .timeline-summary span { flex: 1 1 130px; }
  .timeline-segment { grid-template-columns: 1fr; min-height: 36px; padding: 7px 8px 7px 14px; }

  .dashboard-row,
  .project-summary,
  .project-actions { align-items: stretch; flex-direction: column; }
  .dashboard-row .action-btn,
  .project-actions .action-btn,
  .project-actions form,
  .project-actions button { width: 100%; }
}

@media (max-width: 480px) {
  .calendar-grid { grid-auto-rows: minmax(60px, auto); }
  .day { min-height: 60px; }
  .statistics-period a { flex: 1 1 auto; text-align: center; }
}
