/* Home — Apple-inspired Persian magazine layout */
.home {
    display: grid;
    gap: var(--space-2xl);
    padding-bottom: var(--space-md);
}

/* Visually hidden page title (SEO / a11y) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hero: translucent desktop overlay, with a separate image on phones. */
.home-hero-wrap { margin: 0; min-width: 0; }
.home-hero {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}
.home-hero__viewport {
    position: relative;
    background: #102235;
    overflow: hidden;
}
.home-hero__track { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.home-hero__slide {
    grid-area: 1 / 1;
    min-width: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .35s var(--ease-out), visibility .35s;
}
.home-hero__slide.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}
.home-hero__slide-link {
    display: grid;
    grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
    height: 100%;
    color: #fff !important;
    text-decoration: none !important;
}
.home-hero__bg {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 100%;
    overflow: hidden;
}
.home-hero__media { position: absolute; inset: 0; overflow: hidden; }
.home-hero__media-backdrop {
    position: absolute;
    inset: -14%;
    background-size: cover;
    background-position: center;
    filter: blur(24px);
    opacity: .35;
}
.home-hero__media-img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}
.home-hero__bg-fallback {
    display: block;
    height: 100%;
    background: var(--media-placeholder);
}
.home-hero__scrim {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .45s var(--ease-out);
}
.home-hero__slide.is-active .home-hero__scrim {
    opacity: 1;
}
.home-hero__content {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: clamp(24px, 3vw, 40px);
    text-align: right;
}
.home-hero__copy { width: 100%; min-width: 0; }
.home-hero__badge-slot { margin-bottom: 12px; }
.home-hero__badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    color: #fff;
}
.home-hero__title {
    margin: 0 0 16px;
    font-size: clamp(24px, 2.1vw, 30px);
    font-weight: 700;
    line-height: 1.65;
    color: #fff;
    overflow-wrap: anywhere;
    unicode-bidi: isolate;
}
.home-hero__excerpt {
    margin: 0 0 24px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.9;
    color: #d6dfe9;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.home-hero__excerpt.is-empty { display: none; }
.home-hero__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    padding-top: 10px;
    direction: ltr;
}
.home-hero__date-slot {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    direction: rtl;
    text-align: end;
    padding-inline-end: 4px;
}
.home-hero__date {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    unicode-bidi: plaintext;
    font-size: 12px;
    line-height: 1.6;
    color: #b8c7d8;
}
.home-hero__date::before {
    flex-shrink: 0;
}
.home-hero__actions {
    flex: 0 0 auto;
    max-width: min(100%, 200px);
    margin: 0;
    text-align: end;
}
.home-hero__slide.is-active .home-hero__footer > * {
    animation: homeHeroCopyIn .55s var(--ease-out) both;
}
.home-hero__slide.is-active .home-hero__date-slot { animation-delay: .26s; }
.home-hero__slide.is-active .home-hero__actions { animation-delay: .34s; }
.home-hero__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    background: #fff;
    color: var(--text-primary) !important;
}
.home-hero__cta-icon { display: inline-flex; }
.home-hero__chrome {
    position: relative;
    padding: 0 24px 16px;
    background: #102235;
}
.home-hero__progress {
    height: 4px;
    background: rgba(255, 255, 255, .2);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 12px;
}
.home-hero__progress-bar {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: inherit;
    transform-origin: inline-start center;
    will-change: width;
}
.home-hero__counter.is-tick {
    animation: homeHeroCounterTick .45s var(--ease-out);
}

