@layer reset, tokens, base, components, utilities;

@layer tokens {
    @property --hero-glow {
        syntax: '<percentage>';
        inherits: false;
        initial-value: 70%;
    }

    :root {
        color-scheme: light dark;
        --bg: light-dark(oklch(0.97 0.005 250), oklch(0.17 0.02 262));
        --surface: light-dark(oklch(1 0 0), oklch(0.22 0.025 260));
        --surface-2: light-dark(oklch(0.94 0.008 250), oklch(0.26 0.03 260));
        --primary: light-dark(oklch(0.55 0.2 262), oklch(0.68 0.17 255));
        --accent: light-dark(oklch(0.72 0.12 230), oklch(0.78 0.11 225));
        --text: light-dark(oklch(0.22 0.02 262), oklch(0.93 0.01 250));
        --muted: light-dark(oklch(0.55 0.02 255), oklch(0.7 0.02 250));
        --border: light-dark(oklch(0.9 0.012 250), oklch(0.34 0.03 258));
        --hero-bg: light-dark(
            linear-gradient(135deg, oklch(0.2 0.03 262), oklch(0.26 0.04 260)),
            linear-gradient(135deg, oklch(0.14 0.03 264), oklch(0.2 0.04 262))
        );
        --shadow: 0 10px 30px -10px light-dark(oklch(0.2 0.02 260 / 0.25), oklch(0 0 0 / 0.6));
        --radius: 14px;
        --nav-h: 64px;
    }
    :root[data-theme="light"] { color-scheme: light; }
    :root[data-theme="dark"] { color-scheme: dark; }
}

@layer reset {
    *, *::before, *::after { box-sizing: border-box; margin: 0; }
    img, svg { display: block; max-width: 100%; }
    ul[class] { list-style: none; padding: 0; }
}

