@import url('./fbz-design-tokens.css');

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: radial-gradient(circle at top, #fffaf0 0, var(--fbz-bg) 58%, #efe6d9 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--fbz-text);
  font-family: var(--fbz-font-body);
  background: transparent;
}

.fbz-page {
  width: min(var(--fbz-page-width), 100%);
  margin: 0 auto;
  padding: var(--fbz-page-padding);
}

/* Narrow, centered shell for logo-led pages (access/login/request-access). */
.fbz-shell-center {
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.fbz-narrow {
  width: min(540px, 100%);
  margin: 0 auto;
  text-align: center;
}

@media (max-width: 520px) {
  .fbz-shell-center {
    align-items: start;
  }

  .fbz-narrow {
    padding-top: 10px;
  }
}

.fbz-logo {
  display: block;
  width: clamp(var(--fbz-logo-mobile), 22vw, var(--fbz-logo-desktop));
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.fbz-wordmark {
  font-family: var(--fbz-font-heading);
  font-size: clamp(2rem, 7vw, 4.8rem);
  letter-spacing: -0.04em;
  color: var(--fbz-sage-deep);
  text-align: center;
}

.fbz-tagline {
  margin-top: 8px;
  text-align: center;
  color: var(--fbz-gold);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 700;
}

.fbz-card,
.fbz-panel {
  background: rgba(255, 250, 240, 0.88);
  border: var(--fbz-border);
  border-radius: var(--fbz-radius-panel);
  box-shadow: var(--fbz-shadow-soft);
}

.fbz-card {
  border-radius: var(--fbz-radius-card);
  box-shadow: var(--fbz-shadow-card);
}

.fbz-input {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: var(--fbz-border);
  border-radius: var(--fbz-radius-md);
  background: rgba(255, 253, 248, 0.92);
  color: var(--fbz-text);
  font: inherit;
  outline: none;
}

.fbz-input:focus {
  border-color: rgba(79, 107, 85, 0.55);
  box-shadow: 0 0 0 4px rgba(135, 155, 130, 0.18);
}

.fbz-button {
  min-height: 52px;
  border: 0;
  border-radius: var(--fbz-radius-md);
  padding: 0 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.fbz-button-primary {
  background: linear-gradient(180deg, #81947d 0%, var(--fbz-sage-dark) 100%);
  color: #fffaf0;
}

.fbz-button-secondary {
  background: rgba(255, 250, 240, 0.72);
  color: var(--fbz-sage-dark);
  border: var(--fbz-border);
}

.fbz-button-danger {
  background: rgba(183, 121, 111, 0.14);
  color: var(--fbz-danger-soft);
  border: 1px solid rgba(183, 121, 111, 0.35);
}

.fbz-button-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.85rem;
}

/* Form groups: label + input, consistently spaced. */
.fbz-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.fbz-field {
  display: grid;
  gap: 6px;
}

.fbz-field label {
  color: var(--fbz-text-soft);
  font-size: 0.9rem;
}

.fbz-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--fbz-muted);
  font-size: 0.85rem;
}

.fbz-divider::before,
.fbz-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(116, 101, 78, 0.22);
}

/* Status/availability badges. */
.fbz-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--fbz-radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.6;
}

.fbz-badge-sage {
  background: var(--fbz-sage-soft);
  color: var(--fbz-sage-deep);
}

.fbz-badge-gold {
  background: var(--fbz-gold-soft);
  color: #7a6222;
}

.fbz-badge-outline {
  background: transparent;
  border: var(--fbz-border);
  color: var(--fbz-text-soft);
}

/* Panel heading with a small round icon badge, e.g. "Access by invitation". */
.fbz-panel-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  font-family: var(--fbz-font-heading);
  font-size: 1.4rem;
  color: var(--fbz-sage-deep);
}

.fbz-icon-badge {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--fbz-sage-soft);
  color: var(--fbz-sage-deep);
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.fbz-link {
  color: var(--fbz-sage-dark);
  font-weight: 700;
  text-decoration: none;
}

.fbz-notice {
  border-radius: var(--fbz-radius-md);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  text-align: center;
}

.fbz-notice-error {
  background: rgba(183, 121, 111, 0.12);
  color: var(--fbz-danger-soft);
  border: 1px solid rgba(183, 121, 111, 0.3);
}

.fbz-notice-info {
  background: var(--fbz-sage-soft);
  color: var(--fbz-sage-deep);
}

