/* Subscription page (CodeM Plus). Loads after styles.css and category.css (the head, background and
   entrance are shared with the Scripts page). Tier colours come in as --tone and --glow per card. */

/* ---------- Head: title and a few facts ---------- */

.sub-head { align-items: center; }

.sub-head__facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

.sub-head__facts span {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.sub-head__facts b { color: #fff; }

.sub-main { padding: clamp(24px, 2.4vw, 40px) var(--gutter) clamp(64px, 6vw, 120px); }

/* ---------- Tier cards ----------
   Three cards side by side: Gold, Diamond and Platinum, the same size. The card under the pointer (Diamond when
   the pointer is elsewhere) is full size with a glow under it; the other two step back, smaller and dimmer. */

.tiers {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: clamp(14px, 1.6vw, 28px);
}

@media (max-width: 1100px) {
    .tiers { grid-template-columns: 1fr; max-width: 560px; margin-inline: auto; }
    .tiers .tier--diamond { order: -1; }
}

/* Finishes of the artwork: gold as it is, platinum silver, diamond with an icy blue logo on the purple. */
.tier--platinum .tier__art img { filter: grayscale(1) brightness(1.15) contrast(1.05); }

.tier--diamond .tier__art::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: radial-gradient(34% 46% at 50% 46%, #8fd0ff 0%, #8fd0ff 55%, transparent 100%);
    mix-blend-mode: color;
    pointer-events: none;
}

/* The big artwork is cropped wider, so the logo fills more of it. */
.tier--diamond .tier__art::before { background: radial-gradient(50% 75% at 50% 48%, #8fd0ff 0%, #8fd0ff 70%, transparent 100%); }

/* The card. */
.tier {
    font-family: 'Gilroy', 'Inter', sans-serif;
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
    border-radius: 26px;
    border: 1px solid transparent;
    background: rgba(18, 17, 30, 0.85);
    transform: scale(0.92);
    opacity: 0.72;
    animation: tierIn 0.6s var(--ease) backwards;
    transition: transform 0.55s var(--ease), opacity 0.55s var(--ease), box-shadow 0.55s var(--ease);
}


/* The picked card: full size, fully lit, a glow in its colour under it. */
.tier.is-selected {
    z-index: 1;
    transform: none;
    opacity: 1;
    box-shadow: 0 30px 80px -10px var(--glow), 0 30px 70px rgba(0, 0, 0, 0.45);
}

.tier--diamond { animation-delay: 0.1s; }
.tier--gold { animation-delay: 0.22s; }
.tier--platinum { animation-delay: 0.3s; }

/* Edge, always on: a thin ring in the colours of the card's own artwork (the art blurred and brightened, shown
   only along the edge), like the Scripts cards on hover. */
.tier::after {
    content: '';
    position: absolute;
    inset: -40px;
    z-index: 3;
    padding: 1.5px;
    border: 40px solid transparent;
    border-radius: 66px;
    background: var(--art) center / cover no-repeat border-box;
    filter: blur(14px) saturate(2) brightness(1.6);
    -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0) content-box;
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0) content-box;
    pointer-events: none;
}

@keyframes tierIn { from { opacity: 0; filter: blur(10px); transform: translateY(10px); } }



/* Behind the panel: the artwork blurred and dark, lit in the tier colour from the right. */
.tier::before {
    content: '';
    position: absolute;
    inset: -40px;
    z-index: -1;
    background:
        radial-gradient(60% 80% at 85% 30%, var(--glow), transparent 70%),
        var(--art) center / cover no-repeat;
    filter: blur(44px) saturate(1.2) brightness(0.32);
}

/* A tier with its own artwork: shown as it is (no tint, no dark fade for a label). */
.tier.has-art .tier__art img { filter: none; }
.tier--platinum.has-art::before { filter: blur(44px) saturate(1.2) brightness(0.32); } /* no grey: the art has its own colours */
.tier.has-art .tier__art::before,
.tier.has-art .tier__art::after { display: none; }

.tier.is-best::before { filter: blur(44px) saturate(1.3) brightness(0.42); }

.tier--platinum::before { filter: blur(44px) grayscale(1) brightness(0.4); }

.tier__art { position: relative; aspect-ratio: 16 / 11; overflow: hidden; border-radius: 19px; background: #1b1d25; }
.tier__art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.tier__art::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, transparent 45%, rgba(10, 9, 18, 0.9) 100%);
}

.tier__best {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px 9px 14px;
    border-radius: 999px;
    background: rgba(10, 12, 22, 0.78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
}

.tier__best svg { width: 20px; height: 20px; color: #ff9a3c; } /* the flame */

.tier__label { position: absolute; left: 24px; bottom: 20px; z-index: 2; display: grid; gap: 2px; }
.tier__label small { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }

.tier__label b {
    font-family: 'Big Shoulders Display', 'Inter', sans-serif;
    font-size: clamp(44px, 3.6vw, 64px);
    font-weight: 800;
    line-height: 0.88;
    color: var(--tone);
    text-transform: uppercase;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

.tier__body { display: flex; flex-direction: column; flex: 1; padding: 20px 18px 14px; }

.tier__tag { font-size: 15px; font-weight: 700; color: var(--tone); }

.tier__price { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; }
.tier__price b { font-size: clamp(36px, 2.8vw, 48px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.tier__price small { font-size: 16px; font-weight: 600; color: var(--muted); }
.tier__price em { align-self: center; padding: 3px 9px; border-radius: 8px; background: var(--gold); color: #1a1406; font-style: normal; font-size: 13px; font-weight: 800; }

.tier__bill { margin: 8px 0 0; font-size: 14px; color: var(--faint); }

.tier__terms {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
}

/* Each term is a box: name and saving on top, the price per month under it. The picked one is filled with the
   card's colour. */
.tier__term {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 11px 10px 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    text-align: left;
    color: #fff;
    transition: background 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease), transform 0.3s var(--ease);
}

.tier__term:hover { border-color: color-mix(in srgb, var(--tone) 55%, transparent); transform: translateY(-1px); }
.tier__term-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 6px; } /* the saving drops under the name in a narrow box */
.tier__term-top b { font-size: 15px; font-weight: 800; white-space: nowrap; }
.tier__term-top em { padding: 1px 7px; border-radius: 6px; background: var(--gold); color: #1a1406; font-style: normal; font-size: 11px; font-weight: 800; }
.tier__term small { font-size: 12px; font-weight: 600; color: var(--muted); }

.tier__term.is-active { border-color: transparent; background: var(--tone); color: #0b0c12; }
.tier__term.is-active small { color: rgba(11, 12, 18, 0.7); }
.tier__term.is-active .tier__term-top em { background: #0b0c12; color: var(--tone); }

.tier__perks { display: grid; gap: 12px; margin: 24px 0 0; padding: 0; list-style: none; }
.tier__perks li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: rgba(255, 255, 255, 0.88); }

.tier__perks svg {
    flex: none;
    width: 22px;
    height: 22px;
    padding: 4px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--tone) 20%, transparent);
    color: var(--tone);
}

.tier__worth { margin: 20px 0 0; font-size: 14px; color: var(--faint); }
.tier__worth b { color: var(--tone); }

.tier__actions { display: grid; gap: 8px; margin-top: auto; padding-top: 24px; }

.tier__buy {
    height: 52px;
    padding: 0 30px;
    border-radius: 999px;
    background: #fff;
    color: #0b0c12;
    font-size: 15px;
    font-weight: 800;
    transition: box-shadow 0.3s var(--ease), background 0.3s var(--ease), color 0.3s var(--ease);
}

.tier__buy:hover { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.16); }

.tier__see {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    transition: background 0.3s var(--ease);
}

.tier__see svg { width: 16px; height: 16px; }
.tier__see:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- What's included ----------
   Laid out like the Scripts page (its styles come from category.css): the filter panel on the left with the tier
   and series lists, the search bar and the cards on the right. Cards here only show picture, series and name. */

.included { margin-top: clamp(64px, 6vw, 110px); scroll-margin-top: 24px; }
.included__head { margin-bottom: 24px; }
.included__eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: #c4a6ff; }
.included__head h2 { margin: 8px 0 0; font-size: clamp(28px, 2.4vw, 40px); font-weight: 800; letter-spacing: -0.02em; }
.included__head p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.included__head p b { color: #fff; }

.inc-main {
    display: grid;
    grid-template-columns: clamp(220px, 15vw, 280px) minmax(0, 1fr);
    align-items: start;
    gap: clamp(24px, 2.6vw, 48px);
}

@media (max-width: 960px) {
    .inc-main { grid-template-columns: 1fr; }
    .inc-side { position: static; }
}

/* Phones and tablets: the tier and series lists fold away behind a Filters header (desktop has no header). */
.inc-side > .side__head { display: none; }

@media (max-width: 960px) {
    .inc-side > .side__head { display: flex; }
    .inc-side .side__toggle { display: inline-flex; }
    .inc-side:not(.is-open) > .side__group { display: none; }
}

/* The panel is not part of the page entrance here (it is far down the page). */
.inc-side, .included .results__bar { animation: none; }

/* Tier gem in the tier colour, in place of the series letter. */
.inc-gem { background: color-mix(in srgb, var(--tone) 18%, transparent); }
.inc-gem i { width: 11px; height: 11px; border-radius: 3px; background: var(--tone); transform: rotate(45deg); }
.series__row.is-active .inc-gem { background: rgba(11, 12, 18, 0.16); }
.series__row.is-active .inc-gem i { background: #0b0c12; }

/* Cards: picture, series, name (no price or buttons). */
.included .grid { grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 13vw, 250px), 1fr)); }
.tile--inc { --in-blur: 6px; --in-y: 0px; contain-intrinsic-size: auto 260px; }
.tile--inc .tile__body { gap: 6px; padding: 14px 10px 10px; }
.tile--inc .tile__name { font-size: 17px; }
.tile--inc .tile__art { display: grid; place-items: center; }
.tile--inc .tile__logo { width: 34%; aspect-ratio: 1; background: url("https://cdn.jsdelivr.net/gh/ThaCly/codem-media@v3/img/logo-mark-crop.png") center / contain no-repeat; opacity: 0.16; } /* placeholder when the script has no picture */
div.tile--inc:hover { transform: none; box-shadow: none; }

/* Phones and tablets: smaller cards, and only the first twelve until "Show all" (a tier holds 100+ scripts). */
.inc-more { display: none; }

@media (max-width: 860px) {
    .included .grid { grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 24vw, 200px), 1fr)); }
    .tile--inc .tile__body { padding: 10px 6px 6px; }
    .tile--inc .tile__name { font-size: 15px; }
    .included .grid.is-clipped > :nth-child(n + 13) { display: none; }
    .included .grid.is-clipped + .inc-more {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 50px;
        margin-top: 14px;
        border-radius: 999px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        background: rgba(255, 255, 255, 0.05);
        font-size: 14px;
        font-weight: 800;
        color: var(--text);
    }
}

