/* ==========================================================================
   yvan alvarez — feuille de style unique
   Toute la direction graphique se règle dans les variables ci-dessous.
   ========================================================================== */

:root {
  /* Typographie */
  --font: Arial, Helvetica, sans-serif;
  --size: 13px;
  --size-small: 12px;          /* mobile */
  --line-height: 1.45;

  /* Couleurs */
  --bg: #fff;
  --fg: #161616;
  --muted: #666;
  --line: #d7d7d7;
  --hover: #f3f3f3;
  --table-head-bg: #f8f8f8;    /* fond de la ligne d'en-tête des tableaux */

  /* Espacements */
  --pad-x: 18px;               /* marges latérales */
  --pad-y: 20px;
  --cell-pad: 9px;             /* hauteur des lignes de tableau */
  --cell-indent: 8px;          /* retrait du texte dans les tableaux */
  --gap: 20px;

  /* Proportions du tableau works (ref / title / year / medium / dimensions) */
  --works-ref: 9%;
  --works-title: 29%;
  --works-year: 9%;
  --works-medium: 33%;
  --works-dimensions: 20%;

  /* Proportions des tableaux exhibitions et writings (4 colonnes) */
  --col-1: 34%;
  --col-2: 12%;
  --col-3: 34%;
  --col-4: 20%;

  /* Largeur maximale des textes */
  --measure: 620px;

  /* Fenêtres flottantes */
  --window-width: 560px;
  --window-max-height: 75vh;
  --window-border: #777;
  --window-head-bg: #f8f8f8;
  --window-shadow: none;

  /* Vue images */
  --grid-columns: 5;           /* ordinateur */
  --grid-columns-medium: 3;    /* tablette */
  --grid-columns-small: 1;     /* mobile */
  --grid-gap: 14px;

  /* Aperçu au survol dans works */
  --preview-width: 240px;
}

/* --- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--size) / var(--line-height) var(--font);
}

a, button { font: inherit; color: inherit; }
a { text-decoration: none; }
a:hover, a:focus-visible, button:hover { text-decoration: underline; }
button { cursor: pointer; background: transparent; border: 0; padding: 0; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }

h1, h2, h3 { font-size: inherit; font-weight: 400; margin: 0; }
p { margin: 0 0 1em; }
img { display: block; max-width: 100%; height: auto; }

.muted { color: var(--muted); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- En-tête et navigation ---------------------------------------------- */

.site-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--gap);
  padding: 14px var(--pad-x);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.site-nav ul { display: flex; flex-wrap: wrap; gap: var(--gap); margin: 0; padding: 0; list-style: none; }
.site-nav [aria-current] { text-decoration: underline; }

.site-main { padding: var(--pad-y) var(--pad-x); }

.intro { color: var(--muted); margin: 0 0 24px; }

/* --- Bascule list / images ---------------------------------------------- */

.view-switch { display: flex; gap: 12px; margin: 0 0 12px; }
.view-switch [aria-current] { text-decoration: underline; }

/* --- Tableaux d'inventaire --------------------------------------------- */

.table { width: 100%; border-collapse: collapse; table-layout: fixed; }

.table th,
.table td {
  text-align: left; font-weight: 400; vertical-align: top;
  padding: var(--cell-pad) 10px var(--cell-pad) var(--cell-indent);
  border-bottom: 1px solid var(--line);
}

.table th { color: var(--muted); border-top: 1px solid var(--line); background: var(--table-head-bg); }

/* Toute la ligne est cliquable : chaque cellule contient un lien qui
   la recouvre (fonctionne dans tous les navigateurs, y compris Safari) */
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--hover); }
.table tbody td { position: relative; }
.table .row-link::after { content: ""; position: absolute; inset: 0; }
.table tbody tr:hover .cell-link .row-link { text-decoration: underline; }
.table tbody td:not(.cell-link) .row-link:hover { text-decoration: none; }
.table .row-link:focus-visible { outline: none; }
.table tbody tr:focus-within { outline: 1px solid var(--fg); outline-offset: -1px; }

.table--index th:nth-child(1) { width: var(--col-1); }
.table--index th:nth-child(2) { width: var(--col-2); }
.table--index th:nth-child(3) { width: var(--col-3); }
.table--index th:nth-child(4) { width: var(--col-4); }

.table--works th:nth-child(1) { width: var(--works-ref); }
.table--works th:nth-child(2) { width: var(--works-title); }
.table--works th:nth-child(3) { width: var(--works-year); }
.table--works th:nth-child(4) { width: var(--works-medium); }
.table--works th:nth-child(5) { width: var(--works-dimensions); }

/* --- Vue images ---------------------------------------------------------- */

