/*
 * VEYLOVA storefront fluid layout
 *
 * Scope:
 * - shared storefront pages (home, collections, cart, journal, article)
 * - the customizer host page, but not the renderer inside its iframe
 *
 * This file is loaded after styles.css and responsive.css. It owns geometry,
 * wrapping, media sizing and touch targets only. Brand styling and business
 * state remain in their original modules.
 */

:root {
  --vl-fluid-gutter: clamp(0.75rem, 3vw, 2.5rem);
  --vl-fluid-section: clamp(2rem, 6vw, 5rem);
  --vl-fluid-gap: clamp(0.75rem, 2vw, 1.5rem);
  --vl-content-width: 72.5rem;
  --vl-reading-width: 72ch;
  --vl-proof-outline: rgba(118, 84, 99, 0.34);
  --vl-proof-divider: rgba(118, 84, 99, 0.42);
}

html {
  width: 100%;
  min-width: 20rem;
  max-width: 100%;
  text-size-adjust: 100%;
}

body,
.page {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

body {
  overflow-wrap: break-word;
}

:where(
  main,
  section,
  article,
  aside,
  header,
  footer,
  nav,
  form,
  fieldset,
  .container,
  .panel,
  .content
) {
  min-width: 0;
}

.container {
  width: min(
    var(--vl-content-width),
    calc(100% - (2 * var(--vl-fluid-gutter)))
  ) !important;
  max-width: var(--vl-content-width) !important;
  margin-inline: auto !important;
}

.section {
  padding-block: var(--vl-fluid-section);
}

.section.tight {
  padding-top: clamp(1.75rem, 4vw, 3.25rem);
}

:where(h1, h2, h3) {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

:where(p, li) {
  text-wrap: pretty;
}

/* Keep content media fluid without forcing logos, icons or bead textures to crop. */
:where(img, picture, video) {
  max-width: 100%;
}

:where(img, video) {
  height: auto;
}

:where(
  .responsive-picture,
  .hero-media,
  .home-story-photo,
  .home-hot-media,
  .home-review-card,
  .home-journal-media,
  .journal-card-media,
  .journal-article-image,
  .product-card,
  .cart-bracelet-thumb
) {
  min-width: 0;
  max-width: 100%;
}

:where(
  .hero-full-image,
  .home-story-photo img,
  .home-journal-media img,
  .journal-card-media img
) {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:where(
  .product-card img,
  .home-hot-card img,
  .cart-bracelet-image,
  .cart-material-name img
) {
  max-width: 100%;
  object-fit: contain;
}

/* Canvas dimensions are controlled by the renderer; only its outer boundary is fluid. */
:where(canvas, .cart-bracelet-canvas, .customizer-embed) {
  display: block;
  max-width: 100%;
}

.customizer-embed-page,
.customizer-embed-shell,
.customizer-embed {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.customizer-embed-shell {
  padding-inline: clamp(0.25rem, 1.2vw, 0.75rem) !important;
}

/* Shared control contract. */
:where(button, .button, [role="button"], input, select, textarea) {
  max-width: 100%;
  font: inherit;
}

:where(button, .button, [role="button"]) {
  min-width: 0;
  touch-action: manipulation;
}

/* Keep the home proof modules visually distinct at every responsive layout. */
body.home-page .home-proof-v2 .standard-strip {
  border-color: var(--vl-proof-outline) !important;
}

@media (min-width: 47.5625rem) {
  body.home-page .home-proof-v2 .standard-item + .standard-item {
    border-left: 1px solid var(--vl-proof-divider) !important;
  }
}

@media (min-width: 21.9375rem) and (max-width: 47.5rem) {
  body.home-page .home-proof-v2 .standard-item:nth-child(odd) {
    border-right: 1px solid var(--vl-proof-divider) !important;
  }

  body.home-page .home-proof-v2 .standard-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--vl-proof-divider) !important;
  }
}

@media (max-width: 21.875rem) {
  body.home-page .home-proof-v2 .standard-item {
    border-right: 0 !important;
  }

  body.home-page .home-proof-v2 .standard-item:not(:last-child) {
    border-bottom: 1px solid var(--vl-proof-divider) !important;
  }
}

/* Desktop navigation icons keep their geometry when legacy link padding applies. */
@media (min-width: 47.5625rem) {
  html body[class] .site-header .nav-links a.nav-cart-icon,
  html body[class] .site-header .nav-links a.nav-account-icon,
  html body[class] .site-header .nav-links a.nav-orders-link.nav-account-icon {
    display: inline-grid !important;
    place-items: center !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html body[class] .site-header .nav-links a.nav-cart-icon svg,
  html body[class] .site-header .nav-links a.nav-account-icon svg,
  html body[class] .site-header .nav-links a.nav-orders-link.nav-account-icon svg {
    display: block !important;
    width: 1.375rem !important;
    min-width: 1.375rem !important;
    max-width: 1.375rem !important;
    height: 1.375rem !important;
    min-height: 1.375rem !important;
    max-height: 1.375rem !important;
    flex: 0 0 1.375rem !important;
  }
}

:where(
  .button,
  .text-button.compact,
  .home-story-button,
  .home-hot-button,
  .home-hot-view-all,
  .home-journal-button,
  .journal-filter-bar button
) {
  min-height: 2.75rem !important;
  padding-inline: clamp(0.75rem, 2.4vw, 1.5rem) !important;
}

:where(
  .hero-actions,
  .actions,
  .product-actions,
  .cart-actions,
  .journal-hero-actions,
  .journal-cta-actions,
  .diy-entry-loader__actions,
  .diy-leave-dialog__actions
) {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1.6vw, 0.875rem);
}

:where(
  .hero-actions,
  .actions,
  .product-actions,
  .cart-actions,
  .journal-hero-actions,
  .journal-cta-actions
) > :where(button, .button, [role="button"]) {
  flex: 0 1 auto;
}

:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  min-width: 0;
}

/* Content-driven grids: they reflow when text or available width requires it. */
.grid-3 {
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, 16rem), 1fr)
  ) !important;
  gap: var(--vl-fluid-gap) !important;
}

