/* =========================================================
   CAPS LOCKER — design tokens
   Palette: Canvas (raw cotton bg), Charcoal (header/ink),
            Thread Red (primary accent), Stitch Gold (price/secondary)
   Type: Archivo Black (display, patch-lettering feel) + Inter (body)
   Signature: dashed "running stitch" rule used as the recurring motif
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --canvas: #F2EEE3;
  --charcoal: #1C1B1A;
  --ink: #2B2825;
  --thread-red: #C23D2E;
  --thread-red-dark: #A12F22;
  --stitch-gold: #D4A23A;
  --line: #DDD6C4;
  --muted: #8A8378;
  --white: #FFFFFF;
  --success: #3E7A4A;
  --radius: 10px;
  --shadow: 0 4px 18px rgba(28,27,26,0.08);
  --font-display: 'Archivo Black', 'Arial Black', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--thread-red); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 3px solid var(--stitch-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Signature motif: running stitch divider ---------- */
.stitch-rule {
  border: none;
  border-top: 2px dashed var(--charcoal);
  opacity: 0.18;
  margin: 0;
}
.stitch-rule--gold { border-top-color: var(--stitch-gold); opacity: 0.45; }

.stitch-frame {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Header ---------- */
.site-header {
  background: var(--charcoal);
  border-bottom: 3px dashed var(--stitch-gold);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.logo {
  font-family: var(--font-display);
  color: var(--canvas);
  font-size: 22px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.logo span { color: var(--thread-red); }
.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav a {
  color: var(--canvas);
  font-weight: 500;
  font-size: 14px;
  opacity: 0.85;
}
.nav a:hover { opacity: 1; text-decoration: none; color: var(--stitch-gold); }
.nav a.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.nav .badge-soon {
  font-size: 10px;
  background: var(--stitch-gold);
  color: var(--charcoal);
  padding: 1px 6px;
  border-radius: 20px;
  margin-left: 4px;
  vertical-align: middle;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--canvas);
  font-size: 24px;
  cursor: pointer;
}

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--charcoal);
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 20px 24px;
    gap: 16px;
    display: none;
    border-bottom: 3px dashed var(--stitch-gold);
    z-index: 50;
  }
  .nav.open { display: flex; }
  .site-header__inner { position: relative; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 50px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--thread-red);
  color: var(--white);
}
.btn-primary:hover { background: var(--thread-red-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--muted); cursor: not-allowed; transform: none; }
.btn-outline {
  background: transparent;
  border-color: var(--charcoal);
  color: var(--charcoal);
}
.btn-outline:hover { background: var(--charcoal); color: var(--canvas); }
.btn-ghost {
  background: transparent;
  color: var(--charcoal);
  padding: 10px 16px;
}
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---------- Hero / Carousel ---------- */
.hero {
  padding: 48px 0 40px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 6vw, 56px);
  line-height: 1.05;
  margin: 0 0 12px;
  color: var(--charcoal);
}
.hero h1 em {
  font-style: normal;
  color: var(--thread-red);
}
.hero p {
  max-width: 480px;
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 16px;
}

.carousel {
  position: relative;
  padding: 0 0 16px;
}
.carousel__track {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px 20px 20px;
  scrollbar-width: thin;
}
.carousel__track::-webkit-scrollbar { height: 6px; }
.carousel__track::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.cap-card {
  scroll-snap-align: start;
  flex: 0 0 240px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
  transition: transform 0.2s ease;
  position: relative;
}
.cap-card:hover { transform: translateY(-4px); }
.cap-card__img-wrap {
  aspect-ratio: 1 / 1;
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.cap-card__img-wrap img { width: 100%; height: 100%; object-fit: contain; padding: 18px; }
.cap-card__body { padding: 14px 16px 18px; }
.cap-card__name { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.cap-card__price { color: var(--thread-red); font-weight: 700; font-size: 15px; margin: 0 0 12px; }
.cap-card .btn { width: 100%; }

.out-of-stock-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--charcoal);
  color: var(--canvas);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
}
.cap-card.is-out-of-stock .cap-card__img-wrap img { opacity: 0.4; filter: grayscale(0.6); }
.cap-card.is-out-of-stock .btn { background: var(--muted); pointer-events: none; }

.carousel-arrow {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  background: var(--white);
  border: 1px solid var(--line);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 5;
  font-size: 18px;
}
.carousel-arrow--left { left: -6px; }
.carousel-arrow--right { right: -6px; }
@media (max-width: 720px) { .carousel-arrow { display: none; } }

/* ---------- Section headers ---------- */
.section-eyebrow {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--thread-red);
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
}
.section-title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--charcoal);
  margin: 0 0 24px;
}

