/*
 * Gallery-first landing layout (the `landing-redesign` flag; see GalleryPage.kt + gallery mode in v2.js).
 * Two regions: a large art GRID (main, left) and a compact CONTROL PANEL (chat + wall color, right).
 * Reuses v2.css for the wall backdrop/--wall vars + lightbox, and style.css for the card internals; this
 * file only owns the two-region shell + its responsive behaviour. Mobile stacks (controls on top).
 */

/* Full-bleed so the control panel hugs the right edge of the screen (not a centred 1440 band) - the
 * gallery grid absorbs the extra width on the left. Side padding keeps content off the very edge. */
.gallery2 {
  padding: 0 1.75rem 3rem;
}

/* Marketing hero band (below the nav): the page's h1 + brand pitch, over a background-image slot. Static -
 * it simply scrolls away with the page. Drop an image at /static/hero-bg.jpg and uncomment background-image
 * below to fill the media layer; a gradient + a wall-tinted scrim stand in until then. */
.gallery-hero-band {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  margin: 1rem 0 1.35rem;
  padding: clamp(2rem, 4.5vw, 3.75rem);
  min-height: 300px;
  display: flex;
  align-items: center;
}
.gallery-hero-media {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, #ece7db 0%, #dfe2e4 52%, #d0d7d3 100%);
  background-size: cover;
  background-position: center;
  /* background-image: url("/static/hero-bg.jpg"); */ /* <- drop in a real image here */
}
/* Legibility scrim, tinted to the current wall color so text stays readable over any image or wall. */
.gallery-hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--wall, #f5f2ec) 90%, transparent) 0%,
    color-mix(in srgb, var(--wall, #f5f2ec) 55%, transparent) 45%,
    color-mix(in srgb, var(--wall, #f5f2ec) 12%, transparent) 100%
  );
}
.gallery-hero-content {
  position: relative;
  z-index: 1;
  max-width: 42ch;
}
.gallery-hero-content .eyebrow {
  display: block;
  margin-bottom: 0.6rem;
}
.gallery-hero-title {
  margin: 0 0 0.7rem;
  max-width: 20ch;
  font-size: clamp(2.1rem, 3.9vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.gallery-hero-sub {
  margin: 0;
  max-width: 52ch;
  font-size: 1.02rem;
  line-height: 1.55;
  opacity: 0.85;
}
.on-dark .gallery-hero-title,
.on-dark .gallery-hero-content .eyebrow {
  color: #f3f0ea;
}
.on-dark .gallery-hero-sub {
  color: #f3f0ea;
  opacity: 0.9;
}

/* Two columns (controls | gallery) x two rows (head | body): the head occupies row 1 of the gallery
 * column only, so the controls - pinned to row 2, col 1 - start level with the gallery grid rather than
 * the page top. */
.gallery2-body {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    ".        head"
    "controls gallery";
  column-gap: 1.75rem;
  align-items: start;
}

/* ---- left: the gallery grid ---- */
.gallery2-grid-head {
  grid-area: head;
  margin: 0.75rem 0 1rem;
}
.gallery2-grid-wrap {
  grid-area: gallery;
}
.gallery2-grid-head .eyebrow {
  display: block;
  margin-bottom: 0.3rem;
}
.gallery2-grid-head .gallery-subhead {
  margin: 0;
  max-width: 62ch;
  font-size: 0.95rem;
  line-height: 1.5;
  opacity: 0.85;
}

/* Auto-fill so the grid fills the wide main column and reflows fluidly (more art visible = "art faster"). */
.gallery2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}
/* A light skeleton height while the seed loads so the layout doesn't jump. */
.gallery2-grid:empty {
  min-height: 60vh;
  border-radius: 12px;
  background:
    linear-gradient(100deg, transparent 30%, rgba(0, 0, 0, 0.04) 50%, transparent 70%),
    rgba(0, 0, 0, 0.02);
  background-size: 200% 100%;
  animation: gallery-shimmer 1.4s infinite;
}
@keyframes gallery-shimmer { to { background-position: -200% 0; } }

/* Dock the control panel to the right instead of the left (toggled by dragging it; see v2.js). Gated to
 * desktop so its higher specificity can't override the mobile stacked layout below. */
@media (min-width: 821px) {
  .gallery2-body.controls-right {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas:
      "head    ."
      "gallery controls";
  }
}

/* The panel's header bar (Discovery label + saved count) doubles as the drag handle - grab it to move the
 * panel between sides. Keeps the header's own layout; we only add the grab affordance + a subtle hover so
 * it reads as draggable, with no extra chrome. */
.panel-drag-handle {
  cursor: grab;
  user-select: none;
  touch-action: none;
  border-radius: 8px;
  padding: 0.3rem 0.4rem;
  margin: -0.3rem -0.4rem 0.6rem; /* cancel the padding so the label/pill don't shift; keep header spacing */
  transition: background 0.12s ease;
}
.panel-drag-handle:hover {
  background: rgba(0, 0, 0, 0.05);
}
.gallery2-controls.is-dragging .panel-drag-handle {
  cursor: grabbing;
}

/* While dragging: lift the panel above the gallery and follow the cursor (transform set in v2.js). */
.gallery2-controls.is-dragging {
  cursor: grabbing;
  z-index: 60;
  opacity: 0.96;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.24);
  border-radius: 12px;
}

/* Invisible tripwire below the grid: when it scrolls near the viewport, v2.js reveals the next batch. */
.gallery-sentinel {
  width: 100%;
  height: 1px;
}

/* "Working" state shown in the grid while a room analysis + color search run (see showGalleryLoading). */
.gallery-loading {
  grid-column: 1 / -1;
  padding: 3.5rem 1rem;
  text-align: center;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  animation: gallery-pulse 1.3s ease-in-out infinite;
}
@keyframes gallery-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.85; }
}

.on-dark .panel-drag-handle:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ---- right: the control panel (chat + wall color) ---- */
.gallery2-controls {
  grid-area: controls;
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 2rem);
}
/* Chat fills most of the column; its message list scrolls internally rather than growing the page. */
.gallery2-controls .gallery-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.gallery2-controls .gallery-chat .chat-messages {
  overflow-y: auto;
  min-height: 180px;
}
/* The wall-color controls sit below the chat as a compact block. */
.gallery2-wall {
  flex: 0 0 auto;
}

/* Dark-wall legibility for the grid header (v2.css handles the panels/chrome). */
.on-dark .gallery2-grid-head .gallery-subhead,
.on-dark .gallery2-grid-head .eyebrow {
  color: #f3f0ea;
  opacity: 0.92;
}

/* ---- responsive: stack, controls on top, gallery below ---- */
@media (max-width: 820px) {
  /* Stack: controls (chat + colors) first so they're reachable, then the header, then the gallery. */
  .gallery2-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "controls"
      "head"
      "gallery";
    row-gap: 1.25rem;
    column-gap: 0;
  }
  .gallery2-controls {
    position: static;
    max-height: none;
  }
  /* Stacked layout has no side to dock to: keep the header (Discovery + saved) but drop the grab affordance. */
  .panel-drag-handle {
    cursor: default;
  }
  .panel-drag-handle:hover {
    background: none;
  }
  .gallery2-controls .gallery-chat .chat-messages {
    max-height: 42vh;
  }
  .gallery2-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
@media (max-width: 440px) {
  .gallery2-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
