/* ========================================
   THEME SEMANTIC - Layer 3
   Semantic aliases for easy usage

   Uses .themed class as the common selector for both:
   - .preview-frame (theme editor)
   - .shop-root (public shop pages)
   ======================================== */

.themed {
  /* Apply base theme colors */
  background-color: var(--t-surface-base);
  color: var(--t-text-primary);
  font-family: var(--t-font-body);

  /* Accent color - HSL components set dynamically by CSS generator */
  --t-accent-h: 24;
  --t-accent-s: 95%;
  --t-accent-l: 53%;

  --t-accent: hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l));
  --t-accent-hover: hsl(var(--t-accent-h) var(--t-accent-s) calc(var(--t-accent-l) - 8%));
  --t-accent-subtle: hsl(var(--t-accent-h) 40% 95%);
  --t-accent-ring: hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l) / 0.4);

  /* WCAG AA compliant accent variants for better contrast */
  /* Darker accent for text on light backgrounds (4.5:1 with white) */
  --t-accent-text: hsl(var(--t-accent-h) var(--t-accent-s) 38%);
  /* Darker accent for button backgrounds to ensure 4.5:1 with white text */
  --t-accent-button: hsl(var(--t-accent-h) var(--t-accent-s) 42%);

  /* Secondary colors */
  --t-secondary-accent: #ea580c;
  --t-sale-color: #dc2626;

  /* Font size scale - all sizes use em so they scale with --t-font-size-scale */
  --t-font-size-scale: 1;
  --t-heading-weight: 600;

  /*
   * Type Scale - Limited to 6 body sizes for design consistency
   * These use em units so they scale with the base font size setting
   * Body: caption, small, base, large
   * Display: xl, 2xl (for headings and hero text)
   */
  --t-text-caption: 0.75em;
  --t-text-small: 0.875em;
  --t-text-base: 1em;
  --t-text-large: 1.125em;
  --t-text-xl: 1.25em;
  --t-text-2xl: 1.5em;

  /* Fluid heading sizes - scale smoothly between mobile and desktop */
  --t-heading-sm: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --t-heading-md: clamp(1.25rem, 1rem + 1vw, 1.5rem);
  --t-heading-lg: clamp(1.5rem, 1rem + 2vw, 2rem);
  --t-heading-xl: clamp(1.875rem, 1.25rem + 2.5vw, 2.5rem);
  --t-heading-display: clamp(2.25rem, 1.5rem + 3vw, 3rem);

  /* Layout */
  --t-layout-max-width: 1400px;
  --t-button-style: filled;
  --t-card-shadow: none;
  --t-product-text-align: left;

  /* Page colors */
  --color-page: var(--t-surface-base);
  --color-card: var(--t-surface-raised);
  --color-input: var(--t-surface-raised);

  /* Text colors */
  --color-heading: var(--t-text-primary);
  --color-body: var(--t-text-secondary);
  --color-caption: var(--t-text-tertiary);

  /* Button colors */
  --color-button-primary: var(--t-accent);
  --color-button-primary-hover: var(--t-secondary-accent);
  --color-button-primary-text: var(--t-text-inverse);

  /* Border colors */
  --color-border: var(--t-border-default);

  /* Typography */
  --font-heading: var(--t-font-heading);
  --font-body: var(--t-font-body);
  --weight-heading: var(--t-heading-weight);
  --tracking-heading: var(--t-heading-tracking);

  /* Density-aware spacing */
  --space-xs: calc(var(--p-space-2) * var(--t-density));
  --space-sm: calc(var(--p-space-3) * var(--t-density));
  --space-md: calc(var(--p-space-4) * var(--t-density));
  --space-lg: calc(var(--p-space-6) * var(--t-density));
  --space-xl: calc(var(--p-space-8) * var(--t-density));
  --space-2xl: calc(var(--p-space-12) * var(--t-density));

  /* Border radius */
  --radius-button: var(--t-radius-button);
  --radius-card: var(--t-radius-card);
  --radius-input: var(--t-radius-input);
  --radius-image: var(--t-radius-image);

  /* Shadows */
  --shadow-sm:
    0 1px 2px hsl(var(--p-shadow-color) / calc(var(--p-shadow-strength) * 0.5)),
    0 1px 3px hsl(var(--p-shadow-color) / var(--p-shadow-strength));
  --shadow-md:
    0 2px 4px hsl(var(--p-shadow-color) / calc(var(--p-shadow-strength) * 0.5)),
    0 4px 8px hsl(var(--p-shadow-color) / var(--p-shadow-strength)),
    0 8px 16px hsl(var(--p-shadow-color) / calc(var(--p-shadow-strength) * 0.5));

  /* Transitions */
  --transition-fast: var(--p-duration-fast) var(--p-ease-out);
  --transition-normal: var(--p-duration-normal) var(--p-ease-out);
  --transition-bounce: var(--p-duration-normal) var(--p-ease-out-back);

  /* Dark mode accent-subtle override */
  &[data-mood="dark"] {
    --t-accent-subtle: hsl(var(--t-accent-h) 30% 15%);
  }
}

/* ========================================
   ACCESSIBILITY - Focus Rings
   Visible focus indicators for all interactive elements
   ======================================== */

.shop-container {
  line-height: 1.5;

  /* Base focus ring style */
  & a:focus-visible,
  & button:focus-visible,
  & input:focus-visible,
  & select:focus-visible,
  & textarea:focus-visible,
  & [tabindex]:focus-visible,
  & details summary:focus-visible {
    outline: 2px solid hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l));
    outline-offset: 2px;
  }

  /* Remove default browser outlines when using focus-visible */
  & a:focus:not(:focus-visible),
  & button:focus:not(:focus-visible),
  & input:focus:not(:focus-visible),
  & select:focus:not(:focus-visible),
  & textarea:focus:not(:focus-visible) {
    outline: none;
  }

  /* Minimum touch target size (44x44px) */
  & .header-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  & .filter-pill {
    min-height: 44px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Heading line-heights - tighter for large text */
  & h1 {
    line-height: 1.1;
    letter-spacing: -0.025em;
  }

  & h2 {
    line-height: 1.15;
    letter-spacing: -0.02em;
  }

  & h3 {
    line-height: 1.2;
    letter-spacing: -0.015em;
  }

  & h4,
  & h5,
  & h6 {
    line-height: 1.25;
    letter-spacing: -0.01em;
  }

  /* Small text - slightly wider tracking for readability */
  & .text-xs,
  & .text-sm,
  & .t-caption,
  & .t-small {
    letter-spacing: 0.01em;
  }

  /* Prose content - ideal 65ch for comfortable reading */
  & .prose,
  & .product-description,
  & .about-content {
    max-width: 65ch;
  }

  /* Slightly wider for collection/category descriptions */
  & .collection-description {
    max-width: 75ch;
  }
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l));
  color: var(--t-text-inverse);
  padding: 0.75rem 1.5rem;
  z-index: 9999;
  border-radius: var(--t-radius-button);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
  outline: none;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--t-text-primary);
  outline-offset: 2px;
}

/* Stretched link: makes a parent container fully clickable via ::after overlay */
.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Nav link styling with active state indicator */
.shop-nav a,
.shop-nav span {
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.shop-nav a:hover {
  color: var(--t-text-primary);
}

.shop-nav a[aria-current="page"],
.shop-nav span[aria-current="page"] {
  color: var(--t-text-primary);
  border-bottom-color: hsl(var(--t-accent-h) var(--t-accent-s) var(--t-accent-l));
}
