/* ==== Utilities ==== */

[hidden] {
    display: none !important;
}

.text-center {
    text-align: center !important;
}

.d-none {
    display: none !important;
}

/* ==== 404 ==== */

.space-decor {
    position: relative;
    min-height: 100vh;
}

/* On the 404 page only: fit everything (message, decor, footer) in one viewport height so the copyright is visible without scrolling. */
body.error-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.error-page h1 {
    color: var(--red);
}

body.error-page #ftco-main {
    display: flex;
    flex-direction: column;
    flex: 1;
}

body.error-page .space-decor {
    flex: 1;
    min-height: 0;
}

/* Space icons floating over .space-decor (positions/sizes set here, colours in the SVGs themselves). */
#astronaut {
    position: absolute;
    top: 50%;
    right: 15%;
    animation: rotate-astronaut 200s infinite linear both alternate;
    width: 70px;
}

#earth {
    position: absolute;
    top: 50%;
    left: 25%;
    width: 200px;
}

#moon {
    position: absolute;
    top: 30%;
    left: 15%;
    width: 100px;
}

#rocket {
    position: absolute;
    transform: translateX(-50px);
    top: 75%;
    pointer-events: none;
    animation: rocket-movement 200s linear infinite both running;
    width: 100px;
    z-index: 1;
}

@keyframes rotate-astronaut {
    100% {
        transform: rotate(-720deg);
    }
}

@keyframes rocket-movement {
    100% {
        transform: translate(400px, -100px);
    }
}

@media (max-width: 767.98px) {
    #astronaut {
        width: 44px;
        right: 8%;
    }

    #earth {
        width: 110px;
        left: 5%;
    }

    #moon {
        width: 60px;
        left: 8%;
        top: 22%;
    }

    #rocket {
        width: 60px;
        top: 80%;
    }

    @keyframes rocket-movement {
        100% {
            transform: translate(120px, -60px);
        }
    }
}

/* ==== Copyrights, Terms & Projects ==== */

/* On short legal pages (policy, terms), same sticky-footer pattern as body.error-page above: without it, short content leaves the footer floating short of the bottom of the screen with blank space below it. */
body.legal {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.legal #ftco-main {
    flex: 1;
}

/* Page title only: policy/terms (bodyClass: "legal") and projects (bodyClass: "read-zone", shared with articles - .article-container h1 above already covers those, this is what colours the projects' own h1). */
body.legal h1,
body.read-zone h1 {
    color: var(--primary);
}

/* Constrain the article/project content column only (not .read-zone itself, the <body>) so the footer, a sibling of <main>, still spans the full page. */
.read-zone > main {
    max-width: 50%;
    margin: 16px auto;
}

@media (max-width: 1199.98px) {
    .read-zone > main {
        max-width: 75%;
    }
}

@media (max-width: 767.98px) {
    .read-zone > main {
        max-width: 90%;
    }
}

.read-zone main > a#index {
    display: block;
    text-align: center;
}

.read-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Wraps #dark-icon and #language-switcher on their own centred row below the "Updated on ..." date, on policy / terms (a lone block in <main>'s centered flow, unlike .read-title's projects where the pair sits flush right of the h1 instead). */
.page-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* ==== Articles ==== */

.article-container h1 {
    color: var(--primary);
}

.article-container h2 {
    color: var(--primary);
}

.article-intro {
    font-style: italic;
    margin-bottom: 20px;
}

/* ==== Career Timeline ==== */

.animation-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin: 40px 0;
    padding-left: 50px;
    view-timeline-name: --career-track;
}

.road {
    position: absolute;
    margin: 0;
    top: 0;
    bottom: 0;
    left: 20px;
    width: 4px;
    background: repeating-linear-gradient(to bottom, var(--primary) 0, var(--primary) 10px, transparent 10px, transparent 20px);
    border-radius: 2px;
}

/* Drives itself from the .animation-container's own scroll position via the
   native scroll-driven animations spec - no JS/inline style needed. Starts
   pinned to Dax (top: 0%) the instant the article renders, unlike the old
   getBoundingClientRect()-based JS offset, which depended on where the
   container happened to land relative to the viewport on load. */
#car {
    position: absolute;
    left: 22px;
    top: 0;
    margin: 0;
    transform: translate(-50%, -50%);
    z-index: 2;
    animation-name: drive-car;
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: --career-track;
    animation-range: contain 0% contain 100%;
}

@keyframes drive-car {
    from {
        top: 0%;
    }

    to {
        top: 100%;
    }
}

.city {
    position: relative;
    margin: 0;
    color: var(--primary);
}

.city::before {
    content: '';
    position: absolute;
    left: -35px;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border: 3px solid var(--background);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--primary);
    transform: translateY(-50%);
}

.step {
    position: relative;
    margin: 0;
    padding-left: 4px;
    color: var(--secondary);
}

