/**
 * UK Image Block Styles
 * Custom image block styles for Gutenberg editor
 * 
 * SEO & Accessibility Optimized:
 * - Preserves image accessibility
 * - Reduced motion support
 * - High contrast mode support
 * - Focus state preservation
 */

/* Base Frame Styles */
.wp-block-image.cosw-image-frame,
.wp-block-image[class*="is-style-"][class*="-frame"] {
  position: relative;
  display: inline-block;
  margin: 30px auto;
  width: fit-content;
  --uk-image-frame-color: #4cbcc0;
}

.wp-block-image[class*="is-style-"][class*="-frame"] img {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: -17px 16px 0 0 var(--uk-image-frame-color);
}

.wp-block-image.cosw-image-frame img {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: -17px 16px 0 0 var(--uk-image-frame-color);
}

/* Shadow Position Variants */
.wp-block-image.cosw-frame-position-right-lower img,
.wp-block-image[class*="is-style-"][class*="-frame-right-lower"] img {
  box-shadow: 17px 16px 0 0 var(--uk-image-frame-color);
}

.wp-block-image.cosw-frame-position-left-upper img,
.wp-block-image[class*="is-style-"][class*="-frame-left-upper"] img {
  box-shadow: -17px -16px 0 0 var(--uk-image-frame-color);
}

.wp-block-image.cosw-frame-position-right-upper img,
.wp-block-image[class*="is-style-"][class*="-frame-right-upper"] img {
  box-shadow: 17px -16px 0 0 var(--uk-image-frame-color);
}

/* Legacy (no explicit position) defaults to left-lower */

/* Color Variants */
.wp-block-image.cosw-frame-color-blue,
.wp-block-image[class*="is-style-blue-frame"] {
  --uk-image-frame-color: #0046ad;
}

.wp-block-image.cosw-frame-color-yellow,
.wp-block-image[class*="is-style-yellow-frame"] {
  --uk-image-frame-color: #ffdc00;
}

.wp-block-image.cosw-frame-color-green,
.wp-block-image[class*="is-style-green-frame"] {
  --uk-image-frame-color: #4cbcc0;
}

.wp-block-image.cosw-frame-color-sunset,
.wp-block-image[class*="is-style-sunset-frame"] {
  --uk-image-frame-color: #ffa360;
}

.wp-block-image.cosw-frame-color-light-blue,
.wp-block-image[class*="is-style-light-blue-frame"] {
  --uk-image-frame-color: #1e8aff;
}

.wp-block-image.cosw-frame-color-dark-blue,
.wp-block-image[class*="is-style-dark-blue-frame"] {
  --uk-image-frame-color: #1b365d;
}

.wp-block-image.cosw-image-frame {
  margin-right: 0;
}

.wp-block-image[class*="is-style-"][class*="-frame"] {
  margin-right: 0;
}

/* Responsive adjustments */
@media (max-width: 782px) {
  .wp-block-image[class*="is-style-"][class*="-frame"] img {
    box-shadow: -12px 12px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-right-lower img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-lower"] img {
    box-shadow: 12px 12px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-left-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-left-upper"] img {
    box-shadow: -12px -12px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-right-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-upper"] img {
    box-shadow: 12px -12px 0 0 var(--uk-image-frame-color);
  }
}

@media (max-width: 480px) {
  .wp-block-image[class*="is-style-"][class*="-frame"] {
    margin: 20px auto;
  }

  .wp-block-image[class*="is-style-"][class*="-frame"] img {
    box-shadow: -10px 10px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-right-lower img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-lower"] img {
    box-shadow: 10px 10px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-left-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-left-upper"] img {
    box-shadow: -10px -10px 0 0 var(--uk-image-frame-color);
  }

  .wp-block-image.cosw-frame-position-right-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-upper"] img {
    box-shadow: 10px -10px 0 0 var(--uk-image-frame-color);
  }
}

/* Accessibility: Ensure images remain accessible */
.wp-block-image.cosw-image-frame img,
.wp-block-image[class*="is-style-"][class*="-frame"] img {
  /* Preserve image accessibility - don't hide or obscure images */
  object-fit: contain;
}

