/* Copyright (c) 2025-2026 Spwig contributors. Licensed under AGPL-3.0. */

/**
 * Base CSS Framework - Utilities and Base Styles
 *
 * This file provides utility classes and base styles for the storefront.
 * All values reference CSS custom properties from the theme's tokens.css.
 * This file should load AFTER theme tokens but BEFORE component CSS,
 * so components can override these base defaults.
 *
 * Structure:
 * 1. Reset and Base Styles
 * 2. Typography
 * 3. Layout System
 * 4. Grid System
 * 5. Flexbox Utilities
 * 6. Spacing Utilities
 * 7. Text Utilities
 * 8. Background Utilities
 * 9. Border Utilities
 * 10. Shadow Utilities
 * 11. Display Utilities
 * 12. Position Utilities
 * 13. Size Utilities
 * 14. Transitions
 * 15. Miscellaneous Utilities
 */

/* ==========================================================================
   1. Reset and Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: var(--theme-line-height-normal);
  -webkit-text-size-adjust: 100%;
  font-family: var(--theme-font-sans);
}

body {
  margin: 0;
  color: var(--theme-color-text);
  background-color: var(--theme-color-background);
  font-size: var(--theme-font-size-base);
  line-height: var(--theme-line-height-relaxed);
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   2. Typography
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--theme-space-4) 0;
  font-weight: var(--theme-font-weight-semibold);
  line-height: var(--theme-line-height-tight);
  color: var(--theme-color-text);
}

h1 {
  font-size: var(--theme-font-size-4xl);
}
h2 {
  font-size: var(--theme-font-size-3xl);
}
h3 {
  font-size: var(--theme-font-size-2xl);
}
h4 {
  font-size: var(--theme-font-size-xl);
}
h5 {
  font-size: var(--theme-font-size-lg);
}
h6 {
  font-size: var(--theme-font-size-base);
}

p {
  margin: 0 0 var(--theme-space-4) 0;
}

a:not(.btn) {
  color: var(--theme-color-primary);
  text-decoration: none;
  transition: color var(--theme-transition-duration-fast) var(--theme-transition-easing-default);
}

a:not(.btn):hover {
  color: var(--theme-color-primary-hover);
  text-decoration: underline;
}

/* ==========================================================================
   3. Layout System
   ========================================================================== */
.container {
  max-width: var(--theme-container-max-width);
  margin: 0 auto;
  padding: 0 var(--theme-container-padding);
}

.container-fluid {
  padding: 0 var(--theme-container-padding);
}

.container-narrow {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--theme-container-padding);
}

.container-wide {
  max-width: 1536px;
  margin: 0 auto;
  padding: 0 var(--theme-container-padding);
}

/* ==========================================================================
   4. Grid System
   ========================================================================== */
.grid {
  display: grid;
  gap: var(--theme-space-6);
}

.grid-cols-1 {
  grid-template-columns: repeat(1, 1fr);
}
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.grid-cols-6 {
  grid-template-columns: repeat(6, 1fr);
}
.grid-cols-12 {
  grid-template-columns: repeat(12, 1fr);
}

