/* ========================================
   Features - Video, Markdown, Avatars, Onboarding
   ======================================== */

/* Jdenticon Avatars */

/* Navigation avatar */
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Admin avatar in sidebar */
.admin-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Markdown Editor */
.markdown-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.md-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
}

.md-tabs {
    display: flex;
    gap: 4px;
}

.md-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.md-tab:hover {
    color: var(--text);
    background: var(--bg-card);
}

.md-tab.active {
    color: var(--text);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.md-hint {
    font-size: 12px;
    color: var(--text-light);
}

.markdown-editor textarea {
    border: none;
    border-radius: 0;
    min-height: 200px;
    resize: vertical;
    font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Inconsolata', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.markdown-editor textarea:focus {
    outline: none;
    box-shadow: none;
}

.markdown-preview {
    padding: 16px;
    min-height: 200px;
    background: var(--bg-card);
}

.preview-placeholder {
    color: var(--text-light);
    font-style: italic;
}

/* Markdown Rendered Content */
.markdown-content {
    line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child {
    margin-top: 0;
}

.markdown-content p {
    margin: 0 0 1em 0;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 1em 0;
    padding-left: 1.5em;
}

.markdown-content li {
    margin-bottom: 0.25em;
}

.markdown-content blockquote {
    margin: 0 0 1em 0;
    padding: 0.5em 1em;
    border-left: 3px solid var(--primary);
    background: var(--border-light);
    color: var(--text-muted);
}

.markdown-content blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-content code {
    font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background: var(--border-light);
    border-radius: var(--radius-sm);
}

.markdown-content pre {
    margin: 0 0 1em 0;
    padding: 1em;
    background: var(--border-light);
    border-radius: var(--radius);
    overflow-x: auto;
}

.markdown-content pre code {
    padding: 0;
    background: transparent;
    font-size: 13px;
    line-height: 1.5;
}

.markdown-content a {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: var(--primary-light);
    text-underline-offset: 2px;
}

.markdown-content a:hover {
    text-decoration-color: var(--primary);
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1em 0;
}

.markdown-content th,
.markdown-content td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-content th {
    background: var(--border-light);
    font-weight: 600;
}

/* Dark mode adjustments for code blocks */
[data-theme="dark"] .markdown-content pre,
[data-theme="dark"] .markdown-content code {
    background: #0f172a;
}

[data-theme="dark"] .markdown-content blockquote {
    background: #0f172a;
}

/* Video Grid View */
.post-video-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-video-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: all 0.15s ease;
}

.post-video-item:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
}

.post-video-item.sticky {
    border-left: 3px solid var(--accent);
}

.post-video-thumbnail {
    display: block;
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
}

.post-video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.2s ease;
}

.video-play-button svg {
    width: 28px;
    height: 28px;
    margin-left: 4px;
}

.post-video-thumbnail:hover .video-play-button {
    background: var(--primary);
    transform: translate(-50%, -50%) scale(1.1);
}

.post-video-info {
    display: flex;
    gap: 12px;
    padding: 16px;
}

.post-video-details {
    flex: 1;
    min-width: 0;
}

.post-video-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.post-video-title a {
    color: var(--text);
}

.post-video-title a:hover {
    color: var(--primary);
}