/* Applied by reservation-time.js the instant a hold's countdown reaches
   zero, so the basket becomes visually non-actionable immediately -- the
   server independently rejects the same actions regardless of this. */
.fbz-actions-disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* Page header: small brand mark + nav/actions, reused across customer pages. */
.fbz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.fbz-brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fbz-sage-deep);
  font-family: var(--fbz-font-heading);
  font-size: 1.55rem;
  text-decoration: none;
}

.fbz-brand-mini img {
  width: 64px;
  height: 50px;
  object-fit: cover;
  border-radius: var(--fbz-radius-sm);
}

/* Admin nav: full pill row on wider screens, a single compact select on
   phones -- wrapped pills were eating too much vertical space there. */
.fbz-admin-nav-compact {
  display: none;
}

@media (max-width: 720px) {
  .fbz-header {
    align-items: flex-start;
  }

  .fbz-brand-mini {
    font-size: 1.25rem;
  }

  .fbz-brand-mini img {
    width: 52px;
    height: 42px;
  }

  .fbz-pill-nav.fbz-admin-nav-wide {
    display: none;
  }

  .fbz-admin-nav-compact {
    display: block;
    margin-bottom: 20px;
  }
}

.fbz-pill-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0 12px;
}

.fbz-pill-nav a {
  white-space: nowrap;
  color: var(--fbz-sage-dark);
  text-decoration: none;
  border: var(--fbz-border);
  border-radius: var(--fbz-radius-pill);
  padding: 10px 16px;
  background: rgba(255, 250, 240, 0.65);
}

.fbz-pill-nav a.active {
  background: var(--fbz-sage-dark);
  color: #fffaf0;
  border-color: transparent;
}

/* Storefront-only header: centred, logo-led identity (Step 9 visual
   refinement). Distinct from the compact .fbz-header/.fbz-brand-mini
   used on admin pages, which are unaffected by this block. */
.fbz-storefront-header {
  position: relative;
  text-align: center;
  padding-top: 6px;
  margin-bottom: 18px;
}

.fbz-storefront-header-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}

.fbz-storefront-brand {
  display: inline-block;
}

/* Same .fbz-logo sizing already used on the access page — reused here
   rather than inventing a new size, so "substantially larger" still
   means the one already-approved logo-led scale, not an arbitrary one. */
.fbz-storefront-header .fbz-logo {
  margin: 0 auto;
}

.fbz-storefront-nav {
  flex-wrap: wrap;
  justify-content: center;
  overflow-x: visible;
}

/* Admin: denser shell + list rows for invites/access-requests, still on
   the same tokens per docs/implementation/DESIGN_LOCK.md. */
.fbz-admin-shell {
  max-width: 860px;
  margin: 0 auto;
}

.fbz-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: var(--fbz-section-gap);
}

.fbz-stat-card {
  padding: 18px 20px;
}

.fbz-stat-card .fbz-stat-value {
  font-family: var(--fbz-font-heading);
  font-size: 2.2rem;
  color: var(--fbz-sage-deep);
}

.fbz-list {
  display: grid;
  gap: 10px;
}

.fbz-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: rgba(255, 250, 240, 0.9);
  border: var(--fbz-border);
  border-radius: var(--fbz-radius-md);
}

.fbz-list-row-main {
  display: grid;
  gap: 3px;
}

.fbz-list-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 560px) {
  .fbz-list-row {
    flex-direction: column;
    align-items: stretch;
  }

  .fbz-list-row-actions {
    justify-content: flex-start;
  }

  .fbz-list-row-actions .fbz-button {
    flex: 1;
  }
}

.fbz-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 220px));
  gap: 18px;
}

.fbz-product-card {
  display: block;
  overflow: hidden;
  background: rgba(255, 250, 240, 0.92);
  border: var(--fbz-border);
  border-radius: var(--fbz-radius-card);
  box-shadow: var(--fbz-shadow-card);
  text-decoration: none;
  color: inherit;
}

.fbz-product-image {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--fbz-sage-soft);
  display: grid;
  place-items: center;
  color: var(--fbz-sage-dark);
  font-size: 1.4rem;
  overflow: hidden;
}

