/**
 * SAW LMS Thoughts - Timeline Design System
 * Adapted from SAW_Thoughts_v1 for SAW LMS
 * 
 * @package SawLms\Modules\Thoughts
 * @version 1.0.0
 */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* SAW LMS Colors */
    --saw-primary: #024E74;
    --saw-primary-dark: #023d5a;
    --saw-primary-light: #4FB0D6;
    --saw-accent: #e85d4c;

    /* Text Colors */
    --saw-text: #1a1a1a;
    --saw-text-secondary: #6b6b6b;
    --saw-text-muted: #999999;
    --saw-text-white: #ffffff;
    --saw-text-white-muted: rgba(255, 255, 255, 0.7);

    /* Backgrounds */
    --saw-bg: #f8f8f8;
    --saw-surface: #ffffff;
    --saw-border: #e5e5e5;

    /* Author Colors */
    --author-color: #024E74;
    --author-color-dark: #023d5a;
    --author-color-light: #e8f4f8;

    /* Typography */
    --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9rem;
    --text-md: 1.0625rem;
    --text-lg: 1.125rem;
    --text-xl: clamp(1.5rem, 3vw, 2rem);
    --text-hero: clamp(2rem, 4vw, 3rem);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Z-Index */
    --z-sticky: 100;
    --z-modal: 1000;

    /* Corner fold */
    --saw-corner-size: 70px;
    --saw-gold: #ffd700;
    --saw-gold-dark: #e6b800;
}

/* Import Font */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700;800&display=swap');

.saw-thoughts-wrapper {
    font-family: var(--font-primary);
    color: var(--saw-text);
    line-height: 1.5;
    background: transparent;
    overflow-x: hidden;
    max-width: 100%;
}

.saw-thoughts-wrapper * {
    box-sizing: border-box;
}

/* =========================================
   2. HERO SECTION
   ========================================= */
.saw-thoughts-hero {
    background: transparent;
    padding: 60px 20px 40px 20px;
    text-align: center;
}

.saw-hero-inner {
    max-width: 800px;
    margin: 0 auto;
}

.saw-hero-overline {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--saw-primary);
    display: inline-block;
    margin-bottom: 16px;
    position: relative;
}

.saw-hero-overline::before,
.saw-hero-overline::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 1px;
    background: var(--saw-primary);
    vertical-align: middle;
    margin: 0 10px;
    opacity: 0.5;
}

.saw-hero-title {
    font-size: var(--text-hero);
    font-weight: 800;
    margin: 0 0 16px 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--saw-text);
}

.saw-hero-desc {
    font-size: var(--text-lg);
    color: var(--saw-text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================
   3. QUICKNAV (STICKY)
   ========================================= */
.saw-quicknav {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    padding: 12px 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: top 0.3s;
}

.saw-quicknav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.saw-quicknav-inner::-webkit-scrollbar {
    display: none;
}

.saw-quicknav-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    color: var(--saw-text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.saw-quicknav-list {
    display: flex;
    gap: 8px;
}

.saw-quicknav-btn {
    appearance: none;
    border: 1px solid var(--saw-border);
    background: transparent;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    transition: all 0.2s;
    min-width: 50px;
}

.saw-quicknav-month {
    font-size: var(--text-sm);
    font-weight: 700;
    margin-bottom: 2px;
}

.saw-quicknav-year {
    font-size: 10px;
    color: var(--saw-text-muted);
}

.saw-quicknav-btn:hover {
    background: var(--saw-bg);
    border-color: var(--saw-text-muted);
}

.saw-quicknav-btn--active {
    background: var(--saw-primary) !important;
    border-color: var(--saw-primary) !important;
    color: white;
}

.saw-quicknav-btn--active .saw-quicknav-year {
    color: rgba(255, 255, 255, 0.7);
}

/* =========================================
   4. TYPE FILTERS
   ========================================= */
.saw-filters-bar {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.saw-filter {
    appearance: none;
    border: 1px solid var(--saw-border);
    background: white;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--saw-text);
    cursor: pointer;
    transition: all 0.2s;
}

.saw-filter:hover {
    background: var(--saw-primary);
    color: white;
    border-color: var(--saw-primary);
}

.saw-filter--active {
    background: var(--saw-primary);
    color: white;
    border-color: var(--saw-primary);
    box-shadow: 0 4px 12px rgba(2, 78, 116, 0.2);
}

/* =========================================
   5. FEATURED CARD (Highlighted)
   ========================================= */
.saw-featured {
    max-width: 900px;
    margin: 0 auto 60px auto;
    position: relative;
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: linear-gradient(135deg, var(--author-color), var(--author-color-dark));
    color: white;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    /* Clickable */
}

.saw-featured-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.saw-featured-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
}

.saw-featured-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
}

.saw-featured-circle--1 {
    width: 400px;
    height: 400px;
    top: -100px;
    right: -50px;
}

.saw-featured-circle--2 {
    width: 300px;
    height: 300px;
    bottom: -50px;
    left: -50px;
}

.saw-featured-content {
    position: relative;
    z-index: 1;
    padding: 50px;
}

.saw-featured-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.saw-featured-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saw-featured-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 100px;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: fit-content;
}