.gallery-grid {
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, 14rem), 1fr)
  ) !important;
  gap: var(--vl-fluid-gap) !important;
}

.policy-grid {
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, 13rem), 1fr)
  ) !important;
  gap: var(--vl-fluid-gap) !important;
}

body.home-page .home-review-grid,
body.blog-page .journal-feature-grid,
body.blog-page .journal-grid {
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, 16rem), 1fr)
  ) !important;
}

.cart-layout {
  grid-template-columns:
    minmax(0, 1fr)
    minmax(17.5rem, 22.5rem) !important;
  gap: clamp(1rem, 3vw, 2rem) !important;
}

.checkout-card {
  min-width: 0;
}

.cart-card {
  grid-template-columns:
    minmax(7rem, clamp(7rem, 16vw, 9.375rem))
    minmax(0, 1fr) !important;
}

.cart-bracelet-thumb {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 5 / 4;
}

.cart-bracelet-image,
.cart-bracelet-canvas {
  width: 100% !important;
  height: 100% !important;
}

.cart-material-row,
.cart-material-head {
  min-width: 0;
}

/* Article markup is rendered at runtime; keep it readable at every width. */
.journal-article-hero {
  padding-block: clamp(2rem, 6vw, 5rem);
}

.journal-article-header {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(18rem, 1.1fr);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
}

.journal-article-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: min(1rem, 3vw);
  object-fit: cover;
}

.journal-article-shell {
  display: grid;
  grid-template-columns: minmax(0, var(--vl-reading-width)) minmax(14rem, 18rem);
  justify-content: center;
  gap: clamp(1.5rem, 5vw, 4rem);
  padding-block: clamp(2rem, 6vw, 5rem);
}

.journal-article-content,
.journal-article-aside {
  min-width: 0;
}

.journal-article-content :where(img, video, iframe) {
  width: 100%;
  max-width: 100%;
  height: auto;
}

@media (max-width: 64rem) {
  body.home-page .home-hero.home-hero-v2.home-hero-carousel .home-hero-carousel-controls button {
    width: 2.75rem !important;
    min-width: 2.75rem !important;
    height: 2.75rem !important;
    min-height: 2.75rem !important;
  }

  html body[class] .site-header .nav-links a[href="index.html"]:not(.button):not(.nav-cart-icon):not(.nav-account-icon),
  html body[class] .site-header .nav-links a[href="customizer.html"]:not(.button):not(.nav-cart-icon):not(.nav-account-icon),
  html body[class] .site-header .nav-links a[href="designer.html"]:not(.button):not(.nav-cart-icon):not(.nav-account-icon) {
    height: 2.75rem !important;
    min-height: 2.75rem !important;
  }

  html body[class] .site-header .nav-links a.nav-cart-icon,
  html body[class] .site-header .nav-links a.nav-account-icon,
  html body[class] .site-header .nav-links a.nav-orders-link.nav-account-icon {
    width: 2.75rem !important;
    min-width: 2.75rem !important;
    max-width: 2.75rem !important;
    height: 2.75rem !important;
    min-height: 2.75rem !important;
  }

  .cart-layout {
    grid-template-columns: 1fr !important;
  }

  .checkout-card {
    position: static !important;
    width: 100%;
  }

  .journal-article-header,
  .journal-article-shell {
    grid-template-columns: 1fr;
  }

  .journal-article-aside {
    width: 100%;
  }
}

