/*
 * The Common Threads -- Cinny Custom Theme
 * A warm, calm theme for the Morgellons community platform.
 *
 * Brand: aftrveil / root0
 * Palette:
 *   Parchment  #F2EDE6  (backgrounds)
 *   Char       #1A1814  (primary text)
 *   Navy       #101E3A  (sidebar, deep backgrounds)
 *   Bronze     #5C4A32  (secondary text, icons)
 *   Electric Cyan #00E5CC (accent, links, active states)
 *
 * Typography:
 *   Headings -- Outfit
 *   Body     -- Atkinson Hyperlegible Next
 *   Code     -- Atkinson Hyperlegible Mono
 *
 * Apply in Cinny: Settings > Appearance > Custom CSS
 * Paste or @import this file.
 */

/* ------------------------------------------------------------------ */
/* Font imports                                                        */
/* ------------------------------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/*
 * Note: "Atkinson Hyperlegible Next" and "Atkinson Hyperlegible Mono"
 * are not yet on Google Fonts. The import above loads the original
 * Atkinson Hyperlegible as a fallback. If you have the Next/Mono
 * variants installed locally or served from your own CDN, they will
 * take priority via the font-family declarations below.
 */

/* ------------------------------------------------------------------ */
/* Root theme variables                                                */
/* ------------------------------------------------------------------ */
:root,
.silver-theme,
.dark-theme,
.butter-theme {

  /* -- Typography -------------------------------------------------- */
  --font-primary: 'Atkinson Hyperlegible Next', 'Atkinson Hyperlegible', sans-serif;
  --font-secondary: 'Outfit', sans-serif;

  /* -- Surface backgrounds ----------------------------------------- */
  /* Extra-low is the deepest background layer (sidebar, panels).     */
  /* Low is the main chat area. Surface is cards and elevated UI.     */
  --bg-surface-extra-low: #101E3A;       /* Navy -- sidebar, deepest  */
  --bg-surface-low:       #F2EDE6;       /* Parchment -- chat area    */
  --bg-surface:           #FDFBF8;       /* Warm white -- cards, input*/
  --bg-surface-hover:     #E8E0D5;       /* Parchment darkened        */
  --bg-surface-active:    #DDD4C7;       /* Parchment deeper          */
  --bg-surface-border:    #D4CBBD;       /* Warm border               */

  /* -- Surface text ------------------------------------------------ */
  --tc-surface-high:      #1A1814;       /* Char -- primary text      */
  --tc-surface-normal:    #5C4A32;       /* Bronze -- secondary text  */
  --tc-surface-low:       #8A7A66;       /* Bronze lightened -- muted */

  /* -- Primary accent (buttons, links, active indicators) ---------- */
  --bg-primary:           #00E5CC;       /* Electric Cyan             */
  --bg-primary-hover:     #00CCB5;       /* Cyan darkened on hover    */
  --bg-primary-active:    #00B3A0;       /* Cyan darkened on press    */
  --bg-primary-border:    #00E5CC;
  --tc-primary:           #00E5CC;       /* Cyan text accent          */
  --tc-on-primary:        #101E3A;       /* Navy text on cyan buttons */

  /* -- Secondary accent (sidebar text, nav items) ------------------ */
  --bg-secondary:         #1A2A4D;       /* Navy lightened            */
  --bg-secondary-hover:   #243560;       /* Navy lighter on hover     */
  --bg-secondary-active:  #2D4076;       /* Navy lighter on press     */
  --bg-secondary-border:  #2D4076;
  --tc-secondary:         #F2EDE6;       /* Parchment on dark sidebar */
  --tc-on-secondary:      #F2EDE6;

  /* -- Sidebar-specific overrides ---------------------------------- */
  --bg-navigation:        #101E3A;       /* Navy                      */
  --tc-navigation:        #F2EDE6;       /* Parchment text on sidebar */

  /* -- Semantic / status colors ------------------------------------ */
  --bg-positive:          #2E7D5B;       /* Muted green, not clinical */
  --bg-positive-hover:    #276B4D;
  --bg-positive-active:   #1F5940;
  --bg-positive-border:   #2E7D5B;
  --tc-positive:          #2E7D5B;

  --bg-caution:           #B8860B;       /* Dark goldenrod -- warm    */
  --bg-caution-hover:     #A0750A;
  --bg-caution-active:    #886408;
  --bg-caution-border:    #B8860B;
  --tc-caution:           #B8860B;

  --bg-danger:            #B34040;       /* Muted red                 */
  --bg-danger-hover:      #9C3636;
  --bg-danger-active:     #852D2D;
  --bg-danger-border:     #B34040;
  --tc-danger:            #B34040;

  /* -- Tooltips ---------------------------------------------------- */
  --bg-tooltip:           #1A1814;       /* Char                      */
  --tc-tooltip:           #F2EDE6;       /* Parchment                 */

  /* -- Badges and notifications ------------------------------------ */
  --bg-badge:             #00E5CC;
  --tc-badge:             #101E3A;

  /* -- Overlay / modal --------------------------------------------- */
  --bg-overlay:           rgba(16, 30, 58, 0.6);  /* Navy translucent */

  /* -- Misc Cinny variables ---------------------------------------- */
  --bg-ping:              rgba(0, 229, 204, 0.15); /* Cyan faint glow */
  --bg-ping-hover:        rgba(0, 229, 204, 0.25);

  /* -- Scrollbar --------------------------------------------------- */
  --bg-scrollbar:         #D4CBBD;
  --bg-scrollbar-hover:   #5C4A32;       /* Bronze on hover           */

  /* -- Code blocks ------------------------------------------------- */
  --bg-code:              #101E3A;       /* Navy                      */
  --tc-code:              #00E5CC;       /* Cyan on dark              */

  /* -- Border radius (keep Cinny defaults, slightly warmer) -------- */
  --bo-radius: 12px;
}

