/* ============================================================
   Astra Origins — Space Hub · Cosmos History calendar (new design)
   Themes the new-design cosmos modals (#sh* ids / .sh-cosmos-*).
   Loaded eagerly + small; FullCalendar's own JS/CSS stay lazy.
   ============================================================ */

/* ── Typography (design font everywhere; keep icon fonts) ─────
   ID-based selectors (specificity 1,0,0) so they out-specify
   FullCalendar's `.fc .fc-button` (0,2,0) and Bootstrap modal rules.
   Lives in the head (not inline in the pane) so it survives jQuery
   pane swaps that can drop inline <style> tags. --------------------- */
#shCalendarModal, #shCalendarModal *:not(.bi):not([class*='fc-icon']),
#shDayModal,      #shDayModal      *:not(.bi):not([class*='fc-icon']),
#shViewModal,     #shViewModal     *:not(.bi):not([class*='fc-icon']),
#shSuggestModal,  #shSuggestModal  *:not(.bi):not([class*='fc-icon']),
.sh-cosmos-modal, .sh-cosmos-modal * {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
}
#shCalendarModal .mono, #shDayModal .mono, #shViewModal .mono, #shSuggestModal .mono,
.sh-cosmos-modal .mono,
#shCalendar .fc-col-header-cell-cushion {
  font-family: var(--mono, 'IBM Plex Mono', monospace) !important;
}
#shCalendarModal .bi, #shCalendarModal .bi::before,
#shDayModal .bi, #shDayModal .bi::before,
#shViewModal .bi, #shViewModal .bi::before,
#shSuggestModal .bi, #shSuggestModal .bi::before,
.sh-cosmos-modal .bi,
.sh-cosmos-modal .bi::before { font-family: 'bootstrap-icons' !important; }
#shCalendar .fc-icon,
#shCalendar [class*='fc-icon']::before { font-family: 'fcicons' !important; }

/* ── Modal shell ──────────────────────────────────────────── */
.sh-cosmos-modal .modal-content {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 80px oklch(0 0 0 / 0.4);
}
.sh-cosmos-modal .modal-header,
.sh-cosmos-modal .modal-footer { border-color: var(--line); }
.sh-cosmos-modal .modal-title {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
  font-weight: 800; letter-spacing: -0.01em; color: var(--ink);
  display: inline-flex; align-items: center; gap: 8px; font-size: 16px;
}
.sh-cosmos-modal .modal-title .bi { color: var(--accent); }
.sh-cosmos-modal .btn-close { filter: none; opacity: 0.6; }
.sh-cosmos-modal .btn-close:hover { opacity: 1; }

.sh-cosmos-muted { color: var(--ink-3); font-size: 13px; margin: 0 0 14px; }
.sh-cosmos-empty {
  padding: 18px; border-radius: 10px; text-align: center;
  background: var(--surface-2); color: var(--ink-2); font-size: 13px;
}
.sh-cosmos-error {
  padding: 14px; border-radius: 10px; font-size: 13px;
  background: oklch(0.6 0.2 25 / 0.1); color: oklch(0.5 0.2 25);
  border: 1px solid oklch(0.6 0.2 25 / 0.3);
}

/* Custom scrollbar */
.sh-cosmos-modal .modal-body { scrollbar-width: thin; scrollbar-color: var(--accent-line) transparent; }
.sh-cosmos-modal .modal-body::-webkit-scrollbar { width: 10px; }
.sh-cosmos-modal .modal-body::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.sh-cosmos-modal .modal-body::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px;
  border: 3px solid var(--surface); background-clip: padding-box;
}
.sh-cosmos-modal .modal-body::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* ── Calendar jump bar ────────────────────────────────────── */
.sh-cosmos-jump { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.sh-cosmos-jump-label { font-size: 9px; font-weight: 800; letter-spacing: 0.14em; color: var(--ink-3); }
.sh-cosmos-select {
  padding: 6px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink); font-size: 12px; font-weight: 600; outline: none;
}
.sh-cosmos-select:focus { border-color: var(--accent-line); }

/* ── FullCalendar theming ─────────────────────────────────── */
#shCalendar {
  font-family: var(--font, 'Manrope', system-ui, sans-serif);
  --fc-border-color: var(--line);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--surface-2);
  --fc-today-bg-color: var(--accent-soft);
}
#shCalendar .fc { color: var(--ink); }
/* Force the design font on every FullCalendar node (buttons, title, cells).
   FullCalendar buttons use font-family:inherit, but pin it explicitly so a
   late-loaded fullcalendar.min.css can never win the cascade. */
