/* ==========================================================================
   Totally Impressive · Design Studio
   Brand Palette: White, Warm Wood Brown (#6b4423 / #8a5a2b), Gold (#c9a227), Black
   Zero external assets — system font stacks only
   ========================================================================== */

:root {
  --bg-page: #f5f2ed;
  --bg-surface: #ffffff;
  --bg-subtle: #faf8f5;
  --bg-studio-top: #ece7df;
  --bg-studio-bottom: #dfd7cb;

  --ink-black: #141416;
  --ink-primary: #1f1d1b;
  --ink-secondary: #5c544b;
  --ink-muted: #7a7066;

  --wood-dark: #4e3017;
  --wood-base: #6b4423;
  --wood-warm: #8a5a2b;
  --wood-soft: #f2e8dc;

  --gold-base: #c9a227;
  --gold-bright: #e0bb42;
  --gold-dark: #9c7a14;
  --gold-soft: rgba(201, 162, 39, 0.14);

  --border-light: #e2dbd0;
  --border-strong: #c9bfb0;
  --danger: #9c2b2b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 3px rgba(20, 18, 16, 0.06), 0 4px 12px rgba(20, 18, 16, 0.04);
  --shadow-focus: 0 0 0 3px rgba(201, 162, 39, 0.42);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dynamic garment color variable (updated by JS) */
  --garment-hex: #1d1d1f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.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;
}

/* ==========================================================================
   Header
   ========================================================================== */

.studio-header {
  background-color: var(--ink-black);
  border-bottom: 3px solid var(--gold-base);
  color: var(--gold-base);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold-dark));
  color: var(--ink-black);
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--gold-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sep {
  color: rgba(201, 162, 39, 0.55);
  margin: 0 3px;
}

.studio-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #efe7d8;
  background: rgba(138, 90, 43, 0.34);
  border: 1px solid rgba(201, 162, 39, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ==========================================================================
   Main Layout (Desktop 2-Column)
   ========================================================================== */

.studio-main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 24px 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  align-items: start;
}

/* ==========================================================================
   Garment Stage Column
   ========================================================================== */