.step::before {
    content: '';
    position: absolute;
    left: -32px;
    top: 50%;
    width: 8px;
    height: 8px;
    background: var(--background);
    border: 2px solid var(--primary);
    border-radius: 50%;
    transform: translateY(-50%);
}

/* ==== Rotating Box ==== */

#mountain {
    width: 100%;
}

#future {
    margin: clamp(12px, 4vw, 30px);
    place-items: center;
}

.box-rotate {
    position: relative;
    width: min(300px, 80vw);
    aspect-ratio: 1;
    animation: rotate 8s infinite alternate;
    transform-style: preserve-3d;
}

.img-rotate {
    height: 100%;
    width: 100%;
    object-fit: cover;
    border-radius: 25px;
}

.span-inside {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--white);
    text-shadow: 0 2px 5px var(--dark);
}

@keyframes rotate {
    from {
        transform: rotateX(20deg) rotateY(20deg);
    }

    to {
        transform: rotateX(-15deg) rotateY(-40deg);
    }
}

/* ==== Article Images ==== */

#inpi-process {
    max-width: 100%;
    height: auto;
    display: block;
    margin: auto;
    margin-top: 40px;
    margin-bottom: 40px;
    position: relative;
    box-shadow: 0 4px 8px 0 var(--shadow-xs);
}

#mcs-design,
#mcs-example,
#programming {
    max-width: 70vw;
    height: auto;
    margin-bottom: 15px;
}

#pattern {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* ==== Video ==== */

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==== Cards ==== */

html.dark-mode .card {
    color: var(--dark);
}

.card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 0 4px var(--shadow-sm);
    padding: 24px;
    margin: 20px 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 0 12px var(--shadow-lg);
}

.bien {
    border-left: 5px solid var(--green);
}

.pas-bien {
    border-left: 5px solid var(--red);
}

.modere {
    border-left: 5px solid var(--yellow);
}

.bloc-code {
    position: relative;
    background: var(--dark);
    padding: 12px;
    border-radius: 8px;
    margin: 16px 0;
    overflow-x: auto;
}

.bloc-code .lang-label {
    position: absolute;
    top: 1px;
    left: 10px;
    color: var(--yellow);
    font-size: 10px;
}

.bloc-code .lang-code {
    white-space: pre;
    color: var(--white);
    font-size: 13px;
}

/* ==== Badges ==== */

.badge-definition {
    top: 30px;
    right: 65px;
    left: inherit;
}

/* ==== FAQ Accordion ==== */

.accordion > .card {
    position: relative;
    margin: 8px 0;
    border-radius: 0;
    transition: none;
}

.accordion > .card:hover {
    transform: none;
    box-shadow: 0 0 4px var(--shadow-sm);
}

.accordion > .card .card-header {
    padding: 0;
}

.accordion .card > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.accordion .card-header label {
    display: flex;
    justify-content: space-between;
    padding: 5px 20px;
    margin-bottom: 0;
    cursor: pointer;
    font-weight: bold;
    color: var(--dark);
    transition: background 0.2s;
}

.accordion .card > input:focus-visible ~ .card-header label {
    outline: 2px solid var(--dark);
    outline-offset: -2px;
}

.accordion .card-header label::after {
    content: '+';
    transition: transform 0.3s;
}

.accordion .card > input:checked ~ .card-header label::after {
    transform: rotate(45deg);
}

.accordion .card-body {
    display: none;
    padding: 0 20px;
    color: var(--dark);
}

.accordion .card > input:checked ~ .card-body {
    display: block;
    padding: 15px 20px;
}

/* ==== Theme Tooltip ==== */

/* Pages without Bootstrap: the button's own .sr-only label (kept up to date by toggleDarkMode() in common.js) shows as a Bootstrap 4 look-alike tooltip below it on hover / keyboard focus. :not([data-original-title]) leaves out the blog page, which loads this file for injected articles but already has app.js's Bootstrap tooltip. */
#dark-icon:not([data-original-title]) {
    position: relative;
}

#dark-icon:not([data-original-title]):is(:hover, :focus-visible) .sr-only {
    top: 100%;
    left: 50%;
    z-index: 3;
    width: auto;
    height: auto;
    padding: 4px 8px;
    margin: 6px 0 0;
    overflow: visible;
    clip-path: none;
    font-family: Poppins, 'Poppins Windows', 'Poppins Mac/iOS', 'Poppins Linux', 'Poppins Android', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--white);
    background-color: var(--black);
    border-radius: 4px;
    opacity: 0.9;
    transform: translateX(-50%);
    pointer-events: none;
}

/* The arrow, pointing up at the button. */
#dark-icon:not([data-original-title]):is(:hover, :focus-visible) .sr-only::before {
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -6px;
    content: "";
    border-color: transparent transparent var(--black);
    border-style: solid;
    border-width: 0 6px 6px;
}
