/* CSS Custom Properties for consistent spacing and timing values */
:root {
  /* Menu spacing and dimensions */
  --yk-menu-transition-duration: 0.3s;
  --yk-menu-transition-timing: cubic-bezier(0.22, 0.61, 0.36, 1);
  --yk-menu-scroll-height: 80px;
  --yk-menu-default-height: 100px;
  --yk-menu-positioning-transition: 0.1s ease-in-out;
  
  /* Z-index values for consistent layering */
  --yk-sticky-menu-z-index: 1000;
  --yk-menu-default-z-index: 50;
  
  /* Menu icon sizes */
  --yk-menu-icon-size-default: 28px; /* 7 * 4px (w-7 h-7) */
  --yk-menu-icon-size-scrolled: 24px; /* 6 * 4px (w-6 h-6) */
  
  /* Common transition values */
  --yk-transition-fast: 0.1s ease-in-out;
  --yk-transition-medium: 0.3s ease;
  --yk-transition-slow: 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.wp-block[data-align='full'] {
  max-width: none !important;
}

.yk-mainmenu {
  margin: 0 !important;
}

/* Set dark mode */
body[data-dark-mode='true'] {
  color-scheme: dark;
  color-scheme: dark only;
  /* Add additional logic to toggle WordPress variables here */
}

/* Set light mode */
body[data-dark-mode='false'] {
  color-scheme: light;
  color-scheme: light only;
}

.is-layout-flow > * {
  margin-block-start: 0;
  margin-block-end: 0;
}

.error-404 {
  text-align: center;
  padding: var(--wp--preset--spacing--40) 0;
}

.error-404 .page-title {
  font-size: var(--wp--preset--font-size--large);
  color: var(--wp--preset--color--contrast);
  margin-bottom: var(--wp--preset--spacing--30);
}

.error-404 .page-content {
  color: var(--wp--preset--color--contrast-2);
  max-width: 600px;
  margin: 0 auto;
}

.error-404 .page-content a {
  display: inline-block;
  margin-top: var(--wp--preset--spacing--30);
  color: var(--wp--preset--color--yk-primary);
  text-decoration: none;
}

.error-404 .page-content a:hover {
  text-decoration: underline;
}

.yk-scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
}

.yk-scroll-top .scroll-top-button {
  color: var(--wp--preset--color--base);
  transition:
    opacity 0.3s ease-in-out,
    transform 0.3s ease-in-out;
  cursor: pointer;
  border: none;
  padding: 0;
  display: flex;
}

.yk-scroll-top .scroll-top-button:hover {
  transform: translateY(-5px);
}

.yk-scroll-top .scroll-top-button svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.yk-scroll-top .scroll-top-button div {
  border-color: var(--wp--preset--color--base);
}

@media (max-width: 768px) {
  .yk-scroll-top {
    bottom: 1rem;
    right: 1rem;
  }

  .yk-scroll-top .scroll-top-button div {
    width: 2.5rem;
    height: 2.5rem;
  }

  .yk-scroll-top .scroll-top-button svg {
    width: 28px;
    height: 28px;
  }
}

/* Language switcher styles */
.mobile-language-switcher {
  padding: 15px;
  border-top: 1px solid #eee;
  text-align: left;
}

.wpml-language-selector {
  width: 100%;
  padding: 8px;
  border: 1px solid #eee;
  border-radius: 4px;
  background-color: white;
  color: #333;
  font-size: 14px;
}

@media (min-width: 768px) {
  .mobile-language-switcher {
    display: none;
  }
}

/* Use grid layout for the entire page */
body {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  margin: 0;
}

:root {
  --header-height: 120px;
}

@media (max-width: 768px) {
  :root {
    --header-height: 80px;
  }
}

/* Remove page title pages */
.wp-block-post-title {
  display: none;
}
/* Exclude WooCommerce pages */
.woocommerce .wp-block-post-title {
  display: block !important;
}
/* Exclude Blog Post pages */
.wp-block-post .wp-block-post-title {
  display: block !important;
}

/* Focus styles for links and dropdown titles */
a:focus,
.yk-dropdown-button,
.yk-dropdown-title:focus {
  outline: none;
}

/* Add a different focus indicator for accessibility */
a:focus-visible,
.yk-dropdown-button,
.yk-dropdown-title:focus-visible {
  outline: 2px solid var(--wp--preset--color--accent);
  outline-offset: 2px;
}

/* Remove outline for mouse users while keeping it for keyboard navigation */
a:focus:not(:focus-visible),
.yk-dropdown-button:focus:not(:focus-visible),
.yk-dropdown-title:focus:not(:focus-visible) {
  outline: none;
}

main#wp--skip-link--target {
  margin-block-start: 0 !important;
}

footer.wp-block-template-part {
  margin-block-start: 0 !important;
}

/* Quantity Selector Styles */
.yk-quantity-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
  max-width: 160px;
}