/* ---------- How it works ---------- */

.sub-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(14px, 1.4vw, 24px);
    margin-top: clamp(64px, 6vw, 110px);
}

@media (max-width: 900px) {
    .sub-steps { grid-template-columns: 1fr; }
}

.sub-step {
    padding: 26px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.03);
}

.sub-step__n {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(167, 123, 255, 0.16);
    color: #d4bfff;
    font-family: 'Big Shoulders Display', 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 800;
}

.sub-step h3 { margin: 18px 0 6px; font-size: 18px; font-weight: 800; }
.sub-step p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--muted); }

.tier.is-swapped { animation: none; } /* a term or basket change re-draws the card without the entrance */

/* Background clip: in the middle of the head (no sale block beside the title here). */
.is-subscription .cat-head__bg .hero-layer .hero-layer__main { left: 50%; }

/* "In Basket" on a tier card takes the card's own colour (gold, pink, blue) instead of the store purple. */
.tier .tier__buy.is-in-basket.is-in-basket { background: var(--tone) !important; color: #0b0c12 !important; }
.tier .tier__buy.is-in-basket.is-in-basket:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 30%, transparent); }

/* Prices keep their width when they change (equal-width digits), and fade in softly when a term is picked. */
.tier__price b, .tier__term small, .tier__bill { font-variant-numeric: tabular-nums; }
.tier__price.is-changed, .tier__bill.is-changed { animation: termSwap 0.35s var(--ease); }
@keyframes termSwap { from { opacity: 0.2; filter: blur(4px); } }

/* Until the tier cards are drawn (they need the store data), nothing below them shows and their place is kept,
   so "Scripts in each tier" and the footer do not appear first and then get pushed down. */
.sub-main:not(.is-ready) > :not([data-tiers]) { visibility: hidden; }
.sub-main:not(.is-ready) [data-tiers] { min-height: 70vh; }
.is-subscription:has(.sub-main:not(.is-ready)) .site-footer { visibility: hidden; }