.saw-featured-badge-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
    animation: saw-pulse 2s ease-in-out infinite;
}

@keyframes saw-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
}

.saw-featured-type {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    opacity: 0.9;
}

.saw-featured-date {
    font-family: monospace;
    font-size: var(--text-sm);
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
}

.saw-featured-title {
    font-size: var(--text-xl);
    line-height: 1.2;
    margin: 0 0 16px 0;
    max-width: 800px;
    font-weight: 800;
    color: #ffffff;
}

.saw-featured-text {
    font-size: var(--text-md);
    line-height: 1.6;
    opacity: 0.9;
    margin: 0 0 24px 0;
    max-width: 800px;
}

/* Featured Sources */
.saw-featured-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.saw-featured-source {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 0.875rem;
    color: #ffffff;
    text-decoration: none;
    transition: background 0.2s ease;
    cursor: pointer;
}

.saw-featured-source:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.saw-featured-source-icon {
    width: 18px;
    height: 18px;
    display: flex;
}

.saw-featured-source-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

.saw-featured-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 24px;
}

.saw-featured-author {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: auto;
    /* Allow author click separately */
}

.saw-js-person-modal-trigger {
    cursor: pointer;
    transition: opacity 0.2s;
}

.saw-js-person-modal-trigger:hover {
    opacity: 0.8;
}

.saw-featured-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
}

.saw-featured-author-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.saw-featured-author-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--saw-text-white);
    margin-bottom: 2px;
}

.saw-featured-author-role {
    font-size: 12px;
    opacity: 0.8;
    font-weight: 400;
}

.saw-featured-actions {
    display: flex;
    gap: 12px;
    cursor: auto;
}

