/* ============================================================
   WRITINGS PAGE — writings.css
   Inherits all CSS variables from base/global stylesheet.
   ============================================================ */

/* ============================================================
   HERO
   ============================================================ */
.writings-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52vh;
    min-height: 320px;
    overflow: hidden;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(15, 40, 84, 0.82) 0%,
        rgba(28, 77, 141, 0.70) 60%,
        rgba(73, 136, 196, 0.50) 100%
    );
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 1rem;
    color: var(--color-white);
}

.hero-eyebrow {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 100px;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.hero-title {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    color: var(--color-white);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 16px rgba(0,0,0,0.25);
    line-height: 1.15;
}

.hero-sub {
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    color: rgba(255,255,255,0.82);
    margin-bottom: 1.75rem;
}

.hero-cta {
    font-size: 1rem;
    padding: 0.75rem 1.75rem;
    border-radius: 100px;
    letter-spacing: 0.02em;
    background-color: var(--color-background);
    color: var(--color-text);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.writings-layout {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ============================================================
   CATEGORY TABS
   ============================================================ */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid rgba(73,136,196,0.18);
    padding-bottom: 0;
}

.cat-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    position: relative;
}

.cat-tab:hover {
    color: var(--color-secondary);
    background: rgba(73,136,196,0.06);
}

.cat-tab.active {
    color: var(--color-secondary);
    border-bottom-color: var(--color-secondary);
    background: rgba(28,77,141,0.06);
    font-weight: 600;
}

.cat-icon { font-size: 1.05rem; }
.cat-label { }

.cat-badge {
    background: var(--color-accent);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    min-width: 22px;
    text-align: center;
}

.cat-tab.active .cat-badge {
    background: var(--color-secondary);
}

/* ============================================================
   SUB-CATEGORY PILLS
   ============================================================ */
.subcategory-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 0.75rem 0;
}

.sub-pill {
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-secondary);
    background: rgba(73,136,196,0.1);
    border: 1px solid rgba(73,136,196,0.25);
    text-decoration: none;
    transition: all 0.18s ease;
}

.sub-pill:hover {
    background: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
}

.sub-pill.active {
    background: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.writings-search-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-form { flex: 1; min-width: 260px; }

.search-input-wrap {
    display: flex;
    align-items: center;
    background: white;
    border: 1.5px solid rgba(73,136,196,0.3);
    border-radius: 100px;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
    transition: border-color 0.2s;
}

.search-input-wrap:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(73,136,196,0.12);
}

.search-icon { font-size: 0.95rem; color: var(--color-muted); }

.search-field {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--color-text);
    padding: 0;
}
.search-field:focus{
    background-color: transparent;
}
.search-field::placeholder { color: var(--color-muted); }

.clear-search {
    color: var(--color-muted);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.1rem 0.4rem;
    border-radius: 50%;
}
.clear-search:hover { background: rgba(0,0,0,0.06); }

.result-count {
    font-size: 0.85rem;
    color: var(--color-muted);
    white-space: nowrap;
}

/* ============================================================
   WRITINGS GRID
   ============================================================ */
.writings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* ── Writing Card ─────────────────────────────────────────── */
.writing-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid rgba(73,136,196,0.12);
    box-shadow: var(--shadow-sm);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    position: relative;
    overflow: hidden;
}