.home-hero__controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.home-hero__arrows { display: flex; gap: 8px; }
.home-hero__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
}
.home-hero__btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.home-hero__counter {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 999px;
}
.home-hero__counter-sep { opacity: .5; margin-inline: 4px; }
/* The overlay sizes itself to the copy; controls remain outside its bounds. */
@media (min-width: 768px) {
    .home-hero__slide-link {
        position: relative;
        grid-template-columns: minmax(0, 1fr);
        min-height: clamp(420px, 42vw, 520px);
    }
    .home-hero__bg { position: absolute; inset: 0; grid-column: 1; }
    .home-hero__scrim {
        background:
            linear-gradient(to top, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, .12) 38%, transparent 62%),
            linear-gradient(to inline-start, rgba(0, 0, 0, .42) 0%, rgba(0, 0, 0, .12) 45%, transparent 72%);
    }
    .home-hero__media-img {
        object-fit: cover;
    }
    .home-hero__slide.is-active .home-hero__copy > * {
        animation: homeHeroCopyIn .55s var(--ease-out) both;
    }
    .home-hero__slide.is-active .home-hero__badge-slot { animation-delay: .04s; }
    .home-hero__slide.is-active .home-hero__title { animation-delay: .1s; }
    .home-hero__slide.is-active .home-hero__excerpt { animation-delay: .18s; }
    .home-hero__content {
        /* Room for chrome below the progress bar (controls + bar + padding) */
        --hero-above-timeline: 84px;
        position: relative;
        z-index: 2;
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        align-self: stretch;
        width: min(520px, 48%);
        height: 100%;
        min-height: 100%;
        margin: 0;
        padding: clamp(24px, 2.5vw, 32px);
        padding-bottom: var(--hero-above-timeline);
        box-sizing: border-box;
        border-radius: 0;
        border-start-start-radius: 0;
        border-end-start-radius: 0;
        border-start-end-radius: 20px;
        border-end-end-radius: 20px;
        border: 1px solid rgba(0, 229, 255, .22);
        border-inline-start: 2px solid rgba(255, 159, 10, .45);
        background: linear-gradient(145deg, rgba(8, 18, 30, .6), rgba(8, 28, 48, .46));
        backdrop-filter: blur(10px) saturate(1.1);
        -webkit-backdrop-filter: blur(10px) saturate(1.1);
        box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
    }
    .home-hero__copy {
        flex: 1 1 0;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .home-hero__excerpt {
        margin-bottom: 0;
    }
    .home-hero__footer {
        margin-top: auto;
        min-height: 44px;
    }
    .home-hero__title { font-size: clamp(24px, 2vw, 28px); text-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
    .home-hero__excerpt { color: rgba(255, 255, 255, .94); }
    .home-hero__slide.is-active .home-hero__media-img {
        animation: homeHeroKenBurns 6.5s linear both;
    }
    .home-hero.is-paused .home-hero__media-img { animation-play-state: paused; }
    .home-hero__chrome {
        position: absolute;
        inset-inline: 0;
        bottom: 0;
        z-index: 3;
        padding: 40px 24px 16px;
        background: transparent;
        pointer-events: none;
    }
    .home-hero__chrome .home-hero__progress,
    .home-hero__chrome .home-hero__controls {
        pointer-events: auto;
    }
}
@keyframes homeHeroKenBurns {
    from { transform: scale(1); }
    to { transform: scale(1.035); }
}
@keyframes homeHeroCopyIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes homeHeroCounterTick {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}
.home-hero__btn--playback { font-size: 18px; }
@media (max-width: 767px) {
    .home-hero__slide-link { display: flex; flex-direction: column; }
    .home-hero__bg { aspect-ratio: 16 / 9; min-height: 0; flex: 0 0 auto; width: 100%; }
    .home-hero__media-img { object-fit: cover; }
    .home-hero__content {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
        flex: 1;
        width: 100%;
        box-sizing: border-box;
    }
    .home-hero__copy {
        flex: 0 1 auto;
        min-width: 0;
    }
    .home-hero__title { font-size: 22px; line-height: 1.65; margin-bottom: 12px; }
    .home-hero__excerpt {
        font-size: 14px;
        -webkit-line-clamp: 2;
        margin-bottom: 0;
    }
    .home-hero__footer {
        margin-top: 16px;
        min-height: 44px;
    }
    .home-hero__cta {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 13px;
    }
    .home-hero__chrome {
        position: relative;
        padding: 0 16px 12px;
        background: #102235;
    }
}

/* Thumbnail strip */
.home-hero__thumbs {
    position: relative;
    display: flex;
    flex-direction: row;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
    background: var(--surface);
    direction: rtl;
    height: calc(94px + var(--space-md) + var(--space-lg));
    min-height: calc(94px + var(--space-md) + var(--space-lg));
    box-shadow: inset 0 1px 0 rgba(0, 229, 255, .08);
}
.home-hero__thumbs::-webkit-scrollbar {
    display: none;
}
.home-hero__thumb {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: min(240px, 52vw);
    min-height: 94px;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: transparent;
    cursor: pointer;
    text-align: start;
    font-family: inherit;
    transition: background .2s ease, border-color .2s ease, box-shadow .25s ease;
    scroll-snap-align: start;
}
.home-hero__thumb:hover {
    background: var(--surface-secondary);
}
.home-hero__thumb.is-active {
    background: var(--accent-soft);
    border-color: rgba(10, 132, 255, .22);
    box-shadow: 0 4px 16px rgba(10, 132, 255, .12);
}
.home-hero__thumb-img {
    position: relative;
    flex-shrink: 0;
    width: 66px;
    height: 66px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface-secondary);
}

