/*
 * RV WooCommerce Subcategory Tabs — Stylesheet
 * Plugin: rv-subcategory-tabs
 *
 * YouTube-style scrollable tab bar rendered above product grids on
 * WooCommerce category and subcategory archive pages.
 */


/* -------------------------------------------------------------------------
   LAYOUT FIX — GeneratePress flex container on category pages.

   GeneratePress sets .site-content { display: flex } for its sidebar/
   content layout. By default flex-wrap is "nowrap", which forces ALL
   direct children onto one horizontal line — that is why the tabs and
   products sit side-by-side instead of stacking vertically.

   Two things must work together:

   Step 1) Allow the flex container to wrap onto multiple rows.
   Scoped to .tax-product_cat so this only affects WooCommerce product
   category archives and never touches other pages on the site.

   Step 2) Give .subcategory-tabs-wrapper flex: 0 0 100% so it claims
   the full first row. Once the parent allows wrapping, this forces
   .content-area onto the second row below the tabs.
   ------------------------------------------------------------------------- */

/* Step 1 — allow GeneratePress site-content to wrap on category pages only. */
.tax-product_cat .site-content {
    flex-wrap: wrap;
}

/* Step 2 — make the wrapper claim its own full-width row. */
.subcategory-tabs-wrapper {
    position: relative;     /* anchors the absolutely-positioned nav arrows */
    display: block;
    width: 100%;
    flex: 0 0 100%;         /* claim the entire first flex row */
    align-self: flex-start; /* do not stretch vertically to match siblings */
    min-width: 0;           /* prevents overflow in some flex implementations */
    clear: both;            /* float-layout fallback for older theme variations */
    float: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


/* -------------------------------------------------------------------------
   Scroll strip: horizontally scrollable row of tab links.
   scrollbar-width:none + the ::-webkit-scrollbar rule below hide the native
   scroll bar on all browsers so the UI stays clean.
   ------------------------------------------------------------------------- */
.subcategory-tabs {
    display: flex;
    gap: 2px;
    padding: 14px 0;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;         /* Firefox */
    -ms-overflow-style: none;      /* IE / Edge legacy */
    white-space: nowrap;
    width: 100%;
    margin-bottom: 15px;
}

.subcategory-tabs::-webkit-scrollbar {
    display: none;                 /* Chrome / Safari / new Edge */
}


/* -------------------------------------------------------------------------
   Individual tab link
   flex-shrink:0 prevents the browser from squashing text onto two lines.
   The ::after pseudo-element is the animated underline indicator.
   ------------------------------------------------------------------------- */
.subcategory-tab {
    position: relative;
    padding: 12px 20px;            /* desktop default; overridden in breakpoints */
    color: #f1f1f1;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.3s;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-block;
}

/* Underline indicator — invisible by default, revealed on hover / active */
.subcategory-tab::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background-color: transparent;
    transition: background-color 0.3s;
}

.subcategory-tab:hover {
    color: #ffffff;
}

.subcategory-tab:hover::after {
    background-color: #717171;
}

.subcategory-tab.active {
    color: #ffffff;
}

.subcategory-tab.active::after {
    background-color: #f1f1f1;
}


/* -------------------------------------------------------------------------
   Navigation arrows
   display:none by default; the JS shows them only when overflow exists.
   Using hidden attribute as well; the JS removes it when needed.
   ------------------------------------------------------------------------- */
.nav-arrow {
    display: none;               /* hidden until JS determines overflow */
    position: absolute;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 40px;
    top: 40%;
    transform: translateY(-50%);
    background-color: rgba(15, 15, 15, 0.9);
    border: none;
    color: #f1f1f1;
    font-size: 24px;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.3s;
    border-radius: 4px;
    line-height: 1;
}

.nav-arrow:hover {
    background-color: rgba(40, 40, 40, 0.9);
}

/* The JS adds/removes the hidden attribute; we show with flex when visible. */
.nav-arrow:not([hidden]) {
    display: flex;
}

.nav-prev { left: 0; }
.nav-next { right: 0; }


/* -------------------------------------------------------------------------
   Responsive overrides
   ------------------------------------------------------------------------- */

/* Tablet */
@media (max-width: 1023px) {
    .subcategory-tab {
        font-size: 15px;
        padding: 10px 15px;
    }
}

/* Landscape phones / small tablets */
@media (max-width: 768px) {
    .site-content {
        margin-top: 20px;
    }

    .subcategory-tabs-wrapper {
        margin-top: 5px;
        margin-bottom: 15px;
    }

    .subcategory-tabs {
        padding: 1px 5px;
    }

    .subcategory-tab {
        font-size: 14px;
        padding: 8px 12px;
    }

    .nav-arrow {
        width: 28px;
        height: 36px;
    }
}

/* Portrait phones */
@media (max-width: 480px) {
    .subcategory-tabs-wrapper {
        margin-top: 3px;
        margin-bottom: 15px;
    }

    .subcategory-tab {
        font-size: 13px;
        padding: 8px 14px;
    }

    .nav-arrow {
        width: 24px;
        height: 32px;
    }
}
.tax-product_cat .site-content,
.post-type-archive-product .site-content,
.archive.tax-product_cat .site-content {
    flex-wrap: wrap;
}

/* Make main content also full width so it drops to its own row */
.tax-product_cat .content-area,
.post-type-archive-product .content-area,
.archive.tax-product_cat .content-area {
    flex: 0 0 100%;
}