:root {
    --category-color: var(--color-accent-2);
}

.category-header {
    padding: 60px 0;
    color: white;
    position: relative;
    overflow: hidden;
}

.category-header::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.category-header::after {
    content: '';
    position: absolute;
    bottom: -10%;
    left: -5%;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.category-info {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 40px;
}

.category-icon {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.category-icon:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

.category-details {
    flex: 1;
}

.category-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-description {
    font-size: 1.2rem;
    margin-bottom: 25px;
    opacity: 0.95;
    line-height: 1.5;
}

.category-stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 500;
}

.stat-item i {
    font-size: 1.1rem;
    opacity: 0.8;
}

.controls-section {
    background: var(--color-surface);
    padding: 25px 0;
    border-bottom: 1px solid var(--color-bg-light-mid);
    box-shadow: 0 2px 4px var(--color-shadow-weak);
}

.controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.sort-control {
    /* align label + select neatly */
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.sort-control label {
    font-weight: 500;
    color: var(--color-meta);
    white-space: nowrap;
}

.sort-select {
    /* Custom styled select: neutral, modern, with custom arrow (SVG data-uri) */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 10px 42px 10px 14px; /* room for custom arrow on the right */
    min-width: 220px;
    border: 1px solid var(--color-bg-light-mid);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--color-surface), color-mix(in srgb, var(--color-surface) 92%, white 8%));
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 220ms cubic-bezier(0.4,0,0.2,1), box-shadow 220ms cubic-bezier(0.4,0,0.2,1), background-color 220ms;
    box-shadow: 0 2px 6px rgba(16,24,40,0.04);
    background-repeat: no-repeat;
    background-position: right 12px center;
    /* SVG arrow (subtle) */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='10' viewBox='0 0 16 10'><path d='M1 1l7 7 7-7' fill='none' stroke='%234fd1c7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    /* ensure options text wraps nicely */
    white-space: nowrap;
}

/* platform fixes */
.sort-select::-ms-expand { display: none; }

/* Focus / active */
.sort-select:focus,
.sort-select:focus-visible {
    outline: none;
    border-color: var(--category-color, var(--color-accent-2));
    box-shadow: 0 6px 18px rgba(79,209,199,0.12);
    background-color: var(--color-surface);
}

/* When a data-color-border is provided (inline attribute), allow a subtle border tint */
.sort-select[data-color-border] {
    border-color: color-mix(in srgb, var(--color-bg-light-mid) 70%, var(--color-accent-2) 30%);
}

