/* static/css/base.css — structure only, no hardcoded colours */

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    text-align: justify;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ===== HEADER ===== */
.site-header {
    background-color: var(--main-color);
    padding: 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    min-width: 0;
}

.site-logo-link {
    height: 3.5rem;
    display: flex;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
}

#siteLogoImg {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    transition: filter 0.2s ease;
}

@media (max-width: 767px) {
    .site-header {
        padding: 0.75rem 1rem;
    }
    .header-container {
        gap: 0.5rem;
    }
    .site-logo-link {
        height: 2rem;
    }
    .mobile-menu-btn {
        padding: 0.25rem;
        margin-right: 0;
    }
    #themeToggleBtn {
        padding: 0.25rem;
    }
    #themeToggleIcon {
        height: 1.75rem;
    }
}

#siteLogoImg:hover {
    filter: brightness(0.8);
}

[data-theme="light"] #siteLogoImg:hover {
    filter: opacity(0.6);
}


.mobile-menu-btn {
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    cursor: pointer;
    color: inherit;
}


.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== SEARCH BAR ===== */
.custom-search-form {
    display: none;
}

@media (min-width: 768px) {
    .custom-search-form {
        display: flex;
        width: min(20rem, 40vw);
    }
}

.custom-input-group {
    display: flex;
    align-items: stretch;
    border-radius: 999px;
    overflow: hidden;
    width: 100%;
}

.custom-input-group:focus-within {
    box-shadow: var(--search-focus-shadow, 0 0 0 0.25rem rgba(0, 0, 0, 0.15));
}

.custom-search-input {
    padding: 0.5rem 1.25rem;
    font-size: 1.1rem;
    color: var(--text-color);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 999px 0 0 999px;
    outline: none;
    flex: 1;
    min-width: 0;
}

.custom-search-input:focus {
    border-color: var(--bs-link-color);
    box-shadow: none;
}

.custom-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.1rem;
    background-color: var(--bs-link-color);
    border: 1px solid var(--bs-link-color);
    color: white;
    border-radius: 0 999px 999px 0;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.custom-search-btn:hover {
    background-color: var(--link-hover-color);
    border-color: var(--link-hover-color);
}

/* ===== THEME TOGGLE ===== */
#themeToggleBtn {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    padding: 0.4rem;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

#themeToggleBtn::before,
#themeToggleBtn::after {
    content: '';
    position: absolute;
    inset: -15%;
    border-radius: 50%;
    pointer-events: none;
    transition: opacity 0.2s ease;
    filter: blur(10px);
    z-index: -1;
}

#themeToggleBtn::before {
    background: radial-gradient(circle, var(--toggle-glow) 0%, transparent 70%);
    opacity: 1;
}

#themeToggleBtn::after {
    background: radial-gradient(circle, var(--toggle-glow-hover) 0%, transparent 70%);
    opacity: 0;
}

#themeToggleBtn:hover::before {
    opacity: 0;
}

#themeToggleBtn:hover::after {
    opacity: 1;
}

#themeToggleIcon {
    height: 2.5rem;
    width: auto;
    display: block;
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    display: flex;
    flex-grow: 1;
    width: 100%;
}

/* ===== SIDEBAR ===== */
.desktop-sidebar {
    display: none;
    width: max-content;
}

.sidebar-inner {
    padding: 0.5rem 1.5rem 0 1.5rem;
}

.sidebar-section-heading {
    margin: 0 0 0 0.75rem;
    padding-bottom: 0.75rem;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--recent-date-color);
}

.sidebar-section-heading-link {
    display: block;
    text-decoration: none;
}

.sidebar-section-heading-link:hover {
    color: var(--bs-link-color);
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.desktop-sidebar .sidebar-nav-list {
    width: max-content;
}

.sidebar-nav-link {
    display: block;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.15s ease;
}

.sidebar-nav-link:hover {
    background-color: var(--nav-hover-bg);
    color: var(--bs-link-color);
}

.sidebar-divider {
    margin: 1rem 0;
    border: 0;
    border-top: 0.1rem solid var(--border-color);
}

/* ===== MOBILE OFFCANVAS ===== */
.offcanvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0 1.5rem;
}

.offcanvas-header .sidebar-section-heading {
    padding-bottom: 0;
}


