/* --- Single Violet Glassy Card (Two-Piece Stitch) --- */

/* 1. The Top Half: Page Title
   Using `#main-content >` ensures this ONLY applies to dedicated pages (Courses, About)
   and ignores the index page sections! */
#main-content > h1.title-container {
    position: relative;
    z-index: 1;

    /* FIX: Keeps padding inside the 100% width so it doesn't overhang */
    box-sizing: border-box !important;
    width: 100%;

    /* FORCE CENTERING */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;

    /* Remove default borders and adjust spacing */
    border-bottom: none !important;
    margin-top: 2rem;
    margin-bottom: 0 !important;
    padding: 3rem 2rem 1.5rem;

    /* Top border radius only */
    border-radius: 24px 24px 0 0;

    /* The Glass Effect with Violet Border */
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border-color);
    border-bottom: none; /* Opens the bottom to connect with the content */
}

/* 2. The Bottom Half: Main Text Content */
#main-content #page-content {
    position: relative;
    z-index: 2; /* Sits slightly above the title to hide any internal shadow overlap */

    /* FIX: Ensures the width perfectly matches the title block above it */
    box-sizing: border-box !important;
    width: 100%;

    /* Crush the margins so it perfectly touches the title above it */
    margin-top: 0 !important;
    margin-bottom: 4rem;
    padding: 1.5rem 3.5rem 3.5rem; /* Generous internal padding for reading */

    /* Bottom border radius only */
    border-radius: 0 0 24px 24px;

    /* The Glass Effect with Violet Border */
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border-color);
    border-top: none; /* Opens the top to connect with the title */

    /* The main shadow dropping off the bottom of the complete card */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.05);

    /* Typography formatting for longer reading */
    color: var(--text-color);
    font-weight: 350;
    line-height: 1.8;
    font-size: 1.05rem;
}

/* Ensure any old pseudo-elements from previous ribbon attempts are totally gone */
#main-content > h1.title-container::before,
#main-content #page-content::before {
    content: none !important;
    display: none !important;
}

/* Make links inside the page content pop */
#main-content #page-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

#main-content #page-content a:hover {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    background: transparent;
}

/* Mobile Responsiveness for the Card */
@media only screen and (max-width: 800px) {
    #main-content > h1.title-container {
        padding: 2rem 1rem 1rem;
        border-radius: 16px 16px 0 0;
    }

    #main-content #page-content {
        padding: 1rem 1.5rem 2rem;
        border-radius: 0 0 16px 16px;
    }
}


/* --- Single Violet Glassy Card for Articles/Posts --- */

main > article.h-entry {
    position: relative;
    z-index: 1;

    box-sizing: border-box !important;
    width: 100%;

    /* Card Spacing and Padding */
    margin-top: 2rem;
    margin-bottom: 4rem;
    padding: 3.5rem 3.5rem;

    /* Fully rounded corners for the single card */
    border-radius: 24px;

    /* The Glass Effect with Violet Border */
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border-color);

    /* The main shadow */
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.05);
}

/* 1. Center the article title inside the card */
article.h-entry h1.article-title {
    text-align: center !important;
    margin-top: 0;
    margin-bottom: 1rem;
}

/* 2. Center the metadata (date, reading time, tags) under the title */
article.h-entry ul.meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center !important; /* Pushes the flex items to the middle */
    margin-bottom: 3rem; /* Breathing room before the text starts */
    padding-left: 0;
}

/* 3. Typography formatting for the main text */
article.h-entry section.e-content {
    color: var(--text-color);
    font-weight: 350;
    line-height: 1.8;
    font-size: 1.05rem;
}

/* Make links inside the article content pop */
article.h-entry section.e-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

article.h-entry section.e-content a:hover {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    background: transparent;
}

/* Mobile Responsiveness for Articles */
@media only screen and (max-width: 800px) {
    main > article.h-entry {
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }
}
/* Keep the theme's expanding hover fill from covering content links. */
#main-content #page-content a:hover::before,
article.h-entry section.e-content a:hover::before {
    content: none;
}

.admonition-content {
    min-width: 0;
    overflow-wrap: anywhere;
}

.admonition-icon {
    flex-shrink: 0;
}

.brochure-download {
    margin: 0.75rem 0 2rem;
}

#main-content :is(#page-content, article.h-entry) a.brochure-button {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    box-sizing: border-box;
    padding: 0.65rem 1.1rem;
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--surface-border-color));
    border-radius: 10px;
    background: var(--accent-surface-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    color: var(--accent-color);
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#main-content :is(#page-content, article.h-entry) a.brochure-button::after {
    content: "";
    display: block;
    flex: 0 0 1.1rem;
    width: 1.1rem;
    height: 1.1rem;
    background-color: currentColor;
    -webkit-mask: url("/images/download.svg") center / contain no-repeat;
    mask: url("/images/download.svg") center / contain no-repeat;
}

#main-content :is(#page-content, article.h-entry) a.brochure-button:hover,
#main-content :is(#page-content, article.h-entry) a.brochure-button:focus-visible {
    border-color: var(--accent-color);
    background: var(--accent-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: var(--hover-color);
    text-decoration: none;
}

#main-content :is(#page-content, article.h-entry) a.brochure-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

#main-content :is(#page-content, article.h-entry) a.brochure-button::before,
#main-content :is(#page-content, article.h-entry) a.brochure-button:hover::before {
    content: none !important;
}

/* Connect the tag catalogue and result lists to their page headings. */
#main-content > h1.section-title + :is(.bloglist-container, #tag-cloud) {
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    width: 100%;
    margin-top: 0;
    padding: 1.5rem 3.5rem 3.5rem;
    border: 1px solid var(--surface-border-color);
    border-top: none;
    border-radius: 0 0 24px 24px;
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.05);
}

#main-content > h1.section-title + .bloglist-container > :is(.bloglist-meta, .bloglist-content) {
    background: transparent;
}

#main-content > h1.section-title + .bloglist-container .thumbnail-image {
    background: var(--card-image-background);
    border-radius: 12px;
}

@media only screen and (max-width: 1100px) {
    #main-content > h1.section-title + .bloglist-container > .bloglist-meta {
        padding: 0;
    }

    #main-content > h1.section-title + .bloglist-container > .bloglist-content {
        padding: 1.5rem 0 2rem;
    }
}

@media only screen and (max-width: 800px) {
    #main-content > h1.section-title + :is(.bloglist-container, #tag-cloud) {
        padding: 1rem 1.5rem 2rem;
        border-radius: 0 0 16px 16px;
    }
}

#tag-cloud .tag-intro {
    margin: 0 0 1.75rem;
    color: var(--meta-color);
    font-size: 1rem;
    line-height: 1.6;
}

#tag-cloud .tags {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

#tag-cloud .tags-item { margin: 0; min-width: 0; }

#tag-cloud .tags-item a {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    box-sizing: border-box;
    height: 100%;
    min-height: 72px;
    padding: 1rem;
    border: 1px solid var(--surface-border-color);
    border-radius: 16px;
    background: var(--glass-color);
    color: var(--text-color);
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#tag-cloud .tags-item a:hover,
#tag-cloud .tags-item a:focus-visible {
    background: var(--surface-hover-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

#tag-cloud .tags-item a::before { content: none; }
#tag-cloud .tag-name { font-size: 1rem; font-weight: 600; }
#tag-cloud .tag-count {
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: var(--bg-0);
    color: var(--meta-color);
    font-size: 0.75rem;
    font-weight: 400;
    white-space: nowrap;
}

@media (max-width: 700px) {
    #tag-cloud .tags { grid-template-columns: 1fr; }
}