#shCalendar .fc,
#shCalendar .fc *:not(.fc-icon):not([class*='fc-icon']) {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
}
#shCalendar .fc-toolbar-title {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
  font-weight: 800; letter-spacing: -0.01em; color: var(--ink); font-size: 1.1rem;
}
#shCalendar .fc-col-header-cell-cushion {
  color: var(--ink-3); text-decoration: none; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; padding: 6px 4px;
}
#shCalendar .fc-daygrid-day-number { color: var(--ink-2); text-decoration: none; font-size: 12px; }
#shCalendar .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 800; }
#shCalendar .fc-daygrid-day-frame { min-height: 92px; cursor: pointer; }

#shCalendar .fc-button,
#shCalendar .fc-button-primary {
  background: var(--surface-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink-2) !important;
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
  font-weight: 700; text-transform: capitalize; box-shadow: none !important; border-radius: 8px;
}
#shCalendar .fc-button:hover { background: var(--surface-3) !important; color: var(--ink) !important; }
#shCalendar .fc-button-primary:not(:disabled).fc-button-active,
#shCalendar .fc-button-primary:not(:disabled):active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
#shCalendar .fc-button-primary:disabled { opacity: 0.5; }

/* Suggest button → matches the new-design .ih-add-btn.mono (accent-filled,
   mono, uppercase) instead of FullCalendar's default ghost button. */
#shCalendar .fc-shSuggest-button.fc-button,
#shCalendar .fc-shSuggest-button.fc-button-primary {
  background: var(--accent) !important;
  border: none !important;
  color: #fff !important;
  font-family: var(--mono, 'IBM Plex Mono', monospace) !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  padding: 7px 12px !important;
  border-radius: 7px !important;
  box-shadow: none !important;
}
#shCalendar .fc-shSuggest-button.fc-button:hover,
#shCalendar .fc-shSuggest-button.fc-button-primary:not(:disabled):active,
#shCalendar .fc-shSuggest-button.fc-button-primary:not(:disabled).fc-button-active {
  background: color-mix(in oklch, var(--accent) 88%, black) !important;
  color: #fff !important;
}

/* Prev / next arrows: individual rounded buttons with a clear gap between. */
#shCalendar .fc-prev-button.fc-button { margin-right: 8px !important; }
#shCalendar .fc-prev-button.fc-button,
#shCalendar .fc-next-button.fc-button {
  border-radius: 8px !important;
  width: 38px; padding-left: 0 !important; padding-right: 0 !important;
}

#shCalendar .fc-daygrid-event { background: transparent; border: 0; margin: 0 2px 1px; }
#shCalendar .fc-daygrid-event .fc-event-main,
#shCalendar .fc-daygrid-event a { color: var(--ink) !important; text-decoration: none; }
#shCalendar .fc-daygrid-event .fc-event-title {
  color: var(--ink) !important; white-space: normal; padding: 1px 4px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
}
#shCalendar .fc-daygrid-event .fc-event-title::before { content: '• '; color: var(--accent); }
#shCalendar .fc-daygrid-event:hover .fc-event-title { background: var(--accent-soft); color: var(--accent) !important; }
#shCalendar .cosmos-history-reminder .fc-event-title { color: oklch(0.6 0.17 60) !important; font-style: italic; }
#shCalendar .cosmos-history-reminder .fc-event-title::before { content: '↺ '; color: oklch(0.6 0.17 60); }