.saw-featured-action {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

.saw-featured-action:hover {
    background: white;
    color: var(--author-color-dark);
}

/* =========================================
   6. TIMELINE LAYOUT
   ========================================= */
.saw-timeline {
    position: relative;
    max-width: 1100px;
    margin: 0 auto 100px auto;
    padding: 20px;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.saw-timeline::before {
    content: '';
    position: absolute;
    left: calc(50% + 10px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--saw-border), var(--saw-border) 90%, transparent);
    transform: translateX(-50%);
    z-index: 0;
}

.saw-timeline-marker {
    text-align: center;
    position: relative;
    z-index: 1;
    margin: 0 0 40px 0;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    scroll-margin-top: 100px;
    gap: 0;
}

.saw-timeline-marker-year {
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 900;
    color: var(--saw-primary);
    opacity: 0.2;
    line-height: 1;
    margin: 0;
}

.saw-timeline-marker-month {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color: transparent;
    -webkit-text-stroke: 1px var(--saw-border);
    text-transform: uppercase;
    line-height: 1;
    opacity: 0.8;
    letter-spacing: 0.05em;
    margin: 0;
}

.saw-timeline-item {
    width: 50%;
    margin-bottom: 24px;
    position: relative;
    display: flex;
}

.saw-timeline-item--left {
    padding-right: 48px;
    justify-content: flex-end;
    margin-right: auto;
}

.saw-timeline-item--right {
    margin-left: 50%;
    padding-left: 48px;
    justify-content: flex-start;
}

/* Connector Dot + Line */
.saw-timeline-connector {
    position: absolute;
    top: 25px;
    display: flex;
    align-items: center;
}

.saw-timeline-connector::before {
    content: '';
    position: absolute;
    height: 2px;
    background: var(--saw-border);
    width: 36px;
}

.saw-timeline-item--left .saw-timeline-connector {
    right: 0;
    flex-direction: row-reverse;
}

.saw-timeline-item--left .saw-timeline-connector::before {
    right: 12px;
}

.saw-timeline-item--right .saw-timeline-connector {
    left: 0;
}

.saw-timeline-item--right .saw-timeline-connector::before {
    left: 12px;
}

.saw-timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--author-color);
    box-shadow: 0 0 0 4px var(--saw-bg);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.saw-timeline-item:hover .saw-timeline-dot {
    transform: scale(1.5);
}

/* =========================================
   7. TIMELINE CARD
   ========================================= */
.saw-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 420px;
    position: relative;
    cursor: pointer;
    /* Clickable */
}

.saw-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.saw-card-header {
    background: var(--author-color);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.saw-card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
    pointer-events: none;
}

.saw-card-header--reversed {
    flex-direction: row-reverse;
}

.saw-card-type {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    padding: 6px 12px;
    border-radius: 20px;
    color: var(--saw-primary);
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border: none;
}

.saw-card-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.saw-card-type-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 1.5;
}

.saw-card-date {
    font-size: var(--text-xs);
    opacity: 0.9;
    font-weight: 500;
    z-index: 1;
}

.saw-card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.saw-card-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--saw-text);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.saw-card-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--saw-text-secondary);
}

.saw-card-text p {
    margin-bottom: 0.75em;
}

.saw-card-text p:last-child {
    margin-bottom: 0;
}

/* Sources */
.saw-card-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.saw-card-source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--saw-primary);
    border-radius: 8px;
    font-size: 0.8rem;
    color: white;
    text-decoration: none;
    transition: background 0.2s ease;
    cursor: pointer;
}

.saw-card-source:hover {
    background: var(--saw-primary-dark);
    color: white;
}

.saw-card-source-icon {
    width: 16px;
    height: 16px;
    display: flex;
}

.saw-card-source-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

/* Footer */
.saw-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--saw-border);
    padding-top: 16px;
    margin-top: auto;
}

.saw-card-author {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: auto;
}

.saw-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.saw-card-author-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.saw-card-author-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--saw-text);
    margin-bottom: 2px;
    display: block;
}

.saw-card-author-role {
    font-size: 11px;
    font-weight: 400;
    color: var(--saw-text-muted);
}

/* Actions */
.saw-card-actions {
    display: flex;
    gap: 8px;
    cursor: auto;
}

.saw-card-action {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    color: var(--saw-text-muted);
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.saw-card-action:hover {
    color: var(--saw-text);
    background: var(--saw-bg);
}

.saw-card-action--active {
    color: var(--saw-accent);
}

.saw-card-action-icon {
    width: 18px;
    height: 18px;
    display: flex;
}

.saw-card-action-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.saw-card-action--active .saw-card-action-icon svg {
    fill: var(--saw-accent);
}

/* =========================================
   8. HIGHLIGHTED CARD (Corner Fold)
   ========================================= */
.saw-card--highlighted {
    position: relative;
    border-radius: var(--radius-lg);
    background: transparent;
    overflow: visible;
    color: var(--saw-text-white);
    border: none;
    box-shadow: none;
}

.saw-card--highlighted:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(26, 82, 118, 0.4);
}