@layer base {
    html {
        scroll-behavior: smooth;
        scroll-padding-top: calc(var(--nav-h) + 1rem);
    }
    body {
        font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
        line-height: 1.6;
        color: var(--text);
        background: var(--bg);
        overflow-x: hidden;
    }
    h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; }
    p { text-wrap: pretty; }
    a { color: inherit; }
    :focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: 3px;
        border-radius: 4px;
    }
    @media (prefers-reduced-motion: reduce) {
        html { scroll-behavior: auto; }
        *, *::before, *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

@layer components {
    .skip {
        position: absolute;
        left: -999px;
        top: 0;
        z-index: 100;
        background: var(--primary);
        color: white;
        padding: 0.6rem 1rem;
        border-radius: 0 0 8px 0;
    }
    .skip:focus { left: 0; }

    .progress {
        position: fixed;
        top: 0; left: 0;
        height: 3px;
        width: 100%;
        background: linear-gradient(90deg, var(--primary), var(--accent));
        transform-origin: 0 50%;
        transform: scaleX(0);
        z-index: 1001;
        pointer-events: none;
    }
    @supports (animation-timeline: scroll()) {
        .progress {
            animation: grow-progress linear both;
            animation-timeline: scroll(root);
        }
        @keyframes grow-progress {
            from { transform: scaleX(0); }
            to { transform: scaleX(1); }
        }
    }

    /* Navigation */
    nav {
        position: fixed;
        inset: 0 0 auto 0;
        z-index: 1000;
        height: var(--nav-h);
        background: light-dark(oklch(1 0 0 / 0.8), oklch(0.17 0.02 262 / 0.8));
        backdrop-filter: blur(14px) saturate(1.4);
        border-bottom: 1px solid var(--border);
    }
    .nav-container {
        max-width: 1200px;
        margin: 0 auto;
        height: 100%;
        padding: 0 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }
    .logo {
        display: inline-flex;
        align-items: center;
        text-decoration: none;
    }
    .logo img {
        height: 56px;
        width: auto;
        border-radius: 6px;
    }
    .nav-links {
        display: flex;
        gap: 1.75rem;
    }
    .nav-links a {
        text-decoration: none;
        color: var(--muted);
        font-weight: 500;
        font-size: 0.95rem;
        transition: color 0.2s;
    }
    .nav-links a:hover { color: var(--primary); }
    .nav-links a.active { color: var(--primary); font-weight: 700; }
    .nav-actions { display: flex; align-items: center; gap: 0.75rem; }

    .btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.6rem 1.2rem;
        border-radius: 10px;
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        border: 1px solid transparent;
        cursor: pointer;
        font-family: inherit;
        transition: transform 0.2s, background 0.2s, border-color 0.2s;
    }
    .btn:active { transform: scale(0.97); }
    .btn-primary {
        background: var(--primary);
        color: white;
    }
    .btn-primary:hover { background: color-mix(in oklch, var(--primary) 85%, black); transform: translateY(-1px); }
    .btn-ghost {
        color: var(--text);
        border-color: var(--border);
        background: transparent;
    }
    .btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
    .btn-icon {
        width: 40px; height: 40px;
        padding: 0;
        justify-content: center;
        background: transparent;
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--text);
        font-size: 1.1rem;
    }
    .btn-icon:hover { border-color: var(--primary); }

    /* Menu mobile (dialog natif) */
    dialog#menu {
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: none;
        max-width: none;
        border: none;
        padding: 0;
        background: var(--bg);
        color: var(--text);
        display: grid;
        place-items: center;
        opacity: 0;
        transition: opacity 0.25s;
    }
    dialog#menu[open] { opacity: 1; }
    @supports (animation-timeline: scroll()) {
        dialog#menu {
            @starting-style { opacity: 0; }
        }
    }
    dialog#menu::backdrop {
        background: oklch(0 0 0 / 0.5);
        backdrop-filter: blur(4px);
    }
    .menu-inner {
        display: grid;
        gap: 1.25rem;
        text-align: center;
    }
    .menu-inner a {
        font-size: 1.4rem;
        font-weight: 600;
        text-decoration: none;
        color: var(--text);
    }
    .menu-inner a:hover { color: var(--primary); }

    /* Hero (accueil) */
    .hero {
        min-height: 100dvh;
        background: var(--hero-bg);
        color: white;
        display: grid;
        align-items: center;
        padding: calc(var(--nav-h) + 4rem) 2rem 4rem;
        position: relative;
        overflow: hidden;
    }
    .hero::before {
        content: '';
        position: absolute;
        inset: -20%;
        background: radial-gradient(600px circle at var(--hero-glow) 30%, oklch(0.6 0.2 255 / 0.25), transparent 60%);
        animation: glow-drift 14s ease-in-out infinite alternate;
    }
    @keyframes glow-drift {
        from { --hero-glow: 60%; }
        to { --hero-glow: 80%; }
    }
    .hero-container {
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
        position: relative;
        z-index: 1;
    }
    .hero-eyebrow {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--accent);
        margin-bottom: 1.25rem;
    }
    .hero-eyebrow::before {
        content: '';
        width: 8px; height: 8px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 12px var(--accent);
    }
    .hero h1 {
        font-size: clamp(2.4rem, 5.5vw, 4rem);
        font-weight: 800;
        margin-bottom: 1.25rem;
        max-width: 22ch;
    }
    .hero h1 em,
    .page-hero h1 em {
        font-style: normal;
        background: linear-gradient(90deg, var(--accent), oklch(0.8 0.15 200));
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }
    .hero > .hero-container > p,
    .hero-lede {
        font-size: 1.2rem;
        color: oklch(0.8 0.02 250);
        max-width: 58ch;
        margin-bottom: 2rem;
    }
    .hero-cta { display: flex; flex-wrap: wrap; gap: 1rem; }
    .hero-cta .btn-ghost { color: white; border-color: oklch(1 0 0 / 0.3); }
    .hero-cta .btn-ghost:hover { border-color: white; color: white; }
    .hero-stats {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
        margin-top: 3.5rem;
        padding-top: 2rem;
        border-top: 1px solid oklch(1 0 0 / 0.12);
    }
    .stat-item h3 {
        font-size: clamp(1.5rem, 3vw, 2.2rem);
        font-weight: 700;
        color: var(--accent);
    }
    .stat-item p { font-size: 0.9rem; color: oklch(0.7 0.02 250); }

    /* Page intérieure */
    .page-hero {
        background: var(--hero-bg);
        color: white;
        padding: calc(var(--nav-h) + 4rem) 2rem 3.5rem;
        position: relative;
        overflow: hidden;
    }
    .page-hero::before {
        content: '';
        position: absolute;
        inset: -20%;
        background: radial-gradient(600px circle at 70% 30%, oklch(0.6 0.2 255 / 0.25), transparent 60%);
    }
    .page-hero .container { position: relative; z-index: 1; }
    .page-hero h1 {
        font-size: clamp(2rem, 4.5vw, 3rem);
        margin-bottom: 0.75rem;
        max-width: 24ch;
    }
    .page-hero p {
        color: oklch(0.8 0.02 250);
        max-width: 62ch;
        font-size: 1.1rem;
    }

    /* Sections */
    main > section { padding: 5.5rem 2rem; }
    main > section:nth-child(even of section) { background: var(--surface); }
    .section-header {
        text-align: center;
        max-width: 700px;
        margin: 0 auto 3.5rem;
    }
    .section-header h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); margin-bottom: 0.75rem; }
    .section-header p { color: var(--muted); font-size: 1.05rem; }
    .container { max-width: 1200px; margin: 0 auto; }
    .eyebrow {
        display: inline-block;
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--primary);
        background: color-mix(in oklch, var(--primary) 10%, transparent);
        padding: 0.3rem 0.8rem;
        border-radius: 999px;
        margin-bottom: 1rem;
    }
    .page-hero .eyebrow {
        color: var(--accent);
        background: oklch(1 0 0 / 0.08);
    }

    /* Cards — container queries */
    .grid-3 {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
        gap: 1.5rem;
        container-type: inline-size;
    }
    .card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1.75rem;
        transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    }
    .card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow);
        border-color: color-mix(in oklch, var(--primary) 50%, var(--border));
    }
    .card-icon {
        width: 48px; height: 48px;
        display: grid;
        place-items: center;
        background: color-mix(in oklch, var(--primary) 10%, transparent);
        border-radius: 12px;
        font-size: 1.4rem;
        margin-bottom: 1.25rem;
    }
    .card h3 { font-size: 1.2rem; margin-bottom: 0.6rem; }
    .card > p { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.25rem; }
    .card ul { display: grid; gap: 0.4rem; }
    .card li {
        color: var(--muted);
        font-size: 0.9rem;
        display: flex;
        align-items: baseline;
        gap: 0.5rem;
    }
    .card li::before { content: '→'; color: var(--primary); font-weight: 700; }
    @container (max-width: 380px) {
        .card { padding: 1.25rem; }
    }

    /* Secteurs — certifications & parcours capteur → décision */
    .cert-badges {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
        margin-bottom: 3rem;
    }
    .cert-badge {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        border-radius: 999px;
        border: 1px solid var(--border);
        background: var(--surface);
        font-size: 0.85rem;
        font-weight: 600;
    }
    .cert-badge .dot { width: 8px; height: 8px; border-radius: 50%; }
    .cert-badge.ok .dot { background: oklch(0.75 0.17 160); }
    .cert-badge.wip .dot { background: oklch(0.8 0.15 80); }
    .cert-badge small { color: var(--muted); font-weight: 500; }

    .flow {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1.25rem;
        margin-bottom: 3rem;
    }
    .flow-step {
        position: relative;
        text-align: center;
        padding: 1.5rem 1rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    .flow-step::after {
        content: '→';
        position: absolute;
        right: -1.15rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--primary);
        font-weight: 700;
        font-size: 1.2rem;
        z-index: 1;
    }
    .flow-step:last-child::after { content: none; }
    .flow-icon { font-size: 1.6rem; margin-bottom: 0.5rem; }
    .flow-step h4 { font-size: 0.95rem; margin-bottom: 0.25rem; }
    .flow-step p { font-size: 0.8rem; color: var(--muted); }

    /* Cœur du système — IA agentique + expertises */
    .core {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        max-width: 1100px;
        margin: 0 auto 3rem;
        align-items: stretch;
    }
    .core-center {
        grid-column: 2;
        grid-row: 1 / span 2;
        background: var(--hero-bg);
        color: white;
        border-radius: 20px;
        display: grid;
        place-content: center;
        justify-items: center;
        text-align: center;
        gap: 0.3rem;
        padding: 2rem 1rem;
        box-shadow: 0 0 0 6px color-mix(in oklch, var(--accent) 25%, transparent), var(--shadow);
    }
    .core-icon { font-size: 2rem; }
    .core-center h3 { font-size: 1.3rem; }
    .core-center p { font-size: 0.8rem; color: oklch(0.75 0.02 250); }
    .core-pill {
        display: grid;
        place-content: center;
        text-align: center;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1.25rem 1rem;
        font-weight: 600;
        font-size: 0.9rem;
    }
    .core-pill:last-child { grid-column: 2; }

    /* Piliers du schéma — repliés par défaut, détail au clic */
    details.pillar {
        place-content: start;
        text-align: left;
        gap: 0.6rem;
        padding: 1.25rem;
    }
    details.pillar summary {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 0.4rem 0.6rem;
        cursor: pointer;
        list-style: none;
        position: relative;
        padding-right: 1.5rem;
        border-radius: 10px;
        transition: background 0.2s;
    }
    details.pillar summary::-webkit-details-marker { display: none; }
    details.pillar summary:hover { background: color-mix(in oklch, var(--primary) 6%, transparent); }
    details.pillar summary::after {
        content: '▾';
        position: absolute;
        top: 0.15rem;
        right: 0.2rem;
        color: var(--primary);
        font-size: 1rem;
        transition: transform 0.2s;
    }
    details.pillar[open] summary::after { transform: rotate(180deg); }
    .pillar-num {
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--primary);
        background: color-mix(in oklch, var(--primary) 10%, transparent);
        padding: 0.2rem 0.6rem;
        border-radius: 999px;
        white-space: nowrap;
    }
    details.pillar h3 { font-size: 1rem; }
    .pillar-quote {
        grid-column: 1 / -1;
        font-size: 0.78rem;
        font-style: italic;
        color: var(--muted);
        line-height: 1.4;
    }
    details.pillar ul { display: grid; gap: 0.35rem; }
    details.pillar[open] ul { animation: pillar-open 0.25s ease; }
    @keyframes pillar-open {
        from { opacity: 0; transform: translateY(-4px); }
        to { opacity: 1; transform: none; }
    }
    details.pillar li {
        font-size: 0.8rem;
        font-weight: 400;
        color: var(--muted);
        display: flex;
        align-items: baseline;
        gap: 0.45rem;
        line-height: 1.4;
    }
    details.pillar li::before { content: '→'; color: var(--primary); font-weight: 700; }
    @media (max-width: 700px) {
        .core { grid-template-columns: 1fr; max-width: 420px; }
        .core-center { grid-column: 1; grid-row: auto; order: -1; }
        .core-pill:last-child { grid-column: 1; }
    }

    /* Process */
    .process-steps {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
        gap: 2rem 1.5rem;
        counter-reset: step;
    }
    .step {
        position: relative;
        padding: 2rem 1.5rem 1.5rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    .step::before {
        counter-increment: step;
        content: counter(step);
        position: absolute;
        top: -14px; left: 18px;
        background: var(--primary);
        color: white;
        width: 30px; height: 30px;
        border-radius: 50%;
        display: grid;
        place-items: center;
        font-weight: 700;
        font-size: 0.85rem;
    }
    .step h4 { margin: 0.4rem 0 0.5rem; }
    .step p { color: var(--muted); font-size: 0.95rem; }

    /* Réseau */
    .logo-grid {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.25rem 2.5rem;
        align-items: center;
    }
    .logo-item {
        font-weight: 700;
        font-size: 1rem;
        color: var(--muted);
        letter-spacing: 0.06em;
        opacity: 0.75;
        transition: opacity 0.2s, color 0.2s;
    }
    .logo-item:hover { opacity: 1; color: var(--primary); }

    /* Teasers (accueil) */
    .teaser-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
        gap: 1.5rem;
    }
    .teaser {
        display: grid;
        align-content: start;
        gap: 0.4rem;
        text-decoration: none;
        color: var(--text);
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1.75rem;
        transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    }
    .teaser:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow);
        border-color: color-mix(in oklch, var(--primary) 50%, var(--border));
    }
    .teaser .card-icon { margin-bottom: 0.5rem; }
    .teaser h3 { font-size: 1.15rem; }
    .teaser p { color: var(--muted); font-size: 0.9rem; }
    .teaser-link {
        color: var(--primary);
        font-weight: 600;
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }
    /* Contact au centre de la grille */
    @media (min-width: 1096px) {
        .teaser-grid .teaser:last-child {
            grid-column: 2 / 4;
            justify-items: center;
            text-align: center;
        }
    }
    @media (min-width: 568px) and (max-width: 831px) {
        .teaser-grid .teaser:last-child { grid-column: 1 / -1; }
    }
    .section-cta {
        text-align: center;
        margin-top: 3rem;
    }

    /* Bandeau CTA */
    .cta-band {
        background: var(--hero-bg);
        color: white;
        padding: 4.5rem 2rem;
        text-align: center;
    }
    .cta-band h2 { color: white; font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 0.75rem; }
    .cta-band p {
        color: oklch(0.8 0.02 250);
        max-width: 55ch;
        margin: 0 auto 1.75rem;
    }

    /* Contact */
    .contact-grid {
        display: grid;
        grid-template-columns: 1.2fr 1fr;
        gap: 3rem;
        align-items: start;
    }
    .contact-form {
        display: grid;
        gap: 1.25rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 2rem;
    }
    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
    }
    .field { display: grid; gap: 0.4rem; }
    .field label { font-size: 0.85rem; font-weight: 600; }
    .field input,
    .field select,
    .field textarea {
        font: inherit;
        color: var(--text);
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 0.7rem 0.9rem;
    }
    .field input:focus,
    .field select:focus,
    .field textarea:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 20%, transparent);
    }
    .field textarea { min-height: 140px; resize: vertical; }
    .contact-info { display: grid; gap: 1.25rem; }

    /* Footer */
    footer {
        background: var(--hero-bg);
        color: oklch(0.72 0.02 250);
        padding: 4rem 2rem 2rem;
    }
    .footer-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
        gap: 2.5rem;
        max-width: 1200px;
        margin: 0 auto 3rem;
    }
    .footer-col h4 { color: white; margin-bottom: 1rem; font-size: 1rem; }
    .footer-col a {
        display: block;
        color: oklch(0.72 0.02 250);
        text-decoration: none;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
    .footer-col a:hover { color: white; }
    .footer-col p { font-size: 0.9rem; }
    .footer-bottom {
        text-align: center;
        padding-top: 2rem;
        border-top: 1px solid oklch(1 0 0 / 0.1);
        font-size: 0.85rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem 1.5rem;
        justify-content: center;
        align-items: center;
    }
    .share-btn {
        background: transparent;
        border: 1px solid oklch(1 0 0 / 0.2);
        color: oklch(0.72 0.02 250);
        border-radius: 8px;
        padding: 0.35rem 0.8rem;
        font-size: 0.8rem;
        cursor: pointer;
        font-family: inherit;
    }
    .share-btn:hover { color: white; border-color: white; }

    /* Reveal on scroll (fallback JS) */
    .reveal {
        opacity: 0;
        transform: translateY(24px);
        transition: opacity 0.6s ease, transform 0.6s ease;
    }
    .reveal.in-view { opacity: 1; transform: none; }
    @supports (animation-timeline: view()) {
        .reveal {
            opacity: 1;
            transform: none;
            transition: none;
            animation: reveal-up both;
            animation-timeline: view();
            animation-range: entry 0% entry 40%;
        }
        @keyframes reveal-up {
            from { opacity: 0; transform: translateY(24px); }
            to { opacity: 1; transform: none; }
        }
    }

    /* Performance */
    main > section { content-visibility: auto; contain-intrinsic-size: auto 800px; }
}

@layer utilities {
    @media (max-width: 820px) {
        .nav-links { display: none; }
        .hero-stats { grid-template-columns: 1fr; gap: 1.25rem; }
        main > section { padding: 4rem 1.25rem; }
        .flow { grid-template-columns: 1fr 1fr; }
        .flow-step::after { content: none; }
        .contact-grid { grid-template-columns: 1fr; }
        .form-row { grid-template-columns: 1fr; }
    }
    @media (min-width: 821px) {
        .burger { display: none; }
    }
}
