/* ==========================================================================
   Shaho Theme — Minimal RTL Ghost theme for Persian writing
   ========================================================================== */

/* Variables */
:root {
    /* Palette: warm paper + ink + deep crimson */
    --color-bg: #f7f5f1;
    --color-surface: #ffffff;
    --color-text: #1c1917;
    --color-text-muted: #5c5046;
    --color-text-light: #9a8e82;
    --color-accent: #9b2335;
    --color-accent-hover: #7d1c2a;
    --color-border: #e4ddd5;
    --color-hover: #f0ebe3;
    --color-hero-bg: #111111;

    --font-body: 'Vazirmatn', system-ui, sans-serif;
    --font-size-base: 18px;
    --line-height-base: 2.1;
    --line-height-heading: 1.35;

    --max-width: 760px;
    --max-width-wide: 1100px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;
    --spacing-xl: 6rem;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

/* Base */
html {
    direction: rtl;
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.site-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-main { flex: 1; }

.page-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-sm);
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-inner {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.site-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.site-logo img {
    height: 36px;
    width: auto;
}

.site-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

/* Navigation */
.site-nav ul {
    list-style: none;
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
}

.site-nav a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color 0.15s ease;
    white-space: nowrap;
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
}

/* ==========================================================================
   Homepage Hero — stark, like a Bergman title card
   ========================================================================== */

.site-hero {
    background: var(--color-hero-bg);
    color: #fff;
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Rotating cinematic GIF hero — 8 layers, 5s each, 40s cycle
   GIFs are chaos / cinema / poetry — matching the site's name آشوب
   ========================================================================== */

/* Dark cinematic overlay — makes text legible over any GIF */
.site-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 1;
    pointer-events: none;
}

/* Each GIF layer: positioned behind the overlay */
.hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    opacity: 0;
    animation: heroSlide 40s infinite;
}

/* 8 GIFs × 5 s each = 40 s cycle
   Negative delays stagger the start points evenly.
   Layer 1 (no delay) is visible at t=0; each subsequent layer enters 5 s later. */
.hero-bg-1 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/Trajektorie_eines_Doppelpendels.gif');
    animation-delay: 0s;
}
.hero-bg-2 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/band-of-outsiders-jean-luc-godard-cinematheia.gif');
    animation-delay: -35s;
}
.hero-bg-3 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/MammaRomaFinale_zpse8e5ec4f.gif');
    animation-delay: -30s;
}
.hero-bg-4 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/tumblr_nwa9v71fB81sf2a1uo2_500.gif');
    animation-delay: -25s;
}
.hero-bg-5 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/tumblr_mpbhvrB5Rl1s36zono1_500.gif');
    animation-delay: -20s;
}
.hero-bg-6 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/cropped-Salo-4.gif');
    animation-delay: -15s;
}
.hero-bg-7 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/285ec07184c7b72def784fc2deacc87e.gif');
    animation-delay: -10s;
}
.hero-bg-8 {
    background-image: url('https://ashuob.com/content/images/wp-uploads/2017/02/tumblr_noz0ejmzNE1qghl49o1_r1_540.gif');
    animation-delay: -5s;
}

/* Each layer is opaque for 12 % of the cycle (~4.8 s), then fades to black
   over the next 3 % (~1.2 s), then stays hidden until its next turn. */
@keyframes heroSlide {
    0%, 12%   { opacity: 1; }
    15%, 100% { opacity: 0; }
}

.site-hero-inner {
    position: relative;
    z-index: 2;
    max-width: 580px;
    margin: 0 auto;
}

.site-hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: var(--spacing-sm);
    color: #ffffff;
}

.site-hero-desc {
    font-size: 1rem;
    font-weight: 300;
    color: rgba(255,255,255,0.55);
    max-width: 420px;
    margin: 0 auto var(--spacing-md);
    line-height: 1.9;
    letter-spacing: 0.01em;
}

/* Thin ornamental rule under the description */
.site-hero-rule {
    width: 40px;
    height: 2px;
    background: var(--color-accent);
    margin: 0 auto;
    opacity: 0.8;
}

/* ==========================================================================
   Post feed — editorial card grid
   ========================================================================== */

.post-feed {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    max-width: var(--max-width-wide);
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

/* Card container */
.post-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

.post-card:hover {
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.09);
    transform: translateY(-3px);
    border-color: #d4cbbf;
}

/* Full-card clickable link */
.post-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
}

/* ── Media area ───────────────────────────────────────────────────────────── */

.post-card-media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #1c1714;
    overflow: hidden;
    flex-shrink: 0;
}

/* Diagonal stripe texture on no-image cards — subtle, not loud */
.post-card-media::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -55deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.025) 10px,
        rgba(255, 255, 255, 0.025) 11px
    );
    z-index: 0;
}

.post-card-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
    transition: transform 0.45s ease;
}

.post-card:hover .post-card-image {
    transform: scale(1.05);
}