.saw-card--highlighted .saw-card-bg {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    z-index: 0;
    background: linear-gradient(135deg, var(--author-color) 0%, var(--author-color-dark) 100%);
}

.saw-card--highlighted .saw-card-glass {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg,
            rgba(26, 82, 118, 0.85) 0%,
            rgba(10, 58, 86, 0.95) 100%);
    border-radius: var(--radius-lg);
    z-index: 1;
}

/* Corner Fold */
.saw-card--highlighted .saw-card-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--saw-corner-size);
    height: var(--saw-corner-size);
    z-index: 20;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    background: linear-gradient(135deg, var(--saw-gold) 0%, var(--saw-gold-dark) 100%);
    border-radius: 0 var(--radius-lg) 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 10px;
}

.saw-card--highlighted .saw-card-corner-icon {
    width: 24px;
    height: 24px;
    display: flex;
    color: #ffffff;
    transform: rotate(15deg);
}

.saw-card--highlighted .saw-card-corner-icon svg {
    width: 100%;
    height: 100%;
    fill: #ffffff;
}

/* Highlighted Header */
.saw-card--highlighted .saw-card-header {
    position: relative;
    z-index: 2;
    padding: 16px 20px;
    padding-right: 85px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: none;
}

.saw-card--highlighted .saw-card-date {
    color: var(--saw-text-white) !important;
}

.saw-card--highlighted .saw-card-type {
    background: transparent;
    color: var(--saw-text-white);
    box-shadow: none;
    padding: 0;
}

.saw-card--highlighted .saw-card-type-icon svg {
    stroke: var(--saw-text-white);
    fill: none;
}

/* Highlighted Body */
.saw-card--highlighted .saw-card-body {
    position: relative;
    z-index: 2;
    padding: 20px;
}

