/*
 * Page Outils de tetr4.ch : vitrine des outils web de Tétr4 (EZsit, Atl4s et les suivants).
 * Charte reprise d'EZsit 2.0 et d'Atl4s (src/app/globals.css) : papier à peine verdi, encre noire,
 * bleu-vert Tétr4 (#64ab9d), Space Grotesk pour les titres, Inter pour le texte, JetBrains Mono
 * pour les chiffres et les étiquettes. Clair par défaut, sombre sur demande ou selon le système
 * (html[data-theme="dark"], posé avant l'affichage par page-outils.php).
 * Tout est préfixé « ot- » : la page n'emploie aucun style de Divi.
 */

@font-face {
  font-family: "OT Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "OT Display";
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: "OT Mono";
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}

:root {
  --paper: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f9fbfa;
  --ink: #0a0c0b;
  --ink-2: #414946;
  --ink-3: #5b6461;
  --line: #e1e6e4;
  --line-2: #cfd6d3;
  --accent: #2e6b5f;
  --accent-soft: #e3efec;
  --highlight: #cde6e0;
  --brand: #64ab9d;
  --cta: #367a6d;
  --shadow-float: 0 24px 60px -32px rgba(0, 0, 0, 0.3);

  /* Fonds animés (outils.js) : couleurs en composantes RVB et intensité */
  --contour-rgb: 46, 107, 95;
  --contour-gain: 1.25;
  --ink-rgb: 10, 12, 11;
  --accent-rgb: 46, 107, 95;
  --paper-rgb: 244, 246, 245;
  --field-gain: 1.2;

  --font-sans: "OT Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "OT Display", var(--font-sans);
  --font-mono: "OT Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 4vw, 48px);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #000000;
  --surface: #0d1110;
  --surface-2: #080b0a;
  --ink: #eef1f0;
  --ink-2: #b0b9b6;
  --ink-3: #8a9491;
  --line: #1c2422;
  --line-2: #2b3533;
  --accent: #64ab9d;
  --accent-soft: #16201e;
  --highlight: #1f3f38;
  --shadow-float: 0 30px 70px -30px rgba(0, 0, 0, 0.95);

  --contour-rgb: 100, 171, 157;
  --contour-gain: 1;
  --ink-rgb: 238, 241, 240;
  --accent-rgb: 100, 171, 157;
  --paper-rgb: 13, 17, 16;
  --field-gain: 0.85;
}

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body.ot-page {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

/* Remise à zéro sans poids (:where), pour que les classes de la page l'emportent toujours */
:where(.ot) :where(h1, h2, h3, p, ul) {
  margin: 0;
  padding: 0;
}
:where(.ot) ul {
  list-style: none;
}
:where(.ot) a {
  color: inherit;
  text-decoration: none;
}
.ot ::selection {
  background: var(--highlight);
}
.ot :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ */
/* Scène d'accueil : bandeau, titre, relief en courbes de niveau        */
/* ------------------------------------------------------------------ */

.ot-stage {
  position: relative;
  isolation: isolate;
  min-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
}

.ot-stage-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
  /* Le relief s'efface vers le catalogue */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 62%, transparent 100%);
}

.ot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px var(--gutter);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.ot-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.ot-logo {
  width: 30px;
  height: 30px;
  transition: transform 0.4s var(--ease-out);
}
.ot-brand:hover .ot-logo {
  transform: rotate(-6deg) scale(1.06);
}
.ot-logo-ink {
  fill: var(--ink);
}
.ot-logo-brand {
  fill: var(--brand);
}

.ot-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.ot-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.ot-nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.ot-theme {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 6px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.3s var(--ease-out);
}
.ot-theme:hover {
  color: var(--ink);
  border-color: var(--accent);
  transform: rotate(-20deg);
}
.ot-theme svg {
  grid-area: 1 / 1;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.25s, transform 0.4s var(--ease-out);
}
.ot-moon {
  opacity: 0;
  transform: rotate(-60deg) scale(0.6);
}
html[data-theme="dark"] .ot-sun {
  opacity: 0;
  transform: rotate(60deg) scale(0.6);
}
html[data-theme="dark"] .ot-moon {
  opacity: 1;
  transform: none;
}

