/* ILPH : base graphique commune des sites ilph-creation.party.
   Seul le bloc « Palette » change d'un site à l'autre (voir README, « Changer de palette »). */

/* ---------- Polices (auto-hébergées, jamais Google Fonts) ---------- */

/* JetBrains Mono n'existe qu'en 400 et 500 : le fichier 500 sert aussi tous les poids plus gras,
   sinon le navigateur synthétise un faux gras baveux à chaque font-weight: 700. */
@font-face { font-family: "JetBrains Mono"; font-weight: 100 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500 900; font-display: swap; src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Silkscreen"; font-weight: 400; font-display: swap; src: url("fonts/silkscreen-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Silkscreen"; font-weight: 700; font-display: swap; src: url("fonts/silkscreen-latin-700-normal.woff2") format("woff2"); }

:root {
  /* ---------- Palette ---------- */
  /* En hexadécimal uniquement : pixel.js relit ces valeurs pour le champ et les tramages. */
  --bg: #0b0602;          /* fond de page, fond des icônes */
  --surface: #140a03;     /* surfaces surélevées : cartes, panneaux */
  --accent: #ff7a1a;      /* titres de section, ombres dures, trame, numéros */
  --highlight: #ffac02;   /* survol, état actif, coins en équerre, statut en ligne */
  --text: #f6e7d4;
  --muted: #9c7a5b;       /* texte secondaire */
  --danger: #ff4a2a;
  --field-dark: #4a1f00;  /* teinte la plus sombre du champ animé et des ombres pixel */
  /* Rampe des icônes tramées, de l'ombre à la lumière */
  --icon-0: #2b1404;
  --icon-1: #8f3d00;
  --icon-2: #ff7a1a;
  --icon-3: #ffd9a0;

  /* Dérivés : ne pas toucher */
  --hairline: color-mix(in srgb, var(--accent) 18%, transparent);
  --hairline-strong: color-mix(in srgb, var(--accent) 45%, transparent);
  --checker: repeating-conic-gradient(color-mix(in srgb, var(--accent) 5%, transparent) 0% 25%, transparent 0% 50%) 0 0 / 3px 3px;

  --font-pixel: "Silkscreen", "Courier New", monospace;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  color-scheme: dark;
}

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

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

html { background: var(--bg); }

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Halo d'accent (tramé par pixel.js, le dégradé lisse ne sert qu'au premier affichage)
     + damier de points 3 px */
  background:
    var(--dither-halo, radial-gradient(ellipse 80% 50% at 70% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%)) 0 0 / var(--dither-halo-size, 100% 100%) no-repeat,
    var(--checker),
    var(--bg);
  background-attachment: fixed;
  image-rendering: pixelated;
  overflow-x: hidden;
}

/* image-rendering s'hérite : sans ça, toutes les images de la page seraient pixelisées
   comme le halo. À reproduire sous chaque élément qui reçoit un fond tramé. */
body > * { image-rendering: auto; }

/* Grain teinté. Pour une autre palette : les trois premières valeurs non nulles de la matrice
   (ici 1, .6, .2) sont les composantes R, G, B de l'accent divisées par 255. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: .08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 .6 0 0 0 0 .2 0 0 0 1.2 -.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

::selection { background: var(--accent); color: var(--bg); }

button, input, select, textarea { font: inherit; color: inherit; }

/* Aucun coin arrondi, nulle part. Une exception doit avoir une raison (voir README). */

/* ---------- Barres de défilement pixel ---------- */

/* Firefox / LibreWolf : pas de pseudo-éléments WebKit, on se contente des couleurs.
   Réservé à Firefox, car dans Chromium scrollbar-color désactiverait le dessin ci-dessous. */
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-color: color-mix(in srgb, var(--accent) 60%, var(--surface)) var(--bg); }
}

