.progress-container {
    width: 100%;
    height: 6px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background-color: rgba(0, 0, 0, 0.1);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    box-sizing: border-box;
}

.progress-container.hidden {
    opacity: 0;
    visibility: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    width: 0%;
    box-shadow:
        0 0 15px rgba(30, 60, 114, 0.8),
        0 0 25px rgba(42, 82, 152, 0.6),
        0 0 35px rgba(42, 82, 152, 0.4),
        0 2px 8px rgba(30, 60, 114, 0.5);
    transition: width 0.1s ease-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 500;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    padding: 1.5rem 0;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
}

header .subtitle {
    margin: 0.5rem 0 0 0;
    font-size: 1.1rem;
    font-weight: normal;
    color: #e8eef5;
}

.github-corner {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: opacity 0.3s;
}

.github-corner:hover {
    opacity: 0.7;
}

.github-corner img {
    height: 1.5rem;
    width: 1.5rem;
    filter: invert(1);
}

main {
    padding: 1.5rem;
    margin: 0 auto;
    max-width: 960px;
    flex: 1 0 auto;
}

main section h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #495057;
}

#about {
    text-align: center;
    padding: 2rem 1rem;
    background-color: #ffffff;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}


#about p {
    font-size: 1.1rem;
    color: #6c757d;
    max-width: 800px;
    margin: 0 auto;
}

#skills {
    text-align: center;
    padding: 2rem 1rem;
    background-color: #ffffff; /* Slightly different background to distinguish */
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#skills h3 {
    text-align: left;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    color: #495057;
}

#skills h3:first-of-type {
    margin-top: 0;
}

.skills-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.75rem;
}

.skill-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #f8f9fa;
    color: #495057;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-weight: 500;
    font-size: 1rem;
    border: 1px solid #dee2e6;
    transition: transform 0.3s, box-shadow 0.3s;
}

.skill-item:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.skill-item img {
    height: 1.2em;
    transition: transform 0.3s, filter 0.3s;
}

/* Blue to purple gradient - darker */
.skill-item:nth-child(4n+1) img {
    filter: brightness(0) saturate(100%) invert(20%) sepia(60%) saturate(3000%) hue-rotate(200deg) brightness(90%) contrast(105%); /* Deep blue */
}

.skill-item:nth-child(4n+2) img {
    filter: brightness(0) saturate(100%) invert(28%) sepia(95%) saturate(1800%) hue-rotate(193deg) brightness(92%) contrast(105%); /* Blue */
}

.skill-item:nth-child(4n+3) img {
    filter: brightness(0) saturate(100%) invert(35%) sepia(75%) saturate(2300%) hue-rotate(228deg) brightness(88%) contrast(100%); /* Blue-purple */
}

.skill-item:nth-child(4n+4) img {
    filter: brightness(0) saturate(100%) invert(25%) sepia(80%) saturate(3800%) hue-rotate(274deg) brightness(85%) contrast(108%); /* Purple */
}

.skill-item img.no-filter {
    filter: none !important;
}

.skill-item:hover img {
    transform: scale(1.2);
}

.skill-item:hover img.no-filter {
    filter: none !important;
    transform: scale(1.2);
}

#certifications {
    padding: 2rem 1rem;
    background-color: #ffffff;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.section-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin: 0;
}

.section-actions {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    gap: 0.5rem;
}

.section-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background-color: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s;
}

.section-btn:hover {
    transform: translateY(-2px);
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #1e3c72;
}

.section-btn:focus-visible {
    outline: 2px solid #2a5298;
    outline-offset: 2px;
}

.section-btn svg {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

/* The view toggle holds both of its icons; only the one matching the current
   state is shown. */
#certViewToggle .icon-grid,
.cert-view-text {
    display: none;
}

#certifications.text-mode #certViewToggle .icon-list {
    display: none;
}

#certifications.text-mode #certViewToggle .icon-grid {
    display: block;
}

#certifications.text-mode .cert-view-icons {
    display: none;
}

#certifications.text-mode .cert-view-text {
    display: block;
}

/* Switching between badges and text is meaningless while the list is hidden. */
section.collapsed #certViewToggle {
    display: none;
}

.cert-view-text {
    margin: 0;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.8;
    color: #212529;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    -webkit-user-select: text;
    user-select: text;
}

.cert-view-text strong {
    color: #1e3c72;
}

/* Narrow screens: the buttons would sit on top of the centred heading. */
@media (max-width: 520px) {
    .section-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .section-actions {
        position: static;
        transform: none;
    }
}

