/*
 * CiphaChat design layer (Hark redesign 2026-12-03)
 * All colours come from --cc-* variables printed by includes/theme.php
 * (Admin > Site Theme). Never hard-code colours here.
 */

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--cc-font), ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: rgb(var(--cc-background));
    color: rgb(var(--cc-text));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.006em;
}
h1, h2, h3, h4 { letter-spacing: -0.02em; }
::selection { background: rgb(var(--cc-primary) / .22); }
a, button, [role="button"], input, select, textarea, label { -webkit-tap-highlight-color: transparent; }
a, button { transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .2s ease, transform .1s ease, opacity .15s ease; }
button:not(:disabled):active, a.cc-press:active { transform: scale(.97); }
img { image-rendering: auto; }

/* Form controls follow the theme in both modes unless a utility class overrides */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), select, textarea) {
    background-color: rgb(var(--cc-surface));
    color: rgb(var(--cc-text));
    border-color: rgb(var(--cc-border));
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
:is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea)[class*="border"]:focus, .cc-input:focus {
    outline: none;
    border-color: rgb(var(--cc-primary));
    box-shadow: 0 0 0 4px rgb(var(--cc-primary) / .15);
}
::placeholder { color: rgb(var(--cc-muted) / .75); }
input[type=checkbox], input[type=radio] { accent-color: rgb(var(--cc-primary)); }
:focus-visible { outline: 2px solid rgb(var(--cc-primary) / .6); outline-offset: 2px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgb(var(--cc-border)) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgb(var(--cc-border)); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ---------- Card polish (applies to every existing bg-surface card) ---------- */
main .bg-surface.border:is(.rounded-lg, .rounded-xl, .rounded-2xl) {
    box-shadow: 0 1px 2px rgb(var(--cc-shadow) / var(--cc-shadow-a)), 0 8px 24px -14px rgb(var(--cc-shadow) / calc(var(--cc-shadow-a) * 1.6));
    border-color: rgb(var(--cc-border) / .85);
}
main a.bg-surface.border:hover, main .bg-surface.border.cc-hover:hover {
    box-shadow: 0 2px 4px rgb(var(--cc-shadow) / var(--cc-shadow-a)), 0 16px 32px -16px rgb(var(--cc-shadow) / calc(var(--cc-shadow-a) * 2.2));
    transform: translateY(-1px);
}
/* Buttons using the primary token get a soft glow */
main .bg-primary:is(button, a, [type=submit]) { box-shadow: 0 6px 18px -8px rgb(var(--cc-primary) / .7); }
main .bg-primary:is(button, a, [type=submit]):hover { box-shadow: 0 10px 24px -10px rgb(var(--cc-primary) / .85); }

/* Dark-mode fixes for hard-coded white/black utilities used across older pages */
html.dark .bg-white { background-color: rgb(var(--cc-surface)) !important; }
html.dark .hover\:bg-white:hover { background-color: rgb(var(--cc-surface2)) !important; }
html.dark .text-black { color: rgb(var(--cc-text)) !important; }
html.dark .border-white { border-color: rgb(var(--cc-surface)) !important; }
html.dark .bg-background { background-color: rgb(var(--cc-background)); }
html.dark img { opacity: .97; }

/* ---------- Design-system utilities (new markup) ---------- */
.cc-card { background: rgb(var(--cc-surface)); border: 1px solid rgb(var(--cc-border) / .85); border-radius: var(--cc-radius);
    box-shadow: 0 1px 2px rgb(var(--cc-shadow) / var(--cc-shadow-a)), 0 8px 24px -14px rgb(var(--cc-shadow) / calc(var(--cc-shadow-a) * 1.6)); }
.cc-btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font-weight: 600; font-size: .9rem;
    padding: .65rem 1.15rem; border-radius: 999px; border: 1px solid transparent; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.cc-btn-primary { background: rgb(var(--cc-primary)); color: rgb(var(--cc-on-primary)); box-shadow: 0 6px 18px -8px rgb(var(--cc-primary) / .7); }
.cc-btn-primary:hover { background: rgb(var(--cc-primary-hover)); }
.cc-btn-brand { background: linear-gradient(135deg, rgb(var(--cc-grad-from)), rgb(var(--cc-grad-to))); color: #fff; box-shadow: 0 10px 26px -10px rgb(var(--cc-grad-from) / .8); }
.cc-btn-brand:hover { filter: brightness(1.06) saturate(1.05); }
.cc-btn-ghost { background: rgb(var(--cc-surface2)); color: rgb(var(--cc-text)); }
.cc-btn-ghost:hover { background: rgb(var(--cc-gray-200)); }
.cc-btn-outline { background: transparent; color: rgb(var(--cc-text)); border-color: rgb(var(--cc-border)); }
.cc-btn-outline:hover { border-color: rgb(var(--cc-primary)); color: rgb(var(--cc-primary)); }
.cc-btn:disabled { opacity: .55; cursor: not-allowed; }
.cc-input { width: 100%; background: rgb(var(--cc-surface2)); border: 1px solid rgb(var(--cc-border)); color: rgb(var(--cc-text));
    border-radius: calc(var(--cc-radius) * .75); padding: .8rem 1rem; font-size: .95rem; }
.cc-input:focus { background: rgb(var(--cc-surface)); }
.cc-label { display: block; font-size: .78rem; font-weight: 600; color: rgb(var(--cc-muted)); margin-bottom: .4rem; letter-spacing: .01em; }
.cc-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .85rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
    background: rgb(var(--cc-surface2)); color: rgb(var(--cc-muted)); white-space: nowrap; }
.cc-chip:hover { color: rgb(var(--cc-text)); }
.cc-chip.is-active { background: rgb(var(--cc-text)); color: rgb(var(--cc-surface)); }
.cc-gradient { background: linear-gradient(135deg, rgb(var(--cc-grad-from)), rgb(var(--cc-grad-to))); }
.cc-gradient-text { background: linear-gradient(135deg, rgb(var(--cc-grad-from)), rgb(var(--cc-grad-to))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cc-ring { background: linear-gradient(135deg, rgb(var(--cc-grad-from)), rgb(var(--cc-grad-to))); padding: 2px; border-radius: 999px; }
.cc-muted { color: rgb(var(--cc-muted)); }
.cc-divider { height: 1px; background: rgb(var(--cc-border)); }
.cc-alert { border-radius: calc(var(--cc-radius) * .75); padding: .8rem 1rem; font-size: .9rem; border: 1px solid; }
.cc-alert-error { background: rgb(var(--cc-red-50)); border-color: rgb(var(--cc-red-200)); color: rgb(var(--cc-red-700)); }
.cc-alert-success { background: rgb(var(--cc-green-50)); border-color: rgb(var(--cc-green-200)); color: rgb(var(--cc-green-700)); }

/* Empty states */
.cc-empty { text-align: center; padding: 3rem 1.5rem; }
.cc-empty-icon { width: 4rem; height: 4rem; margin: 0 auto 1rem; border-radius: 1.25rem; display: flex; align-items: center; justify-content: center;
    background: rgb(var(--cc-primary) / .1); color: rgb(var(--cc-primary)); }

/* Skeleton shimmer */
.cc-skeleton { position: relative; overflow: hidden; background: rgb(var(--cc-surface2)); border-radius: calc(var(--cc-radius) * .5); }
.cc-skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgb(var(--cc-surface) / .6), transparent); animation: cc-shimmer 1.4s infinite; }
@keyframes cc-shimmer { 100% { transform: translateX(100%); } }
img[loading=lazy] { background: rgb(var(--cc-surface2)); }

/* Glass bars (top header / bottom nav) */
.cc-glass { background: rgb(var(--cc-surface) / .82); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); }
.cc-navlink { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; height: 100%;
    color: rgb(var(--cc-muted)); font-size: 11px; font-weight: 600; }
