/* ==========================================================================
   1. VARIABLES & BASE SETTINGS
   ========================================================================== */
:root {
    --theme-orange: #ff8300;
    --theme-dark: #333d47;
    --theme-gray: #5c666f;
    --theme-light: #ffffff;
    --theme-bg-card: #e1e1e1;
    --theme-border: #c7c7c7;
    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --transition: 0.3s ease-in-out;
}

div#content {
    width: auto !important;
    max-width: 1400px !important;
    margin: auto !important;
    padding: 0rem !important;
    min-height: 80vh;
}

.container, .container-fluid, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
    max-width: 1400px !important;
}

.main-page-container {
    padding: 0 2rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.no-banner ~ .title-area > .sectionContainer > .utia-page-title {
    padding: 1rem 2rem !important;
}

/* ==========================================================================
   2. LANDSCAPE WARNING
   ========================================================================== */
.landscape-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.landscape-warning button {
    display: block;
    margin-top: 10px; 
}

/* ==========================================================================
   3. SIDEBAR & FILTERS (DESKTOP DEFAULT)
   ========================================================================== */
.floating-sidebar {
    position: fixed;
    top: 6rem;
    left: 0;
    z-index: 19;
    width: 0%;
    height: 100vh; 
    background-color: transparent;
}

.logged-in .floating-sidebar {
    top: 8rem;
}

.floating-button-sidebar {
    position: fixed;
    top: 8rem;
    left: 0;
    z-index: 18;
    width: 2%;
    background-color: transparent;
}

.floating-sidebar.show {
    width: 450px;
    height: fit-content;
}

.sticky-container {
    width: 450px; 
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 19; 
    padding: 1rem 0.5rem;
    background-color: var(--theme-gray); 
    transition: transform var(--transition);
    max-height: 100vh; 
    overflow-y: auto;
    box-sizing: border-box;
}

/* Desktop Sidebar JS States */
#stickyContainer.desk-show {
    transition: transform var(--transition), opacity 0.5s ease;
    transform: translateY(0%);
    opacity: 1;
}
#stickyContainer.desk-hide {
    transform: translateY(-100%);
    transition: transform var(--transition);
    opacity: 0;
}
.sticky-container.desk-side-show {
    transform: translateX(0%);
}
.sticky-container.desk-side-hide {
    transform: translateX(-100%); 
    transition: transform var(--transition);
}

.sticky-container .main-row {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 0.5rem !important;
    margin: 0 auto !important;
}

.desk-side-row [id^="col-desk-side-"],
.desk-side-row #H4-button-div {
    padding: 0.5rem;
}

.sticky-container .row button.h4-button {
    background: none !important;
    font-size: 0.9rem !important;
    border: none !important;
    color: var(--theme-light) !important;
}

.H4-Curriculum p {
    margin: 0rem;
    padding-left: 0.5rem;
}

input#searchtext {
    height: 2.2rem;
    font-size: 14px;
}

/* ==========================================================================
   4. BUTTONS & UI ELEMENTS
   ========================================================================== */
.solution-search-button {
    background-color: var(--theme-dark) !important;
    color: var(--theme-light) !important;
    padding: 0.5rem 1rem !important;
    font-size: 1rem !important;
    border: 3px solid var(--theme-orange) !important;
    border-radius: var(--radius-lg) !important;
    transition: background-color var(--transition), color var(--transition);
}

.solution-search-button:hover, 
.desk-side button:hover {
    background-color: var(--theme-light) !important;
    color: var(--theme-dark) !important;
    border: 3px solid var(--theme-orange) !important;
}

button.filter-btn.m-1 {
    background-color: rgba(92, 102, 111, 0.13);
    color: var(--theme-dark);
    border-radius: var(--radius-sm);
    border-color: var(--theme-orange);
}

#reset-button {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 0 1rem;
    width: 100%;
    margin-top: 1rem;
}

button#shareable-link {
    border-radius: var(--radius-sm);
    color: var(--theme-dark);
}

/* Desktop Floating Filter Button */
button.filter-show-desktop-button-class {
    top: 5%;
    width: max-content;
    z-index: 19;
    background-color: #dbdee2;
    color: var(--theme-dark);
    padding: 10px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transform: rotate(270deg) translate(-155px, -30px);
    position: sticky;
}

button#filter-hide-desktop-button { z-index: 1001; }
.filter-show-desktop-button-class.show, #filter-hide-desktop-button.show { display: inline-block; }
button.filter-show-desktop-button-class.desk-side-btn-hide, button#filter-hide-desktop-button.desk-side-btn-hide { display: none; }
#filter-show-mobile-button, #filter-hide-mobile-button { display: none; }

/* ==========================================================================
   5. RESULTS AREA & TOP SEARCH BAR
   ========================================================================== */
.col.results-container-main { min-height: 60vh; padding: 5px; }

.sticky-container2 {
    position: -webkit-sticky;
    position: sticky;
    top: 6rem;
    z-index: 10;
    background-color: var(--theme-light);
    padding: 1rem 0rem;
    margin-bottom: 1.5rem;
}
.logged-in .sticky-container2 { top: 8rem; }

input#searchtext2:focus {
    background-color: #e0e0e0;
    border-color: var(--theme-orange);
    outline: none;
    box-shadow: none;
}

.container.results-container { margin-top: 2rem; }

/* ==========================================================================
   6. CARDS & GRID LAYOUT
   ========================================================================== */
