/* ---------------------------------------------------------------------------
   Index Apache (FancyIndexing) — habillage Kaury Studio.
   ---------------------------------------------------------------------------
   Même palette et mêmes fontes que le site (beige #F1E8CB, orange #F56E2E,
   noir #1C1A1A ; Cabinet Grotesk pour le titre, Satoshi pour le texte).

   Le HTML est généré par Apache, on ne peut pas y ajouter de classes : tout
   passe par les sélecteurs d'éléments et les attributs qu'Apache produit
   (th[colspan] pour les <hr> de séparation, img[alt="[DIR]"] pour les icônes).

   Les fontes sont cherchées en absolu (/fonts/...) puis en relatif (fonts/...)
   pour marcher que la feuille soit à la racine du domaine ou d'un sous-dossier.
   Si les .woff2 sont absents, les fontes système prennent le relais.
--------------------------------------------------------------------------- */

@font-face {
  font-family: 'Cabinet Grotesk';
  src: url('/fonts/cabinet-grotesk-800.woff2') format('woff2'),
       url('fonts/cabinet-grotesk-800.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/satoshi-400.woff2') format('woff2'),
       url('fonts/satoshi-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/satoshi-700.woff2') format('woff2'),
       url('fonts/satoshi-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --beige: #f1e8cb;
  --paper: #fdfaf1;
  --surface2: #e7dcba;
  --noir: #1c1a1a;
  --orange: #f56e2e;
  --orange-t: #a83e0d;
  --line: rgba(28, 26, 26, 0.15);
  --line-strong: rgba(28, 26, 26, 0.26);
  --ink-muted: #6b6456;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 4rem;
  background: var(--beige);
  color: var(--noir);
  font-family: 'Satoshi', 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Grain léger, comme sur le site */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- Titre « Index of /... » ------------------------------------------------ */
h1 {
  max-width: 880px;
  margin: 0 auto 1.6rem;
  font-family: 'Cabinet Grotesk', 'Satoshi', sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 3.4vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  word-break: break-word;
}

/* Petit filet orange sous le titre */
h1::after {
  content: '';
  display: block;
  width: 56px;
  height: 4px;
  margin-top: 0.9rem;
  border-radius: 999px;
  background: var(--orange);
}

/* --- La liste, en carte ------------------------------------------------------ */
table {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(28, 26, 26, 0.04),
    0 12px 28px -22px rgba(28, 26, 26, 0.45);
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th a {
  color: inherit;
  text-decoration: none;
}

th a:hover {
  color: var(--orange-t);
}

/* Apache insère deux lignes `<th colspan="5"><hr></th>` en haut et en bas de
   la liste : on les neutralise pour ne pas voir deux bandeaux vides. */
th[colspan] {
  padding: 0;
  height: 0;
  background: none;
  border: none;
}

td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--ink-muted);
  vertical-align: middle;
  white-space: nowrap;
}

/* Colonne « Name » : c'est elle qui porte le nom du fichier */
td:nth-child(2) {
  color: var(--noir);
  font-weight: 700;
  width: 100%;
  white-space: normal;
  word-break: break-word;
}

/* Dernière ligne sans filet : soit c'est vraiment la dernière, soit elle est
   suivie de la ligne de séparation `<th colspan>` neutralisée plus haut. */
tr:last-child td,
tr:has(+ tr > th[colspan]) td {
  border-bottom: none;
}

tr:hover td {
  background: var(--beige);
}

td a {
  color: inherit;
  text-decoration: none;
}

td a:hover {
  color: var(--orange-t);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}

td a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 110, 46, 0.45);
  border-radius: 4px;
}

/* --- Icônes ------------------------------------------------------------------
   Les .gif d'Apache jurent avec la palette : on les remplace par des pictos SVG
   inline via `content`. Si le navigateur ne l'applique pas aux images, le .gif
   d'origine reste affiché, simplement adouci. */
td img,
th img {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  opacity: 0.75;
}

/* Dossier — orange */
img[alt='[DIR]'] {
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23f56e2e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
  opacity: 1;
}

/* Dossier parent — flèche vers le haut */
img[alt='[PARENTDIR]'] {
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%231c1a1a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5'/%3E%3Cpath d='m5 12 7-7 7 7'/%3E%3C/svg%3E");
  opacity: 1;
}

/* Tout le reste — fichier, encre douce */
td img:not([alt='[DIR]']):not([alt='[PARENTDIR]']) {
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b6456' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E");
  opacity: 0.9;
}

/* En-tête de la colonne icônes : rien à afficher */
th img {
  display: none;
}

hr {
  display: none;
}

/* --- Signature Apache -------------------------------------------------------- */
address {
  display: block;
  max-width: 880px;
  margin: 1.5rem auto 0;
  font-size: 0.78rem;
  font-style: normal;
  color: var(--ink-muted);
  text-align: center;
}

/* --- Petits écrans ----------------------------------------------------------- */
@media (max-width: 560px) {
  th,
  td {
    padding-inline: 0.7rem;
  }

  /* On garde nom + taille : la date (3e colonne) et l'éventuelle description
     (5e colonne, si SuppressDescription est retiré) passent à la trappe. */
  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
