@import '../utils/variables.css';

/* ══════════════════════════════════════════════════════════════
   PAGE ACTUALITÉS – mobile-first
   Tous les sélecteurs sont préfixés .actualites-page pour ne
   pas entrer en conflit avec home.css.
   ══════════════════════════════════════════════════════════════ */

.actualites-page {
    /* Jetons locaux, avec repli si variables.css ne les définit pas */
    --a-red: var(--institutional-red, #c92525);
    --a-navy: #1e3a5f;
    --a-navy-deep: #0f2238;
    --a-ink: var(--deep-black, #111827);
    --a-muted: var(--text-secondary, #5b6472);
    --a-white: var(--pure-white, #ffffff);
    --a-soft: var(--bg-secondary, #f4f6f9);
    --a-line: rgba(15, 34, 56, 0.12);
    --a-radius: clamp(14px, 1vw + 8px, 22px);
    --a-gap: clamp(1rem, 0.6rem + 1.6vw, 2rem);
    --a-section: clamp(3rem, 2rem + 4vw, 6rem);
    --a-pad: clamp(1.1rem, 0.6rem + 2.4vw, 2rem);
    --a-nav: 80px; /* hauteur de votre navbar fixe */
    --a-heading: var(--font-heading, 'Playfair Display', Georgia, serif);

    color: var(--a-ink);
    overflow-x: clip;
}

.actualites-page .container {
    width: min(100% - 2 * var(--a-pad), 1200px);
    margin-inline: auto;
    padding-inline: 0;
}

.actualites-page img { display: block; max-width: 100%; height: auto; }

.actualites-page .sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.actualites-page a:focus-visible {
    outline: 3px solid var(--a-red);
    outline-offset: 3px;
    border-radius: 6px;
}

/* ───────── HERO ───────── */
.actualites-hero {
    position: relative;
    display: flex;
    align-items: center;
    min-height: clamp(320px, 46svh, 520px);
    padding: calc(var(--a-nav) + clamp(2rem, 6vw, 4rem)) 0 clamp(2.5rem, 6vw, 4.5rem);
    color: var(--a-white);
    background: var(--a-navy-deep);
    overflow: hidden;
    isolation: isolate;
}

.actualites-hero__bg {
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(70% 90% at 90% 0%, rgba(201, 37, 37, 0.32), transparent 60%),
        radial-gradient(60% 80% at 0% 100%, rgba(30, 58, 95, 0.9), transparent 70%),
        linear-gradient(160deg, var(--a-navy-deep) 0%, var(--a-navy) 100%);
}

/* Fines lignes verticales, évoquent les colonnes d'un palais de justice */
.actualites-hero__bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 88px);
    mask-image: linear-gradient(180deg, #000, transparent 85%);
    -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%);
}

.actualites-hero__inner { animation: actu-rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) both; }
.actualites-hero__title { max-width: 18ch; }

.actualites-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1.25rem;
    padding: 0.45rem 1rem 0.45rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.actualites-hero__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--a-red);
    box-shadow: 0 0 0 4px rgba(201, 37, 37, 0.3);
}

.actualites-hero__title {
    margin: 0 0 1rem;
    font-family: var(--a-heading);
    font-size: clamp(2rem, 1.2rem + 4vw, 3.75rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.actualites-hero__subtitle {
    max-width: 56ch;
    margin: 0;
    font-size: clamp(1rem, 0.92rem + 0.4vw, 1.2rem);
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.86);
}

.actualites-hero__meta {
    margin: 1.5rem 0 0;
    padding-top: 1.1rem;
    width: fit-content;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    border-top: 2px solid var(--a-red);
}

/* ───────── SECTIONS ───────── */
.recent-articles,
.older-articles { padding: var(--a-section) 0; }

.recent-articles { background: var(--a-soft); }
.older-articles  { background: var(--a-white); }

.section-head { margin-bottom: clamp(1.5rem, 1rem + 2vw, 3rem); }

.section-head__title {
    margin: 0 0 0.4rem;
    font-family: var(--a-heading);
    font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.35rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--a-ink);
}

