/* ==========================================================================
   MovieFlix — reusable components: card, skeleton, states, buttons, chips
   ========================================================================== */

/* --------------------------------------------------------------------------
   Movie card
   -------------------------------------------------------------------------- */

.mf-card {
    position: relative;
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    overflow: hidden;
    transition: transform var(--mf-base) var(--mf-ease),
                box-shadow var(--mf-base) var(--mf-ease),
                border-color var(--mf-base) var(--mf-ease);
}

.mf-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--mf-shadow-lg);
    border-color: rgba(225, 29, 72, .45);
}

.mf-card__poster {
    position: relative;
    /* Reserving the ratio up front prevents any layout shift (CLS) while
       lazily loaded posters arrive. */
    aspect-ratio: 2 / 3;
    background: var(--mf-surface-2);
    overflow: hidden;
}

.mf-card__poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--mf-base) var(--mf-ease);
}

.mf-card:hover .mf-card__poster img { transform: scale(1.06); }

.mf-card__overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(to top, rgba(8, 8, 12, .85), rgba(8, 8, 12, .1));
    opacity: 0;
    transition: opacity var(--mf-base) var(--mf-ease);
}

.mf-card__overlay i {
    width: 46px; height: 46px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--mf-accent);
    color: #fff;
    transform: scale(.8);
    transition: transform var(--mf-base) var(--mf-ease);
}

.mf-card:hover .mf-card__overlay { opacity: 1; }
.mf-card:hover .mf-card__overlay i { transform: scale(1); }

.mf-card__body { padding: 13px 14px 16px; }

.mf-card__title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
    /* Two-line clamp keeps every card the same height. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mf-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 12px;
    color: var(--mf-text-muted);
}

/* --------------------------------------------------------------------------
   Row/carousel card variant — poster-filling tile with the title overlaid
   at the bottom via a gradient scrim, instead of a separate text body.
   Used only inside .mf-row (curated collections); search results and the
   favorites grid keep the body variant, where visible metadata matters
   more for scanning than the Netflix-style look.
   -------------------------------------------------------------------------- */

.mf-card--overlay {
    background: transparent;
    border-color: transparent;
}

.mf-card--overlay:hover {
    box-shadow: none;
    border-color: transparent;
}

.mf-card__label {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 1;
    padding: 30px 10px 8px;
    background: linear-gradient(to top, rgba(8, 8, 12, .92), transparent);
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.mf-card__label-title {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, .95);
    text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mf-card__label-meta {
    font-size: 10px;
    color: rgba(255, 255, 255, .68);
    /* Capitalizes OMDb's raw "movie"/"series"/"episode" for display only —
       no locale/translation involved, the underlying value passed to the
       DOM is untouched (spec: OMDb response data must not be localized). */
    text-transform: capitalize;
}

.mf-card__label-dot { opacity: .7; }

/* --------------------------------------------------------------------------
   Favorite button — sits above the card link, not inside it, so it never
   creates a nested interactive element (button-in-anchor is invalid HTML).
   -------------------------------------------------------------------------- */

.mf-fav-btn {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 2;
    width: 34px; height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: rgba(8, 8, 12, .55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: rgba(255, 255, 255, .85);
    cursor: pointer;
    transition: transform var(--mf-fast) var(--mf-ease),
                color var(--mf-fast) var(--mf-ease),
                background var(--mf-fast) var(--mf-ease);
}

.mf-fav-btn:hover { transform: scale(1.1); }

.mf-fav-btn.is-active {
    color: var(--mf-accent);
    background: rgba(8, 8, 12, .7);
}

.mf-fav-btn[disabled] { opacity: .6; cursor: wait; }

.mf-badge {
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--mf-border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* --------------------------------------------------------------------------
   Skeleton loading — shimmer reads as faster than a spinner.
   -------------------------------------------------------------------------- */

.mf-skeleton {
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    padding: 0 0 16px;
    overflow: hidden;
}

.mf-skeleton__poster { aspect-ratio: 2 / 3; }

.mf-skeleton__line {
    height: 11px;
    margin: 12px 14px 0;
    border-radius: 6px;
}

.mf-skeleton__line.is-short { width: 45%; }

.mf-skeleton__poster,
.mf-skeleton__line {
    background: linear-gradient(90deg, #15151f 25%, #1f1f2c 37%, #15151f 63%);
    background-size: 400% 100%;
    animation: mf-shimmer 1.35s ease-in-out infinite;
}

@keyframes mf-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* --------------------------------------------------------------------------
   Empty / error / start states
   -------------------------------------------------------------------------- */

.mf-state--message {
    text-align: center;
    padding: 72px 20px;
    color: var(--mf-text-muted);
}

.mf-state--message i {
    font-size: 42px;
    color: var(--mf-accent);
    opacity: .85;
    margin-bottom: 18px;
}

.mf-state--message h1,
.mf-state--message h3 {
    color: var(--mf-text);
    font-size: 20px;
    margin-bottom: 6px;
}

.mf-state--message p { margin: 0 auto 20px; max-width: 42ch; }

.mf-state--page { padding-block: 120px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.mf-btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 26px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--mf-accent);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--mf-fast) var(--mf-ease),
                filter var(--mf-fast) var(--mf-ease),
                background var(--mf-fast) var(--mf-ease);
}

.mf-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.mf-btn:active { transform: translateY(0); }

.mf-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* Ripple: a span sized/positioned by ripple.js, animated here. */
.mf-btn__ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .45);
    transform: scale(0);
    animation: mf-ripple .55s var(--mf-ease);
    pointer-events: none;
}

