/**
 * Product gallery (index.html) — Ocean Calm layer.
 *
 * Loads after the page's own inline <style>, so it only needs to state what it
 * changes. Consumes assets/css/tokens.css; every colour, space and radius here
 * is a token. Nothing in this file may carry a literal size or spacing value.
 *
 * Scope so far: the header, the breadcrumb bar, the product nav and the fixed
 * "Design your own setup" call to action. The rest of the gallery's colour is
 * restyled separately.
 */

:root {
  /* Fixed chrome dimensions, not vertical rhythm, so both are literals by
     intent rather than spacing tokens. --gallery-header-h restates the page's
     own header height; main is sized as the viewport minus it, and the two
     have to stay in step. --gallery-cta-bar-h is the height of the call to
     action once it becomes a full-width bar below 1000px; main subtracts that
     too, so the bar never covers the preview. --gallery-crumbs-h is the
     breadcrumb bar, subtracted the same way. */
  --gallery-header-h: 74px;
  --gallery-crumbs-h: 40px;
  /* One row of the bar. The bar is a single row wherever both calls to action
     fit on a line, and two rows below 600px, where they do not. */
  --gallery-cta-row-h: 56px;
  --gallery-cta-bar-h: var(--gallery-cta-row-h);
}

@media (max-width: 600px) {
  :root {
    --gallery-cta-bar-h: calc(var(--gallery-cta-row-h) * 2);
  }

  /* With the buy button hidden only one row is left to make room for. */
  :root:has(#gallery-buy[hidden]) {
    --gallery-cta-bar-h: var(--gallery-cta-row-h);
  }
}

/* The header and the breadcrumb bar share one inline gutter so the logo, the
   crumb trail and the back link all sit on the same two edges. */
header {
  gap: var(--space-s);
  padding-inline: var(--space-s);
}

/* === HEADER ===
   Was: <h1>catnip <small> / Product gallery</small></h1>, a plain-text
   wordmark with the page label welded to it. The label never sat right against
   the logo's optical centre, so it has moved to the breadcrumb bar below and
   the header is now just the logo and the way back to the store.

   Source order is logo, product picker, back link. The picker only shows below
   720px, so desktop reads logo | back link and mobile reads logo | picker |
   back link, which is the order they should appear in. */
.gallery-home {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

/* 40px matches the store header exactly (theme components.css, a.wordmark img).
   A logo height is a fixed component dimension like the header's own 74px, not
   vertical rhythm, so it is a literal by intent and not a spacing token. */
.gallery-home img {
  display: block;
  height: 40px;
  width: auto;
}

.gallery-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--deep-ocean);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out);
}

.gallery-back:hover {
  background: var(--pebble);
  text-decoration: underline;
}

.gallery-home:focus-visible,
.gallery-back:focus-visible {
  outline: 2px solid var(--deep-ocean);
  outline-offset: 3px;
}

/* === BREADCRUMB BAR ===
   The current crumb is the page's h1, so the page has exactly one heading and
   the label is not written twice for a screen reader. It is styled down to the
   breadcrumb scale rather than the h1 scale type.css gives it. */
.crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  height: var(--gallery-crumbs-h);
  padding-inline: var(--space-s);
  background: var(--white);
  border-bottom: 1px solid var(--hairline);
}

.crumbs__link,
.crumbs__sep,
.crumbs__current {
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
}

.crumbs__link {
  color: var(--deep-ocean);
  text-decoration: none;
}

.crumbs__link:hover {
  text-decoration: underline;
}

.crumbs__link:focus-visible {
  outline: 2px solid var(--deep-ocean);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.crumbs__sep {
  color: var(--graphite);
}

.crumbs__current {
  font-weight: 600;
  color: var(--charcoal);
}

main {
  height: calc(100dvh - var(--gallery-header-h) - var(--gallery-crumbs-h));
}

/* === PRODUCT NAV ===
   Once the buttons took Plus Jakarta Sans 700 at the site's button size, the
   group headings — previously bold 14px against regular 16px buttons — became
   indistinguishable from them. They take the store's palette-group eyebrow
   instead, which restores the hierarchy at a glance.

   The headings used to carry `margin: 20px 12px 6px`, three sibling margins on
   a child. Each group is now its own flex column, so the distance from a
   heading to its buttons is that group's gap and the distance between groups
   is the product nav's own gap. No child in here has a margin. */
.product-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

/* The buttons sit flush, as they did before the restyle, so only the heading is
   separated from them. That is the group's own gap; this nested column carries
   none. */
.nav-group__items {
  display: flex;
  flex-direction: column;
}

.nav-group__title {
  padding-inline: var(--space-2xs);
  font-family: var(--font-body);
  font-size: var(--text-eyebrow);
  font-weight: 700;
  letter-spacing: 1.2px;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--graphite);
}

.product-nav button {
  min-height: 44px;
  padding: var(--space-2xs);
  border-radius: var(--radius-sm);
}

/* The product nav collapses to the header <select> below 720px. This rule used
   to live in the page's own <style>, but a bare `nav` selector in a later
   stylesheet beat the page's `display: none` on source order and the nav
   stopped hiding. It is scoped and owned here now. The breadcrumb bar is also
   a <nav>, which is why none of these rules may be left unscoped. */
@media (max-width: 720px) {
  .product-nav {
    display: none;
  }
}

