/* Groxx Portal — Style 2 "Glance"
 *
 * Apple-Music-vibe, all-white, NO-SCROLL home that fills the viewport
 * (desktop/tablet): a few big image+colour hero cards + the rest as compact
 * image tiles, everything visible at once. Cards open the shared slide-in drawer
 * (reuses portal.js + the data-grx-drawer* contract).
 *
 * This sheet IMPORTS the base portal.css first so the drawer chrome, sub-page
 * components, the defensive reset, tokens, pills and forms keep working
 * unchanged (Style 2 sub-pages inherit Style 1 markup). Everything below is the
 * Style-2 home look + animation polish layered on top.
 */
@import url("portal.css");

/* ── Style-2 tokens ─────────────────────────────────────────────────────── */
.grx-s2 {
  --s2-bg:        #ffffff;
  --s2-ink:       #14151a;
  --s2-ink-soft:  #6b7280;
  --s2-radius:    18px;
  --s2-gap:       clamp(14px, 1.9vw, 26px);
  --s2-ease:      cubic-bezier(.22,.61,.36,1);
}

/* ── No-scroll viewport shell ───────────────────────────────────────────────
   The home occupies the full viewport below the theme header. We measure the
   header via a CSS var the page can't know precisely, so we cap to the viewport
   and let the stage flex; page scroll is suppressed only while this screen is up. */
/* Allow page scroll: the home aims to fit one screen, but if the grid is taller
   than the viewport it must scroll rather than clip (was overflow:hidden, which
   locked the page and trapped content off-screen on shorter viewports). */
body.grx-s2-active { overflow-y: auto; }

.grx-s2 {
  box-sizing: border-box;
  width: 100%;
  /* Aim for one screen MINUS whatever the theme renders above us (header), but
     min-height (not height) so taller content grows and the page scrolls. */
  min-height: calc(100vh - var(--s2-top, 0px));
  max-width: none !important;     /* override base .grx-portal-wrap max-width */
  margin: 0 !important;
  padding: clamp(12px, 1.8vw, 26px);
  display: flex;
  flex-direction: column;
  gap: var(--s2-gap);
  background: var(--s2-bg);
  color: var(--s2-ink);
  font-family: var(--grx-font-body);
  overflow: visible;              /* never clip — overflow scrolls the page */
}
.grx-s2 *, .grx-s2 *::before, .grx-s2 *::after { box-sizing: border-box; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.grx-s2__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.grx-s2__hello { display: block; font-size: clamp(12px, 1vw, 14px); color: var(--s2-ink-soft); letter-spacing: .02em; }
.grx-s2__name  { font-size: clamp(22px, 3vw, 34px); font-weight: 700; line-height: 1.05; color: var(--s2-ink); letter-spacing: -0.02em; }

/* ── Stage: HEIGHT-BOUNDED so everything fits one screen (no scroll). The two
   groups share the available height via flex; a fixed 75px gap separates them.
   Cards are sized by the height their group gets (not by width), so a wide
   screen can't make them tall and push content off-screen. */
.grx-s2__stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.grx-s2group {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grx-s2group--hero  { flex: 1 1 0; }     /* hero shorter — shelf gets more height */
.grx-s2group--shelf { flex: 1.25 1 0; margin-top: 75px; }  /* fixed gap above */

/* Slim section label. */
.grx-s2__label {
  flex: 0 0 auto;
  margin-bottom: 6px;
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--s2-ink-soft);
  padding-left: 2px;
}

/* ── Hero & shelf cards: HEIGHT-DRIVEN with a MAX PROPORTION ─────────────────
   Cards fill the row height; their width = height × aspect-ratio, so they hold a
   proportion and can't go too rectangular. Extra cell width becomes empty space
   (cards align left in their cell). Both grids height-share the stage, so if the
   shelf needs another row the rows get shorter and the hero shrinks with them —
   everything still fits one screen. */
.grx-s2__hero {
  flex: 1 1 auto;
  min-height: 0;
  width: min(60vw, 100%);
  margin-inline: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);   /* one row, height-bounded */
  gap: var(--s2-gap);
  justify-items: start;                 /* cards sit left when capped narrower */
}
.grx-s2card--hero {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 16 / 10;                /* max proportion — not too wide */
}

/* Shelf: auto-fit columns so tiles WRAP to new rows rather than stretching too
   wide. Each row fills the group's height equally (grid-auto-rows:1fr); if tiles
   wrap to an extra row, all rows get shorter and — because the groups height-
   share the stage — the hero shrinks too, so it still fits one screen. */