.offcanvas-close-btn {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    cursor: pointer;
}

.offcanvas-body {
    padding: 1.5rem;
    font-size: 1.25rem;
}

.offcanvas-search-form {
    margin-bottom: 1.5rem;
}

/* Slide-in panel — hidden off-screen by default */
.custom-offcanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 25vw;
    min-width: 260px;
    max-width: 100vw;
    height: 100vh;
    z-index: 1050;
    background-color: var(--main-color);
    transform: translateX(-100%);
    transition: transform 0.15s ease-in-out;
    overflow-y: auto;
}

@media (max-width: 480px) {
    .custom-offcanvas {
        width: 100vw;
    }
}

.custom-offcanvas.open {
    transform: translateX(0);
}

/* Semi-transparent backdrop behind the offcanvas */
.offcanvas-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.offcanvas-backdrop.open {
    display: block;
}



/* ===== MAIN CONTENT ===== */
.content-area {
    flex-grow: 1;
    padding: 1.5rem 1rem;
}

.custom-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}


/* ===== BREADCRUMBS ===== */
/* Default: align with .narrow-page content (max-width 880px, 0.5rem horizontal padding). */
.custom-breadcrumb-nav {
    width: 100%;
    max-width: 880px;
    margin: 0 auto 1rem;
    padding: 0 0.5rem;
}

.custom-breadcrumb-list {
    display: flex;
    flex-wrap: wrap;
    padding: 1rem 0;
    margin: 0;
    list-style: none;
}

.breadcrumb-item {
    display: inline-flex;
    color: var(--text-color);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 0.5rem;
    color: var(--recent-date-color);
}

.breadcrumb-item a {
    color: var(--bs-link-color);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

.breadcrumb-item a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* ===== LEARN DETAIL LAYOUT ===== */
/* Break out of the centered 1200px container so the TOC can sit flush-left.
   Applied to both the breadcrumb container and the content container so the
   breadcrumb can re-center against the article column. */
.content-area:has(.learn-detail-wrapper) > .custom-container {
    max-width: none;
}

/* Align breadcrumb left edge with the article column (max-width 45rem, centered). */
.content-area:has(.learn-detail-wrapper) .custom-breadcrumb-nav {
    max-width: 45rem;
    padding: 0;
}

.learn-detail-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 1.5rem;
    align-items: start;
}

.learn-detail-wrapper > article {
    grid-column: 1;
    min-width: 0;
    width: 100%;
    max-width: 45rem;
    margin: 0 auto;
}

/* Large screens: 3-column grid — TOC | article (centered, capped) | spacer */
@media (min-width: 1100px) {
    .learn-detail-wrapper {
        grid-template-columns: minmax(0, 1fr) min(45rem, 100%) minmax(0, 1fr);
    }

    .learn-detail-wrapper > article {
        grid-column: 2;
        max-width: none;
        margin: 0;
    }
}

.learn-toc {
    display: none;
}

/* Large screens: sticky sidebar in grid column 1, filling the available left space */
@media (min-width: 1100px) {
    .learn-toc.has-items {
        display: block;
        grid-column: 1;
        position: sticky;
        top: 1.5rem;
        width: 100%;
        min-width: 0;
    }
}

/* Small/medium screens: slide-in drawer */
@media (max-width: 1099px) {
    .learn-toc.has-items {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 17rem;
        max-width: 80vw;
        z-index: 1045;
        overflow-y: auto;
        padding: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background-color: var(--main-color);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .learn-toc.has-items.toc-drawer-open {
        transform: translateX(0);
    }
}

/* Backdrop behind the TOC drawer */
body.toc-drawer-active::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 1044;
    background: rgba(0, 0, 0, 0.45);
}

/* TOC hamburger button — always hidden; JS reveals it below 1100px when TOC has content */
.toc-hamburger-btn {
    display: none;
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    margin-right: 0.25rem;
    cursor: pointer;
    color: inherit;
}

@media (max-width: 1099px) {
    .toc-hamburger-btn.toc-hamburger-visible {
        display: block;
    }
}

/* Close button header inside the TOC drawer */
.toc-drawer-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

@media (min-width: 1100px) {
    .toc-drawer-header {
        display: none;
    }
}