/* ------------------------------------------------------------------ */
/* Typography overrides                                                */
/* ------------------------------------------------------------------ */

/* Headings use Outfit */
h1, h2, h3, h4, h5, h6,
.room-header__name,
.sidebar-header__name,
.space-header__name,
.room-intro__name {
  font-family: 'Outfit', sans-serif !important;
  font-weight: 600;
  color: var(--tc-surface-high);
}

/* Code blocks and inline code use monospace variant */
code,
pre,
.markdown-body code,
.markdown-body pre,
.cm-editor {
  font-family: 'Atkinson Hyperlegible Mono', 'Atkinson Hyperlegible', monospace !important;
}

/* ------------------------------------------------------------------ */
/* Sidebar styling                                                     */
/* ------------------------------------------------------------------ */

/* Sidebar gets the deep Navy treatment */
.sidebar,
.navigation,
.sidebar__sticky,
nav.sidebar {
  background-color: var(--bg-surface-extra-low) !important;
  color: var(--tc-navigation) !important;
}

/* Room list items in sidebar */
.sidebar .room-selector:hover,
.navigation .room-selector:hover {
  background-color: var(--bg-secondary-hover) !important;
}

.sidebar .room-selector[aria-selected="true"],
.navigation .room-selector[aria-selected="true"] {
  background-color: var(--bg-secondary-active) !important;
}

/* Space/room names in sidebar should be readable on Navy */
.sidebar .room-selector__name,
.navigation .room-selector__name {
  color: var(--tc-secondary) !important;
}

/* Sidebar icons */
.sidebar .ic-raw,
.navigation .ic-raw {
  color: var(--tc-surface-low) !important;
}

/* Active sidebar icon gets accent color */
.sidebar .room-selector[aria-selected="true"] .ic-raw,
.navigation .room-selector[aria-selected="true"] .ic-raw {
  color: var(--tc-primary) !important;
}

/* ------------------------------------------------------------------ */
/* Message bubbles and chat area                                       */
/* ------------------------------------------------------------------ */

/* Chat background */
.room-view,
.room-view__content {
  background-color: var(--bg-surface-low) !important;
}

