/*!
 * CraftyWorth Component Classes
 * ═══════════════════════════════════════════════════════
 * USE THESE IN HTML — they handle responsive automatically.
 * Never write custom CSS for basic layout/components.
 * ═══════════════════════════════════════════════════════
 */

/* ── CONTAINERS ──────────────────────────────────────── */
.cw-container {
  width: 100%;
  max-width: var(--cw-container-lg, 1320px);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--cw-gutter, 40px);
  padding-right: var(--cw-gutter, 40px);
  box-sizing: border-box;
}
.cw-container--sm  { max-width: var(--cw-container-sm,  760px); }
.cw-container--md  { max-width: var(--cw-container-md, 1100px); }
.cw-container--xl  { max-width: var(--cw-container-xl, 1600px); }

/* ── SECTION ─────────────────────────────────────────── */
.cw-section {
  padding-top: var(--cw-space-16, 64px);
  padding-bottom: var(--cw-space-16, 64px);
}
.cw-section--sm {
  padding-top: var(--cw-space-10, 40px);
  padding-bottom: var(--cw-space-10, 40px);
}
.cw-section--off { background: var(--cw-surface, #FEF7F0); }
.cw-section--dark { background: var(--cw-ink, #1A1208); color: #fff; }

/* ── GRIDS ───────────────────────────────────────────── */
/* Auto-fill grids — most common pattern */
.cw-grid {
  display: grid;
  gap: var(--cw-space-6, 20px);
}
.cw-grid-2 { grid-template-columns: repeat(2, 1fr); }
.cw-grid-3 { grid-template-columns: repeat(3, 1fr); }
.cw-grid-4 { grid-template-columns: repeat(4, 1fr); }
.cw-grid-auto { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.cw-grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); }

/* ── FLEX LAYOUTS ────────────────────────────────────── */
.cw-stack  { display: flex; flex-direction: column; gap: var(--cw-space-5, 16px); }
.cw-cluster{ display: flex; flex-wrap: wrap; gap: var(--cw-space-4, 12px); align-items: center; }
.cw-between{ display: flex; align-items: center; justify-content: space-between; gap: var(--cw-space-4, 12px); }
.cw-center { display: flex; align-items: center; justify-content: center; gap: var(--cw-space-4, 12px); }

/* ── CARDS ───────────────────────────────────────────── */
.cw-card {
  background: var(--cw-bg, #fff);
  border: 1px solid var(--cw-line, #EAD9CC);
  border-radius: var(--cw-radius-card, 14px);
  padding: var(--cw-space-8, 24px);
  overflow: hidden;
}
.cw-card--hover {
  transition: transform var(--cw-dur-base) var(--cw-ease),
              box-shadow var(--cw-dur-base) var(--cw-ease);
}
.cw-card--hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--cw-shadow-card, 0 4px 20px -4px rgba(160,41,62,.12));
}

/* ── BUTTONS ─────────────────────────────────────────── */
.cw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--cw-radius-btn, 999px);
  font-family: var(--cw-font-body, system-ui);
  font-size: var(--cw-text-sm, 13px);
  font-weight: var(--cw-weight-bold, 700);
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--cw-dur-base) var(--cw-ease);
  white-space: nowrap;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cw-btn--primary {
  background: var(--cw-primary);
  color: #fff;
  border-color: var(--cw-primary);
}
.cw-btn--primary:hover { background: var(--cw-primary-dark); border-color: var(--cw-primary-dark); }
.cw-btn--accent {
  background: var(--cw-accent);
  color: #fff;
  border-color: var(--cw-accent);
}
.cw-btn--accent:hover { background: var(--cw-accent-dark); border-color: var(--cw-accent-dark); }
.cw-btn--outline {
  background: transparent;
  color: var(--cw-primary);
  border-color: var(--cw-primary);
}
.cw-btn--outline:hover { background: var(--cw-primary); color: #fff; }
.cw-btn--ghost {
  background: var(--cw-surface);
  color: var(--cw-ink);
  border-color: var(--cw-line);
}
.cw-btn--ghost:hover { background: var(--cw-line); }
.cw-btn--sm { padding: 7px 14px; font-size: var(--cw-text-xs); min-height: 36px; }
.cw-btn--lg { padding: 14px 28px; font-size: var(--cw-text-md); min-height: 52px; }
.cw-btn--full { width: 100%; }

/* ── BADGES ──────────────────────────────────────────── */
.cw-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--cw-radius-full);
  font-size: var(--cw-text-xs);
  font-weight: var(--cw-weight-bold);
  white-space: nowrap;
}
.cw-badge--primary { background: var(--cw-primary); color: #fff; }
.cw-badge--accent  { background: var(--cw-accent);  color: #fff; }
.cw-badge--success { background: var(--cw-success-bg); color: var(--cw-success); }
.cw-badge--warning { background: var(--cw-warning-bg); color: var(--cw-warning); }
.cw-badge--error   { background: var(--cw-error-bg);   color: var(--cw-error); }
.cw-badge--info    { background: var(--cw-info-bg);    color: var(--cw-info); }
.cw-badge--outline { background: transparent; border: 1px solid currentColor; }

/* ── FORMS ───────────────────────────────────────────── */
.cw-input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--cw-line);
  border-radius: var(--cw-radius-md);
  background: var(--cw-bg);
  color: var(--cw-ink);
  font-family: var(--cw-font-body);
  font-size: 16px; /* iOS zoom prevention */
  transition: border-color var(--cw-dur-base) var(--cw-ease);
  box-sizing: border-box;
}
.cw-input:focus {
  outline: none;
  border-color: var(--cw-primary);
  box-shadow: 0 0 0 3px var(--cw-primary-light);
}
.cw-input--error { border-color: var(--cw-error); }
.cw-textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; }
.cw-label {
  display: block;
  font-size: var(--cw-text-xs);
  font-weight: var(--cw-weight-bold);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--cw-ink-3);
  margin-bottom: 6px;
}
.cw-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--cw-space-5);
}
.cw-form-group { display: flex; flex-direction: column; gap: 6px; }

/* ── DIVIDERS ────────────────────────────────────────── */
.cw-divider {
  border: none;
  border-top: 1px solid var(--cw-line);
  margin: var(--cw-space-8) 0;
}

/* ── ASPECT RATIOS ───────────────────────────────────── */
.cw-ratio-1-1  { aspect-ratio: 1 / 1; }
.cw-ratio-4-3  { aspect-ratio: 4 / 3; }
.cw-ratio-16-9 { aspect-ratio: 16 / 9; }
.cw-ratio-3-2  { aspect-ratio: 3 / 2; }

/* ── VISIBILITY ──────────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile  { display: none !important; }
  .show-mobile  { display: block !important; }
  .show-mobile-flex { display: flex !important; }
  .cw-grid-2, .cw-grid-3, .cw-grid-4 { grid-template-columns: 1fr; }
  .cw-form-row { grid-template-columns: 1fr; }
  .cw-section { padding-top: var(--cw-space-10, 40px); padding-bottom: var(--cw-space-10, 40px); }
}
@media (max-width: 1024px) {
  .cw-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .cw-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 769px) {
  .hide-desktop  { display: none !important; }
  .show-desktop  { display: block !important; }
}

/* ── TABLE WRAPPER ───────────────────────────────────── */
.cw-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.cw-table-wrap table { min-width: 480px; }