.saw-card--highlighted .saw-card-title {
    color: var(--saw-text-white) !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.saw-card--highlighted .saw-card-text {
    color: var(--saw-text-white) !important;
    opacity: 0.9;
}

/* Highlighted Source */
.saw-card--highlighted .saw-card-source {
    background: rgba(255, 255, 255, 0.12);
    color: var(--saw-text-white);
}

.saw-card--highlighted .saw-card-source:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Highlighted Footer */
.saw-card--highlighted .saw-card-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.saw-card--highlighted .saw-card-author-name {
    color: var(--saw-text-white) !important;
}

.saw-card--highlighted .saw-card-author-role {
    color: var(--saw-text-white-muted) !important;
}

.saw-card--highlighted .saw-card-avatar {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.saw-card--highlighted .saw-card-action {
    background: rgba(255, 255, 255, 0.1);
    color: var(--saw-text-white);
    border-radius: 8px;
}

.saw-card--highlighted .saw-card-action:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* =========================================
   9. RESPONSIVE
   ========================================= */

/* Tablet */
@media screen and (max-width: 900px) {
    .saw-timeline::before {
        left: 20px;
        transform: translateX(0);
    }

    .saw-timeline-marker {
        align-items: flex-start;
        margin-left: 20px;
        text-align: left;
    }

    .saw-timeline-marker-year {
        margin-left: 10px;
    }

    .saw-timeline-item {
        width: 100%;
        margin-left: 0 !important;
        padding-left: 52px !important;
        padding-right: 0 !important;
        justify-content: flex-start;
    }

    .saw-timeline-connector {
        left: 14px !important;
        right: auto !important;
    }

    .saw-card {
        max-width: 100%;
    }

    .saw-card-header,
    .saw-card-header--reversed {
        flex-direction: row !important;
    }

    .saw-featured-content {
        padding: 30px;
    }

    :root {
        --saw-corner-size: 60px;
    }

    .saw-card--highlighted .saw-card-header {
        padding-right: 75px;
    }
}

/* Mobile */
@media screen and (max-width: 640px) {
    .saw-timeline::before {
        left: 8px;
    }

    .saw-timeline-marker {
        margin-left: 8px;
        margin-top: 32px;
        margin-bottom: 16px;
    }

    .saw-timeline-marker-month {
        font-size: 2rem;
        font-weight: 800;
        color: var(--saw-primary);
        -webkit-text-stroke: 0;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    .saw-timeline-marker-year {
        margin-left: 0;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--saw-primary);
        opacity: 0.6;
    }

    .saw-timeline-item {
        padding-left: 10px !important;
        padding-right: 0 !important;
    }

    .saw-timeline-connector {
        display: none;
    }

    .saw-card {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 12px;
    }

    .saw-card-body {
        padding: 16px 14px;
    }

    .saw-card-header {
        padding: 10px 14px;
    }

    .saw-card-footer {
        padding-top: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .saw-card-author {
        width: 100%;
    }

    .saw-card-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .saw-card-sources {
        gap: 6px;
    }

    .saw-card-source {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .saw-featured-content {
        padding: 24px;
    }

    .saw-featured-header {
        flex-direction: column;
        gap: 12px;
    }

    .saw-featured-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .saw-filters-bar {
        padding: 16px 12px;
        overflow-x: auto;
    }

    :root {
        --saw-corner-size: 50px;
    }

    .saw-card--highlighted .saw-card-header {
        padding-right: 65px;
    }

    .saw-card--highlighted .saw-card-corner-icon {
        width: 18px;
        height: 18px;
    }
}

/* =========================================
   10. DARK THEME
   ========================================= */
[data-theme="dark"] .saw-thoughts-wrapper,
.dark .saw-thoughts-wrapper {
    --saw-text: #e4e6eb;
    --saw-text-secondary: #b0b3b8;
    --saw-text-muted: #8a8d91;
    --saw-surface: #242526;
    --saw-border: #3a3b3c;
    --saw-bg: #18191a;
}

[data-theme="dark"] .saw-card,
.dark .saw-card {
    background: var(--saw-surface);
    border-color: var(--saw-border);
}

[data-theme="dark"] .saw-card-title,
.dark .saw-card-title {
    color: var(--saw-text);
}

[data-theme="dark"] .saw-card-author-name,
.dark .saw-card-author-name {
    color: var(--saw-text);
}

[data-theme="dark"] .saw-filter,
.dark .saw-filter {
    background: var(--saw-surface);
    border-color: var(--saw-border);
    color: var(--saw-text);
}

[data-theme="dark"] .saw-quicknav,
.dark .saw-quicknav {
    background: rgba(24, 25, 26, 0.95);
}

[data-theme="dark"] .saw-quicknav-btn,
.dark .saw-quicknav-btn {
    border-color: var(--saw-border);
    color: var(--saw-text);
}

/* =========================================
   11. SHARE DROPDOWN
   ========================================= */
.saw-share-dropdown {
    position: relative;
}

.saw-share-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--saw-text-muted);
    transition: all 0.2s;
}

.saw-share-toggle:hover {
    background: var(--saw-bg);
    color: var(--saw-text);
}

.saw-share-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 50;
}

.saw-share-dropdown:hover .saw-share-menu,
.saw-share-dropdown:focus-within .saw-share-menu,
.saw-share-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(-8px);
}

.saw-share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--saw-text);
    transition: background 0.2s;
}

.saw-share-item:hover {
    background: var(--saw-bg);
}

.saw-share-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    border-radius: 4px;
}

.saw-share-icon.twitter {
    background: #000;
    color: white;
}

.saw-share-icon.facebook {
    background: #1877f2;
    color: white;
}

.saw-share-icon.linkedin {
    background: #0a66c2;
    color: white;
}

.saw-share-icon.copy {
    background: var(--saw-bg);
}

/* =========================================
   12. LOADING & EMPTY STATES
   ========================================= */
.saw-thoughts-loading {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}

.saw-thoughts-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--saw-border);
    border-top-color: var(--saw-primary);
    border-radius: 50%;
    animation: saw-thoughts-spin 0.8s linear infinite;
}