/* Chromium : piste en damier, curseur carré en relief, flèches en escalier.
   Pour une autre palette, remplacer ff7a1a (%23 = #) dans les quatre flèches. */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track {
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--accent) 14%, transparent) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px,
    var(--bg);
}
::-webkit-scrollbar-track:vertical { box-shadow: inset 1px 0 0 var(--hairline-strong); }
::-webkit-scrollbar-track:horizontal { box-shadow: inset 0 1px 0 var(--hairline-strong); }
::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  background: color-mix(in srgb, var(--accent) 45%, var(--surface)) padding-box;
  box-shadow:
    inset 2px 2px 0 color-mix(in srgb, var(--accent) 85%, white),
    inset -2px -2px 0 color-mix(in srgb, var(--accent) 25%, var(--bg));
}
::-webkit-scrollbar-corner { background: var(--bg); }
::-webkit-scrollbar-button {
  display: block;
  width: 14px;
  height: 14px;
  background: var(--surface) no-repeat center / 10px 6px;
  box-shadow: inset 1px 1px 0 var(--hairline-strong), inset -1px -1px 0 var(--bg);
}
/* Chromium dessine une deuxième paire de boutons à côté de chaque flèche (cases vides) */
::-webkit-scrollbar-button:start:increment,
::-webkit-scrollbar-button:end:decrement { display: none; }
::-webkit-scrollbar-button:horizontal { background-size: 6px 10px; }
::-webkit-scrollbar-button:single-button:vertical:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3' shape-rendering='crispEdges' fill='%23ff7a1a'><path d='M2 0h1v1H2zM1 1h3v1H1zM0 2h5v1H0z'/></svg>");
}
::-webkit-scrollbar-button:single-button:vertical:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3' shape-rendering='crispEdges' fill='%23ff7a1a'><path d='M0 0h5v1H0zM1 1h3v1H1zM2 2h1v1H2z'/></svg>");
}
::-webkit-scrollbar-button:single-button:horizontal:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 5' shape-rendering='crispEdges' fill='%23ff7a1a'><path d='M0 2h1v1H0zM1 1h1v3H1zM2 0h1v5H2z'/></svg>");
}
::-webkit-scrollbar-button:single-button:horizontal:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 5' shape-rendering='crispEdges' fill='%23ff7a1a'><path d='M0 0h1v5H0zM1 1h1v3H1zM2 2h1v1H2z'/></svg>");
}

/* ---------- Champ de pixels animé (canvas#field, dessiné par pixel.js) ---------- */

/* Pas de masque CSS : le champ s'estompe par sa propre trame. */
#field {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 440px;
  image-rendering: pixelated;
  opacity: .7;
}

/* ---------- Mise en page ---------- */

.ilph-wrap {
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
}

.ilph-hero { padding-block: clamp(3.5rem, 12vh, 7rem) 3rem; }

.ilph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  align-content: start; /* sinon une rangée seule s'étire sur toute la hauteur */
  gap: 1rem;
}

.ilph-section { margin-top: 2.5rem; animation: ilph-rise .7s .1s ease-out both; }

.ilph-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-block: 1rem 3rem;
  border-top: 1px solid var(--hairline);
  font-size: .75rem;
  color: var(--muted);
}
.ilph-footer .ilph-label { letter-spacing: .1em; }
.ilph-footer .keys kbd { margin-left: .8rem; margin-right: .2rem; }
@media (max-width: 560px) { .ilph-footer .keys { display: none; } }

/* ---------- Typographie ---------- */

/* Silkscreen : étiquettes courtes en majuscules et titres seulement, jamais de texte long,
   de tableau ou de chiffres à lire. Pas de grec ni de cyrillique : mettre ces caractères
   dans un <span class="ilph-mono">. */
.ilph-label {
  font-family: var(--font-pixel);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.ilph-mono { font-family: var(--font-mono); text-transform: none; letter-spacing: normal; }

.ilph-eyebrow {
  font-family: var(--font-pixel);
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--highlight);
}
.ilph-eyebrow .bracket, .ilph-eyebrow .sep { color: var(--muted); }

.ilph-title {
  margin: .6rem 0 .4rem;
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: clamp(1.6rem, 7.5vw, 5.5rem);
  line-height: .95;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  color: var(--text);
  text-shadow: 0 0 28px color-mix(in srgb, var(--accent) 45%, transparent);
}

.ilph-title.is-small { margin-top: 0; font-size: clamp(1.3rem, 5vw, 2.4rem); }

.ilph-tagline { margin: 0; max-width: 60ch; color: var(--muted); }

/* « // SECTION [03] ────── » : le filet file jusqu'au bord. Les contrôles placés dans le
   titre (.ilph-actions) passent après le filet au lieu de se retrouver dessous. */
.ilph-section-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: .8rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}
.ilph-section-title::before { content: "//"; margin-right: -.4rem; }
.ilph-section-title::after { content: ""; order: 1; flex: 1; height: 1px; background: var(--hairline); }
.ilph-section-title .n { color: var(--muted); }
.ilph-section-title .ilph-actions { order: 2; display: flex; gap: .5rem; letter-spacing: .08em; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 .35em;
  border: 1px solid var(--hairline-strong);
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
}