@media (max-width: 47.5rem) {
  :root {
    --vl-fluid-gutter: clamp(0.75rem, 4vw, 1.25rem);
    --vl-fluid-section: clamp(1.75rem, 8vw, 3rem);
  }

  .page {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  .section-header,
  .home-hot-header,
  .home-review-header,
  .journal-section-head,
  .journal-toolbar,
  .journal-cta-panel {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  :where(
    .section-header h1,
    .section-header h2,
    .home-review-header h2,
    .home-review-header p,
    .home-journal-copy h2,
    .home-flow-section h2
  ) {
    max-width: 100% !important;
    white-space: normal !important;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: clamp(0.625rem, 3vw, 1rem) !important;
  }

  .product-card .content {
    padding: clamp(0.75rem, 3vw, 1rem);
  }

  .product-actions {
    align-items: stretch;
  }

  .product-actions > * {
    min-width: 0;
  }

  body.home-page .home-story-card {
    grid-template-columns: 1fr !important;
  }

  body.home-page .home-story-photo {
    min-height: 0 !important;
    aspect-ratio: 4 / 3 !important;
    border-radius: 0 !important;
  }

  body.home-page .home-story-copy {
    padding: clamp(1.25rem, 6vw, 2rem) !important;
  }

  body.home-page .home-story-copy p {
    display: block !important;
    overflow: visible !important;
    font-size: clamp(0.9375rem, 3.8vw, 1.0625rem) !important;
    line-height: 1.6 !important;
    -webkit-line-clamp: unset !important;
  }

  body.home-page .home-story-button {
    width: 100% !important;
    min-height: 2.75rem !important;
    font-size: clamp(0.8125rem, 3.5vw, 0.9375rem) !important;
  }

  body.home-page .home-hot-scroll,
  body.home-page .home-review-scroll {
    margin-inline: calc(-1 * var(--vl-fluid-gutter)) !important;
  }

  body.home-page .home-hot-track,
  body.home-page .home-review-grid {
    padding-inline: var(--vl-fluid-gutter) !important;
  }

  body.home-page .home-hot-track {
    grid-auto-columns: clamp(10rem, 46vw, 13rem) !important;
  }

  body.home-page .home-hot-media {
    min-height: 0 !important;
    aspect-ratio: 1;
  }

  body.home-page .home-hot-button,
  body.home-page .home-hot-fit {
    max-width: 100% !important;
    height: auto !important;
    white-space: normal !important;
    text-align: center !important;
  }

  body.home-page .home-review-grid {
    display: flex !important;
    width: max-content !important;
  }

  body.home-page .home-review-card {
    width: clamp(15rem, 78vw, 19rem) !important;
  }

  body.home-page .home-hero .hero-actions .button {
    min-width: 0 !important;
    flex: 1 1 9rem !important;
    white-space: normal !important;
    text-align: center !important;
  }

  body.home-page .home-hero.home-hero-v2.home-hero-carousel .home-hero-carousel-controls button,
  body.home-page main .home-hot-view-all,
  body.home-page main .home-hot-button,
  body.home-page main .home-story-button,
  body.home-page main .home-journal-button,
  body.designer-page main .button,
  body.cart-page main .button,
  body.cart-page main button.cart-delete,
  body.blog-page main .button,
  body.blog-page main .journal-hero-actions .button,
  body.blog-page main .journal-cta-actions .button,
  body.blog-page main .journal-filter-bar button,
  body.article-page main .button {
    height: auto !important;
    min-height: 2.75rem !important;
  }

  body.blog-page .journal-feature-grid,
  body.blog-page .journal-grid {
    grid-template-columns: 1fr !important;
  }

  body.blog-page .journal-filter-bar {
    max-width: 100%;
    overscroll-behavior-inline: contain;
  }

  body.blog-page .journal-filter-bar button {
    flex: 0 0 auto;
  }

  .cart-card {
    grid-template-columns: minmax(5.5rem, 7.25rem) minmax(0, 1fr) !important;
    gap: clamp(0.75rem, 3vw, 1rem) !important;
  }

  .cart-material-head {
    display: none !important;
  }

  .cart-material-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    border-radius: 0.75rem !important;
  }

  .cart-material-row > :not(.cart-material-name):not(strong) {
    display: none;
  }

  .checkout-options {
    grid-template-columns: 1fr !important;
  }

  .checkout-option {
    min-height: 2.75rem !important;
  }

  .journal-article-header {
    gap: 1.25rem;
  }

  .journal-article-shell {
    gap: 1.5rem;
  }

  .mobile-sticky-cta {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 22rem) {
  .gallery-grid {
    grid-template-columns: 1fr !important;
  }

  .cart-card {
    grid-template-columns: 1fr !important;
    padding-inline: 0.75rem !important;
  }

  .cart-bracelet-thumb {
    max-width: 10rem;
  }

  :where(
    .hero-actions,
    .actions,
    .product-actions,
    .cart-actions,
    .journal-hero-actions,
    .journal-cta-actions
  ) > :where(button, .button, [role="button"]) {
    width: 100%;
    flex-basis: 100%;
  }
}

@media (hover: none), (pointer: coarse) {
  :where(
    button,
    .button,
    [role="button"],
    .site-header .nav-links a,
    .filter-bar button,
    .journal-filter-bar button
  ) {
    min-height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(*, *::before, *::after) {
    scroll-behavior: auto !important;
  }
}
