/* Top 10 Items Plugin - all selectors prefixed with .topten- to avoid theme conflicts */
/* Uses container queries so layout adapts to the available space, not the viewport */

.topten-wrap {
    width: 100%;
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
    align-items: center;
    font-family: Helmet, Freesans, sans-serif;
    color: #000;
    -webkit-font-smoothing: antialiased;
    container-type: inline-size;
    container-name: topten;
}

.topten-wrap *,
.topten-wrap *::before,
.topten-wrap *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Page Header */
.topten-page-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.topten-page-title {
    font-size: clamp(20px, 3cqi, 36px);
    font-weight: 900;
    line-height: 1.1;
    color: #000;
    margin: 0;
}

.topten-page-subtitle {
    font-size: 13px;
    line-height: 20px;
    color: #52525c;
    margin: 0;
}

/* Main Layout */
.topten-layout {
    display: flex;
    gap: 24px;
    width: 100%;
}

/* Main Card */
.topten-card {
    flex: 1;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 14px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.1);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
    overflow: hidden;
}

/* Featured Item */
.topten-featured {
    display: flex;
    gap: 32px;
}

.topten-featured-img-wrap {
    position: relative;
    width: 40%;
    max-width: 480px;
    aspect-ratio: 1;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 0 1px #e4e4e7;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    margin: 0 auto;
}

.topten-featured-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* Rank Badges */
.topten-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: Helmet, Freesans, sans-serif;
}

.topten-rank--lg {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 48px;
    height: 48px;
    background: #e91e8c;
    color: #fff;
    font-size: 18px;
    font-weight: 900;
    line-height: 28px;
    box-shadow:
        0 10px 15px rgba(0, 0, 0, 0.1),
        0 4px 6px rgba(0, 0, 0, 0.1);
}

.topten-rank--sm {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background: #000;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
}

/* Featured Details */
.topten-featured-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.topten-featured-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topten-featured-name {
    font-size: clamp(18px, 2.5cqi, 24px);
    font-weight: 700;
    line-height: 1.3;
    color: #000;
    margin: 0;
}

/* Features / Description */
.topten-features {
    padding-top: 8px;
}

.topten-features ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.topten-features li {
    font-size: 14px;
    line-height: 20px;
    padding-left: 24px;
    position: relative;
}

.topten-features li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.2em;
    width: 1em;
    height: 1em;
    background: url("../images/bullet.png") no-repeat center / contain;
}

/* Buttons */
.topten-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
}

.topten-btn {
    height: 48px;
    border-radius: 10px;
    border: none;

    font-family: Helmet, Freesans, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topten-btn--primary {
    flex: 1;
    background: #000;
    color: #fff;
}

.topten-btn--primary:hover {
    background: #333;
    color: #fff;
}

/* Divider */
.topten-divider {
    border: none;
    border-top: 1px solid #e4e4e7;
    margin: 0;
}

/* Grid Section */
.topten-grid-section {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.topten-grid-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 16px;
}

.topten-grid-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    color: #18181b;
    margin: 0;
}

.topten-grid-subtitle {
    font-size: 12px;
    line-height: 16px;
    color: #52525c;
    margin: 0;
}

/* Item Grid */
.topten-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.topten-product {
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    background: #fff;
    box-shadow: 0 0 0 1px #e4e4e7;
}

.topten-product:hover {
    box-shadow:
        0 0 0 1px #d4d4d8,
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.topten-product--active {
    box-shadow:
        0 0 0 2px #e91e8c,
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.topten-product-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.topten-product-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.topten-product-info {
    background: #fff;
    border-top: 1px solid #f4f4f5;
    padding: 10px;
    min-height: 56px;
}

.topten-product-name {
    font-size: 12px;
    font-weight: 700;
    line-height: 15px;
    color: #000;
    margin: 0 0 6px 0;
}

.topten-product-link {
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    color: #e91e8c;
    text-decoration: none;
}

.topten-product-link:hover {
    text-decoration: underline;
}

/* Sidebar */
.topten-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 8px;
}

.topten-sidebar-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 20px;
    color: #18181b;
    padding-left: 16px;
    margin: 0;
}

.topten-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topten-nav-item {
    display: block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
    position: relative;
}

.topten-nav-item:hover {
    color: #000;
}

.topten-nav-item--active {
    font-weight: 700;
    color: #000;
}

.topten-nav-item--active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: #e91e8c;
}

/* Nested sidebar (desktop) */
.topten-nav-group {
    display: flex;
    flex-direction: column;
}