.image-grid {
  display: grid; grid-template-columns: repeat(var(--grid-columns), 1fr);
  gap: var(--grid-gap); align-items: end;
  list-style: none; margin: 0; padding: 0;
}
.image-tile a { display: block; }
.image-tile a:hover { text-decoration: none; }
.image-tile a:hover .image-caption { text-decoration: underline; }
.image-tile img { width: 100%; height: auto; background: var(--hover); }
.image-caption { display: block; margin-top: 7px; }

/* --- Fiche (page d'une œuvre, d'une exposition, d'un texte) ------------- */

.entry { max-width: 760px; }

.entry-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--gap);
  padding-bottom: 9px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.entry-close { font-size: 14px; line-height: 1; padding: 0 2px; }
.entry-links { list-style: none; margin: 0 0 22px; padding: 0; }
.entry-links li { padding: 3px 0; }
.entry-links a { text-decoration: underline; }

.metadata {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 0 0 22px;
}
.metadata dt { color: var(--muted); }
.metadata dd { margin: 0; }

.entry-images { display: grid; gap: 14px; margin: 0 0 22px; }
.entry-images figure { margin: 0; }
.entry-images figcaption { color: var(--muted); margin-top: 5px; }

.entry-text { max-width: var(--measure); margin: 0 0 22px; }

.related { border-top: 1px solid var(--line); padding-top: 10px; }
.related h2 { color: var(--muted); margin: 12px 0 6px; }
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { padding: 3px 0; }
.related a { text-decoration: underline; }

.entry-nav {
  display: flex; justify-content: space-between; gap: var(--gap);
  margin-top: 30px; padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* --- Texte courant (about, pages simples) ------------------------------- */

.prose { max-width: var(--measure); line-height: 1.7; }

/* --- Fenêtres flottantes ---------------------------------------------- */

.window {
  position: fixed; z-index: 10;
  left: 22%; top: 70px;
  width: min(var(--window-width), 90vw);
  max-height: var(--window-max-height);
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--window-border);
  box-shadow: var(--window-shadow);
  /* Étirable par le coin bas-droit (ordinateur) */
  resize: both; overflow: hidden;
  min-width: 280px; min-height: 160px;
  max-width: calc(100vw - 16px);
}
/* Une fois étirée, la fenêtre peut aller jusqu'à la hauteur de l'écran */
.window.is-resized { max-height: calc(100vh - 16px); }
.window .entry { max-width: none; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.window .entry-head {
  margin: 0; padding: 9px 11px;
  background: var(--window-head-bg);
  cursor: move; user-select: none; touch-action: none;
}
.window .entry-head h1:focus { outline: none; }
.window .entry-body { overflow: auto; padding: 14px; overscroll-behavior: contain; }
.window .entry-nav { margin-top: 22px; }
.window:not(.is-front) .entry-head { color: var(--muted); }
.window.is-dragging { user-select: none; }

/* --- Tablette ------------------------------------------------------------ */

@media (max-width: 1000px) {
  :root { --grid-columns: var(--grid-columns-medium); }
}

/* --- Mobile -------------------------------------------------------------- */

@media (max-width: 650px) {
  :root {
    --size: var(--size-small); --pad-x: 10px; --pad-y: 14px; --gap: 13px;
    --grid-columns: var(--grid-columns-small);
    --col-1: 33%; --col-2: 12%; --col-3: 35%; --col-4: 20%;
    --works-title: 33%; --works-year: 12%; --works-medium: 35%; --works-dimensions: 20%;
  }

  /* La colonne ref est masquée sur mobile (visible dans la fiche) */
  .table--works th:nth-child(1),
  .table--works td:nth-child(1) { display: none; }

  .site-header { flex-direction: column; align-items: flex-start; gap: 12px; }

  .table th, .table td { padding-right: 5px; }

  .metadata { grid-template-columns: 1fr; }

  /* Sur mobile, les fenêtres deviennent des panneaux presque plein écran */
  .window {
    left: 2vw !important; top: 8px !important;
    width: 96vw !important; max-height: calc(100dvh - 16px); height: calc(100dvh - 16px) !important;
    resize: none;
  }
  .window .entry-head { cursor: default; padding: 12px; }
  .entry-close { font-size: 20px; padding: 0 6px; }
}

/* --- About ---------------------------------------------------------------- */

.about-block { margin: 0 0 24px; }
.about-block h2 { margin: 0 0 6px; }
.about-block ul, .plain-list { list-style: none; margin: 0; padding: 0; }
.prose a { text-decoration: underline; }

/* --- Aperçu au survol (works, ordinateur) ------------------------------- */

.preview {
  position: fixed; z-index: 8;
  width: var(--preview-width);
  pointer-events: none;
  right: var(--pad-x); bottom: var(--pad-y);
  visibility: hidden;
}
.preview.is-visible { visibility: visible; }
.preview img { width: 100%; height: auto; }
