/* Critical above-the-fold styles for media pages — keep in sync with media.css */
:root {
    --media-primary: #2d5bd1;
    --media-primary-soft: #e8effc;
    --media-bg: #ffffff;
    --media-text: #1a1a1a;
    --media-text-muted: #6b7280;
    --media-border: #eef0f4;
    --media-card-shadow: 0 2px 14px rgba(26, 45, 95, 0.08);
    --media-radius: 16px;
    --media-radius-sm: 12px;
    --media-top-nav-h: 3.5rem;
    --media-header-h: 7.5rem;
    --media-return-context-h: 0px;
    --media-max: 480px;
    --media-feed-desktop: 630px;
}

.media-body [hidden] {
    display: none !important;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.media-body {
    margin: 0;
    padding: 0;
    font-family: IRANSans, Tahoma, sans-serif;
    background: var(--media-bg);
    color: var(--media-text);
    -webkit-font-smoothing: antialiased;
}

.media-app {
    min-height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    padding-bottom: 1.25rem;
    background: var(--media-bg);
}

.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;
}

.media-top-nav {
    position: sticky;
    top: 0;
    z-index: 120;
    background: var(--media-bg);
    border-bottom: 1px solid var(--media-border);
    box-shadow: 0 2px 12px rgba(26, 45, 95, 0.05);
    padding-top: env(safe-area-inset-top, 0);
}

.media-top-nav__inner {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    max-width: 100%;
    height: var(--media-top-nav-h);
    margin: 0 auto;
    padding: 0 0.35rem;
}

.media-top-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    min-width: 0;
    text-decoration: none;
    color: var(--media-text-muted);
    font-size: 0.62rem;
    font-weight: 500;
    padding: 0.2rem 0.1rem;
    border-radius: 10px;
    white-space: nowrap;
}

.media-top-nav__item i {
    font-size: 1.15rem;
    line-height: 1;
}

.media-top-nav__logo {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 0.25rem;
}

.media-top-nav__logo img {
    display: block;
    width: auto;
    height: 2.5rem;
    max-width: 100%;
    object-fit: contain;
}

.media-top-nav__icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.media-top-nav__item.is-active {
    color: var(--media-primary);
    font-weight: 700;
}

.media-top-nav__item.is-active i {
    color: var(--media-primary);
}

.media-notification-badge {
    position: absolute;
    top: -0.42rem;
    left: -0.55rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.22rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--media-bg);
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 800;
    line-height: 1;
}

.media-body--create .media-top-nav,
.media-body--no-top-nav .media-top-nav {
    display: none;
}

.media-header {
    position: sticky;
    top: calc(var(--media-top-nav-h) + var(--media-return-context-h));
    z-index: 100;
    background: var(--media-bg);
    padding: 0.65rem 1rem 0.75rem;
    border-bottom: 1px solid var(--media-border);
}

.media-body--create .media-header,
.media-body--no-top-nav .media-header {
    top: var(--media-return-context-h);
}

.media-header__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.media-header--post .media-header__row {
    margin-bottom: 0;
}

.media-header__logo {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.media-header__logo img {
    height: 2.35rem;
    width: auto;
    max-width: 11rem;
    object-fit: contain;
}

.media-header__actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.media-header__post-user {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 0;
    text-decoration: none;
    color: var(--media-text);
}

.media-header__post-user img,
.media-header__post-user > span:first-child {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    object-fit: cover;
    background: #e8effc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.media-header__post-user strong {
    font-size: 0.88rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
}

.media-icon-btn--placeholder {
    visibility: hidden;
    pointer-events: none;
}

.media-stories {
    padding: 0.85rem 0 0.35rem;
    overflow: hidden;
}

.media-stories__track {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0 1rem 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.media-stories__track::-webkit-scrollbar {
    display: none;
}

.media-story {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 4.5rem;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.media-story__ring {
    display: block;
    width: 4.25rem;
    height: 4.25rem;
    padding: 2px;
    border-radius: 50%;
    background: linear-gradient(180deg, #4a7fe8 0%, var(--media-primary) 100%);
}

.media-story__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 2px solid #fff;
}

.media-story__inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-story__label {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--media-text);
    text-align: center;
    line-height: 1.35;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-feed {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem 1rem;
}

.media-card {
    background: var(--media-bg);
    border-radius: var(--media-radius);
    box-shadow: var(--media-card-shadow);
    border: 1px solid var(--media-border);
    overflow: hidden;
}

.media-card.media-card--fixed {
    display: grid;
    grid-template-rows: 45px 605px auto;
    width: min(100%, var(--media-max));
    min-height: 750px;
    margin-right: auto;
    margin-left: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.media-card--fixed .media-card__head {
    height: 45px;
    min-height: 45px;
    padding: 4px 12px;
    border: 0;
}

.media-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0.85rem 0.65rem;
}

.media-card__user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.media-card__avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--media-primary-soft);
}

.media-card--fixed .media-card__avatar {
    width: 36px;
    height: 36px;
}

.media-card__name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--media-text);
}