.section-head__title::after {
    content: '';
    display: block;
    width: 48px; height: 3px; margin-top: 0.75rem;
    background: var(--a-red);
    border-radius: 3px;
}

.section-head__text { margin: 0.9rem 0 0; color: var(--a-muted); font-size: 1rem; }

/* ───────── GRILLE & CARTES ───────── */
.articles-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--a-gap);
}

.news-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--a-white);
    border: 1px solid var(--a-line);
    border-radius: var(--a-radius);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 34, 56, 0.04), 0 8px 24px -12px rgba(15, 34, 56, 0.12);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.4s ease;
}

.news-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--a-navy);
}

.news-card__media img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.7s ease;
}

.news-card__placeholder {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    color: rgba(255, 255, 255, 0.55);
    background: linear-gradient(135deg, var(--a-navy-deep), var(--a-navy));
}

.news-card__date {
    position: absolute;
    top: 0.85rem; left: 0.85rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--a-ink);
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.news-card__content {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: clamp(1.1rem, 0.8rem + 1.2vw, 1.75rem);
}

.news-card__title {
    margin: 0 0 0.65rem;
    font-family: var(--a-heading);
    font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--a-ink);
    text-wrap: balance;
    overflow-wrap: anywhere;
}

.news-card__excerpt {
    flex: 1;
    margin: 0 0 1.25rem;
    font-size: 0.97rem;
    line-height: 1.65;
    color: var(--a-muted);
}

.news-card__link {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.5rem;
    min-height: 44px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--a-red);
    text-decoration: none;
    transition: gap 0.3s ease;
}

/* Toute la carte devient cliquable (idéal au toucher) */
.news-card__link::after { content: ''; position: absolute; inset: 0; z-index: 1; }

@media (hover: hover) {
    .news-card:hover {
        transform: translateY(-6px);
        border-color: rgba(201, 37, 37, 0.45);
        box-shadow: 0 2px 4px rgba(15, 34, 56, 0.06), 0 24px 48px -16px rgba(15, 34, 56, 0.25);
    }
    .news-card:hover .news-card__media img { transform: scale(1.06); }
    .news-card:hover .news-card__link { gap: 0.85rem; }
}

.news-card:active { transform: scale(0.99); }

/* ───────── ARTICLE VEDETTE ───────── */
@media (min-width: 640px) {
    .articles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .news-card--lead { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
    .news-card--lead { flex-direction: row; }
    .news-card--lead .news-card__media { flex: 0 0 56%; aspect-ratio: auto; min-height: 380px; }
    .news-card--lead .news-card__content { justify-content: center; }
    .news-card--lead .news-card__title { font-size: clamp(1.6rem, 1.2rem + 1vw, 2.15rem); line-height: 1.2; }
    .news-card--lead .news-card__excerpt { flex: 0 1 auto; font-size: 1.05rem; }
}

/* Si 3 articles et grand écran : les 2 secondaires restent côte à côte */
@media (min-width: 1280px) {
    .actualites-page .container { width: min(100% - 4rem, 1240px); }
}

/* ───────── ARCHIVES ───────── */
.archive-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--a-line);
}

.archive-item { border-bottom: 1px solid var(--a-line); }

.archive-item__link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "date arrow" "title arrow";
    align-items: center;
    column-gap: 1rem;
    row-gap: 0.2rem;
    min-height: 64px;
    padding: 1rem 0.25rem;
    color: var(--a-ink);
    text-decoration: none;
    transition: background 0.25s ease, padding 0.25s ease;
}

.archive-item__date { grid-area: date; font-size: 0.82rem; font-weight: 600; color: var(--a-red); }