a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: var(--highlight); }

/* Texte posé sur un fond animé ou tramé : toujours sur une plaque opaque à lui.
   Une couleur plus claire ou un halo ne suffisent pas, une crête claire finit par passer derrière. */
.ilph-plate {
  display: inline-block;
  padding: .32rem .5rem;
  border: 1px solid var(--hairline-strong);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  font-family: var(--font-pixel);
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text);
}

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

/* ---------- Cartes et panneaux à coins en équerre ---------- */

.ilph-card, .ilph-panel {
  --corner: var(--hairline-strong);
  position: relative;
  border: 1px solid var(--hairline);
  background: var(--surface);
}
.ilph-card::before, .ilph-card::after,
.ilph-panel::before, .ilph-panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--corner);
  pointer-events: none;
  transition: border-color .2s;
}
.ilph-card::before, .ilph-panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.ilph-card::after, .ilph-panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.ilph-panel { padding: 1.2rem 1.3rem; }

.ilph-card {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1rem 1.1rem;
  color: inherit;
  text-decoration: none;
  outline: none;
  transition: border-color .2s, transform .2s, background-color .2s, box-shadow .2s;
}
/* Survol : la carte monte sur une ombre dure et se remplit de damier */
a.ilph-card:hover, a.ilph-card:focus-visible,
.ilph-card.is-interactive:hover, .ilph-card:focus-within {
  --corner: var(--highlight);
  border-color: var(--hairline-strong);
  transform: translate(-2px, -2px);
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--accent) 12%, transparent) 0% 25%, transparent 0% 50%) 0 0 / 3px 3px,
    var(--surface);
  box-shadow: 4px 4px 0 var(--accent);
}
a.ilph-card:hover { color: inherit; }

.ilph-card-top, .ilph-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ilph-card-foot { padding-top: .8rem; border-top: 1px dashed var(--hairline); letter-spacing: 0; text-transform: none; }
.ilph-card .idx { font-family: var(--font-pixel); color: var(--accent); }
.ilph-card-body { display: flex; align-items: center; gap: 1rem; }
.ilph-card .name {
  font-family: var(--font-pixel);
  font-size: 1.15rem;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  transition: color .2s;
}
.ilph-card .desc { margin-top: .3rem; font-size: .85rem; color: var(--muted); }
.ilph-card .arrow { font-size: 1rem; color: var(--accent); transition: transform .2s; }
a.ilph-card:hover .name, a.ilph-card:focus-visible .name { color: var(--highlight); }
a.ilph-card:hover .arrow, a.ilph-card:focus-visible .arrow { transform: translate(3px, -3px); }

/* Popups, menus, infobulles : ombre dure décalée, jamais de flou */
.ilph-popup {
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--bg) 80%, black);
}

/* ---------- Icône tramée (PIXEL.ditheredIcon) ---------- */

.ilph-icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 1px solid var(--hairline);
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--accent) 8%, transparent) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px,
    var(--bg);
}
.ilph-icon > * {
  grid-area: 1 / 1;
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: opacity .25s;
}
/* Version tramée au repos, vraie couleur au survol de la carte */
.ilph-icon.dithered .icon-orig { opacity: 0; image-rendering: auto; }
:is(a, .is-interactive):is(:hover, :focus-visible) .ilph-icon.dithered .icon-orig { opacity: 1; }
:is(a, .is-interactive):is(:hover, :focus-visible) .ilph-icon.dithered .icon-dither { opacity: 0; }
.ilph-icon.glyph { font-family: var(--font-pixel); font-size: 1.8rem; color: var(--accent); }

/* ---------- Commandes ---------- */

/* Bouton : monte sur une ombre dure au survol */
.ilph-btn {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1rem;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  font-family: var(--font-pixel);
  font-size: .85rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, color .15s;
}
.ilph-btn:hover:not(:disabled), .ilph-btn:focus-visible {
  outline: none;
  color: var(--highlight);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--accent);
}
.ilph-btn:disabled { opacity: .45; cursor: default; }
.ilph-btn.is-small { padding: .3rem .6rem; font-size: .62rem; gap: .4rem; }
.ilph-btn.is-small:hover:not(:disabled) { box-shadow: 3px 3px 0 var(--accent); }
/* Bouton neutre : pour annuler, effacer, revenir */
.ilph-btn.is-quiet { border-color: var(--hairline-strong); background: var(--bg); color: var(--muted); }
.ilph-btn.is-quiet:hover:not(:disabled) { color: var(--text); box-shadow: 4px 4px 0 var(--hairline-strong); }
.ilph-btn kbd { color: inherit; border-color: currentColor; }