.home-hero__thumb-backdrop {
    position: absolute;
    inset: -18%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(14px) saturate(1.1);
    opacity: 0.48;
    transform: scale(1.08);
    pointer-events: none;
}

.home-hero__thumb-photo,
.home-hero__thumb-img img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}
.home-hero__thumb-fallback {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #64d2ff, #7c4dff);
}
.home-hero__thumb-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 22px;
    min-width: 0;
    min-height: 44px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    unicode-bidi: isolate;
}

/* Main layout — single column on tablet/mobile */
.home-layout {
    display: grid;
    gap: var(--space-xl);
    align-items: start;
}
@media (min-width: 1024px) {
    .home-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: var(--space-xl);
    }
    .home-main { min-width: 0; }
    .home-aside { min-width: 0; }
}

.home-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: box-shadow .25s ease;
}
.home-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-lg) var(--space-md);
}
.home-panel__title-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.home-panel__accent {
    width: 4px;
    height: 24px;
    border-radius: 999px;
    background: var(--primary);
    flex-shrink: 0;
}
.home-panel__accent--teal { background: var(--teal); }
.home-panel__accent--violet { background: var(--accent-purple); }
.home-panel__title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 38px;
    color: var(--text-primary);
}
.home-panel__more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary) !important;
    text-decoration: none !important;
    transition: gap .2s var(--ease-out), color .2s ease;
}
.home-panel__more:hover {
    gap: 8px;
    color: var(--primary-hover) !important;
}
.home-panel__body {
    padding: 0 var(--space-lg) var(--space-lg);
}

/* Articles */
.home-articles__lead { margin-bottom: var(--space-md); }
.home-articles--grid {
    display: grid;
    gap: var(--space-md);
}
@media (min-width: 640px) {
    .home-articles--grid { grid-template-columns: repeat(2, 1fr); }
}