.fbz-product-image img {
  /* Absolutely positioned rather than width/height: 100% -- in a plain
     block context (e.g. the listing detail page, not a grid track) a
     percentage-height image can resolve against an indeterminate parent
     height and end up sizing the box by the photo's own aspect ratio
     instead of the intended square, silently breaking aspect-ratio: 1/1
     above. Absolute positioning always resolves against the already-
     settled aspect-ratio box instead. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* contain, not cover: real product photos must never be cropped just
     to hit a shorter card — any letterboxing shows the sage-soft
     background behind, which reads as an intentional soft mount. */
  object-fit: contain;
}

.fbz-product-body {
  padding: 14px;
}

/* Browser default <p> margins (~1em top/bottom) were quietly inflating
   card height far beyond what the title/price/availability lines
   actually need — this is the main fix behind the mobile density pass. */
.fbz-product-body p {
  margin: 0 0 4px;
}

.fbz-product-body p:last-child {
  margin-bottom: 0;
}

.fbz-product-title {
  font-weight: 700;
  line-height: 1.25;
}

.fbz-product-price {
  color: var(--fbz-sage-deep);
  font-weight: 800;
}

.fbz-muted {
  color: var(--fbz-muted);
}

/* Storefront section rows, generated entirely from admin config — see
   app/services/sections.py's resolver. No section here is hard-coded. */
.fbz-section-block {
  margin-top: var(--fbz-section-gap);
}

.fbz-section-title {
  margin: 0 0 14px;
  font-family: var(--fbz-font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--fbz-sage-deep);
}

.fbz-empty-state {
  text-align: center;
  color: var(--fbz-muted);
  margin: 48px 0;
}

.fbz-trust-line {
  margin-top: 28px;
  text-align: center;
  color: var(--fbz-muted);
  font-size: 0.85rem;
}

/* Full-bleed bar for a closing brand note; used outside .fbz-page. */
.fbz-footer-bar {
  background: var(--fbz-sage-dark);
  color: #fffaf0;
  text-align: center;
  padding: 16px 20px;
  font-size: 0.85rem;
}

@media (max-width: 520px) {
  .fbz-page {
    padding-top: 22px;
    padding-bottom: 22px;
  }

  .fbz-logo {
    width: clamp(150px, 42vw, 190px);
  }

  .fbz-panel {
    border-radius: 22px;
  }

  .fbz-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* Shorter than the desktop 1:1 image so more of the collection fits
     on screen at once — still comfortably proportioned for real Tonie/
     Yoto product photography, and object-fit: contain (set above)
     means nothing gets cropped to hit this ratio. */
  .fbz-product-image {
    aspect-ratio: 4 / 3;
  }

  .fbz-product-body {
    padding: 10px 12px;
  }

  .fbz-product-title {
    font-size: 0.92rem;
  }

  .fbz-product-price {
    font-size: 0.92rem;
  }

  .fbz-product-body .fbz-muted {
    font-size: 0.82rem;
  }

  .fbz-trust-line {
    margin-top: 20px;
  }

  .fbz-storefront-header-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
}

/* ---------------------------------------------------------------------
   Product photo gallery + full-screen lightbox viewer
   (watermarked derivatives only -- see app/routes/photos.py)
   --------------------------------------------------------------------- */

.fbz-photo-trigger {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 0;
  font: inherit;
  color: inherit;
  /* touch-action: manipulation removes the ~300ms tap-ambiguity delay
     mobile browsers otherwise use to detect double-tap-to-zoom. */
  touch-action: manipulation;
}

.fbz-photo-trigger:focus-visible {
  outline: 2px solid var(--fbz-sage-dark);
  outline-offset: 2px;
  border-radius: var(--fbz-radius-sm);
}

.fbz-product-image .fbz-photo-trigger {
  position: absolute;
  inset: 0;
  display: block;
}

/* <img> is natively draggable, and starting a native drag on
   mousedown-then-move suppresses the click event entirely -- the classic
   cause of "clicking the photo doesn't reliably open the viewer" on
   desktop, since any pointer drift between mousedown/mouseup (normal for
   a physical mouse) can be interpreted as a drag instead of a click. */
.fbz-photo-trigger img {
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
}

/* The full-screen photo viewer overlay itself is built entirely in
   JavaScript at click time (see app/static/js/photo-lightbox.js) with
   inline styles, and appended directly to <body>. That keeps its
   geometry independent of this stylesheet having loaded, of cascade/
   specificity, and of any ancestor's layout -- so there is no CSS here
   for it. */