/* === FIXED CALL TO ACTION ===
   Was an inline style on the anchor: position:fixed; bottom:16px; left:16px;
   z-index:1000; background:#24566b; color:white; padding:12px 18px;
   border-radius:8px; text-decoration:none.

   Moved to the lower RIGHT on desktop; below 1000px it becomes a bottom bar
   (see the media query). #24566b was a near miss of Deep Ocean and is now the
   token. Terracotta is the site's CTA colour but white on it is only 3.25:1,
   so this takes Deep Ocean rather than inheriting that debt: white on
   --deep-ocean is 7.17:1, and 9.20:1 on the hover shade. Everything else is
   the site's button scale from --btn-*, plus a 44px minimum touch target. */
/* Two calls to action now, so the fixed positioning belongs to the pair rather
   than to either button. Order is secondary then primary, which puts Proceed
   to Checkout nearest the corner — the reading order ends on the one that
   completes the job. */
.gallery-actions {
  position: fixed;
  right: var(--space-s);
  bottom: var(--space-s);
  z-index: 1000;
  display: flex;
  gap: var(--space-2xs);
}

.gallery-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 44px;
  padding: var(--btn-padding-block) var(--btn-padding-inline);
  border-radius: var(--btn-radius);
  background: var(--deep-ocean);
  color: var(--white);
  box-shadow: var(--shadow-md);
  font-family: var(--font-heading);
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  letter-spacing: var(--btn-letter-spacing);
  text-transform: var(--btn-text-transform);
  text-decoration: none;
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}

/* display: inline-flex above beats the hidden attribute, so restate it. The
   buy button stays hidden while ordering is off in catnip-store.js. */
.gallery-cta[hidden] {
  display: none;
}

.gallery-cta:hover {
  background: var(--deep-ocean-hover);
  transform: translateY(-2px);
}

.gallery-cta:focus-visible {
  outline: 2px solid var(--charcoal);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--off-white);
}

/* Designing your own setup is the side door; buying what is on screen is the
   main one. Two solid Deep Ocean buttons would say they are equal, so this one
   is outlined. It also keeps the pair inside the palette's 60/25 ratio rather
   than doubling the Deep Ocean on a page that is mostly Pebble. */
.gallery-cta--secondary {
  background: var(--white);
  color: var(--deep-ocean);
  box-shadow:
    var(--shadow-md),
    inset 0 0 0 var(--btn-border-width) var(--deep-ocean);
}

.gallery-cta--secondary:hover {
  background: var(--pebble);
  color: var(--deep-ocean-hover);
}

/* What the buy button says while it sends a design rather than following its
   link, which only the Space Saver with a climbing pack does. Empty, it takes
   no space and announces nothing. It floats one button row above the pair, so
   it never covers them, and an error is outlined in Terracotta rather than set
   in it: Terracotta text on white is 3.25:1, short of the 4.5:1 this size needs. */
.gallery-status {
  position: fixed;
  right: var(--space-s);
  bottom: calc(var(--space-s) + var(--gallery-cta-row-h) + var(--space-2xs));
  z-index: 1000;
  max-width: min(44ch, calc(100vw - 2 * var(--space-s)));
  margin: 0;
  padding: var(--space-2xs) var(--space-s);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--charcoal);
  box-shadow: var(--shadow-md);
  font-size: var(--text-small);
  line-height: 1.4;
}

.gallery-status:empty {
  display: none;
}

.gallery-status[data-state="error"] {
  box-shadow:
    var(--shadow-md),
    inset 0 0 0 1px var(--terracotta);
}

/* Narrow enough and the preview's own controls reflow down into the bottom
   right corner, where a floating button lands on top of them — at 721px it
   covers Save image and the price line outright. Below 1000px the call to
   action becomes a full-width bar instead, and main gives back exactly the
   height the bar occupies, so it covers nothing at any width. 1000px is the
   breakpoint the design builder already uses. */
@media (max-width: 1000px) {
  main {
    height: calc(
      100dvh - var(--gallery-header-h) - var(--gallery-crumbs-h) -
        var(--gallery-cta-bar-h)
    );
  }

  .gallery-actions {
    inset: auto 0 0;
    gap: 0;
  }

  .gallery-status {
    bottom: calc(var(--gallery-cta-bar-h) + var(--space-2xs));
  }

  .gallery-cta {
    /* Share the bar evenly. min-width: 0 lets a button shrink below the width
       of its own label rather than pushing the pair wider than the screen. */
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    min-height: var(--gallery-cta-row-h);
    padding-block: 0;
    padding-inline: var(--space-2xs);
    border-radius: 0;
    box-shadow: none;
  }

  /* The shadow goes with the floating shape, but the outline is what tells the
     two buttons apart, so in the bar it becomes a divider between them. */
  .gallery-cta--secondary {
    box-shadow: inset calc(var(--btn-border-width) * -1) 0 0 0 var(--deep-ocean);
  }

  .gallery-cta:hover {
    transform: none;
  }
}

/* Both labels on one line need roughly 600px. Below that the bar becomes two
   stacked rows, and --gallery-cta-bar-h doubles to match, so main still gives
   back exactly the height the bar occupies and nothing covers the preview. */
@media (max-width: 600px) {
  .gallery-actions {
    flex-direction: column;
  }

  .gallery-cta--secondary {
    box-shadow: inset 0 calc(var(--btn-border-width) * -1) 0 0 var(--deep-ocean);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-cta {
    transition: background var(--duration-fast) var(--ease-out);
  }

  .gallery-cta:hover {
    transform: none;
  }
}

@media (max-width: 720px) {
  .gallery-back__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
