/* ============================================================================
   PREVIEWER SKIN — the Letterpress Proof Sheet
   The live monogram render sits on a paper-textured plate with a plate number,
   a date line, a cartouche frame, and "approve your proof" language.
   Loaded only on the product detail page.
   ========================================================================== */

.previewer { display: grid; gap: 30px; }
@media (min-width: 960px) {
  .previewer { grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr); gap: 44px; align-items: start; }
}

/* ── the proof sheet (left) ──────────────────────────────────────────────── */
.proof-sheet {
  border: 1px solid var(--hair-strong);
  background-color: #F2EDE3;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.12 0 0 0 0 0.09 0 0 0 0 0.05 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  padding: 16px;
}
@media (min-width: 768px) { .proof-sheet { padding: 22px; } }

.proof-sheet__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--hair);
}
.proof-sheet__head .eyebrow { margin-bottom: 4px; }
.proof-sheet__no { font-family: var(--f-display); font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.proof-sheet__date { text-align: right; }
.proof-sheet__date p:last-child { font-family: var(--f-display); font-size: 1.05rem; font-weight: 500; color: var(--ink); }

/* stage: product photo + composited render + cartouche overlay */
.proof-sheet__stage { position: relative; }
.stage__scene {
  position: relative; width: 100%; overflow: hidden;
  border: 1px solid var(--hair-strong); background: #efe9df;
}
.stage__scene > img { width: 100%; display: block; }
/* the engine appends .ew-render.ew-on-fabric here (position:absolute) */

/* cartouche frame overlaid on the monogram region */
.stage__cartouche {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%);
  width: 66%; aspect-ratio: 3 / 4; pointer-events: none; z-index: 3;
}
.stage__cartouche svg { width: 100%; height: 100%; overflow: visible; }
.stage__cartouche .c-oval { fill: none; stroke: var(--brass); stroke-width: 1; opacity: 0.9; }
.stage__cartouche .c-tick { fill: var(--brass); opacity: 0.9; }

.proof-sheet__promise {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hair);
  font-family: var(--f-display); font-style: italic; font-weight: 500;
  font-size: 1.15rem; line-height: 1.4; color: var(--ink); text-align: center;
}
.proof-sheet__promise::before { content: "“"; color: var(--brass); }
.proof-sheet__promise::after  { content: "”"; color: var(--brass); }

/* ── controls (right) ────────────────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 22px; }
.ctrl-block { }
.ctrl-legend {
  font-size: var(--step-eyebrow); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.2em; color: var(--meta); margin: 0 0 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.ctrl-legend .num { color: var(--brass-text); font-family: var(--f-display); font-size: 0.95rem; letter-spacing: 0; }

/* segmented toggles (variant + mode) */
.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); }
.segmented button {
  background: transparent; border: 0; cursor: pointer; padding: 12px 8px; min-height: 44px;
  font-size: var(--step-eyebrow); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink); transition: background-color .2s ease, color .2s ease;
}
.segmented button + button { border-left: 1px solid var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--bone); }
.segmented__note { margin-top: 8px; font-size: 0.8125rem; color: var(--meta); }

/* style thumbnails */
.style-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 380px) { .style-thumbs { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 960px) { .style-thumbs { grid-template-columns: repeat(3, 1fr); } }
.style-thumb {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 4px 8px; background: var(--bone); cursor: pointer;
  border: 1px solid var(--hair-strong); transition: border-color .2s ease, background-color .2s ease;
}
.style-thumb:hover { border-color: var(--brass); }
.style-thumb[aria-pressed="true"] { border-color: var(--ink); background: color-mix(in srgb, var(--flax) 60%, var(--bone)); }
.style-thumb__glyph { width: 34px; height: 34px; color: var(--ink); display: flex; align-items: flex-end; justify-content: center; }
.style-thumb__glyph svg { max-width: 100%; max-height: 34px; height: auto; width: auto; display: block; }
.style-thumb__name { font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--meta); }
.style-thumb[aria-pressed="true"] .style-thumb__name { color: var(--ink); }