.grx-s2__shelf {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 13vw, 200px), 1fr));
  grid-auto-rows: 1fr;
  grid-auto-flow: row;
  gap: var(--s2-gap);
  justify-items: start;
}
.grx-s2card--tile {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 16 / 7.5;               /* tiles: wider/shorter than heroes */
}

/* ── Card: image + colour, glossy, dynamic contrast ─────────────────────── */
.grx-s2card {
  position: relative;
  display: block;
  min-height: 0;
  border-radius: var(--s2-radius);
  overflow: hidden;
  text-decoration: none !important;
  background: var(--s2-color, #3d3d3d);
  isolation: isolate;
  transform: translateZ(0);
  transition: transform .26s var(--s2-ease), box-shadow .26s var(--s2-ease);
  box-shadow: 0 1px 2px rgba(16,18,27,.06), 0 10px 30px -12px rgba(16,18,27,.30);
  will-change: transform;
}
.grx-s2card:hover  { transform: translateY(-4px); box-shadow: 0 6px 14px rgba(16,18,27,.10), 0 22px 48px -16px rgba(16,18,27,.40); }
.grx-s2card:active { transform: translateY(-1px) scale(.995); }

/* All menu cards use WHITE text. The base reset `.grx-portal-wrap a { color:
   inherit !important }` (0,1,1) forces the card <a> to the dark body colour, so
   we override with a MORE SPECIFIC scoped selector (0,2,0) + set the children
   explicitly so currentColor resolves to white. */
.grx-portal-wrap .grx-s2card,
.grx-portal-wrap a.grx-s2card,
.grx-portal-wrap .grx-s2card:hover {
  color: #fff !important;
}
.grx-s2card .grx-s2card__title,
.grx-s2card .grx-s2card__count,
.grx-s2card .grx-s2card__icon { color: #fff !important; }

/* Media layer (card image/gradient) + a slow zoom on hover.
   cover · no-repeat · centred — the image fills the card without distortion. */
.grx-s2card__media {
  position: absolute; inset: 0; z-index: 0;
  background-image: var(--s2-image, none);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: var(--s2-color, #3d3d3d);
  /* Punch the photo before tinting — deeper darks, richer colour. */
  filter: contrast(1.18) saturate(1.15) brightness(.96);
  transform: scale(1.02);
  transition: transform .6s var(--s2-ease);
}
.grx-s2card:hover .grx-s2card__media { transform: scale(1.08); }

/* Apple-Music duotone tint: the photo keeps its LIGHTNESS but takes the card's
   hue (--s2-color). 'color' replaces hue/sat; a second 'multiply' pass deepens
   the tint so it reads with more contrast (punchier, like Apple Music).
   --s2-tint dials overall strength (1 = full, 0 = off). */
.grx-s2card__media::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--s2-color, #3d3d3d);
  mix-blend-mode: color;
  opacity: var(--s2-tint, 1);
  pointer-events: none;
}
.grx-s2card__media::before {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background: var(--s2-color, #3d3d3d);
  mix-blend-mode: multiply;
  opacity: calc(var(--s2-tint, 1) * .35);   /* deepen the hue for contrast */
  pointer-events: none;
}

/* Contrast scrim: all cards use white text, so every card gets a dark
   bottom-weighted gradient to keep the title/count legible over any image. */
.grx-s2card__overlay {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.14) 0%, rgba(0,0,0,0) 34%, rgba(0,0,0,.62) 100%);
}

/* Body */
.grx-s2card__body {
  position: relative; z-index: 2;
  height: 100%;
  display: flex; flex-direction: column;
  padding: clamp(12px, 1.4vw, 20px);
}
.grx-s2card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  color: currentColor;
}
.grx-s2card__icon svg { width: 40px; height: 40px; stroke: currentColor; fill: none; stroke-width: 1.75; }
.grx-s2card__title {
  margin-top: auto;
  font-weight: 650;
  font-size: clamp(14px, 1.5vw, 20px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: currentColor !important;
}
/* Compact tiles (Payment Terms … Activity Log): smaller title than the heroes. */
.grx-s2card--tile .grx-s2card__title {
  font-size: clamp(12px, 1.1vw, 15px);
  font-weight: 600;
}

.grx-s2card__count {
  display: block;
  font-family: var(--grx-font-mono);
  font-size: clamp(20px, 2.6vw, 34px);
  font-weight: 700;
  line-height: 1;
  margin-top: 2px;
  color: currentColor;
}
.grx-s2card--tile .grx-s2card__count { display: none; }  /* tiles: title only */

.grx-s2card--soon { pointer-events: none; }
.grx-s2card__soon {
  position: absolute; z-index: 3; top: 10px; right: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,.85); color: #6b7280;
}

