/* =====================================================
   SMALL WORLD THINGS — MOBILE / RESPONSIVE OVERRIDES
   Loaded after each page's inline styles so the mobile
   layout stays consistent across the entire site.
===================================================== */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
video,
svg {
  max-width: 100%;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

/* Mobile navigation is created by cart.js. */
.mobile-menu-toggle {
  display: none;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid #526B87;
  border-radius: 50%;
  background: transparent;
  color: #526B87;
  font-family: "Fredoka", sans-serif;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.mobile-nav {
  display: none;
}

@media (max-width: 850px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .top-actions {
    flex-shrink: 0;
  }

  .mobile-nav {
    position: fixed;
    top: 76px;
    left: 0;
    right: 0;
    z-index: 49;
    display: flex;
    flex-direction: column;
    padding: 10px 20px 18px;
    background: rgba(255, 254, 252, 0.98);
    border-bottom: 1px solid #E6E7E2;
    box-shadow: 0 12px 28px rgba(82, 107, 135, 0.08);
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
    backdrop-filter: blur(12px);
  }

  .mobile-nav.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-nav a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 10px 4px;
    border-bottom: 1px solid #EEF0ED;
    font-size: 16px;
    font-weight: 500;
    color: #526B87;
  }

  .mobile-nav a:last-child {
    border-bottom: 0;
  }

  .mobile-nav a:active {
    opacity: .55;
  }

  .topbar {
    min-height: 76px;
  }

  /* Desktop navigation is replaced by the mobile menu. */
  .topbar .nav-links {
    display: none !important;
  }

  /* Keep large sections inside the viewport. */
  .hero,
  .featured,
  .products-hero,
  .category-nav,
  .categories,
  .products-header,
  .product-section,
  .about-hero,
  .intro-section,
  .story-section,
  .values-section,
  .closing,
  .contact-hero,
  .contact-section {
    max-width: 100%;
  }

  .featured-card,
  .contact-grid,
  .intro-grid,
  .product-layout,
  .value-grid,
  .shelfabet-photos {
    width: 100%;
  }

  .featured-image img,
  .main-product-image,
  .intro-image,
  .main-shelf-photo,
  .small-shelf-photo,
  .mounting-photo {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding-left: 16px !important;
    padding-right: 16px !important;
    gap: 10px;
  }

  .logo {
    min-width: 0;
    font-size: 18px !important;
    white-space: nowrap;
  }

  .top-actions {
    gap: 6px !important;
  }

  .account-button,
  .cart-button,
  .mobile-menu-toggle {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  /* Typography */
  .hero h1,
  .products-hero h1,
  .products-header h1,
  .about-hero h1,
  .contact-hero h1 {
    font-size: clamp(48px, 15vw, 70px) !important;
    line-height: .9 !important;
    letter-spacing: -.025em !important;
  }

  .hero h1 .word {
    white-space: normal;
  }

  .hero h1 .things {
    font-size: .68em;
  }

  .products-hero p,
  .products-header p,
  .about-hero p,
  .contact-hero p {
    font-size: 16px !important;
    line-height: 1.5;
  }

  /* Prevent iOS from zooming when a form field receives focus. */
  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  .contact-form input,
  .contact-form textarea,
  .text-input {
    width: 100%;
  }

  .contact-form button,
  .add-cart,
  .cart-popup-button,
  .shipping-calculate-button,
  .global-cart-checkout,
  .global-cart-continue {
    min-height: 46px;
  }

  /* Category chips scroll instead of creating an awkward second line. */
  .category-nav {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 20px !important;
  }

  .category-nav::-webkit-scrollbar {
    display: none;
  }

  .category-link {
    flex: 0 0 auto;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
  }

  /* Shelfabets customizer */
  .preview-letters {
    max-width: 100%;
    overflow: visible;
    flex-wrap: wrap;
  }

  .preview-item {
    flex: 0 0 auto;
  }

  .preview-letter {
    flex: 0 0 auto;
  }

  .mini-swatch {
    flex: 0 0 auto;
  }

  .summary-row {
    flex-wrap: wrap;
  }

  .summary-left {
    min-width: 0;
  }

  /* Product/category cards */
  .featured-card {
    border-radius: 22px !important;
  }

  .featured-copy {
    min-width: 0;
  }

  .featured-image {
    min-height: 280px !important;
  }

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

  /* Contact / about cards */
  .contact-info,
  .intro-copy {
    min-width: 0;
  }

  .contact-info {
    padding: 25px !important;
    border-radius: 22px !important;
  }

  .contact-detail a {
    overflow-wrap: anywhere;
  }

  /* Cart drawer */
  .global-cart-drawer {
    width: 100vw !important;
    max-width: 100vw;
  }

  .global-cart-header {
    padding: 18px 18px !important;
  }

  .global-cart-items {
    padding: 12px 18px !important;
  }

  .global-cart-footer {
    padding: 16px 18px 20px !important;
  }

  .global-cart-item-top,
  .global-cart-item-bottom {
    gap: 10px;
  }

  .cart-shipping-form {
    flex-direction: column;
  }

  .shipping-calculate-button {
    width: 100%;
    min-height: 44px;
  }

  /* Avoid tiny footer layouts on phones. */
  footer {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .logo {
    font-size: 16px !important;
  }

  .account-button,
  .cart-button,
  .mobile-menu-toggle {
    width: 35px;
    height: 35px;
    min-width: 35px;
  }

  .top-actions {
    gap: 4px !important;
  }
}


/* Shelfabets: keep white letters visible on their white preview cards. */
.preview-letter.white-letter {
  -webkit-text-stroke: 1px #c9ced2;
  text-shadow: 0 0 1px #c9ced2;
}

.mini-palette {
  position: absolute;
  top: calc(100% + 10px);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid #d9dcdf;
  box-shadow: 0 10px 28px rgba(30, 40, 50, 0.16);
  z-index: 1000;
}

/* =====================================================
   MOBILE CUSTOMIZER / SWIPE IMPROVEMENTS
===================================================== */

@media (max-width: 600px) {
  /* Mobile color picker: overlay the letters instead of changing their layout. */
  .preview-item {
    position: relative;
    padding-bottom: 0 !important;
    scroll-margin: 20px;
  }

  .preview-item.is-coloring {
    z-index: auto;
  }

  .mini-palette {
    display: none !important;
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: min(320px, calc(100vw - 32px));
    max-width: min(320px, calc(100vw - 32px));
    grid-template-columns: repeat(5, 1fr);
    justify-items: center;
    align-items: center;
    gap: 12px;
    padding: 18px;
    box-sizing: border-box;
    background: #ffffff !important;
    border: 1px solid #D9DCDF;
    border-radius: 22px;
    box-shadow: 0 14px 40px rgba(30, 40, 50, 0.22);
    overflow: visible !important;
    z-index: 99999 !important;
  }

  .mini-palette.is-open {
    display: grid !important;
  }

  .mini-swatch {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    min-height: 44px;
    border-width: 2px;
    box-shadow: 0 1px 3px rgba(60, 70, 80, 0.12);
  }

  .mini-swatch:active {
    transform: scale(.94);
  }

  /* Let the palette extend downward instead of being clipped by the
     horizontal letter scroller. The letters wrap naturally on phones. */
  .preview-letters {
    align-items: flex-start;
    flex-wrap: wrap !important;
    overflow: visible !important;
    padding-bottom: 0;
  }

  .preview-letter.active {
    box-shadow: 0 0 0 3px rgba(157, 185, 209, 0.18);
  }

  /* Make the two swipeable areas feel intentionally touch-driven. */
  .featured-image,
  .review-card {
    touch-action: pan-y;
  }

  .featured-image {
    user-select: none;
    -webkit-user-select: none;
  }

  .review-card {
    user-select: none;
    -webkit-user-select: none;
  }
}


/* Shelfabets mobile color picker: centered overlay */
@media (max-width: 768px) {
  .preview-item.is-coloring {
    position: static !important;
    z-index: auto !important;
    padding-bottom: 0 !important;
  }

  .mini-palette {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    display: none !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    width: min(340px, calc(100vw - 32px)) !important;
    padding: 18px !important;
    gap: 10px !important;
    background: #ffffff !important;
    border: 1px solid #d9dcdf !important;
    border-radius: 18px !important;
    box-shadow: 0 12px 35px rgba(40, 50, 60, 0.22) !important;
    z-index: 99999 !important;
  }

  .mini-palette.is-open {
    display: flex !important;
  }

  .mini-swatch {
    width: 44px !important;
    height: 44px !important;
    flex: 0 0 44px !important;
  }
}


/* =====================================================
   SMALL WORLD THINGS — SHARED REFERENCE DESIGN THEME
===================================================== */
:root {
  --swt-green: #0f3b28;
  --swt-cream: #fffefb;
  --swt-ink: #173026;
  --swt-muted: #5d625f;
  --swt-line: #e1e5e1;
}

body {
  background: var(--swt-cream) !important;
  color: var(--swt-ink) !important;
}

.topbar {
  background: var(--swt-cream) !important;
  border-bottom: 0 !important;
  color: #111 !important;
}

.topbar .logo {
  color: var(--swt-green) !important;
  font-family: "Cormorant Garamond", Georgia, serif !important;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.topbar .logo span {
  color: var(--swt-green) !important;
}

.topbar .nav-links a {
  color: #111 !important;
  font-weight: 500 !important;
}

.top-actions .account-button,
.top-actions .cart-button {
  color: #111 !important;
  border-color: transparent !important;
}

/* The announcement is added by cart.js on pages that don't already have one. */
.announcement-bar {
  height: 38px;
  background: var(--swt-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 850px) {
  .topbar { background: var(--swt-cream) !important; }
}

/* New Small World Things mobile header */
@media (max-width: 850px) {
  .mobile-menu-toggle {
    display:flex!important;
    width:38px!important;
    height:38px!important;
    min-width:38px!important;
    border:0!important;
    border-radius:12px!important;
    background:transparent!important;
    color:#173f35!important;
    font-size:24px!important;
  }
  .topbar .nav-links{display:none!important}
}

.mobile-nav .mobile-account-link{
  font-weight:600;
}

@media (max-width: 600px) {
  header.topbar .top-actions .account-button {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

@media (max-width: 850px) {
  .swt-mobile-menu .mobile-account-link {
    font-weight: 600;
  }
}