/* Champ texte avec l'invite « > » du terminal : <label class="ilph-prompt"><span class="visually-hidden">…</span><input></label> */
.ilph-prompt { position: relative; display: block; max-width: 360px; }
.ilph-prompt::before {
  content: ">";
  position: absolute;
  top: 50%;
  left: .8rem;
  transform: translateY(-50%);
  font-weight: 500;
  color: var(--accent);
  pointer-events: none;
}
.ilph-input, .ilph-select {
  width: 100%;
  padding: .55rem .9rem;
  border: 1px solid var(--hairline-strong);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  font-size: .88rem;
  color: var(--text);
  caret-color: var(--accent);
  transition: border-color .15s, box-shadow .15s;
}
.ilph-prompt .ilph-input { padding-left: 1.8rem; }
.ilph-input::placeholder { color: var(--muted); opacity: .8; }
.ilph-select { width: auto; background: var(--bg); }
.ilph-input:focus, .ilph-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Puces de filtre */
.ilph-chip {
  padding: .28rem .65rem;
  border: 1px solid var(--hairline-strong);
  background: var(--bg);
  font-size: .74rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .12s, color .12s, background-color .12s;
}
.ilph-chip:hover { border-color: var(--accent); color: var(--text); }
.ilph-chip.is-active, .ilph-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 600;
  color: var(--bg);
}

/* Interrupteur LED carrée : <label class="ilph-led"><input type="checkbox"> Texte</label>.
   La couleur se règle avec color: sur le label. */
.ilph-led {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .65rem;
  border: 1px solid currentColor;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}
.ilph-led input {
  appearance: none;
  width: 12px;
  height: 12px;
  min-width: 12px;
  margin: 0;
  border: 1.5px solid currentColor;
  background: transparent;
  cursor: pointer;
}
.ilph-led input:checked { background: currentColor; box-shadow: 0 0 8px currentColor; }
.ilph-led input:focus-visible { outline: 1px solid var(--text); outline-offset: 2px; }

/* Témoin d'état : <span class="ilph-status" data-state="up|down|pending"><i></i> En ligne</span> */
.ilph-status {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ilph-status i { display: inline-block; width: 8px; height: 8px; border: 1px solid currentColor; }
.ilph-status[data-state="pending"] i { animation: ilph-blink 1s steps(2) infinite; }
.ilph-status[data-state="up"] { color: var(--highlight); }
.ilph-status[data-state="up"] i { background: currentColor; box-shadow: 0 0 8px currentColor; }
.ilph-status[data-state="down"] { color: var(--danger); }

/* ---------- Terminal ---------- */

.ilph-term {
  display: grid;
  margin: 1.6rem 0 1.8rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--hairline-strong);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  font-size: .85rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}
/* Le texte final invisible (.ghost) superposé au texte tapé fixe la hauteur dès le départ */
.ilph-term > * { grid-area: 1 / 1; }
.ilph-term .ghost { visibility: hidden; }
.ilph-term .p { color: var(--accent); }
.ilph-term .ok { color: var(--highlight); }
.ilph-term .err { color: var(--danger); }
.ilph-term .hi { color: var(--text); }
.ilph-cursor {
  display: inline-block;
  width: .6em;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: ilph-blink 1s steps(2) infinite;
}

/* Gros texte tramé dans un canvas (voir 404.js) : la hauteur suit les attributs width/height */
.ilph-big { display: block; width: min(100%, 620px); margin: 1.4rem 0 .6rem; image-rendering: pixelated; }

.ilph-narrow { width: min(100%, 620px); }

/* ---------- Mouvement ---------- */

/* Sans opacité : un élément à opacity 0 n'est pas pris en compte pour le LCP */
@keyframes ilph-rise { from { transform: translateY(8px); } }
@keyframes ilph-blink { 50% { opacity: 0; } }

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

@media (max-width: 380px) {
  .ilph-card { padding: .9rem; }
  .ilph-card-body { gap: .8rem; }
  .ilph-icon { width: 56px; height: 56px; }
  .ilph-icon > * { width: 44px; height: 44px; }
  .ilph-card .name { font-size: .95rem; }
}
