/* =====================================================================
   Custom Rewards + generic collapsible cards
   Theme tokens come from styles.css (:root / prefers-color-scheme).
   ===================================================================== */

/* ---- Generic collapsible cards (feature #10) ------------------------ */

.cc-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.375rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.15s ease, background 0.15s ease;
  flex: 0 0 auto;
}
.cc-toggle:hover {
  color: var(--color-mint, #10b981);
  background: color-mix(in srgb, var(--color-mint, #10b981) 12%, transparent);
}
.cc-toggle svg {
  width: 0.85rem;
  height: 0.85rem;
}
/* Chevron points down when expanded, right when collapsed. */
.cc-collapsed .cc-toggle {
  transform: rotate(-90deg);
}
/* Collapsed: keep only the header child (the one containing the card heading). */
.cc-collapsed > *:not([data-cc-header]) {
  display: none !important;
}
.cc-collapsed[data-cr-collapsible] { /* reserved hook, no-op */ }

/* ---- Custom Rewards dashboard card --------------------------------- */

.cr-empty {
  font-size: 10px;
  text-align: center;
  padding: 0.75rem 0;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, monospace);
}

.cr-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cr-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--border-grey) 60%, transparent);
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--card-bg) 60%, transparent);
}
.cr-item-main { min-width: 0; flex: 1 1 auto; }
.cr-item-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-item-sub {
  margin-top: 0.1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cr-chip {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 0.35rem;
  white-space: nowrap;
}
.cr-chip-grace { color: var(--color-mint, #10b981); background: color-mix(in srgb, var(--color-mint, #10b981) 14%, transparent); }
.cr-chip-pool  { color: var(--color-amber-custom, #f59e0b); background: color-mix(in srgb, var(--color-amber-custom, #f59e0b) 14%, transparent); }
.cr-chip-cyc   { color: #38bdf8; background: rgba(56, 189, 248, 0.14); }
.cr-chip-shard { color: #a78bfa; background: rgba(167, 139, 250, 0.16); }
.cr-chip-wheel { color: #fbbf24; background: rgba(251, 191, 36, 0.16); }
.cr-cadence {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cr-claim-btn {
  flex: 0 0 auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  cursor: pointer;
  color: #052e16;
  background: var(--color-mint, #10b981);
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.cr-claim-btn:hover { filter: brightness(1.08); }
.cr-claim-btn:active { transform: translateY(1px); }
.cr-claim-btn.cr-spin { background: linear-gradient(90deg, #f59e0b, #fbbf24); color: #3b2600; }
.cr-claim-btn[disabled] {
  cursor: default;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border-grey) 50%, transparent);
  filter: none;
}
.cr-done {
  flex: 0 0 auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
}
.cr-done-ok { color: var(--color-mint, #10b981); }

/* ---- Settings manager ---------------------------------------------- */

.cr-set-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.cr-set-list { display: flex; flex-direction: column; gap: 0.4rem; }
.cr-set-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--border-grey) 50%, transparent);
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--input-bg) 70%, transparent);
}
.cr-set-row-main { flex: 1 1 auto; min-width: 0; }
.cr-set-row-name { font-size: 11px; font-weight: 700; color: var(--text-main); }
.cr-icon-btn {
  flex: 0 0 auto;
  width: 1.6rem; height: 1.6rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.4rem;
  border: 1px solid color-mix(in srgb, var(--border-grey) 60%, transparent);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cr-icon-btn:hover { color: var(--text-main); border-color: var(--color-mint, #10b981); }
.cr-icon-btn.cr-danger:hover { color: var(--color-crimson, #ef4444); border-color: var(--color-crimson, #ef4444); }

.cr-form { display: flex; flex-direction: column; gap: 0.5rem; }
.cr-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.cr-field { display: flex; flex-direction: column; gap: 0.25rem; }
.cr-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; color: var(--text-muted); font-family: var(--font-mono, ui-monospace, monospace);
}
.cr-input, .cr-select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-grey);
  border-radius: 0.5rem;
  padding: 0.4rem 0.55rem;
  font-size: 12px;
  color: var(--text-main);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.cr-input:focus, .cr-select:focus { outline: none; border-color: var(--color-mint, #10b981); }
.cr-primary-btn {
  width: 100%;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: var(--color-mint, #10b981);
  color: #052e16;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.cr-primary-btn:hover { filter: brightness(1.08); }
.cr-ghost-btn {
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid color-mix(in srgb, var(--border-grey) 60%, transparent);
  font-size: 10px; font-weight: 700; text-transform: uppercase; cursor: pointer;
}
.cr-ghost-btn:hover { color: var(--text-main); }

/* wheel segment editor */
.cr-wheel-editor { display: flex; flex-direction: column; gap: 0.35rem; }
.cr-seg-row { display: grid; grid-template-columns: 1.1fr 0.9fr 1fr auto; gap: 0.35rem; align-items: center; }
.cr-hidden { display: none !important; }

/* ---- Reward Wheel overlay ------------------------------------------ */

.cr-wheel-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: var(--dialog-backdrop, rgba(7, 8, 10, 0.85));
  backdrop-filter: blur(4px);
  animation: cr-fade-in 0.2s ease;
}
@keyframes cr-fade-in { from { opacity: 0; } to { opacity: 1; } }

.cr-wheel-title {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.cr-wheel-stage { position: relative; width: min(78vw, 320px); height: min(78vw, 320px); }
.cr-wheel-pointer {
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 20px solid var(--color-mint, #10b981);
  filter: drop-shadow(0 0 4px var(--color-mint, #10b981));
  z-index: 2;
}
.cr-wheel-svg {
  width: 100%; height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text-muted) 40%, transparent), 0 12px 40px rgba(0,0,0,0.5);
  transition: transform 4s cubic-bezier(0.18, 0.72, 0.12, 1);
}
.cr-wheel-result {
  min-height: 1.5rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 15px;
  font-weight: 800;
  color: var(--color-mint, #10b981);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cr-wheel-result.cr-show { opacity: 1; }
.cr-wheel-dismiss {
  padding: 0.5rem 1.1rem;
  border-radius: 0.6rem;
  background: var(--color-mint, #10b981);
  color: #052e16;
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.cr-wheel-dismiss.cr-show { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  .cr-wheel-svg { transition: none; }
  .cr-wheel-overlay { animation: none; }
}

/* =====================================================================
   Journal
   ===================================================================== */

.journal-compose { margin-bottom: 0.9rem; }
.journal-textarea {
  width: 100%;
  resize: vertical;
  min-height: 3.2rem;
  background: var(--input-bg);
  border: 1px solid var(--border-grey);
  border-radius: 0.6rem;
  padding: 0.55rem 0.65rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  font-family: inherit;
}
.journal-textarea:focus { outline: none; border-color: var(--color-mint, #10b981); }
.journal-compose-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.journal-tag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
}
.journal-date-input {
  background: var(--input-bg);
  border: 1px solid var(--border-grey);
  border-radius: 0.45rem;
  padding: 0.25rem 0.45rem;
  font-size: 11px;
  color: var(--text-main);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.journal-date-input:focus { outline: none; border-color: var(--color-mint, #10b981); }
.journal-compose-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; }
.journal-save-btn {
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  background: var(--color-mint, #10b981);
  color: #052e16;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.journal-save-btn:hover { filter: brightness(1.08); }
.journal-ghost-btn {
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid color-mix(in srgb, var(--border-grey) 60%, transparent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}
.journal-ghost-btn:hover { color: var(--text-main); }

.journal-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  text-align: center;
  padding: 0.6rem 0;
}
.journal-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 420px; overflow-y: auto; }
.journal-entry {
  border: 1px solid color-mix(in srgb, var(--border-grey) 55%, transparent);
  border-radius: 0.6rem;
  padding: 0.55rem 0.65rem;
  background: color-mix(in srgb, var(--card-bg) 55%, transparent);
}
.journal-entry-head { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.3rem; }
.journal-date-badge {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-mint, #10b981);
  background: color-mix(in srgb, var(--color-mint, #10b981) 14%, transparent);
  padding: 0.12rem 0.4rem;
  border-radius: 0.35rem;
}
.journal-general-badge {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border-grey) 40%, transparent);
  padding: 0.12rem 0.4rem;
  border-radius: 0.35rem;
}
.journal-entry-time {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9px;
  color: var(--text-muted);
}
.journal-entry-actions { margin-left: auto; display: inline-flex; gap: 0.25rem; }
.journal-icon-btn {
  width: 1.5rem; height: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.4rem;
  border: 1px solid color-mix(in srgb, var(--border-grey) 55%, transparent);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.journal-icon-btn:hover { color: var(--text-main); border-color: var(--color-mint, #10b981); }
.journal-icon-btn.journal-danger:hover { color: var(--color-crimson, #ef4444); border-color: var(--color-crimson, #ef4444); }
.journal-entry-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Journal box inside the day-log modal */
.journal-daybox {
  border: 1px solid color-mix(in srgb, var(--border-grey) 50%, transparent);
  border-radius: 0.6rem;
  padding: 0.6rem 0.7rem;
  background: color-mix(in srgb, var(--card-bg) 50%, transparent);
}
.journal-daybox-title {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}
.journal-daybox-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.4rem;
  padding-left: 0.6rem;
  border-left: 2px solid color-mix(in srgb, var(--color-mint, #10b981) 45%, transparent);
}