.toc-close-btn {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 0.25rem;
}

.toc-heading {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--recent-date-color);
    margin: 0 0 0.5rem 0;
}

.toc-list,
.toc-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list {
    border-left: 2px solid var(--border-color);
}

.toc-list ul {
    padding-left: 0.6rem;
}

.toc-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.toc-item a {
    flex: 1;
    display: block;
    padding: 0.25rem 0.75rem;
    color: var(--recent-date-color);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1.4;
    transition: color 0.15s ease;
}

.toc-h1 > a { font-size: 1.2rem; font-weight: 600; }
.toc-h2 > a { font-size: 1.1rem; }
.toc-h3 > a { font-size: 1.05rem; }

.toc-item > ul {
    flex-basis: 100%;
}

.toc-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0.25rem 0 0.25rem 0.75rem;
    cursor: pointer;
    color: var(--recent-date-color);
    font-size: 0.6rem;
    line-height: 1.4;
    transition: color 0.15s ease;
}

.toc-toggle svg {
    display: block;
    transition: transform 0.15s ease;
}

.toc-toggle[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

.toc-toggle:hover {
    color: var(--bs-link-color);
}

.toc-item a:hover {
    color: var(--bs-link-color);
}

.toc-item.active > a {
    color: var(--bs-link-color);
    font-weight: 600;
}

.toc-num {
    font-family: monospace;
    opacity: 0.55;
    margin-right: 0.3em;
    font-size: 0.85em;
}

/* ===== LEARN BODY ===== */
.learn-body {
    line-height: 1.7;
    text-align: left;
}

.learn-body h1 {
    line-height: 1.3;
}

.learn-body h2,
.learn-body h3,
.learn-body h4,
.learn-body h5,
.learn-body h6 {
    border-left: 3px solid var(--bs-link-color);
    padding-left: 0.6rem;
    margin-top: 2rem;
    line-height: 1.3;
}

.learn-body blockquote {
    border-left: 4px solid var(--bs-link-color);
    margin: 1.5rem 0;
    padding: 0.5rem 1rem;
    font-style: italic;
    color: var(--recent-date-color);
}

.learn-body pre {
    border-radius: 0.4rem;
    margin: 1.25rem 0;
    overflow-x: auto;
}

/* ===== LEARN DETAIL: MOBILE TYPE SCALE ===== */
/* Desktop sizing is left as-is. On mobile, bump up text sizes across the
   learn article page (title, meta, categories, body, breadcrumb, buttons). */
@media (max-width: 767px) {
    .content-area:has(.learn-detail-wrapper) .custom-breadcrumb-nav {
        font-size: 1.05rem;
    }

    .learn-detail-wrapper > article > h1 {
        font-size: 2rem;
        line-height: 1.2;
    }

    .learn-detail-wrapper .learn-detail-meta p {
        font-size: 1.05rem;
    }

    .learn-detail-wrapper .learn-detail-meta .learn-meta-list {
        font-size: 1.1rem;
    }

    .learn-detail-wrapper .btn-random-inline {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    .learn-body {
        font-size: 1.2rem;
    }

    .learn-body h2 { font-size: 1.6rem; }
    .learn-body h3 { font-size: 1.35rem; }
    .learn-body h4 { font-size: 1.15rem; }
}

/* ===== ITEM CARD LIST ===== */
.item-card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.item-card {
    display: flex;
    flex-direction: column;
    border-radius: 0.9rem;
    background-color: var(--recent-item-bg);
    text-decoration: none;
    color: var(--text-color);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.item-card:hover {
    color: var(--text-color);
    text-decoration: none;
}

.item-card-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: var(--nav-hover-bg);
}

.item-card-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.item-card-thumbnail-placeholder {
    background: linear-gradient(135deg, var(--nav-hover-bg), transparent 70%);
}

.item-card:hover .item-card-thumbnail {
    transform: scale(1.04);
}

.item-card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.55rem;
    padding: 1rem 1.15rem 1.25rem;
    min-width: 0;
}

.item-card-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    margin-top: auto;
}

.item-card-category {
    padding: 0.15rem 0 0.15rem 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-color);
    border-left: 3px solid var(--bs-link-color);
}

.item-card-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--bs-link-color);
    margin: 0;
    line-height: 1.3;
}