.ot-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(40px, 8vh, 96px) var(--gutter) clamp(72px, 12vh, 140px);
  /* Clairière : le relief s'estompe derrière le texte */
  background: radial-gradient(ellipse 52% 60% at 22% 52%, color-mix(in srgb, var(--paper) 78%, transparent) 0%, transparent 100%);
}

.ot-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.ot-hero h1 {
  margin-top: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 8.2vw, 112px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  max-width: 13ch;
}
.ot-hero h1 em {
  font-style: normal;
  color: var(--accent);
  position: relative;
  white-space: nowrap;
}
/* Trait de crayon sous « terrain », tracé à l'ouverture */
.ot-hero h1 em::after {
  content: "";
  position: absolute;
  left: 0.02em;
  right: 0.02em;
  bottom: 0.02em;
  height: 0.07em;
  border-radius: 99px;
  background: var(--brand);
  transform-origin: left;
  animation: ot-underline 1.1s 0.65s var(--ease-out) both;
}
@keyframes ot-underline {
  from {
    transform: scaleX(0);
  }
}

.ot-lead {
  margin-top: 26px;
  max-width: 56ch;
  font-size: clamp(15.5px, 1.35vw, 18px);
  line-height: 1.6;
  color: var(--ink-2);
}

.ot-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 34px;
  font-size: 13px;
  color: var(--ink-3);
}
.ot-facts li {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.ot-facts b {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
}

/* Entrée en fondu, élément par élément (--d : rang) */
.ot-in {
  animation: ot-enter 0.9s calc(var(--d, 0) * 0.09s + 0.05s) var(--ease-out) both;
}
@keyframes ot-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* ------------------------------------------------------------------ */
/* Catalogue                                                           */
/* ------------------------------------------------------------------ */

.ot-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(64px, 10vh, 120px);
}

.ot-section-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}
.ot-section-head h2,
.ot-count {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ot-section-head h2 {
  color: var(--ink);
}
.ot-count {
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: none;
}
.ot-rule {
  flex: 1;
  height: 1px;
  background: var(--line-2);
}

/* Deux colonnes ; une fiche « en préparation » occupe toute la largeur */
.ot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
}

.ot-card {
  --mx: 50%;
  --my: 30%;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  transition:
    transform 0.5s var(--ease-out),
    border-color 0.3s,
    box-shadow 0.5s var(--ease-out);
}
/* Halo qui suit le curseur */
.ot-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx) var(--my), rgba(var(--accent-rgb), 0.09), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
}
a.ot-card:hover {
  transform: translateY(-6px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-float);
}
a.ot-card:hover::before {
  opacity: 1;
}

.ot-visual {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 50% 40%, var(--surface-2), transparent),
    color-mix(in srgb, var(--paper) 55%, var(--surface));
  border-bottom: 1px solid var(--line);
}
.ot-visual canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 1.2s var(--ease-out);
}
a.ot-card:hover .ot-visual canvas {
  transform: scale(1.025);
}
.ot-visual-tag {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.ot-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: clamp(22px, 2.4vw, 32px);
}

.ot-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.ot-num {
  color: var(--ink-3);
  letter-spacing: 0.08em;
}

.ot-word {
  margin-top: 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 4.6vw, 60px);
  line-height: 1;
  letter-spacing: -0.03em;
}
.ot-word span {
  color: var(--accent);
}

.ot-tagline {
  margin-top: 12px;
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
}
.ot-desc {
  margin-top: 10px;
  max-width: 52ch;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.ot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 20px;
}
.ot-tags li {
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
}

.ot-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 26px;
}
.ot-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px 11px 18px;
  border-radius: 12px;
  background: var(--cta);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.25s, gap 0.35s var(--ease-out);
}
.ot-cta svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s var(--ease-out);
}
a.ot-card:hover .ot-cta {
  gap: 12px;
  background: var(--accent);
}
html[data-theme="dark"] a.ot-card:hover .ot-cta {
  color: #000;
}
a.ot-card:hover .ot-cta svg {
  transform: translate(2px, -2px);
}
.ot-url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