@keyframes saw-thoughts-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scroll target highlight */
.saw-card--scroll-target {
    animation: saw-highlight-pulse 0.5s ease-out 2;
    box-shadow: 0 0 0 4px var(--saw-primary);
}

@keyframes saw-highlight-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(26, 82, 118, 0.5);
    }

    100% {
        box-shadow: 0 0 0 10px rgba(26, 82, 118, 0);
    }
}

.saw-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--saw-text-muted);
}

.saw-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.saw-empty-text {
    font-size: var(--text-lg);
}

/* =========================================
   13. FEATURED WRAPPER (SIMPLIFIED)
   ========================================= */
.saw-featured-wrapper {
    width: 100%;
    position: relative;
    /* No expansion or grid logic needed here anymore */
}

/* =========================================
   14. COMMENT PANEL (CHAT STYLE)
   ========================================= */
.saw-chat {
    /* Hidden by default until opened */
    display: none;
}

/* NEW HEADER STYLES (Two-Row) */
.saw-chat__header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    border-bottom: 1px solid var(--saw-border);
    background: var(--saw-surface);
    flex-shrink: 0;
}

.saw-chat__header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.saw-chat__meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.saw-chat__meta-icon {
    font-size: 1.25rem;
}

.saw-chat__meta-label {
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--saw-text-muted);
    letter-spacing: 0.05em;
}

.saw-chat__count {
    background: var(--saw-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    min-width: 24px;
    text-align: center;
}

.saw-chat__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    color: var(--saw-text-secondary);
    transition: all 0.2s;
    margin-right: -8px;
    /* Optical alignment */
}

.saw-chat__close:hover {
    background: var(--saw-border);
    color: var(--saw-text);
}

.saw-chat__close svg {
    width: 20px;
    height: 20px;
}

/* Distinct Thought Title */
.saw-chat__thought-title {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--saw-text);
    margin: 0;
    letter-spacing: -0.01em;
}

.saw-chat__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.saw-chat--loading .saw-chat__content {
    display: none;
}

.saw-chat__loader {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.saw-chat--loading .saw-chat__loader {
    display: flex;
}

.saw-chat__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--saw-border);
    border-top-color: var(--saw-primary);
    border-radius: 50%;
    animation: saw-thoughts-spin 0.8s linear infinite;
}

.saw-chat__empty {
    text-align: center;
    padding: 30px;
    color: var(--saw-text-muted);
}

.saw-chat__empty p {
    margin: 0;
    font-size: var(--text-sm);
}

/* Comment Message (Ultra Compact Threaded) */
.saw-chat__message {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--saw-border);
    position: relative;
}

.saw-chat__message:last-child {
    border-bottom: none;
}

/* Thread Container (Nested Replies) */
.saw-chat__replies {
    margin-left: 14px;
    /* Half of avatar width (28px/2) */
    border-left: 2px solid rgba(26, 82, 118, 0.15);
    /* Thread Line */
    padding-left: 12px;
    position: relative;
}

/* Horizontal Connector from Thread Line to Avatar */
.saw-chat__replies>.saw-chat__message::before {
    content: '';
    position: absolute;
    top: 20px;
    /* Align with avatar center (6px padding + 28px/2) */
    left: -14px;
    /* Reach back to thread line */
    width: 12px;
    height: 2px;
    background: rgba(26, 82, 118, 0.15);
}

/* Nested replies (deeper levels) */
.saw-chat__replies .saw-chat__replies {
    border-left-color: rgba(26, 82, 118, 0.1);
}

.saw-chat__replies .saw-chat__replies>.saw-chat__message::before {
    background: rgba(26, 82, 118, 0.1);
}

