/* ============================================
   HOME SECTIONS — dynamic sections rendered from
   /api/home-sections. Appended after Featured Materials.
   No inline styles in JS — all layout/color here.
   ============================================ */

.homesec-container {
    margin-top: 32px;
    width: 100%;
}

.homesec-section {
    margin-bottom: 28px;
    width: 100%;
}

.homesec-section:last-child {
    margin-bottom: 0;
}

.homesec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.homesec-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ---------- Cards layout (materials-style) ---------- */
.homesec-scroll-cards {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 4px 4px 16px 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
}

.homesec-scroll-cards::-webkit-scrollbar {
    display: none;
}

.homesec-card {
    display: flex;
    flex-direction: column;
    width: 240px;
    min-width: 240px;
    background: transparent;
    border: none;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform var(--transition-fast, 0.15s ease);
    position: relative;
    border-radius: 12px;
    padding: 4px;
}

.homesec-card:hover { transform: translateY(-2px); }
.homesec-card:active { transform: scale(0.97); }

.homesec-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1.8 / 1;
    border-radius: 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}

.homesec-card-icon .material-icons-round {
    font-size: 5rem;
    color: #ffffff;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.homesec-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px;
    min-width: 0;
}

.homesec-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.homesec-card-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Tiles layout (quiz-style) ---------- */
.homesec-scroll-tiles {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.homesec-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--divider-color);
    padding: 14px 4px;
    cursor: pointer;
    transition: background-color var(--transition-fast, 0.15s ease);
    position: relative;
    text-align: left;
}

.homesec-tile:last-child { border-bottom: none; }
.homesec-tile:hover { background: var(--bg-surface-light); }
.homesec-tile:active { background: var(--bg-hover); }

.homesec-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 0.4rem;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}

.homesec-tile-icon .material-icons-round {
    font-size: 2.25rem;
    color: #ffffff;
}

.homesec-tile-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.homesec-tile-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.homesec-tile-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile tuning */
@media (max-width: 600px) {
    .homesec-card {
        width: calc(80vw - 40px);
        min-width: calc(80vw - 40px);
    }
    .homesec-card-icon .material-icons-round {
        font-size: 4.5rem;
    }
    .homesec-tile-icon {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    .homesec-tile-icon .material-icons-round {
        font-size: 2rem;
    }
    .homesec-title {
        font-size: 1.2rem;
    }
}


/* ============================================================
   HS-TILE-FEATURED-STYLE — override the tile layout to match
   Featured Quizzes from main-script.js. Featured quizzes uses
   a 3-row horizontal grid with 280px columns, horizontal scroll
   snap. Appended after the original rules so these win by source
   order without needing !important.
   ============================================================ */
.homesec-scroll-tiles {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, auto);
    grid-auto-columns: 280px;
    gap: 8px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 4px 4px 16px 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
}

.homesec-scroll-tiles::-webkit-scrollbar {
    display: none;
}

.homesec-tile {
    gap: 12px;
    padding: 8px 4px;
    scroll-snap-align: start;
    border-bottom: none;
    border-radius: 8px;
}

.homesec-tile:hover {
    background: var(--bg-surface-light);
}

.homesec-tile:active {
    background: var(--bg-hover);
}

.homesec-tile-icon {
    width: 5rem;
    height: 5rem;
    min-width: 48px;
    border-radius: 8px;
}

.homesec-tile-icon .material-icons-round {
    font-size: 2.125rem;
    color: #ffffff;
}

.homesec-tile-body {
    gap: 2px;
}

.homesec-tile-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.homesec-tile-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Mobile — match featured quizzes mobile override */
@media (max-width: 710px) {
    .homesec-scroll-tiles {
        grid-auto-columns: 80vw;
        gap: 8px 12px;
    }
    .homesec-tile {
        gap: 8px;
        padding: 6px 2px;
    }
    .homesec-tile-icon {
        width: 5rem;
        height: 5rem;
        min-width: 40px;
        border-radius: 6px;
    }
    .homesec-tile-icon .material-icons-round {
        font-size: 1.875rem;
    }
}

/* ============================================================
   HS-SCROLL-ARROWS — match .section-arrow-btn from featured
   quizzes/materials in main-script's CSS.
   ============================================================ */
.homesec-scroll-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.homesec-scroll-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast, 0.15s ease);
    pointer-events: auto;
}

.homesec-scroll-arrow:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.homesec-scroll-arrow:active {
    background-color: var(--bg-active);
}

.homesec-scroll-arrow .material-icons-round {
    font-size: 2rem;
    pointer-events: none;
}