/* =============================================================================
   updates.css — Styles for the /updates timeline page
   ============================================================================= */

/* ── Hero ──────────────────────────────────────────────────────────────────── */
.page-hero {
    background: var(--bg-dark);
    padding: 5rem 1.5rem 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.page-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 20% 80%, rgba(249, 115, 22, .22) 0%, transparent 70%),
        radial-gradient(ellipse 50% 60% at 80% 20%, rgba(249, 115, 22, .12) 0%, transparent 70%);
    pointer-events: none;
}

.chess-deco {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.page-hero-inner {
    position: relative;
    max-width: 680px;
    margin: 0 auto;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    background: rgba(249, 115, 22, .15);
    border: 1px solid rgba(249, 115, 22, .3);
    color: var(--color-primary-light);
    border-radius: var(--radius-full);
    padding: .35rem 1rem;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: var(--space-lg);
}

.hero-eyebrow svg {
    width: 14px;
    height: 14px;
    stroke: var(--color-primary-light);
    flex-shrink: 0;
}

.page-hero h1 {
    font-size: clamp(2.4rem, 6vw, 3.8rem);
    color: var(--color-white);
    margin-bottom: var(--space-md);
}

.page-hero>.page-hero-inner>p {
    font-size: var(--text-lg);
    color: rgba(255, 255, 255, .6);
    max-width: 520px;
    margin: 0 auto;
}

.btn-subscribe {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    background: var(--color-primary);
    color: var(--color-white);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-full);
    padding: .65rem var(--space-xl);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast);
}

.btn-subscribe:hover {
    opacity: .9;
}

.btn-subscribe:disabled {
    opacity: .6;
    cursor: default;
}

.btn-subscribe svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn-subscribe .subscribe-icon-check {
    display: none;
}

.btn-subscribe.is-subscribed {
    background: transparent;
    border-color: rgba(255, 255, 255, .3);
    color: var(--color-white);
}

.btn-subscribe.is-subscribed .subscribe-icon-bell {
    display: none;
}

.btn-subscribe.is-subscribed .subscribe-icon-check {
    display: inline-flex;
    color: var(--color-success);
}

.btn-subscribe.is-subscribed:hover {
    border-color: #fca5a5;
    background: rgba(239, 68, 68, .12);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.updates-main {
    max-width: 820px;
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-lg) var(--space-5xl);
}

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2xl);
}

.flash svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.flash--ok {
    background: var(--color-success-light);
    border: 1px solid #bbf7d0;
    color: #166534;
}

.flash--err {
    background: var(--color-error-light);
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ── Admin banner ───────────────────────────────────────────────────────────── */
.updates-admin-banner {
    background: linear-gradient(135deg, var(--color-gray-900) 0%, var(--color-gray-800) 100%);
    border: 1px solid rgba(249, 115, 22, .25);
    border-radius: var(--radius-2xl);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-2xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.updates-admin-banner-text h3 {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--color-white);
    margin-bottom: .2rem;
}

.updates-admin-banner-text p {
    font-size: var(--text-sm);
    color: var(--color-gray-400);
    margin: 0;
}

.btn-post-update {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    padding: .65rem var(--space-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.btn-post-update:hover {
    opacity: .88;
    color: var(--color-white);
}

.btn-post-update svg {
    width: 15px;
    height: 15px;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.updates-empty {
    text-align: center;
    padding: var(--space-5xl) var(--space-md);
    color: var(--color-gray-400);
}

.updates-empty-icon {
    width: 52px;
    height: 52px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-lg);
    color: var(--color-gray-400);
}

.updates-empty h3 {
    font-size: var(--text-xl);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.updates-empty p {
    font-size: var(--text-sm);
}

/* ── Timeline ───────────────────────────────────────────────────────────────── */
.timeline {
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 22px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: linear-gradient(to bottom, var(--color-primary) 0%, var(--color-gray-200) 100%);
    border-radius: 2px;
}

/* ── Timeline entry ─────────────────────────────────────────────────────────── */
.tl-entry {
    position: relative;
    padding-left: 64px;
    margin-bottom: var(--space-3xl);
}

.tl-entry:last-child {
    margin-bottom: 0;
}

.tl-dot {
    position: absolute;
    left: 0;
    top: 6px;
    width: 46px;
    height: 46px;
    background: var(--bg-dark);
    border: 3px solid var(--color-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    z-index: 1;
}

.tl-dot svg {
    width: 18px;
    height: 18px;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.tl-card {
    background: var(--bg-primary);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-2xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tl-card-head {
    padding: var(--space-lg) var(--space-xl) var(--space-md);
    border-bottom: 1px solid var(--color-gray-200);
}

.tl-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xs);
    color: var(--color-gray-400);
    font-weight: var(--font-medium);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.tl-meta svg {
    width: 13px;
    height: 13px;
}

.tl-meta-sep {
    color: var(--color-gray-200);
}

.tl-title {
    font-size: var(--text-xl);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    line-height: var(--leading-tight);
}

/* Full update HTML rendered directly */
.tl-content-body {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-gray-200);
    font-size: var(--text-sm);
    color: var(--text-primary);
    line-height: var(--leading-relaxed);
}

/* ── Admin action bar ───────────────────────────────────────────────────────── */
.tl-admin-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--color-gray-200);
}

.btn-tl-action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: .38rem var(--space-md);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-tl-action svg {
    width: 13px;
    height: 13px;
}

.btn-tl-edit {
    background: var(--bg-primary);
    border-color: var(--color-gray-200);
    color: var(--text-secondary);
}

.btn-tl-edit:hover {
    background: var(--bg-secondary);
    border-color: var(--color-gray-300);
    color: var(--text-primary);
}

.btn-tl-del {
    background: var(--bg-primary);
    border-color: #fecaca;
    color: var(--color-error);
}

.btn-tl-del:hover {
    background: var(--color-error-light);
    border-color: #fca5a5;
}

/* ── Preview toggle ─────────────────────────────────────────────────────────── */
.tl-preview-wrap {
    overflow: hidden;
}

.tl-preview-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    cursor: pointer;
    user-select: none;
    background: var(--bg-primary);
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    transition: background var(--transition-fast);
}

.tl-preview-toggle:hover {
    background: var(--bg-secondary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--color-primary);
}

.toggle-label svg {
    width: 14px;
    height: 14px;
}

.toggle-chevron {
    color: var(--color-gray-400);
    transition: transform .25s ease;
}

.toggle-chevron svg {
    width: 16px;
    height: 16px;
}

.tl-preview-toggle[aria-expanded="true"] .toggle-chevron {
    transform: rotate(180deg);
}

.tl-preview-body {
    border-top: 1px solid var(--color-gray-200);
    padding: var(--space-lg);
    background: var(--bg-secondary);
}

.preview-iframe-wrap {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--color-gray-200);
    background: var(--bg-primary);
}

.preview-iframe-wrap iframe {
    width: 100%;
    min-height: 220px;
    border: none;
    display: block;
}

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    transform: translateY(12px);
    transition: transform .2s;
}