/* Dark theme thread lines */
[data-theme="dark"] .saw-chat__replies {
    border-left-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .saw-chat__replies>.saw-chat__message::before {
    background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .saw-chat__replies .saw-chat__replies {
    border-left-color: rgba(255, 255, 255, 0.08);
}

.saw-chat__message--pending {
    opacity: 0.7;
    background: rgba(255, 193, 7, 0.1);
    margin: 4px -6px;
    padding: 6px;
    border-radius: 4px;
}

.saw-chat__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    z-index: 1;
    /* Above thread lines */
}

.saw-chat__message-content {
    flex: 1;
    min-width: 0;
}

.saw-chat__message-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 0;
    /* No margin */
    line-height: 1.2;
}

.saw-chat__author {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--saw-text);
}

.saw-chat__time {
    font-size: 0.65rem;
    color: var(--saw-text-muted);
}

.saw-chat__badge {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 3px;
    border-radius: 2px;
}

.saw-chat__badge--pending {
    background: #ffc107;
    color: #000;
}

.saw-chat__text {
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--saw-text-secondary);
    margin-top: 2px;
    word-wrap: break-word;
}

.saw-chat__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.saw-chat__action {
    font-size: 0.65rem;
    color: var(--saw-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-weight: 600;
    transition: opacity 0.2s;
}

.saw-chat__action:hover {
    text-decoration: underline;
}

.saw-chat__votes {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* Vote Buttons styled as Outline Blue Icons */
.saw-chat__vote-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    color: var(--saw-primary);
    background: transparent;
    border: 1px solid rgba(46, 134, 193, 0.2);
    cursor: pointer;
    padding: 1px 6px;
    /* Ultra compact pill */
    border-radius: 100px;
    transition: all 0.2s;
    height: 20px;
}

.saw-chat__vote-btn:hover {
    background: rgba(46, 134, 193, 0.05);
    border-color: var(--saw-primary);
}

.saw-chat__vote-btn--voted {
    background: rgba(46, 134, 193, 0.1);
    border-color: var(--saw-primary);
    font-weight: 700;
}

/* Ensure Icons are Visible */
.saw-chat__vote-btn svg {
    width: 14px;
    height: 14px;
    stroke: var(--saw-primary);
    fill: none;
    stroke-width: 2;
}

.saw-chat__vote-btn--voted svg {
    fill: var(--saw-primary);
}

.saw-chat__admin-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.saw-chat__admin-btn {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #22c55e;
    color: white;
    transition: all 0.2s;
}

.saw-chat__admin-btn:hover {
    opacity: 0.85;
}

.saw-chat__admin-btn--spam {
    background: #ef4444;
}

/* Comment Form */
.saw-chat__form {
    padding: 24px;
    border-top: 1px solid var(--saw-border);
    background: var(--saw-bg);
    flex-shrink: 0;
}

.saw-chat__reply-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--saw-primary);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: var(--text-sm);
}

.saw-chat__reply-indicator-text {
    display: flex;
    align-items: center;
    gap: 6px;
}

.saw-chat__cancel-reply {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}

.saw-chat__cancel-reply:hover {
    opacity: 1;
}

.saw-chat__form-row {
    margin-bottom: 10px;
}

.saw-chat__form-row--main {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
}

.saw-chat__input {
    width: 100%;
    padding: 12px 14px;
    font-size: var(--text-sm);
    border: 1px solid var(--saw-border);
    border-radius: 8px;
    background: white;
    outline: none;
    transition: border-color 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.saw-chat__input:focus {
    border-color: var(--saw-primary);
}

.saw-chat__textarea {
    flex: 1;
    min-height: 48px;
    padding: 12px 14px;
    font-size: var(--text-sm);
    border: 1px solid var(--saw-border);
    border-radius: 12px;
    background: white;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.saw-chat__textarea:focus {
    border-color: var(--saw-primary);
}

.saw-chat__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--saw-primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(26, 82, 118, 0.2);
}

.saw-chat__submit:hover {
    background: var(--saw-primary-dark);
    transform: translateY(-1px);
}

.saw-chat__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.saw-chat__submit svg {
    width: 20px;
    height: 20px;
}

.saw-chat__notice {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: var(--text-sm);
    border-radius: 8px;
    text-align: center;
}

.saw-chat__notice--success {
    background: #dcfce7;
    color: #166534;
}

.saw-chat__notice--error {
    background: #fef2f2;
    color: #991b1b;
}

/* Notify Checkbox for Comment Form */
.saw-chat__form-row--notify {
    padding: 8px 0 0;
    border-top: 1px solid var(--saw-border);
    margin-top: 8px;
}

.saw-chat__notify-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--saw-text-secondary);
    cursor: pointer;
}