/* ── Entrance animation: cards fade-up, staggered ───────────────────────── */
@keyframes grx-s2-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.grx-s2card { opacity: 0; animation: grx-s2-rise .5s var(--s2-ease) forwards; }
.grx-s2__hero  .grx-s2card:nth-child(1) { animation-delay: .02s; }
.grx-s2__hero  .grx-s2card:nth-child(2) { animation-delay: .08s; }
.grx-s2__hero  .grx-s2card:nth-child(3) { animation-delay: .14s; }
.grx-s2__shelf .grx-s2card:nth-child(1) { animation-delay: .16s; }
.grx-s2__shelf .grx-s2card:nth-child(2) { animation-delay: .20s; }
.grx-s2__shelf .grx-s2card:nth-child(3) { animation-delay: .24s; }
.grx-s2__shelf .grx-s2card:nth-child(4) { animation-delay: .28s; }
.grx-s2__shelf .grx-s2card:nth-child(5) { animation-delay: .31s; }
.grx-s2__shelf .grx-s2card:nth-child(6) { animation-delay: .34s; }
.grx-s2__shelf .grx-s2card:nth-child(n+7) { animation-delay: .37s; }

/* ── Drawer polish (Style 2): smoother open + staggered item reveal ──────── */
/* The base drawer animation lives in portal.css; here we add a gentler easing
   and a fade-up stagger for items inside the drawer body (orders/invoices). */
#grx-drawer-panel { transition: transform .34s var(--s2-ease, cubic-bezier(.22,.61,.36,1)); }

@keyframes grx-s2-item { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.grx-drawer__body .grx-order-card,
.grx-drawer__body .grx-rec__section,
.grx-drawer__body .grx-quote,
.grx-drawer__body .grx-table tbody tr {
  animation: grx-s2-item .42s var(--s2-ease) both;
}
.grx-drawer__body .grx-order-card:nth-child(1),
.grx-drawer__body .grx-rec__section:nth-child(1),
.grx-drawer__body .grx-quote:nth-child(1) { animation-delay: .04s; }
.grx-drawer__body .grx-order-card:nth-child(2),
.grx-drawer__body .grx-rec__section:nth-child(2),
.grx-drawer__body .grx-quote:nth-child(2) { animation-delay: .10s; }
.grx-drawer__body .grx-order-card:nth-child(3),
.grx-drawer__body .grx-rec__section:nth-child(3),
.grx-drawer__body .grx-quote:nth-child(3) { animation-delay: .16s; }
.grx-drawer__body .grx-order-card:nth-child(n+4),
.grx-drawer__body .grx-rec__section:nth-child(n+4) { animation-delay: .22s; }
.grx-drawer__body .grx-table tbody tr:nth-child(odd)  { animation-delay: .06s; }
.grx-drawer__body .grx-table tbody tr:nth-child(even) { animation-delay: .12s; }

/* ── Responsive: tablet portrait keeps no-scroll by stacking the hero ────── */
@media (max-width: 900px) {
  .grx-s2__hero { grid-template-columns: repeat(3, 1fr); }
  .grx-s2__stage { grid-template-rows: 1.2fr 1fr; }
}
@media (max-width: 680px) {
  /* Narrow tablets/phones: allow vertical scroll as a graceful fallback so
     content is never clipped on very short viewports. */
  body.grx-s2-active { overflow: auto; }
  .grx-s2 { height: auto; min-height: 100vh; overflow: visible; }
  .grx-s2__stage { display: flex; flex-direction: column; }
  .grx-s2group { flex: 0 0 auto; }                 /* size to content when scrolling */
  .grx-s2__hero  { width: 100%; grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .grx-s2card--hero { aspect-ratio: auto; min-height: 34vw; max-height: none; }
  .grx-s2card--tile { min-height: 22vw; }
}

/* ── Accessibility: honour reduced motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .grx-s2card,
  .grx-drawer__body .grx-order-card,
  .grx-drawer__body .grx-rec__section,
  .grx-drawer__body .grx-quote,
  .grx-drawer__body .grx-table tbody tr { animation: none !important; opacity: 1 !important; transform: none !important; }
  .grx-s2card { transition: none; }
  .grx-s2card:hover { transform: none; }
  .grx-s2card__media, .grx-s2card:hover .grx-s2card__media { transition: none; transform: scale(1.02); }
}