/* Tag badge — overlaid on the media area */
.post-card-tag {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-sm);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #fff;
    background: var(--color-accent);
    padding: 0.28em 0.75em;
    z-index: 2;
    transition: background 0.15s ease;
}

.post-card:hover .post-card-tag {
    background: var(--color-accent-hover);
}

/* ── Body area ────────────────────────────────────────────────────────────── */

.post-card-body {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.post-card-title {
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--color-text);
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}

.post-card:hover .post-card-title {
    color: var(--color-accent);
}

.post-card-excerpt {
    font-size: 0.845rem;
    color: var(--color-text-muted);
    line-height: 1.75;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.post-card-date {
    font-size: 0.72rem;
    color: var(--color-text-light);
    font-weight: 400;
    letter-spacing: 0.04em;
    margin-top: auto;
    padding-top: 0.4rem;
    border-top: 1px solid var(--color-border);
}

/* ── Featured first post — spans all columns on desktop ───────────────────── */

.post-card:first-child {
    grid-column: 1 / -1;
    border-color: #d8d0c6;
}

.post-card:first-child .post-card-link {
    flex-direction: row;
}

.post-card:first-child .post-card-media {
    width: 52%;
    aspect-ratio: auto;
    min-height: 300px;
    flex-shrink: 0;
}

.post-card:first-child .post-card-body {
    padding: var(--spacing-lg) var(--spacing-lg);
    justify-content: center;
}

.post-card:first-child .post-card-title {
    font-size: 1.75rem;
    line-height: 1.4;
    -webkit-line-clamp: 4;
}

.post-card:first-child .post-card-excerpt {
    font-size: 0.95rem;
    -webkit-line-clamp: 3;
    line-height: 1.85;
}

.post-card:first-child .post-card-date {
    font-size: 0.78rem;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-sm);
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
}

.pagination a {
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 3px;
    transition: all 0.15s ease;
}

.pagination a:hover {
    background: var(--color-hover);
    color: var(--color-text);
    border-color: #c8bfb4;
}

.pagination .page-number { color: var(--color-text-light); }

/* ==========================================================================
   Single Post
   ========================================================================== */

.full-post {
    padding-top: var(--spacing-lg);
    padding-bottom: var(--spacing-xl);
}

.post-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.post-title {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: var(--line-height-heading);
    letter-spacing: -0.025em;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.post-meta {
    font-size: 0.82rem;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.post-meta-sep { opacity: 0.35; }

.post-tag {
    color: var(--color-accent);
    font-weight: 500;
    transition: opacity 0.15s ease;
}

.post-tag:hover { opacity: 0.7; }

.post-excerpt {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    line-height: 1.9;
    margin-top: var(--spacing-sm);
    font-style: italic;
}

.post-feature-image {
    margin: 0 0 var(--spacing-lg);
    border-radius: 4px;
    overflow: hidden;
}

.post-feature-image img {
    width: 100%;
    max-height: 480px;
    object-fit: cover;
}

/* Post content typography */
.post-content {
    font-size: 1.05rem;
    line-height: 2.15;
    color: var(--color-text);
}

.post-content p { margin-bottom: 1.7em; }

.post-content h2 {
    font-size: 1.45rem;
    font-weight: 800;
    margin: 2.2em 0 0.75em;
    line-height: var(--line-height-heading);
    letter-spacing: -0.02em;
    padding-bottom: 0.4em;
    border-bottom: 2px solid var(--color-border);
}

.post-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 1.8em 0 0.6em;
    letter-spacing: -0.015em;
}

.post-content h4, .post-content h5, .post-content h6 {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.5em 0 0.5em;
}

.post-content a {
    color: var(--color-accent);
    border-bottom: 1px solid currentColor;
    transition: opacity 0.15s ease;
}

.post-content a:hover { opacity: 0.7; }

.post-content strong { font-weight: 700; }
.post-content em { font-style: italic; }

.post-content ul, .post-content ol {
    padding-right: 2em;
    margin-bottom: 1.5em;
}

.post-content li { margin-bottom: 0.5em; }

/* Blockquote — dramatic, full-width feel */
.post-content blockquote {
    border-right: 3px solid var(--color-accent);
    margin: 2.5em 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 1.05rem;
    line-height: 2;
    position: relative;
}

.post-content blockquote p:last-child { margin-bottom: 0; }

/* Poetry / pre blocks — preserve line breaks */
.post-content pre {
    font-family: var(--font-body);
    white-space: pre-wrap;
    word-wrap: break-word;
    background: var(--color-hover);
    border: 1px solid var(--color-border);
    border-right: 3px solid var(--color-border);
    border-radius: 3px;
    padding: var(--spacing-md) var(--spacing-md);
    font-size: 1rem;
    line-height: 2.3;
    margin: 1.8em 0;
    color: var(--color-text);
}

.post-content code {
    font-family: var(--font-body);
    background: var(--color-hover);
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.95em;
}

.post-content figure { margin: 2.5em 0; }

.post-content figcaption {
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-light);
    margin-top: var(--spacing-xs);
    font-style: italic;
}