.saw-chat__notify-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--saw-primary);
    cursor: pointer;
}

.saw-chat__notify-label span {
    user-select: none;
}

.saw-chat__form-row--email .saw-chat__input {
    font-size: 0.85rem;
}

/* Readonly input for logged-in users */
.saw-chat__input--readonly {
    background: var(--saw-surface-alt, #f3f4f6);
    cursor: default;
    color: var(--saw-text-secondary);
}

/* Active vote state */
.saw-card-action--active {
    color: #e53935 !important;
}

.saw-card-action--active .saw-card-action-icon svg {
    fill: currentColor;
}

/* =========================================
   14. DARK THEME - COMMENTS
   ========================================= */
[data-theme="dark"] .saw-chat {
    background: var(--saw-surface);
    border-color: var(--saw-border);
}

[data-theme="dark"] .saw-chat__header {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--saw-border);
}

[data-theme="dark"] .saw-chat__close:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .saw-chat__message--reply {
    border-left-color: var(--saw-border);
}

[data-theme="dark"] .saw-chat__message--pending {
    background: rgba(255, 193, 7, 0.15);
}

[data-theme="dark"] .saw-chat__form {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--saw-border);
}

[data-theme="dark"] .saw-chat__input,
[data-theme="dark"] .saw-chat__textarea {
    background: var(--saw-surface);
    border-color: var(--saw-border);
    color: var(--saw-text);
}

[data-theme="dark"] .saw-chat__vote-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .saw-chat__notice--success {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

[data-theme="dark"] .saw-chat__notice--error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Featured Title Color Fix */
.saw-featured-title {
    color: #ffffff;
}

/* =========================================
   15. DESKTOP / FIXED SIDEBAR LOGIC
   ========================================= */
@media (min-width: 992px) {
    /* No inline expansion/grid modifications needed */

    /* Fixed Right Sidebar for ALL chats (moved to body) */
    body>.saw-chat.saw-chat--open {
        display: flex;
        flex-direction: column;
        /* Key Fix: Vertical Stack */
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 500px;
        max-width: 100%;
        height: 100vh !important;
        max-height: none !important;
        z-index: 99999;
        margin: 0 !important;
        border-radius: 0;
        border-left: 1px solid var(--saw-border);
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
        transform: translateX(0);
        background: var(--saw-surface);
        animation: saw-slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes saw-slide-in {
        from {
            transform: translateX(100%);
        }

        to {
            transform: translateX(0);
        }
    }
}

/* =========================================
   16. MOBILE / TABLET OVERLAY LOGIC
   ========================================= */
@media (max-width: 991px) {
    .saw-featured-wrapper {
        flex-direction: column;
    }

    .saw-chat {
        display: none;
        /* hidden by default */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99999 !important;
        margin: 0 !important;
        border-radius: 0;
        height: 100dvh;
        width: 100vw;
        max-width: none;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex-direction: column;
        background: var(--saw-surface);
    }

    /* When active (appended to body), it becomes visible and transitions up */
    body>.saw-chat.saw-chat--open {
        display: flex !important;
        transform: translateY(0);
    }

    .saw-chat__connector {
        display: none;
    }

    .saw-chat__header {
        padding: 16px;
    }

    .saw-chat__body {
        padding: 16px;
    }

    .saw-chat__form {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .saw-chat__expand {
        display: none;
    }

    /* Lock body scroll */
    body.saw-chat-open {
        overflow: hidden;
    }
}