/* ===================================================
   TAGS PAGE — Premium Photography Platform Style
   Scope: tags.php only  |  Refinement pass 2
   =================================================== */

body { background: #f5f6f8; }

/* ======== HERO ======== */
.th {
    background: linear-gradient(180deg, #ffffff 0%, #f1f2f5 100%);
    padding: 3.8rem 1.5rem 5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #dfe2e6;
}
.th::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse 600px 300px at 15% 30%, rgba(13,148,136,0.04) 0%, transparent 70%),
        radial-gradient(ellipse 500px 250px at 85% 60%, rgba(37,99,235,0.025) 0%, transparent 70%);
    pointer-events: none;
}
.th::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 60px;
    background: #f5f6f8;
    clip-path: polygon(0 100%, 100% 100%, 100% 0, 0 60%);
}

.th-in {
    position: relative;
    z-index: 2;
    max-width: 1100px;
    margin: 0 auto;
}

.th-text { text-align: center; }

.th-search {
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
}
[dir="rtl"] .th-search { left: auto; right: auto; left: -80px; }

.th h1 {
    font-size: clamp(2.2rem, 5vw, 3.1rem);
    font-weight: 700;
    color: #0f1419;
    margin: 0 0 0.4rem;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.th p {
    font-size: 0.95rem;
    color: #5c6370;
    margin: 0 auto;
    line-height: 1.6;
    max-width: 380px;
    font-weight: 400;
}

.th-nums {
    display: inline-flex;
    gap: 2.5rem;
    margin-top: 1.6rem;
    padding: 1rem 2.2rem;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #d9dce1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.th-n { text-align: center; }
.th-n strong {
    display: block;
    font-size: 1.55rem;
    font-weight: 900;
    color: #0f1419;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.th-n small {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #848b96;
    font-weight: 600;
    margin-top: 0.2rem;
    display: block;
}

/* ======== SEARCH (inside hero) ======== */
.ts {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #d4d8de;
    border-radius: 12px;
    padding: 0.6rem 0.7rem 0.6rem 1rem;
    gap: 0.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ts:hover {
    border-color: #b8bfc8;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.ts:focus-within {
    border-color: #0d9488;
    box-shadow: 0 2px 10px rgba(13,148,136,0.1), 0 0 0 3px rgba(13,148,136,0.07);
}
.ts-i {
    color: #8892a0;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: color 0.2s;
}
.ts:focus-within .ts-i { color: #0d9488; }
.ts input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font: 0.88rem/1.4 var(--font-main);
    color: #1e293b;
    padding: 0.3rem 0;
}
.ts input::placeholder { color: #b0b6c0; }
.ts-x {
    background: #0d9488;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 0.4rem 0.8rem;
    font: 600 0.72rem var(--font-main);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.ts-x:hover {
    background: #0b8578;
    box-shadow: 0 1px 4px rgba(13,148,136,0.25);
}

/* ======== ALPHABET INDEX ======== */
.ix {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.85rem 1.2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    background: #ffffff;
    border: 1px solid #d9dce1;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    position: relative;
    top: -1.5rem;
    z-index: 3;
}
.ix a {
    font: 700 0.72rem/1 var(--font-main);
    color: #5c6370;
    text-decoration: none;
    padding: 0.4rem 0.58rem;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.15s;
    letter-spacing: 0.01em;
}
.ix a:hover {
    color: #0d9488;
    background: #f0fdfa;
    border-color: #ccfbf1;
}

/* ======== SECTIONS WRAP ======== */
.tg-wrap {
    max-width: 900px;
    margin: 0.5rem auto 5rem;
    padding: 0 1.5rem;
}

/* ======== LETTER GROUP CARD ======== */
.tg-sec {
    background: #ffffff;
    border: 1px solid #dfe2e6;
    border-radius: 12px;
    margin-bottom: 0.55rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
}
.tg-sec:hover {
    border-color: #c8ccd2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.tg-sec.is-open {
    border-color: #b2dfdb;
    box-shadow: 0 2px 10px rgba(13,148,136,0.07);
}
.tg-sec:last-of-type { border-bottom: 1px solid #dfe2e6; }
.tg-sec.card-hidden { display: none; }

/* Head row */
.tg-h {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.15rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    gap: 0.9rem;
    transition: background 0.15s;
}
.tg-h:hover { background: #f9fafb; }
.tg-sec.is-open .tg-h {
    background: #f7fffe;
    border-bottom: 1px solid #e8f5f3;
}

/* The big letter */
.tg-letter {
    font-size: 1.5rem;
    font-weight: 900;
    color: #9ca3af;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    border-radius: 10px;
    background: #f0f1f4;
    border: 1px solid #e3e5ea;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.tg-sec:hover .tg-letter {
    color: #6b7280;
    border-color: #d4d7dc;
}
.tg-sec.is-open .tg-letter {
    color: #0d9488;
    background: #edf9f7;
    border-color: #b2dfdb;
}
.tg-sec.is-open:hover .tg-letter { color: #0d9488; }

/* Preview tags (visible when closed) */
.tg-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow: hidden;
    align-items: center;
    mask-image: linear-gradient(to left, transparent 0, #000 40px);
    -webkit-mask-image: linear-gradient(to left, transparent 0, #000 40px);
}
[dir="rtl"] .tg-preview {
    mask-image: linear-gradient(to right, transparent 0, #000 40px);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 40px);
}
.tg-sec.is-open .tg-preview { display: none; }

.tg-preview-tag {
    font-size: 0.78rem;
    color: #848b96;
    white-space: nowrap;
    font-weight: 500;
}
.tg-preview-tag::after {
    content: '\00B7';
    margin-inline-start: 0.45rem;
    opacity: 0.4;
}
.tg-preview-tag:last-child::after { display: none; }

.tg-count {
    font-size: 0.64rem;
    font-weight: 700;
    color: #848b96;
    background: #f0f1f4;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    flex-shrink: 0;
    white-space: nowrap;
    border: 1px solid #e0e3e7;
}
.tg-sec.is-open .tg-count { display: none; }

.tg-arr {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s;
}
.tg-arr svg {
    width: 11px;
    height: 11px;
    stroke: #b0b6c0;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.2s;
}
.tg-sec:hover .tg-arr svg { stroke: #848b96; }
.tg-sec.is-open .tg-arr { transform: rotate(180deg); }
.tg-sec.is-open .tg-arr svg { stroke: #0d9488; }

/* Expanded body */
.tg-body {
    max-height: 0;
    overflow: hidden;
    padding-inline-start: 0;
    margin: 0 1.15rem;
    transition: max-height 0.3s ease, padding 0.25s ease;
}
.tg-sec.is-open .tg-body {
    max-height: 4000px;
    padding-bottom: 1.3rem;
}

.tg-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.4rem;
    align-items: baseline;
    padding-top: 0.9rem;
    padding-inline-start: 0.4rem;
}

/* ======== TAG PILLS ======== */
.tp {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    text-decoration: none;
    font-family: var(--font-main);
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
    line-height: 1;
    padding: 0.38rem 0.65rem;
    border-radius: 7px;
    background: #f7f8fa;
    border: 1px solid transparent;
}
.tp:hover {
    color: #0b8578 !important;
    background: #eef9f7;
    border-color: #ccfbf1;
    box-shadow: 0 1px 3px rgba(13,148,136,0.08);
}
.tp:hover .tp-c { color: #0d9488; }

.tp[data-weight="1"] { font-size: 0.79rem; color: #9ca3af; font-weight: 400; }
.tp[data-weight="2"] { font-size: 0.85rem; color: #6b7280; font-weight: 500; }
.tp[data-weight="3"] { font-size: 0.91rem; color: #374151; font-weight: 500; }
.tp[data-weight="4"] { font-size: 0.98rem; color: #0f766e; font-weight: 600; background: #f0fdfb; }
.tp[data-weight="5"] { font-size: 1.08rem; color: #0d9488; font-weight: 800; background: #edfcf9; }

.tp-c {
    font-size: 0.55em;
    color: #b0b6c0;
    font-weight: 600;
    vertical-align: super;
    transition: color 0.15s;
}
.tp[data-weight="4"] .tp-c,
.tp[data-weight="5"] .tp-c { color: #5eead4; }

.tp.hidden-tag { display: none !important; }

/* No results */
.tg-empty {
    display: none;
    text-align: center;
    padding: 3rem;
    color: #848b96;
    font-size: 0.9rem;
}
.tg-empty.visible { display: block; }

/* ======== MOBILE REDESIGN (phone only) ======== */
@media (max-width: 700px) {

    /* — Hero — */
    .th {
        padding: 2.5rem 1.25rem 3.5rem;
    }
    .th::after { height: 40px; }
    .th-in { position: relative; }

    /* — Search: full-width, comfortable — */
    .th-search {
        position: static;
        transform: none;
        width: 100%;
        max-width: 100%;
        margin: 1.4rem auto 0;
        order: 3;
    }
    .ts {
        padding: 0.7rem 0.85rem 0.7rem 1rem;
        border-radius: 14px;
        min-height: 48px;
    }
    .ts input {
        font-size: 0.92rem;
        padding: 0.35rem 0;
    }
    .ts-x {
        padding: 0.45rem 0.9rem;
        font-size: 0.74rem;
        border-radius: 8px;
    }

    /* — Title & description — */
    .th h1 {
        font-size: 1.75rem;
        letter-spacing: -0.03em;
    }
    .th p {
        font-size: 0.88rem;
        max-width: 340px;
    }

    /* — Stats — */
    .th-nums {
        display: flex;
        justify-content: center;
        gap: 2rem;
        margin-top: 1.3rem;
        padding: 0.9rem 1.5rem;
        border-radius: 10px;
    }
    .th-n strong { font-size: 1.35rem; }
    .th-n small { font-size: 0.58rem; letter-spacing: 1.2px; }

    /* — Alphabet Index: grid for proper touch targets — */
    .ix {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
        gap: 0.3rem;
        top: -1.2rem;
        margin-inline: 1rem;
        padding: 0.75rem 0.85rem;
        border-radius: 10px;
    }
    .ix a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        padding: 0;
        font-size: 0.7rem;
        border-radius: 8px;
        background: #f8f9fa;
        border: 1px solid #edf0f3;
    }

    /* — Tag sections wrapper — */
    .tg-wrap {
        padding: 0 0.85rem;
        margin-top: 0.5rem;
    }

    /* — Tag group cards — */
    .tg-sec {
        border-radius: 12px;
        margin-bottom: 0.5rem;
    }

    /* — Card header — */
    .tg-h {
        gap: 0.7rem;
        padding: 0.8rem 1rem;
    }
    .tg-letter {
        font-size: 1.2rem;
        width: 36px;
        height: 36px;
        border-radius: 9px;
    }

    /* — Hide preview tags on mobile (too cramped, count badge is sufficient) — */
    .tg-preview { display: none; }

    /* — Count badge: slightly larger for readability — */
    .tg-count {
        font-size: 0.68rem;
        padding: 0.25rem 0.7rem;
        margin-inline-start: auto;
    }

    /* — Expanded body — */
    .tg-body { margin: 0 0.9rem; }
    .tg-tags {
        gap: 0.4rem 0.45rem;
        padding-top: 0.8rem;
        padding-inline-start: 0.2rem;
    }

    /* — Tag pills: bigger touch targets — */
    .tp {
        padding: 0.42rem 0.7rem;
        border-radius: 8px;
        min-height: 34px;
        align-items: center;
        line-height: 1.2;
    }
    .tp[data-weight="1"] { font-size: 0.82rem; }
    .tp[data-weight="2"] { font-size: 0.88rem; }
    .tp[data-weight="3"] { font-size: 0.93rem; }
    .tp[data-weight="4"] { font-size: 1rem; }
    .tp[data-weight="5"] { font-size: 1.1rem; }
    .tp-c { font-size: 0.6em; }

    /* — Empty state — */
    .tg-empty { padding: 2.5rem 1.5rem; }
}

/* — Small phone refinements — */
@media (max-width: 480px) {
    .th { padding: 2rem 1rem 3rem; }
    .th h1 { font-size: 1.6rem; }

    .ts input { font-size: 0.9rem; }

    .th-nums {
        gap: 1.5rem;
        padding: 0.8rem 1.2rem;
    }
    .th-n strong { font-size: 1.25rem; }

    .ix {
        grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
        gap: 0.25rem;
        margin-inline: 0.75rem;
        padding: 0.65rem 0.7rem;
    }
    .ix a {
        min-height: 32px;
        font-size: 0.65rem;
    }

    .tg-h { padding: 0.7rem 0.85rem; }
    .tg-letter {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    .tp { padding: 0.38rem 0.6rem; }
}