/* Modern Grid Setup: Auto-fills columns based on available width */
.pub-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 20px; 
    padding: 0 10px;
}

.pub-grid a { border-bottom: none; text-decoration: none; }

.pub-card { 
    background: var(--theme-bg-card); 
    padding-bottom: 5px; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--theme-border); 
    box-sizing: border-box;
    transition: transform 300ms ease, box-shadow 300ms ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.pub-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.fresh-field-img { 
    width: 100%; 
    height: 200px; 
    object-fit: cover; 
    object-position: top center; 
    border-radius: 10px 10px 0 0; 
    display: block; 
}
.fresh-field-img.default { 
    object-position: center; 
    background-color: #d3d3d3; 
    object-fit: contain !important; 
}

.img-placeholder { background-color: #808080; border-radius: 10px 10px 0 0; }

.card-meta { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 8px 10px; 
    width: 100%; 
    box-sizing: border-box;
}
.pub-label { color: var(--theme-gray); font-size: 0.875rem; font-weight: 400; }
.flex-1 { flex: 1; }

.pub-card h4 { 
    padding: 0 10px; 
    margin: 5px 0 10px; 
    font-size: 1.1rem; 
    line-height: 1.3; 
    color: var(--theme-dark);
    font-weight: 600;
}

/* ==========================================================================
   7. CARD RIBBON
   ========================================================================== */
.ribbon {
    position: absolute; top: 0; right: 0; overflow: hidden;
    width: 55px; height: 55px; text-align: right; z-index: 2;
}
.ribbon span {
    font-size: 10px; font-weight: bold; color: var(--theme-light);
    text-transform: uppercase; text-align: center; line-height: 20px;
    transform: rotate(45deg); width: 100px; display: block;
    background: #ff5722; box-shadow: 0 3px 10px -5px rgba(0, 0, 0, 1);
    position: absolute; top: 10px; right: -30px;
}
.ribbon::before, .ribbon::after { content: ""; position: absolute; z-index: -1; }
.ribbon::before { top: 0; left: 0; border-top: 3px solid #ff5722; border-left: 3px solid #ff5722; }
.ribbon::after { bottom: 0; right: 0; border-bottom: 3px solid #ff5722; border-right: 3px solid #ff5722; }

/* ==========================================================================
   8. MEDIA QUERIES (RESPONSIVE DESIGN)
   ========================================================================== */

/* TABLET & MOBILE (Consolidated layout) */
@media screen and (max-width: 992px) {
    .main-page-container { padding: 0 1rem; }
    
    .sticky-container {
        position: fixed;
        top: 10%;
        bottom: 5%; /* Pin bottom for safe mobile scrolling */
        left: 0;
        width: 90%;
        max-width: 500px; /* Prevents it from getting too wide on iPads */
        background-color: var(--theme-gray);
        z-index: 1000;
        padding: 1rem;
        box-sizing: border-box;
        overflow-y: auto; /* Enables inner scrolling */
        transition: transform var(--transition);
        box-shadow: 0 0 20px rgba(0,0,0,0.5);
    }
    
    .sticky-container.mob-show { transform: translateX(0%); }
    .sticky-container.mob-hide { transform: translateX(-105%); }

    .sticky-container .main-row { padding: 0 !important; }
    [id^="col-desk-side-"], #H4-button-div { padding: 0.25rem 0; margin-bottom: 0 !important; width: 100%; }
    [id^="col-desk-side-"] select { font-size: 0.875rem; }

    #filter-show-mobile-button, #filter-hide-mobile-button { display: inline-block; }
    #filter-show-mobile-button.hide, #filter-hide-mobile-button.hide { display: none; }
    button.filter-show-desktop-button-class { transform: rotate(270deg) translate(-100px, -65px); }
    
    .results-container-main h2.heading { text-align: center; }
    .floating-sidebar { top: 9rem; width: 100%; pointer-events: none; } /* Avoid invisible click blocking */
    .floating-sidebar.show { pointer-events: auto; }
    
    .sticky-container2 { top: 9rem; position: relative; padding: 1rem 0; }
    div#search-field, div#H4-Curriculum { padding: 0; width: 100%; }
    
    /* Slightly smaller grid gap for tablets */
    .pub-grid { gap: 15px; }
}

/* SMALL MOBILE (Forcing 2 columns specifically requested) */
@media screen and (max-width: 500px) {
    .sticky-container { width: 95%; max-width: none; top: 12%; }
    
    /* Force 2 columns on small screens down to 376px */
    .pub-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .pub-card h4 { font-size: 0.95rem; }
    .pub-label { font-size: 0.75rem; }
    .fresh-field-img { height: 150px; }
}

/* EXTRA SMALL SCREENS (Stacking to 1 column) */
@media screen and (max-width: 376px) {
    .pub-grid { grid-template-columns: 1fr; }
    .fresh-field-img { height: 200px; }
    
    button#SearchReset, button#filter-hide-desktop-button { padding: 0.75rem 1rem; }
    h1.utia-page-title { font-size: 1.8rem; padding: 0.75rem 1rem !important; }
    button#filter-show-desktop-button, button#SearchReset2 { font-size: 0.875rem !important; }
    .breadcrumb { padding: 0.75rem 1rem !important; }
}

/* LANDSCAPE ORIENTATION WARNING */
@media (orientation: landscape) and (max-width: 789px) and (max-device-width: 1024px) {
    .landscape-warning.see { display: flex !important; }
    body { overflow: hidden; }
    .content, .main-page-container { display: none; }
}