/**
 * Finitions visuelles - Portfolio Nathan Diegelmann
 * Chargé en dernier : corrige alignements, grilles, animations et navigation.
 */

/* ================================================
   NAVIGATION ORDINATEUR (barre fixe en haut)
   ================================================ */
.site-topnav {
    display: none;
}

@media (min-width: 1025px) {
    .site-topnav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2rem;
        padding: 0.9rem 4%;
        background: rgba(10, 10, 10, 0.72);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-bottom: 1px solid rgba(255, 10, 10, 0.15);
        transition: background 0.3s ease, padding 0.3s ease;
    }

    .site-topnav__brand {
        font-family: 'Orbitron', sans-serif;
        font-weight: 800;
        font-size: 1.35rem;
        letter-spacing: 2px;
        color: var(--text-primary, #fff);
        text-decoration: none;
    }

    .site-topnav__brand span {
        color: var(--racing-red, #FF0A0A);
    }

    .site-topnav__links {
        display: flex;
        gap: 2.25rem;
    }

    .site-topnav__links a {
        position: relative;
        font-family: 'Inter', sans-serif;
        font-size: 0.85rem;
        font-weight: 600;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        color: var(--text-secondary, #E0E0E0);
        text-decoration: none;
        padding: 0.4rem 0;
        transition: color 0.2s ease;
    }

    .site-topnav__links a::after {
        content: '';
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 2px;
        background: var(--racing-red, #FF0A0A);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.25s ease;
    }

    .site-topnav__links a:hover,
    .site-topnav__links a.is-active {
        color: #fff;
    }

    .site-topnav__links a:hover::after,
    .site-topnav__links a.is-active::after {
        transform: scaleX(1);
    }

    .site-topnav__cv {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.55rem 1.2rem;
        font-size: 0.8rem;
        font-weight: 700;
        letter-spacing: 1.5px;
        color: #fff;
        text-decoration: none;
        border: 1px solid var(--racing-red, #FF0A0A);
        background: rgba(255, 10, 10, 0.08);
        clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
        transition: background 0.2s ease;
    }

    .site-topnav__cv:hover {
        background: var(--racing-red, #FF0A0A);
    }

    /* Le bouton hamburger reste réservé au mobile / tablette */
    .floating-nav-btn,
    .floating-nav-menu {
        display: none !important;
    }

    /* Les ancres ne passent plus sous la barre fixe */
    section[id],
    header[id] {
        scroll-margin-top: 80px;
    }
}

/* ================================================
   ACCUEIL : cartes de stats alignées en grille 2 x 2
   ================================================ */
.hero-circle {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(140px, 200px));
    gap: 1.25rem;
    justify-content: center;
}

.hero-circle .stat-card {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    transform: none;
}

.hero-circle .stat-card:hover {
    transform: translateY(-4px);
}

/* ================================================
   PROJETS : grille régulière, cartes de même hauteur
   ================================================ */
.projects-grid-full {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    align-items: stretch;
}

@media (min-width: 1200px) {
    .projects-grid-full {
        grid-template-columns: repeat(4, 1fr);
    }
}

.electric-card-wrapper {
    display: flex;
    height: 100%;
}

.project-card-full {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.project-desc {
    flex-grow: 1;
}

.project-title {
    font-size: clamp(1.15rem, 1.6vw, 1.45rem);
    line-height: 1.25;
    letter-spacing: 1px;
    word-break: normal;
    hyphens: none;
}

.project-links {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.project-btn {
    padding: 0.7rem 1.3rem;
    font-size: 0.8rem;
}

/* Une seule ligne de séparation propre si une carte n'a aucun bouton */
.project-card-full > .project-tech:last-child {
    margin-bottom: 0;
}

/* ================================================
   COMPÉTENCES : les colonnes remplissent la largeur
   ================================================ */
.skills-columns {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

/* 4 catégories : 2 x 2 sur ordinateur plutôt que 3 + 1 */
@media (min-width: 900px) {
    .skills-columns {
        grid-template-columns: repeat(2, 1fr);
    }
}

.skills-category:hover {
    margin-bottom: 0;
    max-width: none;
}

/* ================================================
   TECHNOLOGIES : 10 cartes = 2 lignes de 5, même taille
   ================================================ */
.technologies-grid {
    grid-template-columns: repeat(5, 1fr);
    max-width: 1200px;
    align-items: stretch;
}

.tech-card {
    height: 100%;
    margin: 0 !important;
}

.tech-card:hover {
    transform: translateY(-4px);
}

@media (max-width: 1024px) {
    .technologies-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .technologies-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-circle {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }
}

/* ================================================
   PARCOURS
   ================================================ */
.timeline-company {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    align-items: center;
}

/* ================================================
   ANIMATIONS D'APPARITION : plus rapides et plus discrètes
   (avant : 0,8 s + décalages, le contenu restait vide en scrollant)
   ================================================ */
.reveal-on-scroll {
    transform: translateY(16px);
    transition: opacity 0.45s ease-out, transform 0.45s ease-out !important;
    transition-delay: 0s !important;
}

.reveal-on-scroll.revealed {
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .reveal-on-scroll {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ================================================
   ACCESSIBILITÉ : focus visible au clavier
   ================================================ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--racing-red, #FF0A0A);
    outline-offset: 3px;
}

/* ================================================
   FLUIDITÉ : moins d'effets coûteux pendant le défilement
   ================================================ */
/* Pas de couches GPU forcées partout (72 éléments avant) */
.hero-avatar, .floating-nav-btn, .project-btn, .social-link, .tech-tag, .cta-btn,
.reveal-on-scroll, .stat-card, .hero-status, .electric-card-wrapper, .tech-card {
    will-change: auto !important;
    backface-visibility: visible;
}

/* Flous d'arrière-plan recalculés à chaque image : remplacés par des fonds opaques */
.hero-status, .stat-card, .social-link, .floating-nav-btn {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

@media (min-width: 1025px) {
    .site-topnav {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(10, 10, 10, 0.94);
    }
}

/* Halo des cartes projets : ombre au lieu de filtres flous */
.electric-glow-2 {
    filter: none;
    border-width: 1px;
    box-shadow: 0 0 14px rgba(255, 10, 10, 0.35);
}

.electric-bg-glow {
    display: none;
}

.electric-card-wrapper:hover {
    transform: translateY(-6px);
}

/* Fond animé : se met en pause hors de l'accueil */
#speedWavesCanvas {
    transition: opacity 0.4s ease;
}

#speedWavesCanvas.is-paused {
    opacity: 0;
}

/* ================================================
   CURSEUR PERSONNALISÉ v2
   ================================================ */
/* Si le script ne charge pas, le curseur normal revient (avant : plus de curseur du tout) */
html:not(.has-cursor) * {
    cursor: revert !important;
}

html.has-cursor,
html.has-cursor * {
    cursor: none !important;
}

html.has-cursor input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.has-cursor textarea {
    cursor: text !important;
}

#ndCursor,
#ndCursorDot {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    border-radius: 50%;
    will-change: transform;
}

html.cursor-visible #ndCursor,
html.cursor-visible #ndCursorDot {
    opacity: 1;
}

html.cursor-text #ndCursor,
html.cursor-text #ndCursorDot {
    opacity: 0 !important;
}

#ndCursor {
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 1.5px solid rgba(255, 10, 10, 0.85);
    transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

#ndCursor.is-link {
    background: rgba(255, 10, 10, 0.14);
    border-color: rgba(255, 90, 90, 0.6);
}

#ndCursor.is-down {
    background: rgba(255, 10, 10, 0.28);
}

#ndCursorDot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: #FF0A0A;
    box-shadow: 0 0 8px rgba(255, 10, 10, 0.8);
    transition: opacity 0.2s ease;
}

/* ================================================
   TABLETTE (641 px - 1024 px)
   ================================================ */
@media (min-width: 641px) and (max-width: 1024px) {
    :root:not(#nd) .tech-card, :root:not(#nd) .about-card, :root:not(#nd) .contact-card, :root:not(#nd) .skills-category {
        margin: 0 !important;
    }

    :root:not(#nd) .technologies-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1rem !important;
    }

    :root:not(#nd) .tech-card {
        min-height: 0 !important;
        padding: 1.25rem .75rem !important;
    }

    /* Titres de catégories qui débordaient ("PROGRAMMATION", "RELATIONNELLES") */
    :root:not(#nd) .category-title {
        font-size: 1.05rem !important;
        letter-spacing: 1px !important;
        overflow-wrap: anywhere;
        line-height: 1.3 !important;
    }

    :root:not(#nd) .skill-name {
        gap: .5rem;
        font-size: .9rem;
    }

    /* Cartes de contact : une ligne chacune (l'adresse e-mail ne se coupe plus) */
    :root:not(#nd) .contact-grid {
        grid-template-columns: 1fr !important;
        gap: .75rem !important;
        max-width: 560px;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    :root:not(#nd) .contact-card {
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
        padding: 1rem 1.25rem !important;
        gap: 1rem !important;
    }

    :root:not(#nd) .contact-icon {
        margin: 0 !important;
        flex-shrink: 0;
    }

    :root:not(#nd) .about-grid {
        gap: 1rem !important;
    }
}

/* ================================================
   TÉLÉPHONE (≤ 640 px)
   ================================================ */
@media (max-width: 640px) {
    /* Les anciennes feuilles mobiles ajoutaient des marges/paddings partout ([class*="card"], [class*="text"]) */
    :root:not(#nd) .tech-card, :root:not(#nd) .about-card, :root:not(#nd) .contact-card, :root:not(#nd) .skills-category,
    :root:not(#nd) .electric-card-wrapper, :root:not(#nd) .project-card-full, :root:not(#nd) .stat-card {
        margin: 0 !important;
    }

    :root:not(#nd) .electric-card-wrapper {
        padding: 2px !important;
    }

    :root:not(#nd) .about-card-text, :root:not(#nd) .status-text, :root:not(#nd) .contact-info-label, :root:not(#nd) .contact-info-value,
    :root:not(#nd) .about-intro-text, :root:not(#nd) .about-intro-secondary, :root:not(#nd) .alternance-text {
        margin-bottom: .5rem !important;
    }

    :root:not(#nd) .about-card-icon {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.3rem !important;
        margin: 0 auto .75rem !important;
    }

    :root:not(#nd) .about-card-title {
        font-size: 1rem !important;
        margin-bottom: .5rem !important;
    }

    :root:not(#nd) .about-card-text {
        font-size: .9rem !important;
        line-height: 1.6 !important;
    }

    :root:not(#nd) .about-card-link-hint {
        font-size: .78rem !important;
    }

    :root:not(#nd) .timeline-item {
        margin-bottom: 1.1rem !important;
    }

    /* Bouton menu : les 3 traits étaient invisibles (largeur 0) */
    :root:not(#nd) .floating-nav-btn {
        width: 46px !important;
        height: 46px !important;
        padding: 0 !important;
        top: 12px !important;
        right: 12px !important;
        gap: 5px !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(12, 12, 12, .96) !important;
    }

    :root:not(#nd) .floating-nav-btn .nav-line {
        width: 22px !important;
        height: 2px !important;
        margin: 0 !important;
    }

    /* Sections plus compactes */
    :root:not(#nd) .section-dark,
    :root:not(#nd) section {
        padding-top: 3.25rem !important;
        padding-bottom: 3.25rem !important;
    }

    :root:not(#nd) .container,
    :root:not(#nd) .about-content {
        padding-left: 18px !important;
        padding-right: 18px !important;
    }

    :root:not(#nd) .section-title-main {
        font-size: 1.4rem !important;
        letter-spacing: 1.5px !important;
        margin-bottom: .4rem !important;
        padding: 0 40px !important;   /* ne passe plus sous le bouton menu */
    }

    :root:not(#nd) .section-subtitle {
        font-size: .92rem !important;
        margin-bottom: 1.75rem !important;
    }

    /* ---------- Accueil ---------- */
    :root:not(#nd) .hero-v2 {
        min-height: 0 !important;
        padding: 72px 18px 36px !important;
    }

    :root:not(#nd) .hero-left {
        padding: 0 !important;
        min-height: 0 !important;
        align-items: center;
        text-align: center;
    }

    :root:not(#nd) .hero-status {
        padding: 8px 14px !important;
        margin-bottom: 1.25rem !important;
        min-height: 0 !important;
        white-space: nowrap;
    }

    :root:not(#nd) .hero-status .status-text {
        font-size: .68rem !important;
        letter-spacing: 1px !important;
    }

    :root:not(#nd) .hero-greeting {
        margin-bottom: .35rem !important;
    }

    :root:not(#nd) .hero-name {
        font-size: clamp(2rem, 10vw, 2.6rem) !important;
        margin-bottom: .9rem !important;
    }

    :root:not(#nd) .hero-role {
        margin-bottom: 1rem !important;
    }

    :root:not(#nd) .hero-description-v2 {
        font-size: .95rem !important;
        line-height: 1.65 !important;
        margin-bottom: 1.5rem !important;
    }

    :root:not(#nd) .hero-cta {
        width: 100%;
        flex-direction: column !important;
        gap: .75rem !important;
        margin-bottom: 1.5rem !important;
    }

    :root:not(#nd) .hero-cta .cta-btn {
        width: 100% !important;
        justify-content: center !important;
        min-height: 48px;
    }

    :root:not(#nd) .hero-socials {
        justify-content: center !important;
        gap: .75rem !important;
        margin: 0 !important;
    }

    :root:not(#nd) .hero-socials .social-link {
        width: 46px !important;
        height: 46px !important;
    }

    :root:not(#nd) .hero-right {
        padding: 1.75rem 0 0 !important;
        min-height: 0 !important;
    }

    :root:not(#nd) .hero-circle {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: .75rem !important;
        max-width: 100% !important;
    }

    :root:not(#nd) .hero-circle .stat-card {
        padding: .9rem .5rem !important;
    }

    :root:not(#nd) .stat-info h4 {
        font-size: 1.35rem !important;
    }

    :root:not(#nd) .stat-info span {
        font-size: .78rem !important;
        white-space: nowrap;
    }

    /* ---------- Projets ---------- */
    :root:not(#nd) .projects-notice {
        padding: 1rem 1.1rem !important;
        font-size: .86rem !important;
        margin-bottom: 1.75rem !important;
    }

    :root:not(#nd) .projects-grid-full {
        gap: 1.25rem !important;
    }

    :root:not(#nd) .project-card-full {
        padding: 1.5rem 1.25rem !important;
    }

    :root:not(#nd) .project-title {
        font-size: 1.25rem !important;
    }

    :root:not(#nd) .project-desc {
        font-size: .92rem !important;
        line-height: 1.6 !important;
        margin-bottom: 1rem !important;
    }

    :root:not(#nd) .project-tech {
        gap: .4rem !important;
        margin-bottom: 1rem !important;
    }

    :root:not(#nd) .project-links .project-btn {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 46px;
    }

    /* ---------- Compétences ---------- */
    :root:not(#nd) .skills-columns {
        gap: 1.1rem !important;
    }

    :root:not(#nd) .skills-category {
        padding: 1.25rem 1.1rem !important;
    }

    :root:not(#nd) .category-title {
        font-size: 1.05rem !important;
        letter-spacing: 1px !important;
        overflow-wrap: anywhere;
    }

    :root:not(#nd) .skill-item {
        margin-bottom: 1rem !important;
    }

    /* ---------- À propos / technologies ---------- */
    :root:not(#nd) .about-intro {
        margin-bottom: 1.75rem !important;
    }

    :root:not(#nd) .about-intro-text {
        font-size: 1rem !important;
    }

    :root:not(#nd) .about-intro-secondary {
        font-size: .9rem !important;
    }

    :root:not(#nd) .about-grid {
        gap: .9rem !important;
    }

    :root:not(#nd) .about-card {
        padding: 1.25rem 1rem !important;
    }

    :root:not(#nd) .technologies-section {
        margin-top: 2.5rem !important;
    }

    :root:not(#nd) .technologies-title {
        font-size: 1.25rem !important;
    }

    :root:not(#nd) .technologies-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: .75rem !important;
    }

    :root:not(#nd) .tech-card {
        min-height: 0 !important;
        padding: 1rem .5rem !important;
    }

    :root:not(#nd) .tech-icon {
        width: 46px !important;
        height: 46px !important;
        font-size: 1.2rem !important;
        margin-bottom: .5rem !important;
    }

    :root:not(#nd) .tech-name {
        font-size: .72rem !important;
        letter-spacing: .5px !important;
        text-align: center;
    }

    /* ---------- Parcours ---------- */
    :root:not(#nd) .timeline-item {
        padding: 1.25rem 1.1rem !important;
    }

    :root:not(#nd) .timeline-title {
        font-size: 1.05rem !important;
        line-height: 1.35 !important;
    }

    :root:not(#nd) .timeline-desc {
        font-size: .9rem !important;
    }

    /* ---------- Contact ---------- */
    :root:not(#nd) .contact-grid {
        gap: .75rem !important;
        margin-bottom: 1.75rem !important;
    }

    :root:not(#nd) .contact-card {
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
        gap: .9rem !important;
        padding: .9rem 1rem !important;
    }

    :root:not(#nd) .contact-icon {
        width: 42px !important;
        height: 42px !important;
        flex-shrink: 0;
        margin: 0 !important;
    }

    :root:not(#nd) .contact-info-label {
        font-size: .7rem !important;
    }

    :root:not(#nd) .contact-info-value {
        font-size: .9rem !important;
        overflow-wrap: anywhere;
    }

    :root:not(#nd) .contact-form-container {
        padding: 1.5rem 1.1rem !important;
    }

    :root:not(#nd) .contact-form-title {
        font-size: 1.1rem !important;
    }

    :root:not(#nd) .form-row {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    /* 16 px minimum : évite le zoom automatique d'iOS sur les champs */
    :root:not(#nd) #contactForm input,
    :root:not(#nd) #contactForm textarea {
        font-size: 16px !important;
    }

    /* ---------- Pied de page : liens sur 2 lignes au lieu d'une longue liste ---------- */
    :root:not(#nd) .footer-nav {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: .35rem 1.1rem !important;
    }

    :root:not(#nd) .footer-nav a {
        padding: .45rem 0 !important;
        font-size: .82rem !important;
    }
}