/* Fiche « en préparation » : bandeau sur toute la largeur, épure qui se dessine */
.ot-card--soon {
  grid-column: 1 / -1;
  flex-direction: row;
  border-style: dashed;
  border-color: var(--line-2);
  background: transparent;
}
.ot-card--soon .ot-visual {
  flex: 0 0 min(38%, 420px);
  aspect-ratio: auto;
  min-height: 210px;
  border-bottom: 0;
  border-right: 1px dashed var(--line-2);
  background: transparent;
}
.ot-card--soon .ot-card-body {
  justify-content: center;
}
.ot-word--soon {
  font-size: clamp(30px, 3.2vw, 40px);
  color: var(--ink-2);
}
.ot-caret {
  display: inline-block;
  width: 0.08em;
  height: 0.82em;
  margin-left: 0.12em;
  vertical-align: -0.06em;
  background: var(--brand);
  animation: ot-blink 1.1s steps(1) infinite;
}
@keyframes ot-blink {
  50% {
    opacity: 0;
  }
}

.ot-draft {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ot-draft-grid path {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.ot-draft-lines path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: ot-draw 7s calc(var(--i) * 0.7s) var(--ease-out) infinite;
}
.ot-draft-lines .ot-draft-dim {
  stroke: var(--ink-3);
  stroke-width: 0.9;
}
@keyframes ot-draw {
  0% {
    stroke-dashoffset: 1;
    opacity: 1;
  }
  30%,
  78% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  92%,
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}
.ot-draft-cursor {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1;
  animation: ot-cursor 7s var(--ease-out) infinite;
}
@keyframes ot-cursor {
  0% {
    transform: translate(-128px, 0);
  }
  14% {
    transform: translate(-64px, 32px);
  }
  28% {
    transform: translate(0, 0);
  }
  44% {
    transform: translate(-64px, -80px);
  }
  60% {
    transform: translate(-96px, -48px);
  }
  78%,
  100% {
    transform: translate(0, 0);
  }
}

/* Apparition des fiches au défilement (classe posée par outils.js) */
.ot-js .ot-card {
  opacity: 0;
  translate: 0 22px;
  transition:
    opacity 0.9s var(--ease-out),
    translate 0.9s var(--ease-out),
    transform 0.5s var(--ease-out),
    border-color 0.3s,
    box-shadow 0.5s var(--ease-out);
}
.ot-js .ot-card.is-seen {
  opacity: 1;
  translate: 0 0;
}

/* ------------------------------------------------------------------ */
/* Pied de page                                                        */
/* ------------------------------------------------------------------ */

.ot-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px var(--gutter) 34px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-3);
}
.ot-foot div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.ot-foot b {
  color: var(--ink);
  font-weight: 600;
}
.ot-foot nav {
  display: flex;
  gap: 20px;
}
.ot-foot a:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Petits écrans et mouvement réduit                                   */
/* ------------------------------------------------------------------ */

@media (max-width: 860px) {
  .ot-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ot-card--soon {
    flex-direction: column;
  }
  .ot-card--soon .ot-visual {
    flex: none;
    min-height: 180px;
    border-right: 0;
    border-bottom: 1px dashed var(--line-2);
  }
}

@media (max-width: 560px) {
  .ot-stage {
    min-height: 0;
  }
  .ot-nav a {
    display: none;
  }
  /* « Des outils pour / lire le terrain. » plutôt qu'un « lire » orphelin */
  .ot-hero h1 br {
    display: none;
  }
  .ot-section-head {
    flex-wrap: wrap;
    gap: 8px 14px;
  }
  .ot-rule {
    display: none;
  }
  .ot-card-foot {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .ot *,
  .ot *::before,
  .ot *::after {
    animation: none !important;
    transition: none !important;
  }
  .ot-js .ot-card {
    opacity: 1;
    translate: none;
  }
  .ot-draft-lines path {
    stroke-dashoffset: 0;
  }
}
