/* =====================================================
   HONESTLY, E — Storylines (Emory Writing Companion)
   Emory's second-skin layer + storyline/beat styling
   ===================================================== */

/* Emory brand tokens */
:root {
    --emory-slate: #6B7B8C;
    --emory-slate-dark: #4A5A6A;
    --emory-slate-light: #8A9AAA;
    --emory-rainbow: linear-gradient(
        180deg,
        #E74C3C 0%,
        #E67E22 16%,
        #F1C40F 33%,
        #2ECC71 50%,
        #3498DB 66%,
        #9B59B6 83%,
        #E74C3C 100%
    );
}

/* -----------------------------------------------------
   Rainbow Stripe — Emory's signature (right edge)
   ----------------------------------------------------- */
.emory-active::after {
    content: '';
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--emory-rainbow);
    z-index: 9999;
    pointer-events: none;
}

/* -----------------------------------------------------
   Storylines Panel — replaces timeline when Emory active
   ----------------------------------------------------- */
.storylines-panel {
    display: none;
    width: var(--timeline-width, 280px);
    flex-shrink: 0;
    background: var(--bg-card);
    border-left: 1px solid var(--border-light);
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow: hidden;
}

/* Show storylines / hide timeline when Emory is active */
.emory-active .storylines-panel {
    display: flex;
}

.emory-active .timeline-sidebar {
    display: none;
}

.emory-active .timeline-fab {
    display: none !important;
}

/* -----------------------------------------------------
   Storylines Panel Header
   ----------------------------------------------------- */
.storylines-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.storylines-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--text-primary);
    margin: 0;
}

