/**
 * Novara — Premium Polish Stylesheet (v7.0.0)
 *
 * Final flagship refinement pass. Refines existing identity (no redesign):
 *  - Cohesive elevation tokens
 *  - Branded skeleton loaders
 *  - Premium empty states
 *  - Universal focus ring
 *  - Smoother hover transitions
 *  - Consistent dark-mode coverage
 *  - Edge-case spacing fixes
 *  - Refined typography rhythm
 *  - Loading state polish across components
 *
 * Loads LAST so it can fine-tune all preceding styles.
 *
 * @package Novara
 * @since 7.0.0
 */

/* ===================================================================
   1. ELEVATION TOKENS  — cohesive shadow scale
   =================================================================== */
:root {
    --novara-elev-0: none;
    --novara-elev-1: 0 1px 2px rgba(15, 15, 22, 0.04), 0 1px 1px rgba(15, 15, 22, 0.03);
    --novara-elev-2: 0 2px 4px rgba(15, 15, 22, 0.06), 0 1px 2px rgba(15, 15, 22, 0.04);
    --novara-elev-3: 0 4px 12px rgba(15, 15, 22, 0.08), 0 2px 4px rgba(15, 15, 22, 0.04);
    --novara-elev-4: 0 8px 24px rgba(15, 15, 22, 0.10), 0 4px 8px rgba(15, 15, 22, 0.05);
    --novara-elev-5: 0 16px 40px rgba(15, 15, 22, 0.14), 0 6px 14px rgba(15, 15, 22, 0.06);

    /* Brand glow — subtle crimson-tinted shadow for emphasis */
    --novara-glow-soft: 0 6px 24px rgba(230, 57, 70, 0.12);
    --novara-glow-strong: 0 8px 28px rgba(230, 57, 70, 0.28);

    /* Universal motion curve (Apple's "spring") */
    --novara-ease: cubic-bezier(0.32, 0.72, 0, 1);
    --novara-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --novara-dur-fast: 160ms;
    --novara-dur-base: 220ms;
    --novara-dur-slow: 360ms;
}

[data-theme="dark"] {
    --novara-elev-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
    --novara-elev-2: 0 2px 6px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --novara-elev-3: 0 6px 16px rgba(0, 0, 0, 0.48), 0 2px 6px rgba(0, 0, 0, 0.3);
    --novara-elev-4: 0 10px 28px rgba(0, 0, 0, 0.55), 0 4px 10px rgba(0, 0, 0, 0.32);
    --novara-elev-5: 0 18px 48px rgba(0, 0, 0, 0.65), 0 8px 18px rgba(0, 0, 0, 0.4);
}

/* ===================================================================
   2. UNIVERSAL FOCUS RING  — accessibility + polish
   =================================================================== */
*:focus-visible {
    outline: 2px solid var(--novara-crimson, #E63946);
    outline-offset: 3px;
    border-radius: 4px;
    transition: outline-offset var(--novara-dur-fast) var(--novara-ease);
}
button:focus-visible,
a:focus-visible {
    outline-offset: 3px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline-offset: 0;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2);
}

/* ===================================================================
   3. REFINED HOVER STATES  — smoother, branded
   =================================================================== */
a,
button,
.novara-card,
.novara-search-result,
.novara-search-chip,
.novara-suggestion,
.novara-suggestion-tag,
.novara-admin-card,
.novara-icon-btn {
    transition:
        transform var(--novara-dur-fast) var(--novara-ease),
        box-shadow var(--novara-dur-fast) var(--novara-ease),
        background-color var(--novara-dur-fast) var(--novara-ease),
        color var(--novara-dur-fast) var(--novara-ease),
        border-color var(--novara-dur-fast) var(--novara-ease),
        opacity var(--novara-dur-fast) var(--novara-ease);
}

.novara-card:hover,
.novara-admin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--novara-elev-3);
}

.novara-search-result:hover,
.novara-suggestion:hover,
.novara-suggestion-tag:hover {
    transform: translateX(2px);
}

/* Buttons: lift + glow on hover */
.button-primary:hover,
.novara-newsletter__btn:hover,
.novara-search-view-all:hover {
    box-shadow: var(--novara-glow-soft);
    transform: translateY(-1px);
}

/* Active press effect */
button:active,
.button-primary:active,
.novara-icon-btn:active {
    transform: translateY(0) scale(0.985);
}

/* ===================================================================
   4. SKELETON LOADERS  — branded shimmer
   =================================================================== */
.novara-skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.04) 0%,
        rgba(0, 0, 0, 0.08) 50%,
        rgba(0, 0, 0, 0.04) 100%
    );
    background-size: 200% 100%;
    animation: novara-skeleton-pulse 1.4s linear infinite;
    border-radius: 6px;
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}
.novara-skeleton--title  { height: 18px; width: 80%; margin-bottom: 8px; }
.novara-skeleton--text   { height: 12px; width: 100%; margin-bottom: 6px; }
.novara-skeleton--thumb  { aspect-ratio: 16 / 9; width: 100%; }
.novara-skeleton--avatar { width: 40px; height: 40px; border-radius: 50%; }
.novara-skeleton--chip   { height: 28px; width: 80px; border-radius: 20px; display:inline-block; margin-right:8px; }

@keyframes novara-skeleton-pulse {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

[data-theme="dark"] .novara-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 100%
    );
}

@media (prefers-reduced-motion: reduce) {
    .novara-skeleton { animation: none; }
}

/* Pre-baked skeleton card (drop-in replacement during loading) */
.novara-skeleton-card {
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--novara-elev-1);
}
.novara-skeleton-card__media { padding: 0; }
.novara-skeleton-card__body  { padding: 16px; }