.writing-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.writing-card--story::before  { background: linear-gradient(to bottom, #1c4d8d, #4988c4); }
.writing-card--poem::before   { background: linear-gradient(to bottom, #e879a0, #f9a8d4); }
.writing-card--thought::before { background: linear-gradient(to bottom, #16a34a, #86efac); }

.writing-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

/* Card Top */
.card-top { flex: 1; }

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.card-cat-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.7rem;
    border-radius: 100px;
    text-transform: capitalize;
}

.cat-story   { background: rgba(28,77,141,0.1);  color: var(--color-secondary); }
.cat-poem    { background: rgba(232,121,160,0.12); color: #be185d; }
.cat-thought { background: rgba(22,163,74,0.1);   color: #15803d; }

.card-date {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.card-title {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.6rem;
    color: var(--color-primary);
}

.card-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.18s;
}
.card-title a:hover { color: var(--color-secondary); }

.card-excerpt {
    font-size: 0.875rem;
    color: var(--color-muted);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid rgba(73,136,196,0.1);
}

.card-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(73,136,196,0.2);
}

.author-avatar-placeholder {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.author-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text);
}

.card-stats {
    display: flex;
    gap: 0.75rem;
}

.stat {
    font-size: 0.78rem;
    color: var(--color-muted);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--color-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-family: 'Lora', serif;
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ============================================================
   FLOATING ACTION BUTTON
   ============================================================ */
.fab-write {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(28,77,141,0.4);
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 100;
    display: none; /* shown only on mobile via media query */
}

.fab-write:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(28,77,141,0.5);
}

/* ============================================================
   EDITOR PAGE
   ============================================================ */
.editor-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

.editor-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(73,136,196,0.12);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Inherit input/select styles from global but refine */
.writing-input,
.writing-select,
.writing-textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1.5px solid rgba(73,136,196,0.25);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--color-text);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.writing-input:focus,
.writing-select:focus,
.writing-textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(73,136,196,0.12);
    background: white;
}

.writing-textarea {
    resize: vertical;
    font-family: 'Lora', Georgia, serif;
    font-size: 1rem;
    line-height: 1.8;
}

.writing-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.char-counter {
    text-align: right;
    font-size: 0.78rem;
    color: var(--color-muted);
    margin-top: 0.4rem;
}

.form-error {
    display: block;
    font-size: 0.8rem;
    color: #ef4444;
    margin-top: 0.35rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* ── Tips sidebar ───────────────────────────────────────────── */
.tips-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid rgba(73,136,196,0.12);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.tips-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-left: 1rem;
}

.tips-list li {
    font-size: 0.85rem;
    color: var(--color-muted);
    list-style: disc;
    line-height: 1.55;
}

.guide-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.guide-icon { font-size: 1.3rem; flex-shrink: 0; }

.guide-item strong {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text);
    margin-bottom: 0.15rem;
}

.guide-item p {
    font-size: 0.78rem;
    color: var(--color-muted);
    line-height: 1.5;
}

/* ============================================================
   DETAIL PAGE
   ============================================================ */
.detail-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2.5rem;
    align-items: start;
}

.detail-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-bottom: 1.5rem;
}

.detail-breadcrumb a {
    color: var(--color-secondary);
    text-decoration: none;
}
.detail-breadcrumb a:hover { text-decoration: underline; }
.detail-breadcrumb span { color: var(--color-muted); }

.detail-header {
    margin-bottom: 2rem;
}

.detail-title {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.25;
    margin: 0.75rem 0 1.25rem;
}

.detail-author-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.detail-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(73,136,196,0.25);
}

.detail-avatar-placeholder {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--color-secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.detail-author-info {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.detail-author-info strong { color: var(--color-text); font-size: 0.925rem; }

.detail-stats {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* Writing body */
.detail-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--color-text);
    border-top: 1px solid rgba(73,136,196,0.12);
    padding-top: 2rem;
    margin-bottom: 2.5rem;
}

/* Poem gets special formatting */
.writing-poem {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    line-height: 2.1;
    font-style: italic;
}

.writing-story {
    font-family: 'Lora', Georgia, serif;
    text-align: justify;
}

.writing-thought {
    font-size: 1.15rem;
    line-height: 1.85;
    background: rgba(73,136,196,0.04);
    border-left: 4px solid var(--color-accent);
    padding: 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Detail actions */
.detail-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid rgba(73,136,196,0.12);
}

.like-writing-btn.liked {
    background: #fce7f3;
    border-color: #f9a8d4;
    color: #be185d;
}

/* Sidebar */
.related-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid rgba(73,136,196,0.12);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 1.5rem;
}

.related-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(73,136,196,0.12);
}

.related-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(73,136,196,0.08);
    text-decoration: none;
    transition: padding-left 0.2s;
}

.related-item:hover { padding-left: 0.5rem; }
.related-item:last-child { border-bottom: none; }

.related-sub  { font-size: 0.72rem; color: var(--color-accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.related-name { font-size: 0.9rem; font-weight: 600; color: var(--color-text); font-family: 'Lora', serif; }
.related-author { font-size: 0.78rem; color: var(--color-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .editor-layout,
    .detail-layout {
        display: flex;
        flex-direction: column-reverse;
        padding: 0;
    }

    .editor-sidebar,
    .editor-main{
        width: 100%;
    }
    .editor-sidebar,
    .detail-sidebar {
        order: -1;
    }

    .related-card {
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .related-title { width: 100%; }

    .related-item {
        background: rgba(73,136,196,0.05);
        border-radius: var(--radius-md);
        border-bottom: none;
        padding: 0.65rem 0.75rem;
        min-width: 160px;
        flex: 1;
    }
}

@media (max-width: 640px) {
    .writings-layout { padding: 0; }

    .writings-grid {
        grid-template-columns: 1fr;
    }

    .category-tabs {
        gap: 0.25rem;
    }

    .cat-tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.82rem;
    }

    .cat-label { display: none; }

    .fab-write { display: flex; }

    .writings-search-bar { flex-direction: column; align-items: stretch; }

    .form-row { grid-template-columns: 1fr; }

    .detail-actions { flex-direction: column; }

    .hero-title { font-size: 1.8rem; }
}