@keyframes mf-ripple {
    to { transform: scale(2.2); opacity: 0; }
}

/* Submit-loading state: label fades out, spinner fades in, same footprint. */
.mf-btn__spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
}

.mf-btn.is-loading { cursor: wait; }
.mf-btn.is-loading [data-btn-label] { visibility: hidden; position: absolute; }
.mf-btn.is-loading .mf-btn__spinner { display: inline-block; animation: mf-spin .7s linear infinite; }

.mf-btn--ghost {
    background: transparent;
    border-color: var(--mf-border);
    color: var(--mf-text);
}

.mf-btn--ghost:hover { background: rgba(255, 255, 255, .06); }

/* --------------------------------------------------------------------------
   Bottom nav — always on (this is a fixed-width mobile app, not a page that
   grows a desktop nav at wider viewports). Constrained to the app frame's
   width so it doesn't stretch across the letterboxing on wide screens.
   -------------------------------------------------------------------------- */

.mf-bottom-nav {
    display: flex;
    position: fixed;
    left: 50%;
    max-width: var(--mf-container);
    transform: translateX(-50%);
    bottom: 0;
    z-index: 60;
    width: 100%;
    justify-content: space-around;
    align-items: stretch;
    background: rgba(10, 10, 16, .9);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-top: 1px solid var(--mf-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mf-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 0 8px;
    border: none;
    background: none;
    color: var(--mf-text-muted);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: color var(--mf-fast) var(--mf-ease);
}

.mf-bottom-nav__item i { font-size: 18px; }

.mf-bottom-nav__item.is-active,
.mf-bottom-nav__item:hover { color: var(--mf-accent); }

/* --------------------------------------------------------------------------
   Detail page
   -------------------------------------------------------------------------- */

.mf-detail { position: relative; padding-bottom: 80px; }

.mf-detail__backdrop {
    position: absolute;
    inset: 0 0 auto;
    height: 480px;
    background-size: cover;
    background-position: center 22%;
    filter: blur(38px) saturate(130%);
    opacity: .28;
    transform: scale(1.15);
    pointer-events: none;
}

.mf-detail__backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(8, 8, 12, .35), var(--mf-bg));
}

.mf-detail__inner { position: relative; padding-top: 32px; }

.mf-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--mf-text-muted);
    font-size: 14px;
    margin-bottom: 28px;
    transition: color var(--mf-fast) var(--mf-ease);
}

.mf-back:hover { color: var(--mf-text); }

.mf-detail__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 26px;
    align-items: start;
}

.mf-detail__poster {
    /* Wide enough to feel intentional in a single-column layout, capped so
       it doesn't dominate the page above the title and synopsis. */
    max-width: 260px;
    margin-inline: auto;
}

.mf-detail__poster img {
    width: 100%;
    border-radius: var(--mf-radius-lg);
    /* A faint accent-tinted glow ties the poster to the blurred backdrop
       behind it, so the two read as one composition rather than two
       separate images. */
    box-shadow: var(--mf-shadow-lg), 0 20px 45px -20px rgba(225, 29, 72, .35);
    border: 1px solid var(--mf-border);
}

.mf-detail__heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.mf-detail__title {
    /* A fixed px size, not vw-based: vw tracks the real browser window, not
       the ~460px .mf-app-frame this renders inside, so it needs a value
       that already assumes a narrow frame rather than scaling with it. */
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0;
}

.mf-detail__fav.is-active {
    /* A filled tint reads as "on" more clearly than an outline alone,
       consistent with the row-card heart and the hero-banner favorite
       button, which use the same treatment. */
    background: rgba(225, 29, 72, .12);
    border-color: rgba(225, 29, 72, .5);
    color: var(--mf-accent);
}

.mf-detail__fav.is-active i { color: var(--mf-accent); }

.mf-detail__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    list-style: none;
    padding: 0;
    /* Shared 24px rhythm with the sections below, for a consistent vertical
       cadence down the page. */
    margin: 0 0 24px;
    color: var(--mf-text-muted);
    font-size: 14px;
}

.mf-detail__facts li + li { position: relative; }
.mf-detail__facts li + li::before {
    content: '•';
    position: absolute;
    left: -13px;
}

.mf-detail__plot { max-width: 68ch; margin-bottom: 24px; }

.mf-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }

.mf-chip {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--mf-border);
    background: rgba(255, 255, 255, .04);
    font-size: 12px;
}

.mf-ratings { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }

.mf-rating {
    padding: 12px 18px;
    border-radius: var(--mf-radius);
    border: 1px solid var(--mf-border);
    background: var(--mf-surface);
    min-width: 100px;
    text-align: center;
}

.mf-rating strong {
    display: block;
    font-family: 'Montserrat', sans-serif;
    font-size: 19px;
}

.mf-rating span {
    font-size: 10px;
    color: var(--mf-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.mf-meta { margin: 0; }

.mf-meta__row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 12px 0;
    border-top: 1px solid var(--mf-border);
    font-size: 14px;
}

/* A small uppercase label over the value, like a form field label, so the
   two are easy to tell apart at a glance. */
.mf-meta__row dt {
    color: var(--mf-text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.mf-meta__row dd { margin: 0; }