/* ===================================================================
   5. PREMIUM EMPTY STATES
   =================================================================== */
.novara-empty {
    text-align: center;
    padding: 56px 24px;
    max-width: 520px;
    margin: 0 auto;
}
.novara-empty__icon {
    font-size: 56px;
    margin-bottom: 18px;
    opacity: 0.5;
    filter: grayscale(0.2);
    animation: novara-empty-pop 600ms var(--novara-ease-out) both;
}
.novara-empty__title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 22px;
    margin: 0 0 8px;
    color: var(--text-primary, #15151C);
}
.novara-empty__desc {
    font-size: 14px;
    color: var(--text-muted, #888);
    line-height: 1.6;
    margin: 0 auto 18px;
    max-width: 380px;
}
.novara-empty__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--novara-crimson, #E63946);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

@keyframes novara-empty-pop {
    from { transform: scale(0.86); opacity: 0; }
    to   { transform: scale(1);    opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
    .novara-empty__icon { animation: none; }
}

/* ===================================================================
   6. PAGE ENTRY ANIMATION  — subtle fade-up
   =================================================================== */
.novara-main {
    animation: novara-page-enter 480ms var(--novara-ease-out) both;
}

@keyframes novara-page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .novara-main { animation: none; }
}

/* ===================================================================
   7. CARD VISUAL HIERARCHY  — spacing rhythm
   =================================================================== */
.novara-card {
    box-shadow: var(--novara-elev-1);
    border-radius: 12px;
    background: var(--bg-primary, #fff);
}
.novara-card__title {
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.novara-card__excerpt {
    margin-top: 6px;
    color: var(--text-secondary, #555);
}
.novara-card__meta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, #eef0f3);
    font-size: 11.5px;
}

/* ===================================================================
   8. DARK MODE — COVERAGE POLISH
   =================================================================== */
[data-theme="dark"] {
    --bg-primary:   #0F0F14;
    --bg-secondary: #181820;
    --text-primary:   #ffffff;
    --text-secondary: rgba(255,255,255,0.78);
    --text-muted:     rgba(255,255,255,0.55);
    --border-color:   rgba(255,255,255,0.08);
}
[data-theme="dark"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}
[data-theme="dark"] .novara-card,
[data-theme="dark"] .novara-admin-card,
[data-theme="dark"] .novara-search-section,
[data-theme="dark"] .novara-empty {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
[data-theme="dark"] .novara-card__meta,
[data-theme="dark"] .novara-card__excerpt {
    color: var(--text-secondary);
}
[data-theme="dark"] hr {
    border-color: var(--border-color);
}
[data-theme="dark"] .novara-empty__title {
    color: var(--text-primary);
}
[data-theme="dark"] .novara-empty__desc {
    color: var(--text-muted);
}

/* ===================================================================
   9. LOADING STATE POLISH — across components
   =================================================================== */
.novara-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--novara-crimson, #E63946), transparent);
    background-size: 200% 100%;
    z-index: 99999;
    animation: novara-loading-sweep 1.2s linear infinite;
    pointer-events: none;
}
@keyframes novara-loading-sweep {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ===================================================================
   10. TRANSITIONS — page exit handled by SPA-router class
   =================================================================== */
.novara-spa-exiting .novara-main {
    opacity: 0.5;
    transition: opacity 120ms var(--novara-ease);
}

/* ===================================================================
   11. EDGE-CASE TYPOGRAPHY FIXES
   =================================================================== */
/* Long words / URLs in cards shouldn't break layout */
.novara-card__title,
.novara-search-result__title,
.novara-card__excerpt {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* Drop quotes are stylized */
blockquote {
    quotes: "“" "”" "‘" "’";
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.18em;
    line-height: 1.55;
    border-inline-start: 4px solid var(--novara-crimson, #E63946);
    padding: 8px 22px;
    margin: 24px 0;
    color: var(--text-secondary, #555);
}

/* ===================================================================
   12. RESPONSIVE POLISH
   =================================================================== */
@media (max-width: 480px) {
    .novara-empty { padding: 40px 20px; }
    .novara-empty__icon { font-size: 44px; }
    .novara-empty__title { font-size: 19px; }
    .novara-card__meta { font-size: 11px; }
}

/* ===================================================================
   13. PRINT-FRIENDLY (premium publishers print articles)
   =================================================================== */
@media print {
    .novara-header,
    .novara-footer,
    .novara-sidebar,
    .novara-share-sticky,
    .novara-mobile-ad-sticky,
    .novara-ad,
    .novara-scroll-top,
    .novara-bottom-nav,
    .novara-search-overlay {
        display: none !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .novara-post-content {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.5;
    }
    .novara-post-content a::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #555;
    }
}

/* ===================================================================
   14. ACCESSIBILITY ENHANCEMENTS
   =================================================================== */
.screen-reader-text,
.visually-hidden {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    -webkit-clip-path: inset(50%);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}
.screen-reader-text:focus {
    background: var(--novara-crimson, #E63946);
    color: #fff;
    clip: auto !important;
    clip-path: none;
    height: auto;
    padding: 10px 16px;
    width: auto;
    z-index: 100000;
}

/* High contrast preference */
@media (prefers-contrast: more) {
    .novara-card,
    .novara-search-result {
        border: 1px solid var(--text-primary, #000);
    }
}

/* ===================================================================
   15. FINAL TOUCHES — image rendering, selection color
   =================================================================== */
::selection {
    background: var(--novara-crimson, #E63946);
    color: #fff;
}
::-moz-selection {
    background: var(--novara-crimson, #E63946);
    color: #fff;
}

img {
    max-width: 100%;
    height: auto;
    image-rendering: auto;
}