.storylines-add-btn {
    background: none;
    border: 1px solid var(--emory-slate);
    color: var(--emory-slate);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.storylines-add-btn:hover {
    background: var(--emory-slate);
    color: white;
}

/* -----------------------------------------------------
   Storylines List
   ----------------------------------------------------- */
.storylines-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

/* Empty state */
.storylines-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.storylines-empty-icon {
    margin-bottom: 0.75rem;
    opacity: 0.4;
    color: var(--emory-slate);
}

.storylines-empty-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.storylines-empty-text {
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Storyline cards */
.storyline-card {
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    margin-bottom: 0.5rem;
}

.storyline-card:hover {
    background: var(--bg-hover);
}

.storyline-card.active {
    background: var(--bg-secondary);
    border-color: var(--emory-slate-light);
}

.storyline-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.storyline-card-title {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
}

.storyline-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.storyline-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status badges */
.storyline-status-badge {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    white-space: nowrap;
}

.status-idea { background: #E8E4DF; color: var(--text-secondary); }
.status-in_progress { background: #E3EDF7; color: #2A6CB6; }
.status-revision { background: #FFF3E0; color: #B8860B; }
.status-complete { background: #E8F5E9; color: #2E7D32; }
.status-archived { background: #F5F5F5; color: #999; }

.storyline-meta-tag {
    background: var(--bg-secondary);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.storyline-meta-beats {
    color: var(--text-muted);
}

.storyline-structure-badge {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* -----------------------------------------------------
   Storyline Detail View (inside panel)
   ----------------------------------------------------- */
.storyline-detail-header {
    padding: 0 0 0.75rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.75rem;
}

.storyline-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: var(--emory-slate);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.25rem 0;
    margin-bottom: 0.5rem;
    transition: color var(--transition-fast);
}

.storyline-back-btn:hover {
    color: var(--emory-slate-dark);
}

.storyline-detail-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 0.35rem 0;
}

.storyline-detail-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
}

.storyline-detail-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* -----------------------------------------------------
   Beats List
   ----------------------------------------------------- */
.beats-section {
    flex: 1;
}

.beats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.beats-count {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.beats-add-btn {
    background: none;
    border: none;
    color: var(--emory-slate);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.beats-add-btn:hover {
    background: var(--bg-hover);
    color: var(--emory-slate-dark);
}

.beats-empty {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Beat cards */
.beat-card {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.beat-card:hover {
    background: var(--bg-hover);
}

.beat-card-left {
    padding-top: 0.15rem;
    flex-shrink: 0;
}

.beat-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
}

.beat-status-dot.status-idea { background: transparent; border-color: var(--text-muted); }
.beat-status-dot.status-drafted { background: #E3EDF7; border-color: #2A6CB6; }
.beat-status-dot.status-revised { background: #FFF3E0; border-color: #B8860B; }
.beat-status-dot.status-done { background: #E8F5E9; border-color: #2E7D32; }

.beat-card-content {
    flex: 1;
    min-width: 0;
}

.beat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
}

.beat-card-label {
    font-family: var(--font-serif);
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.beat-type-badge {
    font-family: var(--font-sans);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    padding: 0.1rem 0.3rem;
    background: var(--bg-secondary);
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.beat-card-notes {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.beat-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.beat-entry-count {
    color: var(--emory-slate);
}

/* -----------------------------------------------------
   Add Beat Form (inline)
   ----------------------------------------------------- */
.beat-add-form {
    padding: 0.6rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-light);
}

.beat-add-input {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text-primary);
    box-sizing: border-box;
}

.beat-add-input:focus {
    outline: none;
    border-color: var(--emory-slate);
}

.beat-add-options {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.beat-add-select {
    flex: 1;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: var(--bg-card);
    color: var(--text-primary);
}

.beat-add-save, .beat-add-cancel {
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    font-family: var(--font-sans);
}

.beat-add-save {
    background: var(--emory-slate);
    color: white;
}

.beat-add-save:hover {
    background: var(--emory-slate-dark);
}

.beat-add-cancel {
    background: none;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}

.beat-add-cancel:hover {
    background: var(--bg-hover);
}

/* -----------------------------------------------------
   Create Storyline Modal
   ----------------------------------------------------- */
#modal-create-storyline .modal {
    max-width: 480px;
}

/* -----------------------------------------------------
   Mobile: hide storylines panel, show as drawer
   ----------------------------------------------------- */
@media (max-width: 1024px) {
    .storylines-panel {
        display: none !important;
    }

    /* On mobile when Emory is active, show a FAB for storylines */
    .emory-active .storylines-fab {
        display: flex;
    }
}

/* Storylines FAB (mobile, Emory-only) */
.storylines-fab {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: var(--emory-slate);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(75, 90, 106, 0.3);
    z-index: 100;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.storylines-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(75, 90, 106, 0.4);
}

/* Storylines Drawer (mobile) */
.storylines-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 200;
    max-height: 80vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.storylines-drawer.active {
    transform: translateY(0);
}

@media (max-width: 1024px) {
    .storylines-drawer {
        display: block;
    }
}

.storylines-drawer-handle {
    width: 40px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    margin: 0.75rem auto;
}

.storylines-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.storylines-drawer-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-primary);
}

.storylines-drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.storylines-drawer-content {
    padding: 1rem 1.25rem 2rem;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* =====================================================
   STORY BEAT TILE — Center column card (Emory feed)
   ===================================================== */

.story-beat-tile {
    display: flex;
    background: var(--bg-card, #fff);
    border: 1px solid rgba(107, 123, 140, 0.2);
    border-radius: 12px;
    overflow: hidden;
    cursor: default;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 0.75rem;
}

.story-beat-tile:hover {
    border-color: var(--emory-slate);
    box-shadow: 0 2px 8px rgba(107, 123, 140, 0.1);
}

.story-beat-tile-accent {
    width: 4px;
    background: var(--emory-rainbow);
    flex-shrink: 0;
}

.story-beat-tile-body {
    padding: 1rem 1.25rem;
    flex: 1;
    min-width: 0;
}

.story-beat-tile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.story-beat-tile-type {
    font-size: 11px;
    font-family: var(--font-sans, sans-serif);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--emory-slate);
}

.story-beat-tile-status {
    font-size: 12px;
    color: var(--emory-slate-light);
    font-family: var(--font-sans, sans-serif);
}

.story-beat-tile-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary, #2C2420);
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.story-beat-tile-notes {
    font-size: 14px;
    color: var(--text-secondary, #5C534A);
    line-height: 1.5;
    margin-top: 0.35rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-beat-tile-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 12px;
    font-family: var(--font-sans, sans-serif);
}

.story-beat-tile-links {
    color: var(--text-muted, #8B8279);
}