.cc-navlink:hover { color: rgb(var(--cc-text)); }
.cc-navlink.is-active { color: rgb(var(--cc-primary)); }
.cc-navlink.is-active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: rgb(var(--cc-primary)); }
.cc-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 999px; color: rgb(var(--cc-muted)); position: relative; }
.cc-iconbtn:hover { background: rgb(var(--cc-surface2)); color: rgb(var(--cc-text)); }
.cc-iconbtn.is-active { color: rgb(var(--cc-primary)); background: rgb(var(--cc-primary) / .1); }
.cc-toplink { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .85rem; border-radius: 999px; font-weight: 600; font-size: .9rem; color: rgb(var(--cc-muted)); }
.cc-toplink:hover { background: rgb(var(--cc-surface2)); color: rgb(var(--cc-text)); }
.cc-toplink.is-active { color: rgb(var(--cc-text)); background: rgb(var(--cc-surface2)); }

/* Feed tabs as pills */
.cc-tabs a { border-radius: 999px; }

/* Sidebar drawer links */
#sidebar-menu nav a { border-radius: 12px; margin: 0 .75rem; padding-left: 1rem !important; padding-right: 1rem !important; }
#sidebar-menu nav a:hover { background: rgb(var(--cc-surface2)); }

/* Menus / dropdowns */
.post-action-menu { border-radius: calc(var(--cc-radius) * .75) !important; padding: .25rem; box-shadow: 0 16px 40px -12px rgb(var(--cc-shadow) / calc(var(--cc-shadow-a) * 3)) !important; }
.post-action-menu li > a, .post-action-menu li > button { border-radius: 10px; }

/* Page entrance */
@media (prefers-reduced-motion: no-preference) {
    main > * { animation: cc-rise .35s ease-out both; }
}
@keyframes cc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Legacy helpers kept from the original stylesheet ---------- */
.aspect-square-container { position: relative; width: 100%; }
.aspect-square-container::after { content: ""; display: block; padding-bottom: 100%; }
.aspect-square-container img { position: absolute; width: 100%; height: 100%; object-fit: cover; }

.messages-container ::-webkit-scrollbar { width: 8px; }
.messages-container ::-webkit-scrollbar-track { background: rgb(var(--cc-surface)); }
.messages-container ::-webkit-scrollbar-thumb { background-color: rgb(var(--cc-border)); border-radius: 4px; }
.chat-list-item.active { background-color: rgb(var(--cc-primary)); }
.chat-list-item.active h3, .chat-list-item.active p { color: rgb(var(--cc-on-primary)); }
.chat-list-item.has-unread { background-color: rgb(var(--cc-primary) / .1); }
.chat-list-item.has-unread h3 { font-weight: 900; }

.cipher-skin-matrix { font-family: 'Courier New', Courier, monospace; color: #32cd32; text-shadow: 0 0 5px #32cd32; animation: matrix-fade 1.5s infinite; }
@keyframes matrix-fade { 0% { opacity: 1; } 50% { opacity: 0.7; } 100% { opacity: 1; } }

#more-menu-modal #more-menu-overlay { transition: opacity 0.3s ease-in-out; }
#more-menu-modal #more-menu-content { transition: transform 0.3s ease-in-out; }

.no-select { -webkit-user-select: none; user-select: none; }
.text-shadow { text-shadow: 1px 1px 3px rgba(0,0,0,0.5); }
.line-clamp-6 { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