.stage-column {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 14px;
  position: sticky;
  top: 74px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stage-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stage-summary {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.stage-dims {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

/* Soft Pro Print-Shop Studio Backdrop */
.studio-backdrop {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background:
    radial-gradient(circle at 50% 34%, #f8f6f2 0%, var(--bg-studio-top) 58%, var(--bg-studio-bottom) 100%);
  padding: 18px 16px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.garment-root {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 600 / 660;
}

.garment-svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Show only the active garment group */
.garment-group {
  display: none;
}

.garment-root[data-garment="shirt"] #shirtGroup {
  display: inline;
}

.garment-root[data-garment="sweatshirt"] #sweatshirtGroup {
  display: inline;
}

/* Garment fill & SVG blend layers */
.garment-base,
.garment-collar {
  fill: var(--garment-hex);
  transition: fill 160ms ease;
}

.garment-outline {
  fill: none;
  stroke: rgba(20, 18, 16, 0.16);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.garment-root[data-color="white"] .garment-outline {
  stroke: rgba(60, 52, 44, 0.24);
}

.garment-root[data-color="black"] .garment-outline {
  stroke: rgba(0, 0, 0, 0.55);
}

.blend-multiply {
  mix-blend-mode: multiply;
}

.blend-screen {
  mix-blend-mode: screen;
}

/* Keep highlights crisp on very dark garments so 3D folds stay clear */
.garment-root[data-color="black"] .blend-screen {
  opacity: 1;
}

.fabric-noise-layer {
  opacity: 0.28;
  mix-blend-mode: overlay;
}

.heather-layer {
  opacity: 0;
  mix-blend-mode: multiply;
  transition: opacity 150ms ease;
}

.garment-root[data-color="heather-gray"] .heather-layer {
  opacity: 0.72;
}

.seam-line {
  stroke: rgba(0, 0, 0, 0.2);
  stroke-width: 1.4;
}

.stitch-dashed {
  stroke: rgba(0, 0, 0, 0.26);
  stroke-width: 1.25;
  stroke-dasharray: 3.5 2.5;
  stroke-linecap: round;
}

.garment-root[data-color="black"] .seam-line,
.garment-root[data-color="navy"] .seam-line {
  stroke: rgba(255, 255, 255, 0.14);
}

.garment-root[data-color="black"] .stitch-dashed,
.garment-root[data-color="navy"] .stitch-dashed {
  stroke: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   Printable Front Imprint Zone (12" x 14" proportional)
   ========================================================================== */

.print-area {
  position: absolute;
  left: 32%;
  top: 25.5%;
  width: 36%;
  height: 38.2%;
  border: 1.5px dashed rgba(201, 162, 39, 0.9);
  background: transparent;
  border-radius: 3px;
  transition: border-color 150ms ease;
}

.garment-root[data-color="white"] .print-area,
.garment-root[data-color="heather-gray"] .print-area {
  border-color: rgba(107, 68, 35, 0.72);
  background: transparent;
}

.print-area-label {
  position: absolute;
  top: -19px;
  left: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-bright);
  background: rgba(20, 20, 22, 0.72);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}

.garment-root[data-color="white"] .print-area-label {
  color: #fff;
  background: rgba(107, 68, 35, 0.82);
}

/* Clean Preview hides guide box, label, and selection handles */
.garment-root[data-guide="hidden"] .print-area {
  border-color: transparent;
  background: transparent;
}

.garment-root[data-guide="hidden"] .print-area-label,
.garment-root[data-guide="hidden"] .resize-handle {
  display: none;
}

.garment-root[data-guide="hidden"] .design-wrapper {
  outline-color: transparent;
}

/* Subtle fold/shading overlay over the print area so art looks printed on cloth */
.print-fabric-overlay {
  position: absolute;
  left: 32%;
  top: 25.5%;
  width: 36%;
  height: 38.2%;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.55;
  z-index: 6;
}

/* ==========================================================================
   Direct-Manipulation Design Element
   ========================================================================== */

.design-wrapper {
  position: absolute;
  left: 5%;
  top: 6%;
  width: 90%;
  height: 40%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline: 1.5px solid rgba(201, 162, 39, 0.85);
  outline-offset: 1px;
  z-index: 4;
}

.design-wrapper:active,
.design-wrapper.is-dragging {
  cursor: grabbing;
}

.design-wrapper:focus-visible {
  outline: 2px solid var(--gold-bright);
}

.design-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  opacity: 0.96;
  filter: contrast(1.02);
}

.design-ink-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      rgba(0, 0, 0, 0.03) 1px,
      rgba(0, 0, 0, 0.03) 2px
    );
  mix-blend-mode: soft-light;
}

/* Bottom-right corner resize handle */
.resize-handle {
  position: absolute;
  right: -9px;
  bottom: -9px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--ink-black);
  background: var(--gold-base);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  touch-action: none;
  z-index: 8;
  transition: transform 100ms ease, background-color 100ms ease;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-right: 2px solid var(--ink-black);
  border-bottom: 2px solid var(--ink-black);
}

.resize-handle:hover,
.resize-handle:focus-visible {
  background: var(--gold-bright);
  transform: scale(1.1);
  outline: none;
}

.stage-hint {
  margin: 10px 2px 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-align: center;
}

/* ==========================================================================
   Control Rail Panels
   ========================================================================== */

.control-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 15px 16px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}

.panel-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--wood-dark);
}

.panel-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--wood-base);
}

