/* ========================================================= Cover Studio
   web/js/cover-studio.js: the steps across the top, the binder shut on the
   left (the very drawing the shelf and its page use, cover-design.css) and the
   step's choices on the right; on a phone the binder sits above them. */

.modal.modal-studio {
  width: min(1180px, 100%); height: min(820px, 92vh); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.modal-studio.is-apply { height: auto; width: min(920px, 100%); }
.cs { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cs-head { padding: 15px 56px 10px 20px; flex: none; }
.cs-head h2 { font-size: var(--fs-h2); }
.cs-muted { color: var(--ink-3); font-size: 12.5px; margin: 0; }
.cs-lead { color: var(--ink-2); font-size: 13.5px; margin: 0 0 4px; line-height: 1.45; }
.cs-h { font-size: 16px; margin: 0; }

/* the steps */
.cs-steps {
  display: flex; gap: 4px; padding: 0 16px 10px; flex: none;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.cs-steps::-webkit-scrollbar { display: none; }
.cs-step-tab {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 34px; padding: 0 12px 0 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.cs-step-tab:hover { color: var(--ink); background: var(--bg-3); }
.cs-step-tab.is-on { color: var(--accent-ink, #fff); background: var(--accent); border-color: var(--accent); }
.cs-step-n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; background: color-mix(in srgb, currentColor 16%, transparent);
}

/* binder and choices */
.cs-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, 1fr); }
.cs-stage {
  min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 26px 24px 16px;
  background:
    radial-gradient(70% 60% at 50% 45%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    color-mix(in srgb, var(--bg) 70%, #000 10%);
  border-right: 1px solid var(--line);
}
.cs-preview {
  position: relative; width: min(100%, 440px, calc((92vh - 260px) * .76));
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.cs-object { width: 100%; }
.cs-stage-hint { color: var(--ink-3); font-size: 12px; text-align: center; max-width: 420px; margin: 0; }
/* Everything a design puts on the cover can be picked up here. */
.cs-preview .bcover [data-cd] { pointer-events: auto; cursor: grab; }
.cs-preview .bcover [data-cd]:active { cursor: grabbing; }
.cs-preview .bcover .cd-charm * { pointer-events: auto; }
.cs-preview .bcover [data-cd]:hover { outline: 1.5px dashed color-mix(in srgb, #fff 60%, transparent); outline-offset: 3px; }
.cs-preview .bcover .cs-picked { outline: 2px solid var(--accent) !important; outline-offset: 3px; }
.cs-preview .cover-hint { display: none; }
.cs-guide { position: absolute; z-index: 30; pointer-events: none; background: var(--accent); opacity: .8; }
.cs-guide.is-v { top: 0; bottom: 0; width: 1px; left: calc(50% + 2.9%); }
.cs-guide.is-h { left: 6%; right: 0; height: 1px; top: 50%; }

.cs-panel { min-height: 0; overflow-y: auto; padding: 16px 20px 24px; overscroll-behavior: contain; }
.cs-step { display: flex; flex-direction: column; gap: 16px; }
.cs-row { display: flex; flex-direction: column; gap: 8px; }
.cs-row-t { font-size: 11.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.cs-sub { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.cs-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cs-swatches .swatch { width: 28px; height: 28px; border-radius: 50%; }
.cs-swatch-none {
  display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #1b1d22;
  background: linear-gradient(135deg, #f3dc9c, #d8b160 50%, #8a6a2c) !important;
}

/* choices as tiles */
.cs-tiles { display: grid; grid-template-columns: repeat(var(--cs-cols, auto-fill), minmax(86px, 1fr)); gap: 7px; }
.cs-tiles.is-compact { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.cs-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-align: center;
}
.cs-tile:hover { color: var(--ink); background: var(--bg-3); }
.cs-tile.is-on { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-2)); }
.cs-tile-t { line-height: 1.15; }

/* the materials and finishes, as small swatches of themselves */
.cs-mat, .cs-fin {
  position: relative; display: block; width: 100%; height: 30px; border-radius: 5px; overflow: hidden;
  background-color: var(--cover, #2f6f4f);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.cs-mat::after, .cs-fin::after { content: ""; position: absolute; inset: 0; }
.cs-mat.is-leatherette { background-image: var(--grain, none); background-size: 96px; background-blend-mode: overlay; }
.cs-mat.is-linen::after { background: repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px); }
.cs-mat.is-canvas::after { background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 2px, transparent 2px 5px), repeating-linear-gradient(90deg, rgba(0,0,0,.14) 0 2px, transparent 2px 5px); }
.cs-mat.is-carbon::after { background: repeating-conic-gradient(rgba(0,0,0,.4) 0 25%, rgba(255,255,255,.06) 0 50%) 0 0 / 8px 8px; }
.cs-mat.is-quilted::after { background: repeating-linear-gradient(45deg, transparent 0 9px, rgba(0,0,0,.35) 9px 10px), repeating-linear-gradient(-45deg, transparent 0 9px, rgba(0,0,0,.35) 9px 10px); }
.cs-mat.is-croc::after { background: radial-gradient(ellipse 46% 40% at 50% 50%, rgba(255,255,255,.12), rgba(0,0,0,.4) 95%) 0 0 / 9px 7px; }
.cs-mat.is-velvet::after { background: radial-gradient(90% 90% at 25% 15%, rgba(255,255,255,.28), transparent 60%); }
.cs-mat.is-denim::after { background: repeating-linear-gradient(45deg, rgba(255,255,255,.1) 0 1px, transparent 1px 3px), repeating-linear-gradient(-45deg, rgba(0,0,0,.18) 0 1px, transparent 1px 4px); }
.cs-mat.is-wood::after { background: repeating-radial-gradient(ellipse 160% 40% at 10% -40%, rgba(0,0,0,.2) 0 2px, transparent 2px 6px); }
.cs-fin.is-matte::after { background: rgba(0,0,0,.18); }
.cs-fin.is-satin::after { background: linear-gradient(135deg, rgba(255,255,255,.18), transparent 60%); }
.cs-fin.is-gloss::after { background: linear-gradient(118deg, rgba(255,255,255,.5) 0, rgba(255,255,255,.1) 35%, transparent 45%); }
.cs-fin.is-holo::after { background: linear-gradient(115deg, #ff4d6d, #ffd166, #06d6a0, #4cc9f0, #b5179e); mix-blend-mode: color-dodge; opacity: .55; }
.cs-fin.is-pearl::after { background: linear-gradient(135deg, rgba(255,226,248,.5), rgba(206,240,255,.45), rgba(255,250,222,.5)); mix-blend-mode: soft-light; }
.cs-fin.is-glitter::after { background: radial-gradient(circle, #fff 0 .7px, transparent 1.2px) 0 0 / 7px 6px, radial-gradient(circle, #fff 0 .6px, transparent 1px) 3px 2px / 5px 8px; opacity: .8; }

.cs-shape { display: block; width: 22px; height: 30px; border: 2px solid currentColor; border-radius: 3px; opacity: .8; }
.cs-shape.is-rounded { border-radius: 7px; }
.cs-shape.is-circle { width: 28px; height: 28px; border-radius: 50%; }
.cs-shape.is-oval { width: 23px; border-radius: 50%; }
.cs-shape.is-arch { border-radius: 12px 12px 3px 3px; }
.cs-shape.is-hex { width: 28px; height: 26px; border: 0; background: currentColor; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }

.cs-tiles.is-fonts { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.cs-font-sample { font-size: 22px; line-height: 1.2; color: var(--ink); }
.cs-font-sample[data-font="serif"] { font-family: 'Playfair Display', Georgia, serif; font-weight: 700; }
.cs-font-sample[data-font="engraved"] { font-family: 'Cinzel', Georgia, serif; font-weight: 700; }
.cs-font-sample[data-font="script"] { font-family: 'Pacifico', 'Brush Script MT', cursive; }
.cs-font-sample[data-font="display"] { font-family: 'Bebas Neue', Impact, sans-serif; }
.cs-font-sample[data-font="pixel"] { font-family: 'Press Start 2P', monospace; font-size: 14px; }
.cs-font-sample[data-font="gothic"] { font-family: 'UnifrakturMaguntia', 'Old English Text MT', serif; }
.cs-font-sample[data-font="marker"] { font-family: 'Permanent Marker', 'Comic Sans MS', cursive; }
.cs-font-sample[data-font="scifi"] { font-family: 'Orbitron', sans-serif; font-weight: 700; }
.cs-font-sample[data-font="rounded"] { font-family: 'Baloo 2', ui-rounded, sans-serif; font-weight: 700; }
.cs-font-sample[data-font="mono"] { font-family: 'Space Mono', ui-monospace, monospace; font-weight: 700; }
.cs-font-sample[data-font="sans"] { font-weight: 750; }

/* segmented choices */
.cs-seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); align-self: flex-start; }
.cs-seg .seg-btn {
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ink-2);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.cs-seg .seg-btn:hover { color: var(--ink); background: var(--bg-3); }
.cs-seg .seg-btn.is-on { color: var(--accent-ink, #fff); background: var(--accent); }

/* sliders and switches */
.cs-slider { display: grid; grid-template-columns: 80px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.cs-slider input { width: 100%; accent-color: var(--accent); }
.cs-slider-v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.cs-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.cs-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* a picture, sticker or charm being edited */
.cs-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-2); overflow: hidden; }
.cs-item.is-on { border-color: var(--accent); }
.cs-item-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; background: none; color: var(--ink); font: inherit; font-size: 13px; font-weight: 650; text-align: left; cursor: pointer;
}
div.cs-item-head { cursor: default; }
.cs-item-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg-3); }
.cs-item-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; }
.cs-item-acts { display: flex; flex-wrap: wrap; gap: 6px; }

.cs-charms { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.cs-charm-pick {
  display: grid; place-items: center; height: 46px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-2); cursor: pointer;
}
.cs-charm-pick:hover { background: var(--bg-3); border-color: var(--accent); }
.cs-charm-pick .cd-charm-art { width: 28px; margin: 0; }
.cs-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.cs-sticker-pick {
  height: 40px; font-size: 22px; line-height: 1; border-radius: 8px; border: 1px solid transparent;
  background: none; cursor: pointer;
}
.cs-sticker-pick:hover { background: var(--bg-3); border-color: var(--line); }
.cs-own { flex: 1; min-width: 160px; }

/* ready-made looks and templates */
.cs-looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.cs-look { position: relative; }
.cs-look-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%;
  padding: 8px 6px 6px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; color: var(--ink-2); font: inherit; cursor: pointer;
}
.cs-look-btn:hover { background: var(--bg-2); border-color: var(--line); color: var(--ink); }
.cs-look-art { width: 100%; pointer-events: none; }
.cs-look-name { font-size: 12px; font-weight: 650; text-align: center; }
.cs-look-del {
  position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink-2); cursor: pointer; line-height: 1;
  opacity: 0; transition: opacity var(--t-2) var(--ease-out);
}
.cs-look:hover .cs-look-del, .cs-look-del:focus-visible { opacity: 1; }
@media (hover: none) { .cs-look-del { opacity: 1; } }

.cs-apply-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; }
.cs-apply-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.cs-apply-row:hover { background: var(--bg-2); }
.cs-apply-row.is-all { font-weight: 700; border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; }
.cs-apply-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.cs-dot { width: 14px; height: 18px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.cs-apply-body { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; max-height: 70vh; }

.cs .cs-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; flex: none; }
.cs-foot-l, .cs-foot-r { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* a phone: the binder above, its choices below */
@media (max-width: 820px) {
  .modal.modal-studio:not(.is-apply) {
    position: fixed; inset: 0; width: auto; height: auto; max-height: none;
    border: none; border-radius: 0;
  }
  .cs-long { display: none; }
  .cs .cs-foot { padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 6px; border-top: 1px solid var(--line); }
  .cs-foot-l, .cs-foot-r { width: 100%; gap: 6px; flex-wrap: nowrap; }
  .cs-foot-l .btn, .cs-foot-r .btn { flex: 1; }
  .cs-looks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .cs-head { padding: 12px 52px 8px 16px; }
  .cs-steps { padding: 0 12px 8px; }
  .cs-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .cs-stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px 8px; }
  .cs-preview { width: min(62vw, 250px, calc(34dvh * .76)); }
  .cs-stage-hint { display: none; }
  .cs-panel { padding: 14px 16px 20px; }
  .cs-foot-l .btn, .cs-foot-r .btn { height: 34px; padding: 0 10px; font-size: 12.5px; }
  .cs-foot-r [data-wide] { display: none; }
}

/* Binder settings → Look: the way into the Studio */
.set-studio { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* the binder page, shut: a way into the Studio beside the cover */
.cover-style-btn {
  position: absolute; z-index: 12; top: 14px; right: 14px;
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg-2) 86%, transparent);
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer;
  box-shadow: var(--shadow-1); backdrop-filter: blur(8px);
}
.cover-style-btn:hover { border-color: var(--accent); }
.cover-style-btn svg { width: 15px; height: 15px; }
.cover-style-btn[hidden] { display: none; }