.post-content hr {
    border: none;
    text-align: center;
    margin: 3em 0;
    letter-spacing: 0.4em;
    color: var(--color-text-light);
    font-size: 0.8rem;
}

.post-content hr::after {
    content: '* * *';
}

/* Post footer */
.post-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* Post tags in footer */
.post-footer-tags {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.post-footer-tag {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    padding: 0.2em 0.7em;
    border-radius: 2px;
    transition: all 0.15s ease;
}

.post-footer-tag:hover {
    background: var(--color-hover);
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.back-link {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    transition: color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.35em;
}

.back-link:hover { color: var(--color-accent); }

/* ==========================================================================
   Tag archive pages
   ========================================================================== */

.page-header {
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: var(--line-height-heading);
    letter-spacing: -0.025em;
    margin-bottom: var(--spacing-xs);
}

.page-description {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* ==========================================================================
   Static page
   ========================================================================== */

.page .post-header {
    text-align: right;
}

/* ==========================================================================
   Error page
   ========================================================================== */

.error-page {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
}

.error-code {
    font-size: 5rem;
    font-weight: 300;
    color: var(--color-border);
    line-height: 1;
    margin-bottom: var(--spacing-sm);
}

.error-message {
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
}

.error-link {
    color: var(--color-accent);
    border-bottom: 1px solid currentColor;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    border-top: 1px solid var(--color-border);
    background: var(--color-hero-bg);
    color: rgba(255,255,255,0.45);
    padding: var(--spacing-md);
}

.site-footer-inner {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    font-size: 0.82rem;
}

.site-footer-brand {
    font-weight: 700;
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    letter-spacing: -0.01em;
}

.site-footer-copy {
    color: rgba(255,255,255,0.3);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet: 2-col grid, first post goes horizontal across both */
@media (max-width: 999px) {
    .post-feed {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    /* First post: still full-width horizontal on tablet */
    .post-card:first-child {
        grid-column: 1 / -1;
    }

    .post-card:first-child .post-card-media {
        min-height: 220px;
    }

    .post-card:first-child .post-card-title {
        font-size: 1.4rem;
    }

    .post-card:first-child .post-card-body {
        padding: var(--spacing-md);
    }
}

/* Mobile: single column, first post goes back to vertical */
@media (max-width: 599px) {
    :root {
        --font-size-base: 16px;
    }

    .site-header-inner {
        padding: var(--spacing-sm);
        flex-wrap: wrap;
    }

    .site-hero-title {
        font-size: 2.4rem;
    }

    .post-title {
        font-size: 1.6rem;
    }

    .post-feed {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: var(--spacing-md) var(--spacing-sm);
    }

    /* First post collapses to vertical on mobile */
    .post-card:first-child .post-card-link {
        flex-direction: column;
    }

    .post-card:first-child .post-card-media {
        width: 100%;
        aspect-ratio: 16 / 9;
        min-height: auto;
    }

    .post-card:first-child .post-card-body {
        padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
        justify-content: flex-start;
    }

    .post-card:first-child .post-card-title {
        font-size: 1.2rem;
    }

    /* No lift on touch */
    .post-card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ==========================================================================
   Ghost built-ins
   ========================================================================== */

.kg-card { margin: 2em 0; }
.kg-image-card img { border-radius: 4px; width: 100%; }
.kg-gallery-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.kg-gallery-row { display: contents; }
.kg-gallery-image img { width: 100%; height: 200px; object-fit: cover; border-radius: 3px; }
.kg-embed-card { display: flex; justify-content: center; }
.kg-bookmark-card { border: 1px solid var(--color-border); border-radius: 4px; overflow: hidden; }
.kg-bookmark-container { display: flex; padding: var(--spacing-sm); gap: var(--spacing-sm); }
.kg-bookmark-title { font-weight: 700; font-size: 0.9rem; }
.kg-bookmark-description { font-size: 0.8rem; color: var(--color-text-muted); }
.kg-bookmark-url { font-size: 0.75rem; color: var(--color-text-light); margin-top: var(--spacing-xs); }

/* Ghost Koenig editor — wide/full width cards */
.kg-width-wide {
    margin-left: -4vw;
    margin-right: -4vw;
}

.kg-width-full {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    width: 100vw;
}

.kg-width-wide img,
.kg-width-full img {
    width: 100%;
}

/* ==========================================================================
   Accessibility — respect reduced-motion preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .hero-bg {
        animation: none;
        opacity: 0;
    }
    /* Show only the first GIF, frozen, no animation */
    .hero-bg-1 {
        opacity: 1;
    }
}

/* ==========================================================================
   Hero mobile tweaks
   ========================================================================== */

@media (max-width: 640px) {
    .site-hero {
        min-height: 50vh;
    }
}