/* Sidebar tutorials */
.home-aside {
    display: grid;
    gap: var(--space-lg);
}
.home-panel--compact .home-panel__head {
    padding-block: var(--space-md) var(--space-sm);
}
.home-panel--compact .home-panel__title {
    font-size: 18px;
    line-height: 30px;
}
.home-tuts {
    list-style: none;
    margin: 0;
    padding: 0 var(--space-md) var(--space-md);
    display: grid;
    gap: 2px;
}
.home-tuts__link {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas: "num media text arrow";
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-sm);
    border-radius: 14px;
    color: inherit !important;
    text-decoration: none !important;
    transition: background .2s ease, transform .25s ease;
}
.home-tuts__link:hover {
    background: var(--surface-secondary);
}
.home-tuts__num {
    width: 24px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.home-tuts__media {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-secondary);
    flex-shrink: 0;
}
.home-tuts__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.home-tuts__media-fallback {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #64d2ff, #7c4dff);
}
.home-tuts__text { min-width: 0; }
.home-tuts__title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 28px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.home-tuts__meta {
    display: block;
    font-size: 13px;
    font-weight: 500;
    line-height: 22px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.home-tuts__arrow {
    color: var(--text-tertiary);
    font-size: 14px;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity .2s ease, transform .25s var(--ease-out);
}
.home-tuts__link:hover .home-tuts__arrow {
    opacity: 1;
    transform: translateX(0);
}
.home-panel__more-icon {
    display: inline-flex;
    flex-shrink: 0;
    transition: transform .2s var(--ease-out);
}
.home-panel__more:hover .home-panel__more-icon {
    transform: translateX(-3px);
}

/* Apps */
.home-apps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    padding: 0 var(--space-md) var(--space-md);
}
.home-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    color: inherit !important;
    text-decoration: none !important;
    box-shadow: var(--shadow-soft);
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.home-app:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(124, 77, 255, .2);
}
.home-app:hover .home-app__icon {
    border-color: rgba(0, 229, 255, .42);
    box-shadow: var(--play-icon-glow-hover, 0 0 0 1px rgba(0, 229, 255, .26), 0 0 16px rgba(0, 229, 255, .28), 0 4px 14px rgba(0, 0, 0, .08));
    transform: scale(1.02);
}
.home-app__icon {
    --home-app-hue: 142;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    margin-bottom: var(--space-sm);
    border-radius: var(--play-radius-icon, 22.5%);
    background: linear-gradient(145deg,
        hsl(var(--home-app-hue) 55% 52%) 0%,
        hsl(calc(var(--home-app-hue) + 25) 50% 42%) 100%);
    color: #fff;
    border: 1px solid var(--play-icon-ring, rgba(0, 184, 212, .32));
    box-shadow: var(--play-icon-glow, 0 0 0 1px rgba(0, 229, 255, .1), 0 0 10px rgba(0, 229, 255, .16), 0 0.5px 1px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .07));
    overflow: hidden;
    transition:
        box-shadow 220ms ease,
        border-color 220ms ease,
        transform 220ms ease;
}
.home-app__icon--img {
    background: #fff;
    padding: 0;
}
.home-app__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.home-app__icon-letter {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}
.home-app__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 28px;
}
.home-app__tag {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 22px;
    color: var(--text-tertiary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-empty {
    padding: var(--space-3xl) var(--space-lg);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 15px;
}

/* Skeleton shimmer (optional loading state) */
.home-skeleton {
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--surface-secondary) 25%, #e8ecf1 50%, var(--surface-secondary) 75%);
    background-size: 200% 100%;
    animation: homeShimmer 1.4s infinite;
}
@keyframes homeShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

body.is-home main {
    padding-top: var(--space-md);
    overflow-x: clip;
}
body.is-home .home {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
@media (max-width: 767px) {
    body.is-home main.wrap {
        width: 100%;
        max-width: 100%;
        padding-inline: var(--space-md);
    }

    .home-hero-wrap,
    .home-layout,
    .home-main,
    .home-aside,
    .home-panel,
    .home-panel__body {
        min-width: 0;
        max-width: 100%;
    }

    .home {
        gap: var(--space-xl);
    }
    .home-panel__title {
        font-size: 20px;
        line-height: 32px;
    }
    .home-panel__head,
    .home-panel__body {
        padding-inline: var(--space-md);
    }
    .home-apps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-sm);
        padding-inline: var(--space-sm);
    }
    .home-app {
        padding: var(--space-md) var(--space-sm);
    }
    .home-articles--grid {
        grid-template-columns: 1fr;
    }

    .home-hero__thumbs {
        padding: 12px var(--space-md);
        height: 100px;
        min-height: 100px;
    }

    .home-hero__thumb {
        width: min(220px, 78vw);
        min-height: 76px;
    }

    .home-tuts__title {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 767px) {
    .home-layout { gap: var(--space-lg); }
    .home-aside { gap: var(--space-lg); }
}

@media (prefers-reduced-motion: reduce) {
    .home-hero__slide,
    .home-hero__media-img,
    .home-hero__slide.is-active .home-hero__copy > *,
    .home-hero__slide.is-active .home-hero__footer > *,
    .home-hero__counter.is-tick,
    .post-card__link,
    .home-app,
    .home-app:hover .home-app__icon {
        transition: none;
        animation: none;
    }
    .home-app:hover .home-app__icon {
        transform: none;
    }
    .home-hero__slide.is-active .home-hero__media-img {
        animation: none;
        transform: none;
    }
}