/* initials */
.initials { display: flex; gap: 12px; }
.initials .field { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: var(--step-eyebrow); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--meta);
}
.field input[type="text"], .field select {
  font-family: var(--f-body); font-size: 1rem; color: var(--ink);
  background: var(--bone); border: 1px solid var(--hair-strong); border-radius: 0;
  padding: 11px 12px; width: 100%;
}
.field input.initial-input {
  text-align: center; text-transform: uppercase;
  font-family: var(--f-display); font-size: 1.6rem; font-weight: 600; padding: 8px 4px;
}
.field select { padding-right: 32px; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2355606E' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--brass-text); outline-offset: 1px; border-color: var(--brass); }

/* etiquette helper */
.etq {
  margin-top: 12px; padding: 12px 14px; background: var(--flax);
  border-left: 2px solid var(--brass);
  font-size: 0.9375rem; line-height: 1.5; color: var(--ink-soft);
}
.etq b { color: var(--ink); font-weight: 600; }
.etq .etq-render { font-family: var(--f-display); font-weight: 600; color: var(--brass-text); font-size: 1.05rem; letter-spacing: 0.04em; }

/* block-style toggle */
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.check span { font-size: 0.9375rem; color: var(--ink-soft); }
.check b { color: var(--ink); font-weight: 600; }

/* thread swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 0; padding: 0; cursor: pointer;
  border: 1px solid var(--hair-strong); box-shadow: inset 0 0 0 2px var(--bone);
  transition: transform .15s ease, box-shadow .15s ease;
}
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--bone), 0 0 0 2px var(--ink); }
.swatch:hover { transform: translateY(-1px); }
.swatch-name { margin-top: 10px; font-size: 0.875rem; color: var(--ink-soft); }
.swatch-name b { color: var(--ink); font-weight: 600; }

/* custom-only block (fabric + welting) */
.custom-only { display: grid; gap: 14px; }
.custom-only[hidden] { display: none; }
.fabric-note { font-size: 0.8125rem; color: var(--meta); margin-top: -2px; }
.fabric-note a { color: var(--brass-text); }

/* add-to-order bar */
.addbar { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.addbar__row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.confirm {
  border: 1px solid var(--brass); background: color-mix(in srgb, var(--flax) 55%, var(--bone));
  padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
}
.confirm[hidden] { display: none; }
.confirm svg { width: 20px; height: 20px; flex: none; color: var(--brass-text); margin-top: 2px; }
.confirm p { font-size: 0.9375rem; color: var(--ink-soft); }
.confirm b { color: var(--ink); }

/* keep the engine's hidden mount off-screen */
.ew-hidden-mount { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* the fabric/welting swatch preview (engine instance B surface) */
.fabric-preview { margin-top: 4px; }
.fabric-preview .ew-surface { min-height: 118px; border-radius: 0 !important; overflow: hidden; }
.fabric-preview .ew-render { transform: scale(0.46); }
.fabric-preview__cap { margin-top: 8px; font-size: 0.8125rem; color: var(--meta); text-align: center; }

/* suppress the engine's plate rectangle: the faint inset-shadow box behind the
   composite reads as a plate on the fabric. Thread the stitch INTO the cloth via
   the engine's multiply blend instead (Prototype C fix, adopted at skin level). */
#ew-scene .ew-render.ew-on-fabric::after { content: none !important; display: none !important; }

/* composite render sizing on the product photo (overrides engine transform,
   keeps its centering + rotation, adds a tunable scale for the pillow).
   Retuned so the monogram reads believable on a 20″ face (~⅓ of the pillow),
   sitting comfortably inside the cartouche oval rather than spanning it. */
#ew-scene .ew-render.ew-on-fabric {
  transform: translate(-50%, -50%) rotate(var(--ew-rotate, 0deg)) scale(var(--ew-scale, 0.45));
}
@media (min-width: 620px) {
  #ew-scene .ew-render.ew-on-fabric { transform: translate(-50%, -50%) rotate(var(--ew-rotate, 0deg)) scale(var(--ew-scale, 0.5)); }
}
