/*
 * CraftWorks Premium Modern Industrial — Design Tokens
 * M-WEB-THEME-R1 | mycraftworks.com
 * No gaming neon, no heavy glow, no dashboard density
 */

:root {
  /* ── Colors ── */
  --cw-graphite: #1A1D21;
  --cw-charcoal: #24282E;
  --cw-charcoal-light: #2E3339;
  --cw-copper: #B87333;
  --cw-copper-hover: #A3662E;
  --cw-gold: #C9A227;
  --cw-gold-muted: rgba(201, 162, 39, 0.15);
  --cw-text: #F5F0E8;
  --cw-text-muted: #A8A29E;
  --cw-text-subtle: #78716C;
  --cw-border: rgba(245, 240, 232, 0.08);
  --cw-border-strong: rgba(245, 240, 232, 0.14);
  --cw-success: #4ADE80;
  --cw-error: #F87171;

  /* Semantic aliases (map to legacy vars where needed) */
  --bg-primary: var(--cw-graphite);
  --bg-secondary: var(--cw-charcoal);
  --bg-tertiary: var(--cw-charcoal-light);
  --accent-orange: var(--cw-copper);
  --accent-orange-rgb: 184, 115, 51;
  --accent-gold: var(--cw-gold);
  --accent-gold-rgb: 201, 162, 39;
  --accent-orange-hover: var(--cw-copper-hover);
  --text-light: var(--cw-text);
  --text-muted: var(--cw-text-muted);
  --text-dark: var(--cw-graphite);
  --border-color: var(--cw-border);
  --border-color-glow: rgba(184, 115, 51, 0.25);
  --glass-bg: rgba(36, 40, 46, 0.92);
  --glass-border: var(--cw-border);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);

  /* ── Spacing ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ── Typography ── */
  --font-heading: 'Outfit', 'Prompt', 'Noto Sans Thai', sans-serif;
  --font-body: 'Prompt', 'Outfit', 'Noto Sans Thai', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-thai: 1.6;

  /* ── Radius ── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --border-radius-sm: var(--radius-sm);
  --border-radius-md: var(--radius-md);
  --border-radius-lg: var(--radius-lg);

  /* ── Borders ── */
  --border-width: 1px;
  --border-default: var(--border-width) solid var(--cw-border);
  --border-strong: var(--border-width) solid var(--cw-border-strong);
  --border-accent: var(--border-width) solid var(--cw-copper);

  /* ── Shadows (subtle, no neon glow) ── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.35);

  /* ── Containers ── */
  --max-width: 1280px;
  --container-padding: var(--space-6);
  --header-row1-height: 64px;
  --header-row2-height: 48px;

  /* ── Breakpoints (reference) ── */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1440px;

  /* ── Transitions ── */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  /* ── Buttons ── */
  --btn-height-sm: 32px;
  --btn-height-md: 40px;
  --btn-height-lg: 48px;
  --btn-padding-x-sm: var(--space-3);
  --btn-padding-x-md: var(--space-5);
  --btn-padding-x-lg: var(--space-6);
  --btn-font-weight: 600;
  --btn-primary-bg: var(--cw-copper);
  --btn-primary-hover: var(--cw-copper-hover);
  --btn-primary-text: var(--cw-graphite);
  --btn-secondary-bg: transparent;
  --btn-secondary-border: var(--cw-border-strong);
  --btn-secondary-text: var(--cw-text);

  /* ── Forms ── */
  --input-height: 44px;
  --input-bg: var(--cw-graphite);
  --input-border: var(--cw-border-strong);
  --input-border-focus: var(--cw-copper);
  --input-radius: var(--radius-md);
  --input-padding-x: var(--space-4);
  --input-text: var(--cw-text);
  --input-placeholder: var(--cw-text-subtle);

  /* ── Cards ── */
  --card-bg: var(--cw-charcoal);
  --card-border: var(--cw-border);
  --card-radius: var(--radius-lg);
  --card-padding: var(--space-5);

  /* ── Navigation ── */
  --nav-link-color: var(--cw-text-muted);
  --nav-link-hover: var(--cw-text);
  --nav-link-active: var(--cw-copper);
  --nav-link-size: var(--text-sm);
  --nav-gap: var(--space-6);

  /* ── R2 Phase 1 ── */
  --cw-matte-black: #121416;
  --cw-bronze: #9A6B3F;
  --cw-warm-white: #F5F0E8;
  --section-gap: var(--space-16);
  --section-gap-sm: var(--space-10);
  --content-max: 1200px;
  --product-cover-ratio: 4 / 5;
  --header-r2-height: 72px;
  --nav-r2-height: 52px;
  --card-cover-min-h: 280px;

  /* ── Visual Hook Batch 1 (3100-036) — overlays / texture / motion helpers ── */
  --cw-image-overlay-start: rgba(18, 20, 22, 0.92);
  --cw-image-overlay-mid: rgba(18, 20, 22, 0.55);
  --cw-image-overlay-end: rgba(18, 20, 22, 0.22);
  --cw-texture-opacity: 0.04;
  --cw-section-border: var(--cw-border-strong);
  --cw-hero-min-vh: 82vh;
  --cw-hero-max-vh: 88vh;
  --cw-reveal-distance: 12px;
  --cw-reveal-duration: 0.4s;
  --cw-brand-divider: linear-gradient(90deg, var(--cw-copper), transparent);

  /* ── Unified semantic tokens (FE + Backoffice) — COMMAND 3100-002 ── */
  --color-bg: var(--cw-matte-black);
  --color-surface: var(--cw-graphite);
  --color-surface-elevated: var(--cw-charcoal);
  --color-primary: var(--cw-copper);
  --color-primary-hover: var(--cw-copper-hover);
  --color-text: var(--cw-text);
  --color-muted: var(--cw-text-muted);
  --color-border: var(--cw-border);
  --radius: var(--radius-md);
  --shadow: var(--shadow-md);
  --control-height: var(--input-height);

  /*
   * ── 062B Global storefront foundation (semantic aliases) ──
   * Breakpoint custom properties are DOCUMENTATION + JS/layout reference only.
   * Do NOT use them inside @media() in this no-build stack.
   *
   * Canonical map (literal px in stylesheets):
   *   COMPACT  max-width: 480px   (--bp-compact / --bp-sm)
   *   MOBILE   max-width: 767px   (< --bp-mobile / --bp-md)
   *   TABLET   768px–1023px
   *   DESKTOP  min-width: 1024px  (--bp-desktop / --bp-lg)
   *   NAV      max-width: 900px   component-specific (theme-r2 header/hamburger)
   */
  --bp-compact: 480px;
  --bp-mobile: 768px;
  --bp-tablet-min: 768px;
  --bp-tablet-max: 1023px;
  --bp-desktop: 1024px;
  --bp-nav: 900px;

  --surface-page: var(--color-bg);
  --surface-elevated: var(--color-surface-elevated);
  --surface-card: var(--card-bg);
  --surface-subtle: var(--cw-charcoal-light);

  --text-primary: var(--cw-text);
  --text-secondary: var(--cw-text-muted);

  --border-standard: var(--cw-border);
  --border-subtle: rgba(245, 240, 232, 0.05);

  --product-image-ratio: var(--product-cover-ratio);
  --product-card-gap: var(--space-6);
  --product-card-radius: var(--card-radius);

  --price-normal: var(--cw-text);
  --price-effective: var(--cw-warm-white);
  --price-reference: var(--cw-text-muted);
  --price-promo-fg: var(--cw-copper);
  --price-promo-bg: rgba(184, 115, 51, 0.14);
  --price-promo-border: rgba(184, 115, 51, 0.4);

  --stock-ready-fg: #86efac;
  --stock-mto-fg: var(--cw-copper);
  --stock-low-fg: var(--cw-gold);
  --stock-out-fg: var(--cw-text-muted);

  --type-display: clamp(1.75rem, 4vw, 2.75rem);
  --type-h1: clamp(1.5rem, 3vw, 2.25rem);
  --type-h2: clamp(1.25rem, 2.4vw, 1.75rem);
  --type-h3: var(--text-lg);
  --type-body: var(--text-base);
  --type-meta: var(--text-sm);
  --type-product-name: var(--text-base);
  --type-price: var(--text-lg);
}