/* ── Day list ─────────────────────────────────────────────── */
.sh-cosmos-day-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sh-cosmos-day-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  cursor: pointer;
}
.sh-cosmos-day-item:hover { background: var(--surface-3); }
.sh-cosmos-day-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; }
.sh-cosmos-day-thumb--ph {
  display: grid; place-items: center; color: #fff; font-size: 22px;
  background: linear-gradient(135deg, oklch(0.15 0.05 270), oklch(0.08 0.02 250));
}
.sh-cosmos-day-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sh-cosmos-day-title { font-size: 13px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sh-cosmos-day-desc { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.sh-cosmos-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em; padding: 2px 7px; border-radius: 999px;
  background: oklch(0.62 0.17 60 / 0.15); color: oklch(0.5 0.17 60);
}
.sh-cosmos-day-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ── Buttons ──────────────────────────────────────────────── */
.sh-cosmos-btn-ghost {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.sh-cosmos-btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.sh-cosmos-btn-primary {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 9px;
  background: var(--accent); color: #fff; border: none; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; cursor: pointer;
}
.sh-cosmos-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════════
   History view modal · rebuilt for the new design (.shv-* )
   Self-contained, design-token themed, font pinned explicitly.
   ════════════════════════════════════════════════════════════ */
.shv-body { font-family: var(--font, 'Manrope', system-ui, sans-serif) !important; }
.shv-modal-title { display: inline-flex; align-items: center; gap: 8px; }
.shv-modal-title .bi { color: var(--accent); font-size: 17px; }

/* Reminder banner */
.shv-reminder {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px; border-radius: 10px; font-size: 12px; font-weight: 600; margin-bottom: 16px;
  background: oklch(0.62 0.17 60 / 0.12); color: oklch(0.45 0.17 60); border: 1px solid oklch(0.62 0.17 60 / 0.3);
}

/* Image */
.shv-figure { margin: 0 0 18px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.shv-img { display: block; width: 100%; max-height: 380px; object-fit: cover; }

/* Title + description */
.shv-title {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
  font-size: 22px; font-weight: 800; letter-spacing: -0.015em; line-height: 1.25;
  margin: 0 0 12px; color: var(--ink);
}
.shv-desc {
  font-family: var(--font, 'Manrope', system-ui, sans-serif) !important;
  font-size: 14px; line-height: 1.75; color: var(--ink-2); white-space: pre-wrap;
}

/* Error state */
.shv-error {
  display: flex; align-items: center; gap: 8px;
  padding: 14px; border-radius: 10px; font-size: 13px;
  background: oklch(0.6 0.2 25 / 0.1); color: oklch(0.5 0.2 25); border: 1px solid oklch(0.6 0.2 25 / 0.3);
}
.shv-error .bi { font-size: 16px; }

/* Skeleton */
.shv-skel-img { height: 220px; border-radius: 14px; background: var(--surface-2); margin-bottom: 16px; position: relative; overflow: hidden; }
.shv-skel-line { height: 14px; border-radius: 7px; background: var(--surface-2); margin-bottom: 11px; position: relative; overflow: hidden; }
.shv-skel-img::after, .shv-skel-line::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, oklch(1 0 0 / 0.7), transparent);
  animation: shv-shimmer 1.4s ease-in-out infinite;
}
@keyframes shv-shimmer { 100% { transform: translateX(100%); } }

/* ── Suggestion form ──────────────────────────────────────── */
.sh-cosmos-field { margin-bottom: 14px; }
.sh-cosmos-label { display: block; font-size: 9px; font-weight: 800; letter-spacing: 0.12em; color: var(--ink-3); margin-bottom: 6px; }
.sh-cosmos-opt { color: var(--ink-3); font-weight: 600; letter-spacing: 0; }
.sh-cosmos-input {
  width: 100%; padding: 9px 12px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 13px; outline: none;
}
.sh-cosmos-input:focus { border-color: var(--accent-line); }
.sh-cosmos-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.sh-cosmos-drop { display: block; position: relative; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; overflow: hidden; }
.sh-cosmos-drop:hover { border-color: var(--accent-line); background: var(--surface-3); }
.sh-cosmos-drop-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px; color: var(--ink-3); font-size: 12px; }
.sh-cosmos-drop-empty .bi { font-size: 26px; }
.sh-cosmos-preview { position: relative; }
.sh-cosmos-preview img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.sh-cosmos-preview-clear {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: none; border-radius: 50%;
  background: oklch(0 0 0 / 0.6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.sh-cosmos-hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.sh-cosmos-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.sh-cosmos-modal .alert { border-radius: 9px; font-size: 13px; }

/* ── Opening / loading overlay ────────────────────────────── */
.sh-cosmos-loader {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: oklch(0 0 0 / 0.55); backdrop-filter: blur(5px);
  animation: sh-cosmos-fade 0.2s ease;
}
@keyframes sh-cosmos-fade { from { opacity: 0; } to { opacity: 1; } }
.sh-cosmos-loader-orb { position: relative; width: 58px; height: 58px; }
.sh-cosmos-loader-orb span { position: absolute; border-radius: 50%; border: 2px solid transparent; animation: sh-cosmos-spin 1s linear infinite; }
.sh-cosmos-loader-orb span:nth-child(1) { inset: 0; border-top-color: var(--accent, #7c5cff); }
.sh-cosmos-loader-orb span:nth-child(2) { inset: 9px; border-top-color: #fff; animation-duration: 1.4s; }
.sh-cosmos-loader-orb span:nth-child(3) { inset: 18px; border-top-color: var(--accent, #7c5cff); animation-duration: 1.9s; }
.sh-cosmos-loader-text { color: #fff; font-size: 11px; letter-spacing: 0.2em; font-weight: 700; font-family: var(--mono, 'IBM Plex Mono', monospace); }
@keyframes sh-cosmos-spin { to { transform: rotate(360deg); } }