.archive-item__title {
    grid-area: title;
    font-family: var(--a-heading);
    font-size: clamp(1rem, 0.95rem + 0.4vw, 1.2rem);
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.archive-item__arrow { grid-area: arrow; color: var(--a-muted); transition: transform 0.25s ease, color 0.25s ease; }

@media (hover: hover) {
    .archive-item__link:hover { background: var(--a-soft); padding-inline: 1rem; }
    .archive-item__link:hover .archive-item__arrow { color: var(--a-red); transform: translateX(4px); }
}

@media (min-width: 720px) {
    .archive-item__link {
        grid-template-columns: 170px minmax(0, 1fr) auto;
        grid-template-areas: "date title arrow";
        column-gap: 1.5rem;
        padding-block: 1.25rem;
    }
}

/* ───────── ÉTAT VIDE ───────── */
.actualites-empty {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    padding: clamp(2rem, 6vw, 4rem) 1.25rem;
    text-align: center;
    color: var(--a-muted);
    background: var(--a-white);
    border: 2px dashed var(--a-line);
    border-radius: var(--a-radius);
}

.actualites-empty__title { margin: 0.5rem 0 0; font-family: var(--a-heading); font-size: 1.2rem; font-weight: 700; color: var(--a-ink); }
.actualites-empty__text  { margin: 0; font-size: 0.95rem; }

/* ───────── PAGINATION (Laravel) ───────── */
.pagination-wrapper { display: flex; justify-content: center; margin-top: clamp(1.5rem, 4vw, 2.5rem); }

/* Évite les icônes géantes si le gabarit Tailwind de Laravel est utilisé sans Tailwind */
.pagination-wrapper svg { width: 1.1rem; height: 1.1rem; }

.pagination-wrapper nav > div:first-child { display: none; } /* version « Précédent / Suivant » mobile en doublon */
.pagination-wrapper nav > div:last-child > div:first-child { display: none; } /* texte « Showing x to y » */
.pagination-wrapper nav span[class*="relative"],
.pagination-wrapper nav a[class*="relative"] { display: inline-flex; align-items: center; justify-content: center; }

.pagination-wrapper .pagination {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem;
    margin: 0; padding: 0; list-style: none;
}

.pagination-wrapper .page-link,
.pagination-wrapper nav a,
.pagination-wrapper nav span[aria-current] > span,
.pagination-wrapper nav span[aria-disabled] > span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px; padding: 0 0.85rem;
    font-size: 0.92rem; font-weight: 600; text-decoration: none;
    color: var(--a-ink);
    background: var(--a-white);
    border: 1px solid var(--a-line);
    border-radius: 12px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pagination-wrapper .active .page-link,
.pagination-wrapper nav span[aria-current] > span {
    color: var(--a-white);
    background: var(--a-red);
    border-color: var(--a-red);
}

.pagination-wrapper .disabled .page-link,
.pagination-wrapper nav span[aria-disabled] > span { opacity: 0.45; }

@media (hover: hover) {
    .pagination-wrapper .page-link:hover,
    .pagination-wrapper nav a:hover { color: var(--a-white); background: var(--a-navy); border-color: var(--a-navy); }
}

.pagination-wrapper nav > div:last-child { display: flex; justify-content: center; }
.pagination-wrapper nav > div:last-child span.relative { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; box-shadow: none; }

/* ───────── ANIMATION & ACCESSIBILITÉ ───────── */
@keyframes actu-rise {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .actualites-page *, .actualites-page *::before, .actualites-page *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}

/* Paysage sur téléphone : hero plus compact */
@media (max-height: 500px) and (orientation: landscape) {
    .actualites-hero { min-height: 0; padding-top: calc(var(--a-nav) + 1rem); padding-bottom: 1.5rem; }
}

/* Impression */
@media print {
    .actualites-hero { color: #000; background: none; padding: 1rem 0; min-height: 0; }
    .actualites-hero__bg { display: none; }
    .news-card { box-shadow: none; break-inside: avoid; }
    .pagination-wrapper { display: none; }
}