/* Mobile / small screens: full-width and easier tap targets */
@media (max-width: 768px) {
    .sort-control {
        width: 100%;
        gap: 8px;
        align-items: flex-start;
        flex-direction: column;
    }

    .sort-control label {
        width: 100%;
        font-size: 0.95rem;
    }

    .sort-select {
        width: 100%;
        min-width: 0;
        padding: 12px 42px 12px 14px;
        font-size: 1rem;
        border-radius: 12px;
        box-shadow: none;
        background-position: right 14px center;
    }
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.view-btn {
    width: 35px;
    height: 35px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #4a5568;
}

@media (max-width: 768px) {
    .view-controls {
        display: none;
    }

    .articles-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .articles-grid.grid-view {
        display: grid !important;
    }
}

.view-btn.active {
    color: white;
}

.results-count {
    color: #4a5568;
    font-size: 0.9rem;
    font-weight: 500;
}

.breadcrumb {
    background: transparent;
    padding: 20px 0;
    font-size: 1rem;
    font-weight: 400;
}

.breadcrumb-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-link {
    color: var(--color-muted);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s ease;
    letter-spacing: 0.01em;
}

@media (hover: hover) {
    .breadcrumb-link:hover {
        color: #4fd1c7;
        text-decoration: none;
    }

    .breadcrumb-list:hover .breadcrumb-link:not(:hover) {
        color: #a0aec0;
        transition: color 0.2s ease;
    }

    .breadcrumb-list:hover .breadcrumb-link:hover {
        color: #4fd1c7;
    }
}

.breadcrumb-link:active {
    color: #4fd1c7;
    transform: scale(0.98);
}

.breadcrumb-link:focus {
    outline: none;
    color: #4fd1c7;
}

.breadcrumb-current {
    color: #2d3748;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.breadcrumb-separator {
    color: #565859;
    font-size: 0.9rem;
    font-weight: 300;
    user-select: none;
    margin: 0 4px;
}

@media (max-width: 768px) {
    .breadcrumb {
        padding: 15px 0;
        font-size: 0.9rem;
    }

    .breadcrumb-container {
        padding: 0 15px;
    }

    .breadcrumb-list {
        gap: 8px;
    }

    .breadcrumb-separator {
        margin: 0 2px;
    }
}

@media (max-width: 480px) {
    .breadcrumb {
        font-size: 0.85rem;
    }

    .breadcrumb:has(.breadcrumb-item:nth-child(4)) .breadcrumb-item:nth-child(3):not(:nth-last-child(2))::before {
        content: "...";
        color: #cbd5e0;
        margin-right: 8px;
    }
}

.breadcrumb {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.articles-section {
    padding: 10px 0 40px;
}

.articles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

.articles-grid.grid-view {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.article-card.visible {
    background: var(--color-surface);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px var(--shadow-0-08);
    transition: all 0.3s ease;
    border: 1px solid var(--color-bg-light-mid);
    display: flex;
    gap: 20px;
}

.article-card {
    display: none;
}

@media (hover: hover) {
    .article-card.visible:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
        border-color: var(--category-color, #4fd1c7);
    }

    .article-image img:hover {
        transform: scale(1.05);
    }

    .read-more:hover {
        color: var(--category-color);
    }
}

.article-card:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--category-color, #4fd1c7);
}

.read-more:active {
    color: #38f9d7 !important;
}

.article-image {
    width: 100%;
    height: 100%;
    background: var(--color-bg-light-start);
    border-radius: 10px;
    display: flex;
    position: relative;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.article-image:hover img {
    transform: scale(1.1);
}

#articlImgLink {
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
    width: 18%;
    height: 100%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.grid-view #articlImgLink {
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
}

.article-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-title {
    max-width: max-content;
    white-space: normal;
    word-break: break-word;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 10px;
    line-height: 1.3;
    text-decoration: none;
    transition: color 0.3s ease;
}

.article-title:focus {
    color: var(--category-color, #38f9d7);
}

@media (max-width: 768px) {
    #articlImgLink {
        text-decoration: none;
        color: inherit;
        width: 100%;
        height: 100%;
    }

    .article-meta {
        flex-direction: row;
        justify-content: flex-start;
        gap: 10px;
    }

    .controls-left {
        justify-content: flex-start;
        align-items: flex-start;
        flex-direction: column;
        gap: 15px;
    }

    .sort-control {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .sort-control label {
        align-self: flex-start;
    }

    .sort-select {
        width: 100%;
        min-width: auto;
    }
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #4a5568;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.article-excerpt {
    display: -webkit-box;
    text-overflow: ellipsis;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    color: black;
    line-height: 1.6;
    margin-bottom: 15px;
    flex: 1;
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.read-more {
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.read-more:hover {
    text-decoration: underline;
}

.article-actions {
    display: flex;
    gap: 15px;
}

.action-btn {
    background: none;
    border: none;
    color: #4a5568;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.3s ease;
}

.action-btn:hover {
    color: #43e97b;
}

.action-btn.liked {
    color: #e53e3e;
}

.articles-grid.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
}

.grid-view .article-card {
    flex-direction: column;
}

.grid-view .article-image {
    width: 100%;
    height: 200px;
}

#show-more-btn {
    background: linear-gradient(135deg, var(--color-accent-2), var(--color-accent-3));
    color: var(--color-surface);
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 30px auto;
    min-width: 200px;
    box-shadow: 0 4px 15px rgba(79, 209, 199, 0.3);
    position: relative;
    overflow: hidden;
}

@media (hover: hover) {
    #show-more-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(79, 209, 199, 0.4);
    }
}

#show-more-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 10px rgba(79, 209, 199, 0.3);
}

@media (max-width: 768px) {
    #show-more-btn:active {
        transform: translateY(3px) scale(0.96);
        box-shadow: 0 1px 8px rgba(79, 209, 199, 0.4);
    }
}