/* ---------- Customizer page ---------- */
.customizer {
  padding: 32px 0 64px;
}
.customizer__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}
@media (max-width: 880px) {
  .customizer__grid { grid-template-columns: 1fr; }
}

.preview-stage {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  position: sticky;
  top: 20px;
}
@media (max-width: 880px) { .preview-stage { position: static; } }

.preview-canvas-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--canvas);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-canvas-wrap img.cap-base {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.preview-text-layer {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  max-width: 80%;
  overflow: visible;
}
.preview-text-layer svg text {
  fill: var(--ink);
}
.preview-logo-layer {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.preview-logo-layer img { width: 100%; object-fit: contain; }

.preview-price-tag {
  margin-top: 20px;
  background: var(--charcoal);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-price-tag .label { color: var(--canvas); opacity: 0.7; font-size: 13px; }
.preview-price-tag .amount {
  font-family: var(--font-display);
  color: var(--stitch-gold);
  font-size: 26px;
}
.preview-price-tag .breakdown {
  font-size: 11px;
  color: var(--canvas);
  opacity: 0.55;
  margin-top: 2px;
}

.controls-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.field-group { margin-bottom: 24px; }
.field-group:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--charcoal);
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.text-input, select.text-input, textarea.text-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--white);
  color: var(--ink);
}
.text-input:focus { border-color: var(--thread-red); outline: none; }

.char-counter { font-size: 12px; color: var(--muted); text-align: right; margin-top: 4px; }
.char-counter.is-limit { color: var(--thread-red); }

.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--thread-red);
  cursor: pointer;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 1px var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--thread-red);
  cursor: pointer;
  border: 3px solid var(--white);
}
.slider-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
  min-width: 38px;
  text-align: right;
}

.radio-row { display: flex; gap: 10px; }
.radio-pill { flex: 1; position: relative; }
.radio-pill input { position: absolute; opacity: 0; }
.radio-pill label {
  display: block;
  text-align: center;
  padding: 11px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.radio-pill input:checked + label {
  border-color: var(--thread-red);
  background: rgba(194,61,46,0.06);
  color: var(--thread-red);
  font-weight: 600;
}

.font-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.font-pill { position: relative; }
.font-pill input { position: absolute; opacity: 0; }
.font-pill label {
  display: block;
  text-align: center;
  padding: 14px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
}
.font-pill input:checked + label {
  border-color: var(--thread-red);
  background: rgba(194,61,46,0.06);
}

.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch { position: relative; }
.color-swatch input { position: absolute; opacity: 0; }
.color-swatch label {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--line);
}
.color-swatch input:checked + label { box-shadow: 0 0 0 2px var(--thread-red); }

.upload-zone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.upload-zone:hover { border-color: var(--thread-red); }
.upload-zone input { display: none; }
.upload-zone__text { font-size: 14px; color: var(--muted); }
.upload-zone__filename { font-size: 13px; color: var(--thread-red); font-weight: 600; margin-top: 6px; }
.upload-remove {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.qty-stepper button {
  background: var(--canvas);
  border: none;
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
  color: var(--charcoal);
}
.qty-stepper input {
  width: 56px;
  text-align: center;
  border: none;
  font-size: 15px;
  font-weight: 600;
  height: 42px;
}

/* ---------- Forms (account / checkout) ---------- */
.form-page { max-width: 480px; margin: 0 auto; padding: 48px 0 80px; }
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.form-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 6px;
  color: var(--charcoal);
}
.form-card .subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-row input, .form-row textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font-body);
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--thread-red); outline: none; }
.form-foot { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert-error { background: #FBE9E6; color: var(--thread-red-dark); border: 1px solid #F0C5BD; }
.alert-success { background: #E8F2EA; color: var(--success); border: 1px solid #BFE0C8; }

/* ---------- Order summary / receipt ---------- */
.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row.total { font-weight: 700; font-size: 17px; color: var(--charcoal); }
.summary-thumb { display: flex; gap: 14px; align-items: center; }
.summary-thumb img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--canvas);
  border-radius: 6px;
}

.status-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: capitalize;
}
.status-received { background: #EFE7D8; color: #8a6d2f; }
.status-in_process { background: #DCEAF7; color: #2c5d82; }
.status-shipped { background: #E1F0E3; color: var(--success); }
.status-paid { background: #E1F0E3; color: var(--success); }
.status-pending { background: #F7E9D8; color: #9a6b1f; }
.status-failed { background: #FBE2DF; color: var(--thread-red-dark); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--charcoal);
  color: var(--canvas);
  padding: 36px 0 24px;
  margin-top: 60px;
}
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.site-footer a { color: var(--canvas); opacity: 0.75; }
.site-footer .copy { font-size: 12px; opacity: 0.5; margin-top: 18px; width: 100%; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--line);
}
table.data-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }

.spinner {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