.panel-sub {
  font-size: 0.74rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

/* Garment Selector */
.garment-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.garment-btn {
  appearance: none;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.garment-btn:hover {
  border-color: var(--wood-warm);
}

.garment-btn.is-active {
  background: var(--wood-soft);
  border-color: var(--wood-base);
  box-shadow: inset 0 0 0 1px var(--wood-base);
}

.garment-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.garment-btn-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.garment-btn-meta {
  font-size: 0.74rem;
  color: var(--ink-secondary);
}

/* Color Swatches */
.swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch-btn {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(20, 18, 16, 0.16);
  background-color: var(--swatch-hex);
  cursor: pointer;
  position: relative;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.swatch-btn.swatch-light {
  border-color: #c5bdb2;
}

.swatch-btn.swatch-heather {
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    radial-gradient(rgba(0, 0, 0, 0.22) 1px, transparent 1px);
  background-size: 6px 6px;
  background-position: 0 0, 3px 3px;
}

.swatch-btn:hover {
  transform: translateY(-1px);
}

.swatch-btn.is-active {
  border-color: var(--ink-black);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4.5px var(--gold-base);
}

.swatch-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Upload Drop Zone */
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 16px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.drop-zone.is-dragover {
  border-color: var(--gold-base);
  background: var(--gold-soft);
}

.drop-zone-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--wood-soft);
  color: var(--wood-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.drop-zone-text {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.upload-btn {
  cursor: pointer;
}

.active-file-bar {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.active-file-label {
  color: var(--ink-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.active-file-name {
  color: var(--ink-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-section {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-light);
}

.sample-heading {
  margin: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.sample-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-toggle {
  background: var(--ink-black);
  color: var(--gold-bright);
  border-color: var(--ink-black);
  padding: 7px 12px;
  font-size: 0.79rem;
  white-space: nowrap;
}

.btn-toggle[aria-pressed="false"] {
  background: var(--bg-subtle);
  color: var(--ink-primary);
  border-color: var(--border-strong);
}

.btn-secondary {
  background: var(--wood-base);
  color: #ffffff;
  border-color: var(--wood-dark);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--wood-warm);
}

.btn-sample {
  background: var(--bg-subtle);
  color: var(--ink-primary);
  border-color: var(--border-strong);
  justify-content: flex-start;
  text-align: left;
  padding: 8px 11px;
}

.btn-sample:hover:not(:disabled) {
  border-color: var(--gold-base);
  background: var(--wood-soft);
}

.preset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 13px;
}

.btn-preset {
  background: var(--bg-subtle);
  color: var(--ink-primary);
  border-color: var(--border-strong);
}

.btn-preset:hover:not(:disabled) {
  border-color: var(--wood-base);
  background: var(--wood-soft);
}

.btn-preset.is-active {
  background: var(--ink-black);
  color: var(--gold-bright);
  border-color: var(--ink-black);
}

.slider-group {
  margin-bottom: 13px;
}

.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.slider-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.slider-readout {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--wood-dark);
  font-variant-numeric: tabular-nums;
}

.size-slider {
  width: 100%;
  accent-color: var(--wood-base);
  cursor: pointer;
}

.size-slider:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-primary);
  border-color: var(--border-strong);
  flex: 1 1 auto;
  font-size: 0.79rem;
  padding: 7px 9px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--wood-base);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(156, 43, 43, 0.35);
  font-size: 0.79rem;
  padding: 7px 10px;
}

.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(156, 43, 43, 0.08);
  border-color: var(--danger);
}

/* Add to Order & Confirmation */
.order-card {
  background: linear-gradient(180deg, #ffffff 0%, #faf6f0 100%);
  border-color: #dfd3c2;
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold-base) 100%);
  color: var(--ink-black);
  border-color: var(--gold-dark);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #e8c652 0%, #d3ac2e 100%);
}

.btn-order {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
}

.order-note {
  margin: 8px 0 0;
  font-size: 0.74rem;
  color: var(--ink-muted);
  text-align: center;
}

.order-confirm {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: calc(100vw - 48px);
  max-width: 420px;
  z-index: 100;
  margin: 0;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  background: var(--ink-black);
  color: #f7f4ee;
  border: 1.5px solid var(--gold-base);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.36);
}

.order-confirm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.35);
}

.order-confirm-title {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--gold-bright);
  line-height: 1.35;
}

.btn-close {
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  width: 26px;
  height: 26px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: rgba(201, 162, 39, 0.25);
  border-color: var(--gold-base);
}

.order-details {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.8rem;
}

.order-details dt {
  color: #bfb5a5;
  font-weight: 600;
}

.order-details dd {
  margin: 0;
  color: #ffffff;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-word;
}

.confirm-chip {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive Single-Column Layout (< 820px, verified for 390x844)
   ========================================================================== */

@media (max-width: 820px) {
  .header-inner {
    padding: 11px 14px;
  }

  .brand-title {
    font-size: 0.98rem;
  }

  .studio-badge {
    display: none;
  }

  .studio-main {
    grid-template-columns: 1fr;
    padding: 12px 12px 28px;
    gap: 14px;
  }

  .stage-column {
    position: static;
    padding: 12px 12px 10px;
  }

  .stage-toolbar {
    gap: 8px;
  }

  .stage-summary {
    font-size: 0.86rem;
  }

  .studio-backdrop {
    padding: 12px 8px 14px;
  }

  .garment-root {
    max-width: 440px;
  }

  .panel-card {
    padding: 13px 14px;
  }

  .swatch-btn {
    width: 36px;
    height: 36px;
  }

  .resize-handle {
    width: 24px;
    height: 24px;
    right: -11px;
    bottom: -11px;
  }

  .order-confirm {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    padding: 14px;
  }
}