#show-more-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

#show-more-btn.loading .btn-text {
    opacity: 0.7;
}

#show-more-btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

#show-more-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#show-more-btn:active::before {
    width: 300px;
    height: 300px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .category-info {
        flex-direction: column;
        text-align: center;
        gap: 25px;
    }

    .category-icon {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }

    .category-stats {
        justify-content: center;
    }

    .controls-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .controls-left {
        justify-content: space-between;
    }

    .results-count {
        text-align: center;
    }

    .article-card {
        flex-direction: column;
        gap: 15px;
    }

    .article-image {
        width: 100%;
        height: 150px;
    }

    .articles-grid.grid-view {
        grid-template-columns: 1fr;
    }

    #show-more-btn {
        width: 100%;
        margin: 20px 0;
        padding: 15px 20px;
        font-size: 0.9rem;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-card {
    animation: fadeInUp 0.6s ease-out both;
}

#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background-color: #38b2ac;
    color: white;
    font-size: 24px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

#backToTop.hide {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9);
}

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #4fd1c7, #38b2ac);
    z-index: 1000;
    transition: width 0.1s ease;
}

body.dark-theme .category-icon {
    background: rgba(28, 31, 36, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.dark-theme .controls-section {
    background: var(--color-bg-dark-start);
    border-bottom: 1px solid var(--color-bg-dark-mid);
}

body.dark-theme .sort-control label {
    color: #a0aec0;
}

body.dark-theme .sort-select {
    background: #111827;
    border: 1px solid #2d3748;
    color: #e2e8f0;
}

body.dark-theme .sort-select:focus {
    border-color: #4fd1c7;
}

body.dark-theme .view-btn {
    background: transparent;
    border: 1px solid #111827;
}

body.dark-theme .view-btn.active {
    background: #4fd1c7;
    border-color: #4fd1c7;
    color: white;
}

body.dark-theme .view-btn:hover {
    border-color: #4fd1c7;
    color: #4fd1c7;
}

body.dark-theme .view-btn.active:hover {
    color: white;
}

body.dark-theme .results-count {
    color: #a0aec0;
}

body.dark-theme .breadcrumb-current {
    color: #f7fafc;
}

body.dark-theme .breadcrumb {
    background: #111827;
}

body.dark-theme .breadcrumb-separator {
    color: #a0aec0;
}

body.dark-theme .articles-section {
    background: #111827;
}

body.dark-theme .article-card.visible {
    background: var(--color-bg-dark-start);
    border: 1px solid var(--color-bg-dark-mid);
}

body.dark-theme .article-card.visible:hover {
    border-color: #4fd1c7;
}

body.dark-theme .article-title {
    color: #f7fafc;
}

@media (hover: hover) {
    body.dark-theme .article-title:hover {
        color: #4fd1c7;
    }
}

body.dark-theme .article-meta {
    color: #a0aec0;
}

body.dark-theme .article-excerpt {
    color: #a0aec0;
}

body.dark-theme .read-more:hover {
    color: #38f9d7;
}

body.dark-theme .action-btn {
    color: #a0aec0;
}

body.dark-theme .action-btn:hover {
    color: #4fd1c7;
}

body.dark-theme .action-btn.liked {
    color: #e53e3e;
}

body.dark-theme #backToTop {
    background-color: #38b2ac;
}

.view-btn:focus-visible,
.article-title:focus-visible,
.read-more:focus-visible,
.breadcrumb-link:focus-visible,
#show-more-btn:focus-visible,
#backToTop:focus-visible {
    outline: 2px solid var(--color-accent-2);
    outline-offset: 4px;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .category-header {
        padding: 30px 0;
        min-height: auto;
    }

    .category-info {
        gap: 20px;
    }

    .category-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .category-title {
        font-size: 1.8rem;
        line-height: 1.3;
    }

    .category-description {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .category-stats {
        flex-direction: row;
        gap: 8px;
    }

    .stat-item {
        font-size: 0.85rem;
    }

    .controls-container {
        padding: 0 10px;
    }

    .sort-control {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        width: 100%;
    }

    .sort-select {
        width: 100%;
        font-size: 0.9rem;
        padding: 10px 12px;
        margin: 0;
        margin-top: 10px;
    }

    .view-controls {
        gap: 8px;
    }

    .view-btn {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    .results-count {
        font-size: 0.85rem;
        margin-top: 10px;
    }

    .article-card.visible {
        padding: 15px;
        gap: 15px;
    }

    .article-image {
        height: 120px;
    }

    .article-title {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    .article-meta {
        gap: 10px;
    }

    .meta-item {
        font-size: 0.8rem;
    }

    .article-excerpt {
        font-size: 0.85rem;
        line-height: 1.5;
        -webkit-line-clamp: 3;
    }

    #show-more-btn {
        padding: 12px 20px;
        font-size: 0.85rem;
        min-width: auto;
    }

    #backToTop {
        width: 45px;
        height: 45px;
        bottom: 15px;
        right: 15px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 0 10px;
    }

    .category-header {
        padding: 25px 0;
    }

    .category-icon {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }

    .category-title {
        font-size: 1.6rem;
    }

    .article-card.visible {
        padding: 12px;
    }

    .article-image {
        height: 120px;
    }

    .breadcrumb-container {
        padding: 0 10px;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .category-header {
        padding: 20px 0;
        min-height: auto;
    }

    .category-info {
        flex-direction: row;
        text-align: left;
        gap: 20px;
    }

    .category-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .category-title {
        font-size: 1.5rem;
    }

    .category-description {
        font-size: 0.9rem;
    }

    .controls-container {
        flex-direction: row;
        align-items: center;
    }

    .controls-left {
        flex-direction: row;
    }

    .sort-control {
        flex-direction: row;
        align-items: center;
    }
}

@media (hover: none) and (pointer: coarse) {

    .view-btn,
    .sort-select,
    #show-more-btn,
    #backToTop {
        min-height: 44px;
        min-width: 44px;
    }

    .article-card.visible {
        transition: none;
    }

    .article-card.visible:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    }

    .read-more {
        padding: 8px 0;
        display: inline-block;
    }
}