.item-card:hover .item-card-title {
    color: var(--link-hover-color);
}

.item-card-meta {
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--recent-date-color);
    margin: 0;
}

.item-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.item-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid;
    background-color: var(--recent-badge-note-bg);
    color: var(--recent-badge-note-color);
    border-color: var(--recent-badge-note-border);
    text-decoration: none;
}

.item-badge:hover {
    opacity: 0.8;
}

/* ===== CONTENT IMAGES ===== */

/* Flat figure counter for general pages */
.page-content {
    counter-reset: figure;
    max-width: 70ch;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1.5rem;
}

/* Hierarchical figure counter for learn pages — resets per H2 section */
.learn-body {
    counter-reset: h2-section figure;
}

.learn-body h2 {
    counter-increment: h2-section;
    counter-reset: figure;
}

/* Standalone img (no figure) */
img.img-content {
    display: block;
    height: auto;
    max-width: 100%;
    margin: 1rem auto;
}

/* figure-based image with optional caption */
figure.img-content {
    display: block;
    margin: 1.5rem auto;
}

figure.img-content img {
    display: block;
    width: 100%;
    height: auto;
}

figure.img-content figcaption {
    margin-top: 0.4rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--recent-date-color);
    text-align: left;
}

/* Add img-numbered to opt into auto figure numbering */
figure.img-content.img-numbered {
    counter-increment: figure;
}

/* Flat numbering for general pages */
.page-content figure.img-content.img-numbered figcaption::before {
    content: "Figure " counter(figure) ". ";
    font-weight: 700;
    color: var(--text-color);
}

/* Hierarchical numbering for learn pages: Fig. 2.3 */
.learn-body figure.img-content.img-numbered figcaption::before {
    content: "Fig. " counter(h2-section) "." counter(figure) " ";
    font-weight: 700;
    color: var(--text-color);
}

.img-xs { max-width: 15%; }
.img-sm { max-width: 30%; }
.img-md { max-width: 50%; }
.img-lg { max-width: 75%; }
.img-xl { max-width: 100%; }

@media (max-width: 600px) {
    .img-xs { max-width: 40%; }
    .img-sm { max-width: 60%; }
    .img-md { max-width: 85%; }
}

/* ===== FOOTER ===== */
.site-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    background-color: var(--main-color);
    font-size: 0.8em;
}

.footer-text {
    margin: 0;
    padding: 0.5rem;
    color: var(--text-color);
}

.footer-link {
    padding: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.footer-link:hover {
    color: var(--bs-link-color);
}

.social-link {
    display: flex;
    align-items: center;
    margin: 0 0.25rem;
    color: var(--text-color);
    transition: color 0.2s ease-in-out;
}

.social-link:hover {
    color: var(--bs-link-color);
}

.footer-divider {
    width: 1px;
    height: 1.25rem;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

/* ===== NARROW PAGE LAYOUT (home, learn list, category) ===== */
.narrow-page {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 0.5rem;
}

.home-jumbotron {
    padding: 2rem 0.5rem 1.5rem;
}

.jumbotron-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.jumbotron-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-color);
    margin: 0;
}

.jumbotron-tagline {
    font-size: 1.1rem;
    color: var(--recent-date-color);
    margin: 0 0 0.75rem 0;
    max-width: 36rem;
}

.jumbotron-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

.btn-jumbotron-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.8rem;
    background-color: transparent;
    color: var(--bs-link-color);
    border: 1px solid var(--bs-link-color);
    border-radius: 999px;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.btn-jumbotron-secondary:hover {
    background-color: var(--bs-link-color);
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
}

.btn-jumbotron-secondary:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    .jumbotron-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .jumbotron-actions .btn-random-hero,
    .jumbotron-actions .btn-jumbotron-secondary {
        width: 100%;
        padding: 0.65rem 1.2rem;
        box-sizing: border-box;
    }
}

.btn-random-hero {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 0.75rem 1.8rem;
    background-color: var(--bs-link-color);
    color: white;
    border-radius: 999px;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 0.5rem 1.2rem rgba(0, 0, 0, 0.22);
    transition: background-color 0.15s ease-in-out, transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn-random-hero:hover {
    background-color: var(--link-hover-color);
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.30);
}

