/* ============================================================
   home-grid.css — "Catalog grid" home paradigm.
   A dense, browsable grid of RECTANGULAR rounded cards for retail,
   grocery and large menus. Scoped to `.home-grid` (root class set by
   renderer/home-grid.js); landscape rules under `.stage.landscape .home-grid`.
   Colours ONLY via the shared branding vars (--bg/--ink/--accent/
   --accent-strong/--accent-soft/--border) plus the fixed internal
   tokens already declared in styles.css (--surface/--radius-card/…).
   ============================================================ */

.home-grid {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Tighter than the circular home's big centred title — the catalog below is the
   focus. (.home-title base styling comes from styles.css.) */
.home-grid .home-title {
  margin: 20px 0 22px;
}

/* ---------- The reflowing card grid ----------
   auto-fill + minmax means ANY tile count reflows with no code change:
   ~3 columns on the 1080-wide portrait canvas. */
.home-grid .grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px 28px;
  align-content: start;
  padding: 2px 2px 18px;
}

/* ---------- One catalog card ---------- */
.home-grid .grid-card {
  /* Native <button> chrome reset — done in CSS so the JS writes no inline
     styles at all (colour stays entirely on the tokens below). */
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;

  /* The only colours: fixed white surface + branding ink, both from tokens. */
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-card);

  min-height: 212px;              /* generous, touch-first tap target (>=120px) */
  padding: 28px 22px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  position: relative;
  overflow: hidden;               /* clip the ripple to the rounded card */
  transition: transform 0.14s ease;
  animation: grid-card-in 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) backwards;
}
.home-grid .grid-card:active { transform: scale(0.96); }

/* Short staggered reveal for the first cards (neutralised by the global
   prefers-reduced-motion rule in styles.css). */
.home-grid .grid-cards .grid-card:nth-child(1)  { animation-delay: 0.02s; }
.home-grid .grid-cards .grid-card:nth-child(2)  { animation-delay: 0.05s; }
.home-grid .grid-cards .grid-card:nth-child(3)  { animation-delay: 0.08s; }
.home-grid .grid-cards .grid-card:nth-child(4)  { animation-delay: 0.11s; }
.home-grid .grid-cards .grid-card:nth-child(5)  { animation-delay: 0.14s; }
.home-grid .grid-cards .grid-card:nth-child(6)  { animation-delay: 0.17s; }
.home-grid .grid-cards .grid-card:nth-child(7)  { animation-delay: 0.20s; }
.home-grid .grid-cards .grid-card:nth-child(8)  { animation-delay: 0.23s; }
.home-grid .grid-cards .grid-card:nth-child(9)  { animation-delay: 0.26s; }
.home-grid .grid-cards .grid-card:nth-child(10) { animation-delay: 0.29s; }
.home-grid .grid-cards .grid-card:nth-child(11) { animation-delay: 0.32s; }
.home-grid .grid-cards .grid-card:nth-child(12) { animation-delay: 0.35s; }

@keyframes grid-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* The icon sits on a soft branded tint chip — the one branding accent that
   gives the catalog card its character (colour stays on --accent-soft). */
.home-grid .grid-card-icon {
  flex: 0 0 auto;
  width: 128px;
  height: 128px;
  padding: 20px;
  border-radius: 26px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-grid .grid-card-icon svg { width: 100%; height: 100%; display: block; }

.home-grid .grid-card-label {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0.5px;
  white-space: pre-line;          /* honour \n in labels (set via textContent) */
  /* Wrap at word boundaries, hyphenate as the fallback. `anywhere` chopped
     single-word labels one letter short ("Løsninge / r") the moment a label
     was a few px wider than the column — a broken word is worse than a
     hyphenated or slightly tight one. */
  overflow-wrap: break-word;
  hyphens: auto;
  text-wrap: balance;
}

/* ---------- Empty Layout ---------- */
.home-grid .grid-empty {
  margin: auto;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 40px;
  color: var(--ink);
  opacity: 0.7;
}

/* ============================================================
   Landscape (1920×1080) — main.js adds `.landscape` on #stage.
   More columns, shorter cards, and each card reshapes to
   icon-left / label-right so the wide canvas reads well.
   ============================================================ */

.stage.landscape .home-grid .home-title { margin: 12px 0 16px; }

.stage.landscape .home-grid .grid-cards {
  /* 400px min (4 columns on the 1920 canvas, was 5): the icon-left/label-right
     card leaves the label only ~(col − 56px padding − 108px icon − 26px gap),
     and at 320px min that was ~150px — too narrow for ordinary single-word
     Norwegian labels ("Løsninger", "Næringsliv") at the 32px display weight. */
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 26px 24px;
}

.stage.landscape .home-grid .grid-card {
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  min-height: 150px;
  padding: 22px 28px;
  gap: 26px;
}

.stage.landscape .home-grid .grid-card-icon {
  width: 108px;
  height: 108px;
  padding: 16px;
  border-radius: 22px;
}

.stage.landscape .home-grid .grid-card-label {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-size: 32px;
}