/* Accessibility: Preserve focus states for linked images */
.wp-block-image.cosw-image-frame a:focus-visible img,
.wp-block-image[class*="is-style-"][class*="-frame"] a:focus-visible img {
  outline: 3px solid #FFDC00; /* High contrast yellow */
  outline-offset: 2px;
  box-shadow: -17px 16px 0 0 var(--uk-image-frame-color),
              0 0 0 3px rgba(255, 220, 0, 0.5),
              0 0 0 5px rgba(0, 51, 160, 0.3); /* Blue shadow for depth */
}

.wp-block-image.cosw-frame-position-right-lower a:focus-visible img,
.wp-block-image[class*="is-style-"][class*="-frame-right-lower"] a:focus-visible img {
  box-shadow: 17px 16px 0 0 var(--uk-image-frame-color),
              0 0 0 3px rgba(255, 220, 0, 0.5),
              0 0 0 5px rgba(0, 51, 160, 0.3);
}

.wp-block-image.cosw-frame-position-left-upper a:focus-visible img,
.wp-block-image[class*="is-style-"][class*="-frame-left-upper"] a:focus-visible img {
  box-shadow: -17px -16px 0 0 var(--uk-image-frame-color),
              0 0 0 3px rgba(255, 220, 0, 0.5),
              0 0 0 5px rgba(0, 51, 160, 0.3);
}

.wp-block-image.cosw-frame-position-right-upper a:focus-visible img,
.wp-block-image[class*="is-style-"][class*="-frame-right-upper"] a:focus-visible img {
  box-shadow: 17px -16px 0 0 var(--uk-image-frame-color),
              0 0 0 3px rgba(255, 220, 0, 0.5),
              0 0 0 5px rgba(0, 51, 160, 0.3);
}

/* Accessibility: Reduced motion support (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  .wp-block-image.cosw-image-frame img,
  .wp-block-image[class*="is-style-"][class*="-frame"] img {
    /* Keep box-shadow but remove any transitions/animations */
    transition: none !important;
    animation: none !important;
  }
}

/* Image Title Overlay */
.wp-block-image.cosw-image-has-title,
.cosw-image-title-editor-wrapper {
    position: relative;
}

.cosw-image-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    z-index: 2;
    pointer-events: none; /* Allow clicks to pass through to image */
}

.cosw-image-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    font-family: "usual", sans-serif;
    line-height: 1.3;
}

/* Responsive adjustments for title overlay */
@media (max-width: 768px) {
    .cosw-image-title-overlay {
        padding: 1rem;
    }
    
    .cosw-image-title {
        font-size: 16px;
    }
}

/* Accessibility: High contrast mode support (WCAG 1.4.11) */
@media (prefers-contrast: high) {
  .wp-block-image.cosw-image-frame,
  .wp-block-image[class*="is-style-"][class*="-frame"] {
    border: 2px solid CanvasText;
  }
  
  .wp-block-image.cosw-image-frame img,
  .wp-block-image[class*="is-style-"][class*="-frame"] img {
    /* Ensure frame is visible in high contrast mode */
    box-shadow: -17px 16px 0 0 CanvasText !important;
    border: 1px solid CanvasText;
  }
  
  .wp-block-image.cosw-frame-position-right-lower img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-lower"] img {
    box-shadow: 17px 16px 0 0 CanvasText !important;
  }
  
  .wp-block-image.cosw-frame-position-left-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-left-upper"] img {
    box-shadow: -17px -16px 0 0 CanvasText !important;
  }
  
  .wp-block-image.cosw-frame-position-right-upper img,
  .wp-block-image[class*="is-style-"][class*="-frame-right-upper"] img {
    box-shadow: 17px -16px 0 0 CanvasText !important;
  }
  
  .wp-block-image.cosw-image-frame a:focus-visible img,
  .wp-block-image[class*="is-style-"][class*="-frame"] a:focus-visible img {
    outline: 3px solid Highlight;
    box-shadow: -17px 16px 0 0 CanvasText !important;
  }
}