.btn-random-hero:active {
    transform: translateY(0);
}

.btn-random-hero-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.learn-detail-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.learn-detail-header .learn-detail-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.learn-detail-header .learn-detail-meta > p:last-child {
    margin-bottom: 0;
}

.learn-meta-list {
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.learn-meta-row {
    display: flex;
    flex-direction: column;
}

.learn-meta-list dt {
    font-weight: bold;
}

.learn-meta-list dd {
    margin: 0;
}

.learn-detail-header .learn-detail-actions {
    align-self: center;
}

@media (min-width: 768px) {
    .learn-detail-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .learn-detail-header .learn-detail-actions {
        align-self: flex-start;
        flex-shrink: 0;
        margin: 0;
    }
}

.learn-detail-actions {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin: 1rem 0 1.25rem;
}

.btn-random-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem;
    width: 140px;
    aspect-ratio: 1 / 1;
    background-color: transparent;
    color: var(--bs-link-color);
    border: 1px solid var(--bs-link-color);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.2;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.btn-random-inline:hover {
    background-color: var(--bs-link-color);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-random-inline:active {
    transform: translateY(0);
}

.btn-random-inline-icon {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.btn-random-dice {
    display: inline-block;
    background-color: currentColor;
    -webkit-mask-image: var(--dice-mask);
    mask-image: var(--dice-mask);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.section-heading {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--recent-date-color);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Inside the narrow page layout the card grid is always 2-wide */
.narrow-page .item-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-top: 0;
}

@media (max-width: 700px) {
    .narrow-page .item-card-list {
        grid-template-columns: 1fr;
    }
}

/* 2x2 pinned grid */
.pinned-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

/* 2-across recent grid */
.recent-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-top: 0;
}

@media (max-width: 700px) {
    .pinned-grid,
    .recent-grid {
        grid-template-columns: 1fr;
    }
}

.item-card-empty {
    opacity: 0.5;
    pointer-events: none;
}

.recent-sentinel {
    height: 1px;
    width: 100%;
}

.recent-status {
    text-align: center;
    color: var(--recent-date-color);
    font-size: 0.9rem;
    margin: 1rem 0 0;
    min-height: 1.2em;
}

/* ===== LISTING PAGE (learn list / category filter / search results) ===== */
.listing-header {
    margin-bottom: 1.5rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

/* Inside the listing header, the heading drops its own border so the
   single border under the meta line acts as the section divider. */
.listing-header .section-heading {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0.5rem;
}

.listing-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.listing-meta {
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--recent-date-color);
    margin: 0;
}

.listing-sort-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.listing-sort-label {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--recent-date-color);
}

.listing-sort-select {
    /* Suppress native widget so left/right padding behave symmetrically
       and the chevron matches the site theme. Chevron is supplied per-theme
       via the --select-chevron CSS variable in light.css / dark.css. */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 0.4rem 2rem 0.4rem 0.7rem;
    border-radius: 0.4rem;
    background-color: var(--input-bg);
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 0.75rem 0.75rem;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1.3;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.listing-sort-select::-ms-expand {
    display: none;
}

.listing-sort-select:hover {
    border-color: var(--bs-link-color);
}

.listing-sort-select:focus {
    outline: none;
    border-color: var(--bs-link-color);
    box-shadow: var(--search-focus-shadow);
}

.listing-sort-apply {
    padding: 0.4rem 0.85rem;
    border-radius: 0.4rem;
    background-color: var(--bs-link-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.listing-empty {
    color: var(--recent-date-color);
    font-style: italic;
    text-align: center;
    padding: 2.5rem 0;
}

.listing-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.1rem;
    border-radius: 0.6rem;
    background-color: var(--recent-item-bg);
    color: var(--bs-link-color);
    text-decoration: none;
    font-weight: 600;
    border: 1px solid var(--border-color);
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.pagination-btn:hover {
    background-color: var(--recent-item-hover-bg);
    color: var(--link-hover-color);
    text-decoration: none;
    transform: translateY(-1px);
}

.pagination-btn-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination-status {
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--recent-date-color);
}

@media (max-width: 480px) {
    .listing-pagination {
        flex-direction: column;
        gap: 0.75rem;
    }
    .pagination-status {
        order: -1;
    }
}