.topten-nav-parent {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.topten-nav-chevron {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 2px solid #52525c;
    border-bottom: 2px solid #52525c;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    margin-right: 8px;
    flex-shrink: 0;
}

.topten-nav-group--expanded .topten-nav-chevron {
    transform: rotate(45deg);
}

.topten-nav-children {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 2px 0 4px;
}

.topten-nav-group--expanded .topten-nav-children {
    display: flex;
}

.topten-nav-child {
    padding-left: 32px !important;
    font-size: 13px;
    color: #52525c;
}

.topten-nav-child.topten-nav-item--active {
    color: #000;
}

a:link {
    -webkit-tap-highlight-color: transparent !important;
}

/* Category Dropdown (mobile) */
.topten-category-select {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23000' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    -webkit-tap-highlight-color: transparent;
}

.topten-category-select:focus {
    outline: none;
    border-color: #e91e8c;
    box-shadow: 0 0 0 2px rgba(233, 30, 140, 0.2);
}

/* ----------------------------------------------------------------
   Container Queries — adapt to the plugin's own available width.
   Works inside any WP theme regardless of surrounding layout.
   ---------------------------------------------------------------- */

@container topten (max-width: 800px) {
    .topten-layout {
        flex-direction: column;
        gap: 16px;
    }
    .topten-sidebar {
        width: 100%;
        padding-top: 0;
        order: -1;
    }
    .topten-sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0;
    }
    .topten-nav-item {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    .topten-nav-item--active::before {
        width: 100%;
        height: 3px;
        top: auto;
        bottom: 0;
        left: 0;
    }
    .topten-featured {
        flex-direction: column;
        gap: 20px;
    }
    .topten-featured-img-wrap {
        width: 100%;
        aspect-ratio: 16 / 9;
    }
    .topten-card {
        padding: 20px;
        gap: 24px;
        order: 1;
    }
}

@container topten (max-width: 500px) {
    .topten-card {
        padding: 14px;
        gap: 20px;
        border-radius: 10px;
    }
    .topten-btn {
        height: 42px;
        font-size: 14px;
    }
    .topten-features li {
        font-size: 13px;
        line-height: 18px;
    }
    .topten-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .topten-grid-section {
        gap: 20px;
    }
}

/* ----------------------------------------------------------------
   Media Query Fallbacks — ensures mobile works even if the browser
   doesn't support container queries or the theme wrapper blocks them.
   ---------------------------------------------------------------- */

/* Tablet / narrow desktop — sidebar on top, horizontal nav */
@media (max-width: 1200px) {
    #topten-app .topten-layout {
        flex-direction: column !important;
        gap: 16px !important;
    }
    #topten-app .topten-sidebar {
        width: 100% !important;
        padding-top: 0;
        order: -1 !important;
    }
    #topten-app .topten-sidebar-nav {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0;
    }
    #topten-app .topten-nav-item {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    #topten-app .topten-nav-item--active::before {
        width: 100%;
        height: 3px;
        top: auto;
        bottom: 0;
        left: 0;
    }
    #topten-app .topten-featured {
        flex-direction: column !important;
        gap: 20px !important;
    }
    #topten-app .topten-featured-img-wrap {
        width: 100% !important;
        aspect-ratio: 16 / 9 !important;
    }
    #topten-app .topten-card {
        padding: 20px;
        gap: 24px;
        order: 1 !important;
    }
}

/* Touch devices — use pointer detection to catch phones/tablets
   regardless of their reported viewport width */
@media (pointer: coarse) {
    #topten-app .topten-layout {
        flex-direction: column !important;
        gap: 16px !important;
    }
    #topten-app .topten-sidebar {
        width: 100% !important;
        padding-top: 0;
        order: -1 !important;
    }
    #topten-app .topten-sidebar-nav {
        gap: 0;
    }
    #topten-app .topten-nav-item--active::before {
        width: 100%;
        height: 3px;
        top: auto;
        bottom: 0;
        left: 0;
    }
    #topten-app .topten-featured {
        flex-direction: column !important;
        gap: 20px !important;
    }
    #topten-app .topten-featured-img-wrap {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 2 / 1 !important;
        margin: 0 auto !important;
    }
    #topten-app .topten-featured-img {
        position: absolute !important;
        top: 10% !important;
        left: 20% !important;
        right: 20% !important;
        bottom: 10% !important;
        width: auto !important;
        height: auto !important;
        max-width: 60% !important;
        max-height: 80% !important;
        object-fit: contain !important;
        margin: auto !important;
    }
    #topten-app .topten-product-img-wrap {
        aspect-ratio: 4 / 3 !important;
        padding: 8px;
    }
    #topten-app .topten-product-img {
        width: 60% !important;
        height: 60% !important;
    }
    #topten-app .topten-product-info {
        padding: 10px !important;
        min-height: auto !important;
    }
    #topten-app .topten-product-name {
        font-size: 18px !important;
        line-height: 22px !important;
        margin: 0 0 4px 0 !important;
    }
    #topten-app .topten-product-link {
        font-size: 18px !important;
        line-height: 22px !important;
    }
    #topten-app .topten-rank--sm {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }
    #topten-app .topten-featured-name {
        font-size: 36px !important;
        line-height: 42px !important;
    }
    #topten-app .topten-features li {
        font-size: 21px !important;
        line-height: 30px !important;
    }
    #topten-app .topten-btn {
        font-size: 24px !important;
        height: 60px !important;
    }
    #topten-app .topten-page-title {
        font-size: 36px !important;
        line-height: 42px !important;
    }
    #topten-app .topten-page-subtitle {
        font-size: 20px !important;
    }
    #topten-app .topten-grid-title {
        font-size: 30px !important;
    }
    #topten-app .topten-grid-subtitle {
        font-size: 18px !important;
    }
    #topten-app .topten-sidebar-title {
        font-size: 27px !important;
    }
    #topten-app .topten-nav-item {
        font-size: 21px !important;
    }
    #topten-app .topten-card {
        padding: 16px;
        gap: 20px;
        order: 1 !important;
    }
    #topten-app .topten-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
}

/* Small screens — tighter spacing only, no font overrides (pointer: coarse handles those) */
@media (max-width: 600px) {
    #topten-app.topten-wrap {
        padding: 16px 0;
        gap: 16px;
    }
    #topten-app .topten-card {
        padding: 14px;
        gap: 20px;
        border-radius: 10px;
    }
    #topten-app .topten-grid-section {
        gap: 20px;
    }
}