.modal-backdrop.open .modal {
    transform: translateY(0);
}

.modal--narrow {
    max-width: 440px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--color-gray-200);
}

.modal-head h3 {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-gray-400);
    padding: var(--space-xs);
    display: flex;
    align-items: center;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: var(--space-xl);
}

/* Form fields */
.f-grp {
    margin-bottom: var(--space-md);
}

.f-grp label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: .02em;
    text-transform: uppercase;
}

.f-grp input,
.f-grp textarea {
    width: 100%;
    border: 1.5px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: .65rem var(--space-md);
    font-size: var(--text-sm);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: border-color var(--transition-fast);
}

.f-grp input:focus,
.f-grp textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.f-grp textarea {
    resize: vertical;
    min-height: 80px;
}

.f-grp textarea.code-area {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    min-height: 200px;
    line-height: var(--leading-relaxed);
}

.f-hint {
    font-size: var(--text-xs);
    color: var(--color-gray-400);
    margin-top: var(--space-xs);
}

/* Live preview pane shown under each HTML textarea */
.live-preview-wrap {
    margin-top: var(--space-sm);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.live-preview-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin: 0;
    padding: .4rem var(--space-sm);
    font-size: 0.7rem;
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--color-gray-400);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--color-gray-200);
}

.live-preview-label svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.live-preview-frame {
    display: block;
    width: 100%;
    min-height: 60px;
    max-height: 320px;
    border: none;
    background: var(--bg-primary);
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--color-gray-200);
}

.btn-modal-cancel {
    padding: .6rem var(--space-lg);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition-fast);
}

.btn-modal-cancel:hover {
    background: var(--bg-secondary);
}

.btn-modal-submit {
    padding: .6rem var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: var(--color-white);
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    cursor: pointer;
    font-family: inherit;
    transition: opacity var(--transition-fast);
}

.btn-modal-submit:hover {
    opacity: .88;
}

.btn-modal-submit--danger {
    background: var(--color-error);
}

.btn-modal-submit--danger:hover {
    opacity: .88;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .updates-main {
        padding: var(--space-xl) var(--space-md) var(--space-4xl);
    }

    .timeline::before {
        left: 18px;
    }

    .tl-entry {
        padding-left: 52px;
    }

    .tl-dot {
        width: 38px;
        height: 38px;
    }

    .updates-admin-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Modals become fullscreen sheets so editor + live preview both have room */
    .modal-backdrop {
        padding: 0;
        align-items: stretch;
    }

    .modal {
        max-width: none;
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-head {
        flex-shrink: 0;
    }

    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: var(--space-md);
    }

    .modal-foot {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: var(--bg-primary);
    }

    .f-grp textarea.code-area {
        min-height: 140px;
    }

    .live-preview-frame {
        max-height: 200px;
    }
}