/* Projects and Certifications used to leave 2rem under their heading; the
   grid body below stops the first child's margin collapsing through, so the
   spacing is set on the header instead. */
/* :where() keeps these ids at zero specificity, so the collapsed rule below
   can still override the gap. */
:where(#projects, #certifications) .section-header {
    margin-bottom: 2rem;
}

#certifications .cert-view-icons h3:first-of-type {
    margin-top: 0;
}

/* The gap under the heading belongs to the body; drop it once collapsed so the
   card closes up tight instead of leaving a band of empty space. */
.section-header {
    transition: margin-bottom 0.35s ease;
}

section.collapsed .section-header {
    margin-bottom: 0;
}

.section-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.35s ease, opacity 0.25s ease;
}

/* Exactly one child, or grid-template-rows only collapses the first row and
   the rest stay at their auto height. */
.section-body > * {
    min-height: 0;
}

section.collapsed .section-body {
    grid-template-rows: 0fr;
    opacity: 0;
}

/* Only clip while collapsed or mid-animation - certification badges scale
   past their card on hover and must not be cut off when expanded. */
section.collapsed .section-body > *,
section.animating .section-body > * {
    overflow: hidden;
}

/* Expanded reads as a minus; collapsing grows the vertical stroke into a plus. */
.section-toggle .icon-plus-stroke {
    transform-box: view-box;
    transform-origin: 12px 12px;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

section.collapsed .section-toggle .icon-plus-stroke {
    transform: scaleY(1);
}

@media (prefers-reduced-motion: reduce) {
    .section-header,
    .section-body,
    .section-toggle .icon-plus-stroke {
        transition: none;
    }
}



#certifications h3 {
    text-align: left;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    color: #495057;
}

.cert-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 0;
    margin: 0 auto 2rem auto;
    max-width: 960px;
}

.cert-break {
    width: 100%;
    grid-column: 1 / -1;
    height: 0;
}

.cert-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: 0.75rem;
    background-color: #f8f9fa;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #212529;
    aspect-ratio: 1 / 1;
    transition: transform 0.3s, box-shadow 0.3s;
    overflow: visible;
    position: relative;
}

.cert-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.cert-item img {
    width: 100%;
    height: 0;
    flex-grow: 1;
    object-fit: contain;
    min-height: 0;
    transition: transform 0.3s, filter 0.3s;
    position: relative;
    z-index: 1;
}

.cert-item:hover img {
    transform: scale(1.45) translateY(-15%);
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.4)) brightness(1.15);
    z-index: 10;
}

.cert-item span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 3.8rem; /* Reserve space for about 2-3 lines of text */
    line-height: 1.5;
    text-align: center;
    width: 100%;
    padding: 0 0.15rem;
}

.cert-item .cert-text {
    display: inline;
}

#certifications hr {
    border: 0;
    height: 1px;
    background-color: #dee2e6;
    margin: 3rem 0;
}

#projects {
    padding: 2rem 1rem;
    background-color: #ffffff;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#projects h2 {
    text-align: center;
    margin-top: 0;
    color: #495057;
}


.project-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.project-item {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

.project-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.project-item h3 {
    margin-top: 0;
    font-size: 1.5rem;
    color: #007bff;
}

.project-item p {
    margin-bottom: 1rem;
    color: #6c757d;
}

.project-item a {
    display: inline-block;
    color: #ffffff;
    background-color: #007bff;
    text-decoration: none;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.project-item a:hover {
    background-color: #0056b3;
}

.project-links {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
}

.project-item a.btn-secondary {
    background-color: #6c757d;
}

.project-item a.btn-secondary:hover {
    background-color: #5a6268;
}

.project-links a {
    width: 150px; /* Or any other width that you prefer */
    box-sizing: border-box;
    text-align: center;
}

.project-item-placeholder {
    border-style: dashed;
    border-color: #adb5bd;
    background-color: #f8f9fa;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.project-item-placeholder h3 {
    color: #6c757d;
}

.project-item-placeholder p {
    color: #adb5bd;
}

.project-item-placeholder:hover {
    transform: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: default;
}

.social-links {
    margin-bottom: 1rem;
}

.social-links a {
    color: #ffffff;
    text-decoration: none;
    margin: 0 0.5rem;
    font-weight: bold;
    transition: color 0.2s, text-decoration 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.social-links a:hover {
    color: #007bff;
    text-decoration: underline;
}

.social-links a img {
    filter: invert(1);
    height: 1.2em;
}

footer {
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}