/* =====================================================================
   INFOSOLUTION - Portail de sélection de solutions
   Grille adaptative "plein écran" (façon Netflix)
   ===================================================================== */

:root {
  --bg-color: #f4f6f5;
  --text-color: #1c1c1c;
  --header-bg: #ffffff;
  --card-border-w: 2px;
  --card-radius: 14px;
  --card-border-color: #e2e5e4;
  --gap: 14px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- HEADER ---------- */
.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(10px, 3vw, 28px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.topbar .logo-wrap {
  display: flex;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.topbar .logo-wrap img {
  height: clamp(24px, 5.5vh, 40px);
  width: auto;
  max-width: 42vw;
  object-fit: contain;
  display: block;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2.5vw, 26px);
  flex-shrink: 0;
}

.topbar nav a {
  color: var(--text-color);
  text-decoration: none;
  font-size: clamp(0.72rem, 1.8vh, 0.95rem);
  font-weight: 600;
  opacity: 0.85;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.topbar nav a:hover,
.topbar nav a:focus-visible {
  opacity: 1;
  text-decoration: underline;
}

/* ---------- MAIN / STAGE ---------- */
.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 1.4vh, 16px) clamp(8px, 2vw, 22px);
  min-height: 0;
  width: 100%;
}

.grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: var(--gap);
  align-content: center;
  justify-content: stretch;
}

/* Quand JS n'a pas encore calculé la grille (avant hydration / no-js) :
   grille de secours, simple et responsive, qui scrolle si besoin. */
.grid.grid--fallback {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: minmax(130px, auto);
  height: auto;
  overflow: visible;
}

.stage.stage--scroll {
  align-items: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- CASES : SECTION ---------- */
.card-section {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 clamp(10px, 1.6vw, 20px);
  border-radius: calc(var(--card-radius) * 0.6);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: clamp(0.62rem, calc(var(--section-h, 40px) * 0.32), 0.95rem);
  overflow: hidden;
  min-height: 0;
}

.card-section span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
}

/* ---------- CASES : SOLUTION ---------- */
.card-solution {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(var(--row-h, 140px) * 0.045);
  padding: calc(var(--row-h, 140px) * 0.09) calc(var(--col-w, 220px) * 0.075);
  border-radius: var(--card-radius);
  border: var(--card-border-w) solid var(--card-border-color);
  text-decoration: none;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
}

.card-solution.no-border {
  border-color: transparent;
}

.card-solution:hover,
.card-solution:focus-visible {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  filter: brightness(1.04);
  z-index: 2;
  outline: none;
}

.card-solution:active {
  transform: translateY(-1px) scale(1.0);
}

.card-solution .app-name {
  font-weight: 800;
  line-height: 1.15;
  font-size: clamp(0.72rem, calc(var(--row-h, 140px) * 0.155), 1.4rem);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-solution .app-desc {
  font-weight: 400;
  opacity: 0.92;
  font-size: clamp(0.58rem, calc(var(--row-h, 140px) * 0.088), 0.85rem);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card-solution .app-arrow {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1rem;
  opacity: 0.55;
}

.card-solution .app-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.32;
}

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px 20px;
  opacity: 0.7;
}

/* ---------- Print / very small fallback safety ---------- */
@media (max-width: 260px) {
  .topbar nav a:nth-child(n+3) { display: none; }
}