/* Shared UI states — reusable across storefront + backoffice */
.cw-empty {
  text-align: center;
  color: var(--color-muted);
  font-size: var(--text-sm);
  padding: var(--space-10) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: rgba(245, 240, 232, 0.02);
}
.cw-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  min-height: var(--control-height);
}
.cw-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: cw-spin 0.7s linear infinite;
}
@keyframes cw-spin {
  to { transform: rotate(360deg); }
}
.cw-alert {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
}
.cw-alert-success {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--cw-success);
}
.cw-alert-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--cw-error);
}
.cw-focus-ring:focus-visible,
.cw-focus-ring:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.is-disabled,
[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Visual Hook helpers */
.cw-brand-divider {
  display: block;
  width: 48px;
  height: 2px;
  background: var(--cw-brand-divider);
  border: 0;
  margin: var(--space-4) 0;
}
.cw-image-overlay {
  position: relative;
  isolation: isolate;
}
.cw-image-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    var(--cw-image-overlay-start) 0%,
    var(--cw-image-overlay-mid) 48%,
    var(--cw-image-overlay-end) 100%
  );
  pointer-events: none;
  z-index: 0;
}
.cw-section-texture {
  position: relative;
}
.cw-section-texture::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: var(--cw-texture-opacity);
  background-image: radial-gradient(circle at 1px 1px, rgba(245, 240, 232, 0.45) 1px, transparent 0);
  background-size: 18px 18px;
  pointer-events: none;
  z-index: 0;
}
.cw-reveal {
  opacity: 0;
  transform: translateY(var(--cw-reveal-distance));
  transition: opacity var(--cw-reveal-duration) ease, transform var(--cw-reveal-duration) ease;
}
.cw-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .cw-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .cw-loading::before {
    animation: none;
  }
}