.post-video-meta {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.post-video-meta a {
    color: var(--text-muted);
}

.post-video-meta a:hover {
    color: var(--primary);
}

/* Video view vote buttons - override white text for light background */
.post-video-info .grid-vote-btn {
    background: var(--border-light);
    color: var(--text-muted);
}

.post-video-info .grid-vote-btn:hover {
    background: var(--primary);
    color: #fff;
}

.post-video-info .grid-vote-btn.voted {
    background: var(--primary);
    color: #fff;
}

.post-video-info .grid-vote-score {
    color: var(--text);
}

/* Video empty state */
.video-empty {
    text-align: center;
    padding: 60px 20px;
}

/* Video Embed in Post Detail */
.post-video {
    margin: 20px 0;
}

.video-embed-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.video-embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Inline Video Player (Board View) */
.post-video-player {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
}

.post-video-player .video-thumbnail-wrapper {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.post-video-player .video-thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-video-player iframe {
    width: 100%;
    height: 100%;
}

.post-video-player.playing {
    background: #000;
}

/* Mention Autocomplete */
.mention-autocomplete-wrapper {
    position: relative;
}

.mention-autocomplete {
    position: absolute;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 180px;
    display: none;
}

.mention-autocomplete.visible {
    display: block;
}

.mention-autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mention-autocomplete-item:hover,
.mention-autocomplete-item.active {
    background: var(--border-light);
}

.mention-autocomplete-item .mention-username {
    color: var(--primary);
    font-weight: 500;
}

.mention-autocomplete-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mention-autocomplete-empty {
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.mention-in-thread {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Onboarding Tutorial System */
/* Backdrop overlay */
.tutorial-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.tutorial-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Spotlight hole for highlighting elements */
.tutorial-spotlight {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    border-radius: var(--radius);
    transition: all 0.4s ease;
}

.tutorial-spotlight::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--primary);
    border-radius: calc(var(--radius) + 4px);
    animation: tutorial-pulse 2s ease-in-out infinite;
}

@keyframes tutorial-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.02); }
}

/* Arrow pointer */
.tutorial-arrow {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    transition: all 0.4s ease;
}

.tutorial-arrow svg {
    width: 48px;
    height: 48px;
    stroke: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    animation: tutorial-bounce 1s ease-in-out infinite;
}

@keyframes tutorial-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Tutorial modal */
.tutorial-modal {
    position: fixed;
    z-index: 10000;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: calc(100vw - 40px);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tutorial-modal.visible {
    opacity: 1;
}

.tutorial-modal.position-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Modal positioned near highlighted element */
.tutorial-modal.position-bottom {
    /* JavaScript will set top/left */
}

.tutorial-modal.position-top {
    /* JavaScript will set top/left */
}

.tutorial-modal.position-left {
    /* JavaScript will set top/left */
}

.tutorial-modal.position-right {
    /* JavaScript will set top/left */
}

/* Tutorial slide content */
.tutorial-slide {
    padding: 32px 28px 24px;
    text-align: center;
}

.tutorial-illustration {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-illustration svg {
    width: 100%;
    height: 100%;
}

.tutorial-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 12px;
    line-height: 1.2;
}

.tutorial-text {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

.tutorial-text strong {
    color: var(--text);
    font-weight: 600;
}

/* Tutorial footer */
.tutorial-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--border-light);
    border-top: 1px solid var(--border);
}

.tutorial-progress {
    display: flex;
    gap: 6px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.2s ease;
}

.tutorial-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.tutorial-dot.completed {
    background: var(--primary-light);
}

.tutorial-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tutorial-skip {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.tutorial-skip:hover {
    color: var(--text);
    background: var(--border);
}

.tutorial-next {
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: var(--radius);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tutorial-next:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.tutorial-next svg {
    width: 16px;
    height: 16px;
}

/* Welcome slide special styling */
.tutorial-slide.welcome .tutorial-illustration {
    width: 140px;
    height: 140px;
}

/* Feature list in slides */
.tutorial-features {
    text-align: left;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.tutorial-features li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.tutorial-features li:last-child {
    margin-bottom: 0;
}

.tutorial-features li svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Mini icons in tutorial text */
.tutorial-icon-inline {
    display: inline-flex;
    vertical-align: middle;
    width: 20px;
    height: 20px;
    padding: 2px;
    background: var(--border-light);
    border-radius: 4px;
    margin: 0 2px;
}

.tutorial-icon-inline svg {
    width: 100%;
    height: 100%;
    stroke: var(--text);
}

/* Dark mode adjustments */
[data-theme="dark"] .tutorial-backdrop {
    background: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tutorial-spotlight {
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tutorial-modal {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .tutorial-footer {
    background: var(--bg);
}