/* Individual messages */
.message {
  border-radius: 8px;
}

.message:hover {
  background-color: var(--bg-surface-hover) !important;
}

/* Message sender names -- Bronze for warmth */
.message__header-name {
  color: var(--tc-surface-normal) !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 500;
}

/* Timestamps */
.message__header-ts,
.message__time {
  color: var(--tc-surface-low) !important;
}

/* ------------------------------------------------------------------ */
/* Input / composer area                                                */
/* ------------------------------------------------------------------ */

.room-input,
.room-input__input-container {
  background-color: var(--bg-surface) !important;
  border-color: var(--bg-surface-border) !important;
}

.room-input:focus-within {
  border-color: var(--bg-primary) !important;
  box-shadow: 0 0 0 2px rgba(0, 229, 204, 0.2);
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

/* Primary buttons get the Electric Cyan treatment */
.btn-primary,
button[class*="primary"] {
  background-color: var(--bg-primary) !important;
  color: var(--tc-on-primary) !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 600;
  border: none;
  transition: background-color 0.15s ease;
}

.btn-primary:hover,
button[class*="primary"]:hover {
  background-color: var(--bg-primary-hover) !important;
}

.btn-primary:active,
button[class*="primary"]:active {
  background-color: var(--bg-primary-active) !important;
}

/* ------------------------------------------------------------------ */
/* Links                                                               */
/* ------------------------------------------------------------------ */

a,
.markdown-body a {
  color: var(--tc-primary) !important;
  text-decoration: none;
}

a:hover,
.markdown-body a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Code blocks                                                         */
/* ------------------------------------------------------------------ */

.markdown-body pre {
  background-color: var(--bg-code) !important;
  border-radius: 8px;
  padding: 12px 16px;
}

.markdown-body code {
  color: var(--tc-code) !important;
}

.markdown-body :not(pre) > code {
  background-color: rgba(16, 30, 58, 0.08);
  color: var(--tc-surface-high) !important;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Scrollbar                                                           */
/* ------------------------------------------------------------------ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--bg-scrollbar);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--bg-scrollbar-hover);
}

/* ------------------------------------------------------------------ */
/* Emoji reactions                                                     */
/* ------------------------------------------------------------------ */

.msg-reactions .reaction-btn {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--bg-surface-border) !important;
  border-radius: 16px;
}

.msg-reactions .reaction-btn:hover {
  border-color: var(--bg-primary) !important;
}

.msg-reactions .reaction-btn.active {
  background-color: rgba(0, 229, 204, 0.12) !important;
  border-color: var(--bg-primary) !important;
}

/* ------------------------------------------------------------------ */
/* Room intro / empty state                                            */
/* ------------------------------------------------------------------ */

.room-intro {
  text-align: center;
  padding: 48px 24px;
}

.room-intro__name {
  font-family: 'Outfit', sans-serif !important;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tc-surface-high) !important;
}

.room-intro__desc {
  color: var(--tc-surface-normal) !important;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Notification badge                                                  */
/* ------------------------------------------------------------------ */

.notification-badge,
.room-selector__badge {
  background-color: var(--bg-badge) !important;
  color: var(--tc-badge) !important;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Dialogs and modals                                                  */
/* ------------------------------------------------------------------ */

.dialog-overlay {
  background-color: var(--bg-overlay) !important;
}

.dialog {
  background-color: var(--bg-surface) !important;
  border-radius: var(--bo-radius);
}

/* ------------------------------------------------------------------ */
/* User avatars -- subtle border on light backgrounds                  */
/* ------------------------------------------------------------------ */

.avatar-container img {
  border: 1.5px solid var(--bg-surface-border);
  border-radius: 50%;
}

/* ------------------------------------------------------------------ */
/* Selection and focus rings                                           */
/* ------------------------------------------------------------------ */

::selection {
  background-color: rgba(0, 229, 204, 0.25);
  color: var(--tc-surface-high);
}

*:focus-visible {
  outline: 2px solid var(--bg-primary);
  outline-offset: 2px;
}