/* Responsive Grid */
@media (max-width: 768px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-6 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   5. Flexbox Utilities
   ========================================================================== */
.flex {
  display: flex;
}
.inline-flex {
  display: inline-flex;
}
.flex-col {
  flex-direction: column;
}
.flex-row {
  flex-direction: row;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-nowrap {
  flex-wrap: nowrap;
}
.flex-1 {
  flex: 1;
}
.flex-auto {
  flex: auto;
}
.flex-none {
  flex: none;
}

.items-start {
  align-items: flex-start;
}
.items-center {
  align-items: center;
}
.items-end {
  align-items: flex-end;
}
.items-stretch {
  align-items: stretch;
}
.items-baseline {
  align-items: baseline;
}

.justify-start {
  justify-content: flex-start;
}
.justify-center {
  justify-content: center;
}
.justify-end {
  justify-content: flex-end;
}
.justify-between {
  justify-content: space-between;
}
.justify-around {
  justify-content: space-around;
}
.justify-evenly {
  justify-content: space-evenly;
}

/* ==========================================================================
   6. Spacing Utilities
   ========================================================================== */
/* Margin */
.m-0 {
  margin: 0;
}
.m-1 {
  margin: var(--theme-space-1);
}
.m-2 {
  margin: var(--theme-space-2);
}
.m-3 {
  margin: var(--theme-space-3);
}
.m-4 {
  margin: var(--theme-space-4);
}
.m-6 {
  margin: var(--theme-space-6);
}
.m-8 {
  margin: var(--theme-space-8);
}
.m-auto {
  margin: auto;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}
.my-auto {
  margin-top: auto;
  margin-bottom: auto;
}

.mt-0 {
  margin-top: 0;
}
.mt-1 {
  margin-top: var(--theme-space-1);
}
.mt-2 {
  margin-top: var(--theme-space-2);
}
.mt-3 {
  margin-top: var(--theme-space-3);
}
.mt-4 {
  margin-top: var(--theme-space-4);
}
.mt-6 {
  margin-top: var(--theme-space-6);
}
.mt-8 {
  margin-top: var(--theme-space-8);
}
.mt-12 {
  margin-top: var(--theme-space-12);
}
.mt-16 {
  margin-top: var(--theme-space-16);
}

.mb-0 {
  margin-bottom: 0;
}
.mb-1 {
  margin-bottom: var(--theme-space-1);
}
.mb-2 {
  margin-bottom: var(--theme-space-2);
}
.mb-3 {
  margin-bottom: var(--theme-space-3);
}
.mb-4 {
  margin-bottom: var(--theme-space-4);
}
.mb-6 {
  margin-bottom: var(--theme-space-6);
}
.mb-8 {
  margin-bottom: var(--theme-space-8);
}
.mb-12 {
  margin-bottom: var(--theme-space-12);
}
.mb-16 {
  margin-bottom: var(--theme-space-16);
}

.ml-0 {
  margin-left: 0;
}
.ml-1 {
  margin-left: var(--theme-space-1);
}
.ml-2 {
  margin-left: var(--theme-space-2);
}
.ml-3 {
  margin-left: var(--theme-space-3);
}
.ml-4 {
  margin-left: var(--theme-space-4);
}
.ml-auto {
  margin-left: auto;
}

.mr-0 {
  margin-right: 0;
}
.mr-1 {
  margin-right: var(--theme-space-1);
}
.mr-2 {
  margin-right: var(--theme-space-2);
}
.mr-3 {
  margin-right: var(--theme-space-3);
}
.mr-4 {
  margin-right: var(--theme-space-4);
}
.mr-auto {
  margin-right: auto;
}

/* Padding */
.p-0 {
  padding: 0;
}
.p-1 {
  padding: var(--theme-space-1);
}
.p-2 {
  padding: var(--theme-space-2);
}
.p-3 {
  padding: var(--theme-space-3);
}
.p-4 {
  padding: var(--theme-space-4);
}
.p-6 {
  padding: var(--theme-space-6);
}
.p-8 {
  padding: var(--theme-space-8);
}

.px-2 {
  padding-left: var(--theme-space-2);
  padding-right: var(--theme-space-2);
}
.px-3 {
  padding-left: var(--theme-space-3);
  padding-right: var(--theme-space-3);
}
.px-4 {
  padding-left: var(--theme-space-4);
  padding-right: var(--theme-space-4);
}
.px-6 {
  padding-left: var(--theme-space-6);
  padding-right: var(--theme-space-6);
}
.px-8 {
  padding-left: var(--theme-space-8);
  padding-right: var(--theme-space-8);
}

.py-2 {
  padding-top: var(--theme-space-2);
  padding-bottom: var(--theme-space-2);
}
.py-3 {
  padding-top: var(--theme-space-3);
  padding-bottom: var(--theme-space-3);
}
.py-4 {
  padding-top: var(--theme-space-4);
  padding-bottom: var(--theme-space-4);
}
.py-6 {
  padding-top: var(--theme-space-6);
  padding-bottom: var(--theme-space-6);
}
.py-8 {
  padding-top: var(--theme-space-8);
  padding-bottom: var(--theme-space-8);
}
.py-12 {
  padding-top: var(--theme-space-12);
  padding-bottom: var(--theme-space-12);
}
.py-16 {
  padding-top: var(--theme-space-16);
  padding-bottom: var(--theme-space-16);
}

.pt-0 {
  padding-top: 0;
}
.pt-4 {
  padding-top: var(--theme-space-4);
}
.pt-8 {
  padding-top: var(--theme-space-8);
}

.pb-0 {
  padding-bottom: 0;
}
.pb-4 {
  padding-bottom: var(--theme-space-4);
}
.pb-8 {
  padding-bottom: var(--theme-space-8);
}

.pl-0 {
  padding-left: 0;
}
.pl-3 {
  padding-left: var(--theme-space-3);
}
.pl-4 {
  padding-left: var(--theme-space-4);
}
.pl-10 {
  padding-left: var(--theme-space-10);
}

.pr-0 {
  padding-right: 0;
}
.pr-4 {
  padding-right: var(--theme-space-4);
}

/* Gap */
.gap-1 {
  gap: var(--theme-space-1);
}
.gap-2 {
  gap: var(--theme-space-2);
}
.gap-3 {
  gap: var(--theme-space-3);
}
.gap-4 {
  gap: var(--theme-space-4);
}
.gap-6 {
  gap: var(--theme-space-6);
}
.gap-8 {
  gap: var(--theme-space-8);
}

/* Space utilities */
.space-y-2 > * + * {
  margin-top: var(--theme-space-2);
}
.space-y-4 > * + * {
  margin-top: var(--theme-space-4);
}
.space-y-6 > * + * {
  margin-top: var(--theme-space-6);
}
.space-x-2 > * + * {
  margin-left: var(--theme-space-2);
}
.space-x-4 > * + * {
  margin-left: var(--theme-space-4);
}

/* ==========================================================================
   7. Text Utilities
   ========================================================================== */
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

.text-xs {
  font-size: var(--theme-font-size-xs);
}
.text-sm {
  font-size: var(--theme-font-size-sm);
}
.text-base {
  font-size: var(--theme-font-size-base);
}
.text-lg {
  font-size: var(--theme-font-size-lg);
}
.text-xl {
  font-size: var(--theme-font-size-xl);
}
.text-2xl {
  font-size: var(--theme-font-size-2xl);
}
.text-3xl {
  font-size: var(--theme-font-size-3xl);
}
.text-4xl {
  font-size: var(--theme-font-size-4xl);
}

.font-normal {
  font-weight: var(--theme-font-weight-normal);
}
.font-medium {
  font-weight: var(--theme-font-weight-medium);
}
.font-semibold {
  font-weight: var(--theme-font-weight-semibold);
}
.font-bold {
  font-weight: var(--theme-font-weight-bold);
}

/* Text colors using theme tokens */
.text-primary {
  color: var(--theme-color-primary);
}
.text-secondary {
  color: var(--theme-color-secondary);
}
.text-muted {
  color: var(--theme-color-text-muted);
}
.text-success {
  color: var(--theme-color-success);
}
.text-warning {
  color: var(--theme-color-warning);
}
.text-error {
  color: var(--theme-color-error);
}
.text-info {
  color: var(--theme-color-info);
}
.text-white {
  color: white;
}
.text-inverse {
  color: var(--theme-color-text-inverse);
}

/* Line heights */
.leading-none {
  line-height: 1;
}
.leading-tight {
  line-height: var(--theme-line-height-tight);
}
.leading-snug {
  line-height: 1.375;
}
.leading-normal {
  line-height: var(--theme-line-height-normal);
}
.leading-relaxed {
  line-height: var(--theme-line-height-relaxed);
}
.leading-loose {
  line-height: 2;
}

.whitespace-nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   8. Background Utilities
   ========================================================================== */
.bg-white {
  background-color: white;
}
.bg-transparent {
  background-color: transparent;
}
.bg-primary {
  background-color: var(--theme-color-primary);
}
.bg-primary-light {
  background-color: var(--theme-color-primary-light);
}
.bg-secondary {
  background-color: var(--theme-color-secondary);
}
.bg-success {
  background-color: var(--theme-color-success);
}
.bg-success-light {
  background-color: var(--theme-color-success-light);
}
.bg-warning {
  background-color: var(--theme-color-warning);
}
.bg-warning-light {
  background-color: var(--theme-color-warning-light);
}
.bg-error {
  background-color: var(--theme-color-error);
}
.bg-error-light {
  background-color: var(--theme-color-error-light);
}
.bg-info {
  background-color: var(--theme-color-info);
}
.bg-info-light {
  background-color: var(--theme-color-info-light);
}
.bg-surface {
  background-color: var(--theme-color-surface);
}
.bg-surface-hover {
  background-color: var(--theme-color-surface-hover);
}
.bg-background-alt {
  background-color: var(--theme-color-background-secondary);
}

/* ==========================================================================
   9. Border Utilities
   ========================================================================== */
.border {
  border: var(--border-width-1) solid var(--theme-color-border);
}
.border-0 {
  border: 0;
}
.border-t {
  border-top: var(--border-width-1) solid var(--theme-color-border);
}
.border-b {
  border-bottom: var(--border-width-1) solid var(--theme-color-border);
}
.border-l {
  border-left: var(--border-width-1) solid var(--theme-color-border);
}
.border-r {
  border-right: var(--border-width-1) solid var(--theme-color-border);
}

.border-primary {
  border-color: var(--theme-color-primary);
}
.border-secondary {
  border-color: var(--theme-color-secondary);
}
.border-success {
  border-color: var(--theme-color-success);
}
.border-error {
  border-color: var(--theme-color-error);
}
.border-transparent {
  border-color: transparent;
}

.rounded-none {
  border-radius: var(--theme-radius-none);
}
.rounded-sm {
  border-radius: var(--theme-radius-sm);
}
.rounded {
  border-radius: var(--theme-radius-base);
}
.rounded-md {
  border-radius: var(--theme-radius-md);
}
.rounded-lg {
  border-radius: var(--theme-radius-lg);
}
.rounded-xl {
  border-radius: var(--theme-radius-xl);
}
.rounded-2xl {
  border-radius: var(--theme-radius-2xl);
}
.rounded-full {
  border-radius: var(--theme-radius-full);
}

/* ==========================================================================
   10. Shadow Utilities
   ========================================================================== */
.shadow-none {
  box-shadow: var(--theme-shadow-none);
}
.shadow-xs {
  box-shadow: var(--theme-shadow-xs);
}
.shadow-sm {
  box-shadow: var(--theme-shadow-sm);
}
.shadow {
  box-shadow: var(--theme-shadow-base);
}
.shadow-md {
  box-shadow: var(--theme-shadow-md);
}
.shadow-lg {
  box-shadow: var(--theme-shadow-lg);
}
.shadow-xl {
  box-shadow: var(--theme-shadow-xl);
}
.shadow-2xl {
  box-shadow: var(--theme-shadow-2xl);
}
.shadow-inner {
  box-shadow: var(--theme-shadow-inner);
}

/* ==========================================================================
   11. Display Utilities
   ========================================================================== */
.hidden {
  display: none;
}
.block {
  display: block;
}
.inline-block {
  display: inline-block;
}
.inline {
  display: inline;
}

/* Responsive display */
@media (min-width: 640px) {
  .sm\:hidden {
    display: none;
  }
  .sm\:block {
    display: block;
  }
  .sm\:flex {
    display: flex;
  }
  .sm\:inline {
    display: inline;
  }
}

@media (min-width: 768px) {
  .md\:hidden {
    display: none;
  }
  .md\:block {
    display: block;
  }
  .md\:flex {
    display: flex;
  }
  .md\:inline {
    display: inline;
  }
  .md\:grid {
    display: grid;
  }
}

@media (min-width: 1024px) {
  .lg\:hidden {
    display: none;
  }
  .lg\:block {
    display: block;
  }
  .lg\:flex {
    display: flex;
  }
  .lg\:inline {
    display: inline;
  }
}

/* ==========================================================================
   12. Position Utilities
   ========================================================================== */
.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.fixed {
  position: fixed;
}
.sticky {
  position: sticky;
}
.static {
  position: static;
}

.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.inset-x-0 {
  left: 0;
  right: 0;
}
.inset-y-0 {
  top: 0;
  bottom: 0;
}
.top-0 {
  top: 0;
}
.right-0 {
  right: 0;
}
.bottom-0 {
  bottom: 0;
}
.left-0 {
  left: 0;
}

/* Z-index */
.z-0 {
  z-index: var(--theme-z-0);
}
.z-10 {
  z-index: var(--theme-z-10);
}
.z-20 {
  z-index: var(--theme-z-20);
}
.z-30 {
  z-index: var(--theme-z-30);
}
.z-40 {
  z-index: var(--theme-z-40);
}
.z-50 {
  z-index: var(--theme-z-50);
}
.z-dropdown {
  z-index: var(--theme-z-dropdown);
}
.z-modal {
  z-index: var(--theme-z-modal);
}

/* ==========================================================================
   13. Size Utilities
   ========================================================================== */
.w-full {
  width: 100%;
}
.w-auto {
  width: auto;
}
.w-screen {
  width: 100vw;
}
.w-4 {
  width: var(--theme-space-4);
}
.w-5 {
  width: var(--theme-space-5);
}
.w-6 {
  width: var(--theme-space-6);
}
.w-8 {
  width: var(--theme-space-8);
}
.w-10 {
  width: var(--theme-space-10);
}
.w-12 {
  width: var(--theme-space-12);
}
.w-48 {
  width: 12rem;
}

.min-w-0 {
  min-width: 0;
}
.max-w-none {
  max-width: none;
}
.max-w-xs {
  max-width: 20rem;
}
.max-w-sm {
  max-width: 24rem;
}
.max-w-md {
  max-width: 28rem;
}
.max-w-lg {
  max-width: 32rem;
}
.max-w-xl {
  max-width: 36rem;
}
.max-w-2xl {
  max-width: 42rem;
}
.max-w-3xl {
  max-width: 48rem;
}
.max-w-4xl {
  max-width: 56rem;
}
.max-w-5xl {
  max-width: 64rem;
}
.max-w-6xl {
  max-width: 72rem;
}
.max-w-7xl {
  max-width: 80rem;
}
.max-w-full {
  max-width: 100%;
}

.h-auto {
  height: auto;
}
.h-full {
  height: 100%;
}
.h-screen {
  height: 100vh;
}
.h-4 {
  height: var(--theme-space-4);
}
.h-5 {
  height: var(--theme-space-5);
}
.h-6 {
  height: var(--theme-space-6);
}
.h-8 {
  height: var(--theme-space-8);
}
.h-10 {
  height: var(--theme-space-10);
}
.h-12 {
  height: var(--theme-space-12);
}

.min-h-0 {
  min-height: 0;
}
.min-h-full {
  min-height: 100%;
}
.min-h-screen {
  min-height: 100vh;
}

/* ==========================================================================
   14. Transitions
   ========================================================================== */
.transition {
  transition-property:
    background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-timing-function: var(--theme-transition-easing-default);
  transition-duration: var(--theme-transition-duration-fast);
}

.transition-all {
  transition-property: all;
  transition-timing-function: var(--theme-transition-easing-default);
  transition-duration: var(--theme-transition-duration-base);
}

.transition-colors {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: var(--theme-transition-easing-default);
  transition-duration: var(--theme-transition-duration-fast);
}

.transition-opacity {
  transition-property: opacity;
  transition-timing-function: var(--theme-transition-easing-default);
  transition-duration: var(--theme-transition-duration-fast);
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: var(--theme-transition-easing-default);
  transition-duration: var(--theme-transition-duration-fast);
}

.duration-fast {
  transition-duration: var(--theme-transition-duration-fast);
}
.duration-base {
  transition-duration: var(--theme-transition-duration-base);
}
.duration-normal {
  transition-duration: var(--theme-transition-duration-base, 200ms);
}
.duration-slow {
  transition-duration: var(--theme-transition-duration-slow);
}

/* ==========================================================================
   15. Miscellaneous Utilities
   ========================================================================== */
/* Overflow */
.overflow-hidden {
  overflow: hidden;
}
.overflow-auto {
  overflow: auto;
}
.overflow-scroll {
  overflow: scroll;
}
.overflow-x-auto {
  overflow-x: auto;
}
.overflow-y-auto {
  overflow-y: auto;
}
.overflow-x-hidden {
  overflow-x: hidden;
}
.overflow-y-hidden {
  overflow-y: hidden;
}

/* Opacity */
.opacity-0 {
  opacity: 0;
}
.opacity-25 {
  opacity: 0.25;
}
.opacity-50 {
  opacity: 0.5;
}
.opacity-75 {
  opacity: 0.75;
}
.opacity-100 {
  opacity: 1;
}

/* Visibility */
.visible {
  visibility: visible;
}
.invisible {
  visibility: hidden;
}

/* Cursor */
.cursor-pointer {
  cursor: pointer;
}
.cursor-default {
  cursor: default;
}
.cursor-not-allowed {
  cursor: not-allowed;
}

/* Pointer events */
.pointer-events-none {
  pointer-events: none;
}
.pointer-events-auto {
  pointer-events: auto;
}

/* Object fit */
.object-contain {
  object-fit: contain;
}
.object-cover {
  object-fit: cover;
}
.object-fill {
  object-fit: fill;
}
.object-none {
  object-fit: none;
}

/* Transform */
.transform {
  transform: translateZ(0);
}
.rotate-90 {
  transform: rotate(90deg);
}
.rotate-180 {
  transform: rotate(180deg);
}
.-rotate-90 {
  transform: rotate(-90deg);
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.focus\:not-sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: var(--theme-space-2);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* List style */
.list-none {
  list-style: none;
}
.list-disc {
  list-style: disc;
}
.list-decimal {
  list-style: decimal;
}

/* Aspect ratio */
.aspect-square {
  aspect-ratio: 1;
}
.aspect-video {
  aspect-ratio: 16 / 9;
}

/* Group hover states */
.group:hover .group-hover\:visible {
  visibility: visible;
}
.group:hover .group-hover\:opacity-100 {
  opacity: 1;
}
.group:hover .group-hover\:scale-105 {
  transform: scale(1.05);
}

/* ==========================================================================
   Responsive Design Overrides
   ========================================================================== */
@media (max-width: 640px) {
  .container {
    padding: 0 var(--theme-space-4);
  }

  h1 {
    font-size: var(--theme-font-size-3xl);
  }
  h2 {
    font-size: var(--theme-font-size-2xl);
  }
  h3 {
    font-size: var(--theme-font-size-xl);
  }
}

/* ==========================================================================
   16. CKEditor Rich Content Output
   Styles for HTML produced by CKEditor 5 (image alignment, captions,
   media embeds, self-hosted video). These are structural and not
   theme-customisable, so they live here rather than in theme CSS.
   ========================================================================== */

/* Image alignment styles (output by CKEditor 5 ImageStyle plugin) */
.image-style-align-left {
  float: left;
  margin: 0 var(--theme-space-4) var(--theme-space-4) 0;
  max-width: 50%;
}
.image-style-align-right {
  float: right;
  margin: 0 0 var(--theme-space-4) var(--theme-space-4);
  max-width: 50%;
}
.image-style-align-center {
  display: block;
  margin: var(--theme-space-4) auto;
}
.image-style-side {
  float: right;
  margin: 0 0 var(--theme-space-4) var(--theme-space-4);
  max-width: 50%;
}
.image-style-block-align-left {
  display: block;
  margin: var(--theme-space-4) auto var(--theme-space-4) 0;
}
.image-style-block-align-right {
  display: block;
  margin: var(--theme-space-4) 0 var(--theme-space-4) auto;
}

/* CKEditor image figure & resize */
figure.image {
  display: inline-block;
  max-width: 100%;
}
figure.image img {
  display: block;
  max-width: 100%;
  height: auto;
}
figure.image.image_resized {
  max-width: initial;
}
figure.image figcaption {
  text-align: center;
  color: var(--theme-color-text-muted);
  font-size: var(--theme-font-size-sm);
  padding: var(--theme-space-2) 0;
}

/* CKEditor media embeds (YouTube, Vimeo, etc.) */
figure.media {
  margin: var(--theme-space-6) 0;
}
.ck-media__wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--theme-border-radius);
}
.ck-media__wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Self-hosted video from media library */
.media-video {
  margin: var(--theme-space-6) 0;
}
.media-video video {
  width: 100%;
  max-width: 100%;
  border-radius: var(--theme-border-radius);
}

/* Clear floats after content with floated images */
.product-description::after,
.blog-content::after,
.ck-content::after {
  content: '';
  display: table;
  clear: both;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .no-print {
    display: none !important;
  }
}