.yk-quantity-minus,
.yk-quantity-plus {
  background-color: var(--wp--preset--color--yk-primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.yk-quantity-minus {
  border-right: none;
}

.yk-quantity-plus {
  border-left: none;
}

.yk-quantity-minus:hover,
.yk-quantity-plus:hover {
  background-color: var(--wp--preset--color--yk-primary-55);
}

.yk-quantity-selector .quantity {
  flex: 1;
}

.yk-quantity-selector .qty {
  width: 80px !important;
  text-align: center !important;
  margin: 0 !important;
  height: 40px !important;
  border: 1px solid #ddd !important;
  font-size: 16px !important;
  font-weight: bold !important;
  -moz-appearance: textfield !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

.yk-quantity-selector .qty::-webkit-outer-spin-button,
.yk-quantity-selector .qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.yk-quantity-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0;
  margin-top: 0;
  width: 100%;
  border-collapse: collapse;
}

.yk-quantity-preset {
  background-color: white;
  border: 1px solid #ddd;
  padding: 8px 0;
  cursor: pointer;
  font-weight: normal;
  transition: all 0.2s ease;
  text-align: center;
  margin: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Position the preset buttons in the exact layout from the screenshot */
.yk-quantity-preset:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.yk-quantity-preset:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.yk-quantity-preset:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}

.yk-quantity-preset:nth-child(4) {
  grid-column: 1;
  grid-row: 2;
}

.yk-quantity-preset:nth-child(5) {
  grid-column: 2;
  grid-row: 2;
}

/* Hide any additional presets */
/* .yk-quantity-preset:nth-child(n + 6) {
  display: none;
} */

.yk-quantity-preset:hover {
  background-color: #f5f5f5;
}

.yk-quantity-preset.active {
  background-color: var(--wp--preset--color--yk-primary);
  color: white;
  border-color: var(--wp--preset--color--yk-primary);
}

/* YK Quantity Grid - Wine products (2x3 layout with presets) */
.yk-quantity-grid.yk-wine-product {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto;
  width: 100%;
  max-width: 140px;
  border-collapse: collapse;
  margin-bottom: 15px;
  gap: 1px;
}

/* YK Quantity Grid - Non-wine products (single row layout, no presets) */
.yk-quantity-grid.yk-non-wine-product {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr;
  width: 100%;
  max-width: 140px;
  border-collapse: collapse;
  margin-bottom: 15px;
  gap: 1px;
}

/* Legacy support for existing grid without specific product type class */
.yk-quantity-grid:not(.yk-wine-product):not(.yk-non-wine-product) {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto;
  width: 100%;
  max-width: 140px;
  border-collapse: collapse;
  margin-bottom: 15px;
  gap: 1px;
}

/* Position grid items explicitly to match the layout in the screenshot */
.yk-quantity-grid > div {
  border: 1px solid #ddd;
  margin: 0;
  padding: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* First row - control buttons */
.yk-quantity-minus {
  grid-column: 1;
  grid-row: 1;
  background-color: var(--wp--preset--color--yk-primary);
  color: white;
}

.yk-quantity-current {
  width: 60px;
  grid-column: 2;
  grid-row: 1;
  background-color: white;
}

.yk-quantity-plus {
  grid-column: 3;
  grid-row: 1;
  background-color: var(--wp--preset--color--yk-primary);
  color: white;
}

/* Auto-layout for preset quantities */
.yk-quantity-preset {
  background-color: white;
  cursor: pointer;
  font-weight: normal;
  transition: all 0.2s ease;
}

/* Shared styling for grid items */
.yk-quantity-minus,
.yk-quantity-plus {
  font-weight: bold;
  cursor: pointer;
  user-select: none;
}

.yk-quantity-minus:hover,
.yk-quantity-plus:hover {
  background-color: var(--wp--preset--color--yk-primary-55);
}

.yk-quantity-current {
  cursor: default;
  font-size: 16px;
}

/* Preset quantity buttons */
.yk-quantity-preset {
  background-color: white;
  transition: background-color 0.2s ease;
}

.yk-quantity-preset:hover {
  background-color: #f5f5f5;
}

.yk-quantity-preset.active {
  background-color: var(--wp--preset--color--yk-primary-30);
}

/* Container for quantity selector and add to cart button */
.yk-quantity-container {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

/* Make sure form is sized correctly */
form.cart {
  max-width: none;
}

/* Adjust add to cart button placement */
.single_add_to_cart_button {
  margin-top: 0 !important;
  background-color: var(--wp--preset--color--yk-accent) !important;
  color: black !important;
  border: none !important;
  padding: 10px 24px !important;
  font-weight: bold !important;
  text-transform: uppercase !important;
  transition: background-color 0.2s ease !important;
  width: auto !important;
  border-radius: 0 !important;
  align-self: stretch !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Override the .button class margin-top specifically for the Add to Cart button */
.yk-quantity-container .single_add_to_cart_button.button {
  margin-top: 0 !important;
}

.single_add_to_cart_button:hover {
  background-color: var(--wp--preset--color--yk-secondary) !important;
  color: black !important;
}

/* Accordion details */
details summary {
  position: relative;
  cursor: pointer;
  list-style: none;
  padding: 15px 15px 15px 15px;
  margin-bottom: 0.75em; /* Space before the answer text */
  border-bottom: 0.5px solid #3d3d3d;
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--medium);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--wp--preset--color--grey) !important;
}
details summary::after {
  content: '﹢'; /* Unicode: U+FE62 */
  color: #68b8cf;
  font-size: 3.5rem;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}
details[open] summary::after {
  content: '﹣'; /* U+FE63 */
  color: #68b8cf;
  font-size: 3.5rem;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
}
/* Apply bottom border only when the details is CLOSED */
details:not([open]) summary {
  border-bottom: 0.5px solid #3d3d3d;
}
/* Remove border when open */
details[open] summary {
  border-bottom: none;
}
/* Remove detail black arrow marker */
.wp-block-details summary::-webkit-details-marker {
  display: none;
}
.wp-block-details summary::marker {
  display: none;
}

details[open] p {
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (max-width: 767px) {
  details summary::after {
    font-size: 4.5rem;
    top: 32%;
  }
  details[open] summary::after {
    font-size: 4.5rem;
    top: 32%;
  }
}
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
  details summary::after {
    font-size: 3.5rem;
    top: 50%;
  }
  details[open] summary::after {
    font-size: 3.5rem;
    top: 50%;
  }
}
/* Default (no invert) */
.invert-on-mobile {
  filter: none;
}

/* Apply invert on screens <= 768px */
@media (max-width: 1050px) {
  .invert-on-mobile {
    filter: invert(1);
  }
}

/* Cloudflare Turnstile Styling */
.cf-turnstile {
  margin: 20px 0 !important;
  display: flex !important;
  justify-content: flex-start !important;
  align-items: center !important;
}

/* Turnstile container styling to match form theme */
.cf-turnstile iframe {
  border-radius: 5px !important;
  border: 1px solid #ccc !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Turnstile error message styling */
.turnstile-error {
  color: var(--wp--preset--color--yk-accent) !important;
  font-size: 14px !important;
  font-family: "raleway", sans-serif !important;
  margin-top: 8px !important;
  margin-bottom: 5px !important;
  padding: 8px 12px !important;
  background-color: rgba(122, 31, 56, 0.1) !important;
  border: 1px solid var(--wp--preset--color--yk-accent) !important;
  border-radius: 5px !important;
  display: block !important;
}

/* Turnstile success state (when verified) */
.cf-turnstile.turnstile-verified {
  opacity: 0.8;
}

/* Turnstile loading state */
.cf-turnstile.turnstile-loading::after {
  content: "Loading security verification...";
  display: block;
  font-size: 14px;
  color: #666;
  margin-top: 8px;
  font-style: italic;
}

/* Responsive Turnstile on mobile */
@media only screen and (max-width: 600px) {
  .cf-turnstile {
    margin: 15px 0 !important;
    justify-content: center !important;
  }
  
  .cf-turnstile iframe {
    max-width: 100% !important;
    transform: scale(0.9) !important;
    transform-origin: center !important;
  }
  
  .turnstile-error {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }
}

/* Integration with Contact Form 7 layout */
.wpcf7-form .cf-turnstile {
  width: 100% !important;
  margin-bottom: 20px !important;
}

/* Dark mode support for Turnstile (if theme supports it) */
@media (prefers-color-scheme: dark) {
  .cf-turnstile iframe {
    border-color: #555 !important;
    background-color: #2a2a2a !important;
  }
  
  .turnstile-error {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ff6b6b !important;
    border-color: #ff6b6b !important;
  }
}

/* Hide reCAPTCHA when Turnstile is active */
.turnstile-active .grecaptcha-badge,
.turnstile-active .g-recaptcha {
  display: none !important;
}

/* ===== TOP MENU POSITIONING SYSTEM ===== */
/* Top menu should appear above main menu */
.yk-topmenu {
  z-index: 9999 !important; /* Higher than main menu's z-50 */
}

/* CSS fallback: When top menu is present, push main menu down */
.yk-topmenu:not(:empty) ~ .yk-mainmenu [style*='position: fixed'],
.yk-topmenu:not(:empty) ~ .yk-mainmenu .yk-sticky-header,
.yk-topmenu:not(:empty) ~ .yk-mainmenu header[style*='position'] {
  top: 48px !important; /* Fallback height */
}

/* More specific CSS fallback targeting common sticky patterns */
body:has(.yk-topmenu:not(:empty)) .yk-mainmenu [style*='position: fixed'] {
  top: 48px !important;
}

/* Smooth transition for main menu position changes */
.yk-mainmenu [style*='position: fixed'],
.yk-mainmenu .yk-sticky-header,
.yk-mainmenu header[style*='position'] {
  transition: top 0.1s ease-in-out !important;
}

/* Also target any sticky positioned elements in main menu */
.yk-mainmenu [style*='position: sticky'] {
  transition: top 0.1s ease-in-out !important;
}