@media (prefers-contrast: high) {
    .article-card.visible {
        border: 2px solid;
    }

    .sort-select,
    .view-btn {
        border: 2px solid;
    }

    #show-more-btn {
        border: 2px solid;
    }
}

@media (prefers-reduced-motion: reduce) {

    .article-card.visible,
    .view-btn,
    #show-more-btn,
    #backToTop {
        transition: none;
        animation: none;
    }

    .article-card.visible:hover {
        transform: none;
    }

    #show-more-btn:hover {
        transform: none;
    }

    html {
        scroll-behavior: auto;
    }
}

@media print {
    .category-header {
        background: none !important;
        color: black !important;
        padding: 20px 0;
    }

    .controls-section,
    #show-more-btn,
    #backToTop,
    .social-links {
        display: none !important;
    }

    .article-card.visible {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 20px;
    }

    .article-image {
        display: none;
    }

    .article-title {
        color: black !important;
        text-decoration: none !important;
    }

    .read-more {
        display: none;
    }

    .breadcrumb {
        background: none !important;
        border: none !important;
    }
}

@media (max-width: 480px) {
    body.dark-theme .controls-section {
        background: #0f172a;
    }

    body.dark-theme .article-card.visible {
        background: #1e293b;
        border-color: #334155;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .category-info {
        gap: 30px;
    }

    .category-icon {
        width: 90px;
        height: 90px;
        font-size: 2.2rem;
    }

    .category-title {
        font-size: 2rem;
    }

    .article-card.visible {
        padding: 20px;
    }

    .article-image {
        height: 160px;
    }

    .controls-left {
        gap: 15px;
    }
}

.article-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

.sort-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.view-btn:focus-visible,
.sort-select:focus-visible {
    z-index: 10;
}

@media (max-width: 480px) {
    .breadcrumb {
        font-size: 0.85rem;
    }

    .breadcrumb:has(.breadcrumb-item:nth-child(4)) .breadcrumb-item:nth-child(3):not(:nth-last-child(2))::before {
        content: "...";
        color: #cbd5e0;
        margin-right: 8px;
    }
}