.media-card__visual {
    width: 100%;
    height: 605px;
    min-height: 605px;
    overflow: hidden;
    background: #0b0f14;
}

.media-gallery-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.media-gallery {
    position: relative;
    overflow: hidden;
    direction: ltr;
    width: 100%;
    touch-action: pan-y;
}

.media-gallery__viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.media-gallery__track {
    display: flex;
    width: 100%;
    height: 100%;
}

.media-gallery__slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: block;
    background: #f3f4f6;
}

.media-gallery__slide img,
.media-card__visual .media-gallery__slide img {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    object-fit: contain;
    display: block;
    background: #0b0f14;
}

.media-card__actions {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    padding: 0.35rem 0.85rem 0.5rem;
}

.media-card__action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.82rem;
    color: #4b5563;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    padding: 0.35rem 0.55rem;
    margin: -0.35rem -0.55rem;
}

.media-card__action i {
    font-size: 1.15rem;
}

.media-card__action--bookmark {
    margin-right: auto;
}

.media-card__likes-line {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    padding: 0 0.85rem 0.55rem;
    font-size: 0.75rem;
    color: var(--media-text-muted);
    line-height: 1.5;
    min-width: 0;
}

.media-caption-text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--media-text);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.media-body--post-detail .media-post-detail {
    padding: 0 0 calc(4.75rem + env(safe-area-inset-bottom));
    max-width: var(--media-feed-desktop);
    margin: 0 auto;
}

.media-post-detail--ig .media-post-detail__card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    background: var(--media-bg);
}

.media-post-detail__card {
    background: var(--media-bg);
    overflow: hidden;
}

.media-post-detail__media {
    width: min(100%, var(--media-max));
    height: 605px;
    min-height: 605px;
    max-height: 605px;
    margin: 0 auto;
    overflow: hidden;
    background: #0b0f14;
}

.media-post-detail__media .media-gallery__viewport,
.media-post-detail__media .media-gallery__track,
.media-post-detail__media .media-gallery__slide {
    width: 100%;
    height: 100%;
    min-height: 0;
}

.media-post-detail__media img,
.media-post-detail__media .media-gallery__slide img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
    display: block;
    background: #0b0f14;
}

.media-post-detail__body {
    padding: 0.35rem 0.85rem 0.5rem;
}

.media-post-detail__actions {
    padding: 0.35rem 0 0.15rem;
    gap: 1rem;
}

.media-post-detail__actions .media-card__action--bookmark,
.media-post-detail__actions .media-save-btn {
    margin-right: auto;
}

.media-post-detail__caption {
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--media-text);
    margin: 0.15rem 0 0.35rem;
}

.media-post-detail__caption-user {
    font-weight: 700;
    color: var(--media-primary);
    text-decoration: none;
    margin-left: 0.35rem;
}

.media-rich-link {
    color: var(--media-primary);
    font-weight: 500;
    text-decoration: none;
    word-break: break-word;
}

.media-post-detail__time {
    display: block;
    margin: 0 0 0.65rem;
    font-size: 0.68rem;
    color: var(--media-text-muted);
}

.media-return-context[hidden] {
    display: none !important;
}

@media (min-width: 768px) {
    .media-app {
        max-width: 720px;
        padding-bottom: 2rem;
        box-shadow: 0 0 0 1px var(--media-border);
    }
}

@media (min-width: 992px) {
    .media-post-detail__media img {
        max-height: 75vh;
    }
}
