/* ═══════════════════════════════════════════════════════════════
   ToolkitsApp — STUDIO overlay (designer tools)
   ───────────────────────────────────────────────────────────────
   Load AFTER main.css + redesign.css (base.html).
   Provides the "neutral studio" pattern used by the color/CSS
   tools: a strictly achromatic stage (surface switchable
   white / grey N5 / deep / checker), a dark equipment rail, and
   an optional page-wide neutral mode. The stage area is
   theme-independent by design — judging color needs a surround
   with zero chroma, in light AND dark mode.
   ═══════════════════════════════════════════════════════════════ */

/* ── Host: strip the card padding when a studio lives inside ── */
.tool-container:has(> .studio) {
  padding: 0;
  overflow: hidden;
}
.studio { display: flex; flex-direction: column; }

/* ═══ Equipment rail — always dark, always achromatic ═══ */
.studio-rail {
  background: #232323;
  color: #cfcfcf;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 10px 20px;
}
.studio-rail-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8f8f8f;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.studio-rail-label::before {
  content: '';
  width: 6px; height: 6px;
  background: #efefef;
  display: inline-block;
}
.studio-rail-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.studio-rail-div { width: 1px; height: 18px; background: #3d3d3d; }
@media (max-width: 640px) { .studio-rail-div { display: none; } }

/* format chips (HEX / RGB / HSL / OKLCH) */
.rail-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid #3d3d3d;
  color: #b9b9b9;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 0;
}
.rail-chip:hover { border-color: #6a6a6a; color: #efefef; }
.rail-chip.on { background: #efefef; color: #1a1a1a; border-color: #efefef; }

/* surface dots */
.surface-dot {
  width: 20px; height: 20px;
  border: 1px solid #555;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s;
  border-radius: 0;
}
.surface-dot:hover { transform: scale(1.12); }
.surface-dot.on { outline: 1.5px solid #efefef; outline-offset: 2.5px; }
.surface-dot[data-surface="white"]   { background: #ffffff; }
.surface-dot[data-surface="n95"]     { background: #ececec; }
.surface-dot[data-surface="n50"]     { background: #7d7d7d; }
.surface-dot[data-surface="deep"]    { background: #1d1d1f; }
.surface-dot[data-surface="checker"] { background: repeating-conic-gradient(#fff 0% 25%, #d9d9d9 0% 50%); background-size: 8px 8px; }

/* neutral-page switch */
.studio-extent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #cfcfcf;
}
.studio-extent .track {
  width: 30px; height: 16px;
  border: 1px solid #555;
  position: relative;
  background: #2d2d2d;
  transition: background 0.2s;
}
.studio-extent .knob {
  position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px;
  background: #9a9a9a;
  transition: all 0.2s;
}
.studio-extent.on .track { background: #efefef; border-color: #efefef; }
.studio-extent.on .knob { left: 16px; background: #1a1a1a; }

/* ═══ Stage — the achromatic surround ═══ */
.studio-stage { transition: background 0.25s; }
.studio-stage[data-surface="white"]   { background: #ffffff; }
.studio-stage[data-surface="n95"]     { background: #ececec; }
.studio-stage[data-surface="n50"]     { background: #7d7d7d; }
.studio-stage[data-surface="deep"]    { background: #1d1d1f; }
.studio-stage[data-surface="checker"] { background: repeating-conic-gradient(#ffffff 0% 25%, #d9d9d9 0% 50%); background-size: 18px 18px; }

.stage-pad { padding: clamp(20px, 4vw, 44px); }

/* hairline frame that adapts to the surface */
.stage-frame { border: 1px solid rgba(0, 0, 0, 0.28); }
.studio-stage[data-surface="deep"] .stage-frame { border-color: rgba(255, 255, 255, 0.22); }

/* ═══ Bench — controls below the stage, in site theme ═══ */
.studio-bench {
  border-top: 1px solid var(--border-light);
  padding: 18px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 26px;
}
.bench-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bench-row { display: flex; align-items: center; gap: 8px; }
.bench-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
@media (max-width: 640px) {
  .bench-actions { margin-left: 0; width: 100%; }
  .bench-actions .btn { flex: 1; justify-content: center; }
}

.studio-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  height: 42px;
  outline: none;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.studio-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.studio-input.w-hex { width: 108px; }
select.studio-input { font-family: var(--font-sans); cursor: pointer; }

.studio-well {
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  display: inline-block;
}
.studio-well input[type="color"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

.studio-iconbtn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.studio-iconbtn:hover { color: var(--text-primary); border-color: var(--accent); }

.studio-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  height: 42px;
  overflow: hidden;
}
.studio-stepper button {
  width: 38px; height: 100%;
  display: grid; place-items: center;
  color: var(--text-secondary);
  background: transparent; border: 0;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}
.studio-stepper button:hover { color: var(--text-primary); background: var(--bg-secondary); }
.studio-stepper span {
  min-width: 34px; text-align: center;
  font-family: var(--font-mono); font-size: 14px;
}

.studio-chipbtn {
  font-size: 12.5px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.studio-chipbtn:hover { border-color: var(--accent); color: var(--text-primary); }
.studio-chipbtn.on { background: var(--text-primary); color: var(--bg-card); border-color: var(--text-primary); }

/* redesign.css absolutely positions .kbd-hint for the nav search pill;
   scope the studio variant to buttons and make it flow inline there */
.btn .kbd-hint {
  position: static;
  transform: none;
  background: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  border: 1px solid currentColor;
  opacity: 0.55;
  padding: 2px 5px;
  border-radius: 2px;
}

/* ═══ Palette columns (palette generator) ═══ */
.swatch-block {
  height: clamp(380px, 52vh, 560px);
  display: flex;
  overflow: hidden;
}
.swatch-block.stage-frame { /* frame supplied above */ }
.swatch-col {
  flex: 1;
  position: relative;
  cursor: pointer;
  min-width: 0;
  transition: flex-grow 0.25s;
}
.swatch-col:hover { flex-grow: 1.14; }

.col-actions {
  position: absolute;
  left: 50%; top: 44%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  gap: 7px;
  opacity: 0;
  transition: opacity 0.18s;
}
.swatch-col:hover .col-actions,
.swatch-col:focus-within .col-actions { opacity: 1; }
.col-act {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  cursor: pointer;
  border: 1px solid;
  background: transparent;
  transition: all 0.15s;
  border-radius: 0;
}
.col-act svg { width: 15px; height: 15px; }

.col-label {
  position: absolute;
  left: 0; right: 0; bottom: 24px;
  text-align: center;
  pointer-events: none;
  padding: 0 8px;
}
.col-hex {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.col-name {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-top: 5px;
}

.shade-step {
  flex: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shade-step span {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.12s;
}
.shade-step:hover span { opacity: 0.9; }

@media (max-width: 640px) {
  .swatch-block { height: auto; flex-direction: column; }
  .swatch-col { min-height: 76px; }
  .swatch-col:hover { flex-grow: 1; }
  .col-actions {
    opacity: 1;
    left: auto; right: 12px; top: 50%;
    transform: translateY(-50%);
    flex-direction: row; gap: 6px;
  }
  .col-act { width: 34px; height: 34px; }
  .col-label {
    left: 16px; right: auto; bottom: auto; top: 50%;
    transform: translateY(-50%);
    text-align: left; padding: 0;
  }
  .col-name { margin-top: 3px; }
}

/* ═══ Tile grid (random color generator) ═══ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}
.tile {
  height: 150px;
  position: relative;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.18);
}
.studio-stage[data-surface="deep"] .tile { border-color: rgba(255, 255, 255, 0.18); }
.tile .col-label { bottom: 12px; text-align: left; left: 14px; right: auto; }
.tile .col-hex { font-size: 13.5px; }
.tile .col-actions {
  left: auto; right: 10px; top: 10px;
  transform: none;
  flex-direction: row; gap: 6px;
}
.tile .col-act { width: 30px; height: 30px; }
.tile .col-act svg { width: 13px; height: 13px; }
@media (max-width: 640px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .tile { height: 120px; }
}

/* ═══ Contrast checker ═══ */
.contrast-grid {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) { .contrast-grid { grid-template-columns: 1fr; } }

.specimen-panel { min-height: 420px; overflow: hidden; }

.verdict-card {
  background: #f7f7f7;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.28);
  padding: 22px;
}
.studio-stage[data-surface="deep"] .verdict-card { border-color: rgba(255, 255, 255, 0.22); }
.verdict-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8a8a;
}
.verdict-ratio {
  font-family: var(--font-serif);
  font-size: 58px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #1a1a1a;
}
.verdict-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 12.5px;
  color: #4c4c4c;
}
.verdict-row small { color: #9a9a9a; font-size: 12px; }
.pass-chip, .fail-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.pass-chip { background: #1a1a1a; color: #f5f5f5; }
.fail-chip { background: transparent; color: #6c6c6c; border: 1px dashed #9a9a9a; }

.fix-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #ffffff;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #333;
}
.fix-row .fix-swatch { width: 16px; height: 16px; border: 1px solid rgba(0,0,0,0.2); flex-shrink: 0; }
.fix-row button {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  background: #1a1a1a;
  color: #f5f5f5;
  padding: 5px 12px;
  cursor: pointer;
  border: 0;
  transition: opacity 0.15s;
}
.fix-row button:hover { opacity: 0.82; }

.verdict-ghostbtn {
  margin-top: 18px;
  width: 100%;
  font-size: 12.5px;
  padding: 10px 0;
  border: 1px solid rgba(0, 0, 0, 0.3);
  color: #333;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.verdict-ghostbtn:hover { background: #1a1a1a; color: #f5f5f5; }

/* ═══ Converter stage ═══ */
.converter-panel {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.converter-hex {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(26px, 4.5vw, 40px);
  letter-spacing: 0.02em;
}
.converter-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.65;
}
.fmt-rows { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 4px; }
.fmt-row { display: flex; align-items: center; gap: 10px; }
.fmt-row .fmt-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  width: 56px;
  flex-shrink: 0;
}

/* ═══ Gradient generator ═══ */
.grad-preview { min-height: 340px; }
.grad-track-wrap { padding: 18px 20px 2px; }
.grad-track {
  position: relative;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: copy;
}
.grad-handle {
  position: absolute;
  top: 50%;
  width: 18px; height: 26px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.3);
  cursor: grab;
}
.grad-handle.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.grad-handle:active { cursor: grabbing; }
.grad-stops { display: flex; flex-direction: column; gap: 8px; }
.grad-stop-row { display: flex; align-items: center; gap: 8px; }
.grad-stop-row .studio-well, .grad-stop-row .studio-iconbtn { width: 36px; height: 36px; }
.grad-stop-row input[type="number"] { height: 36px; width: 74px; padding: 6px 8px; }

/* ═══ Shadow / radius demo object — a neutral, real UI card ═══ */
.demo-wrap {
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 60px);
}
.demo-object {
  width: min(320px, 72%);
  aspect-ratio: 8 / 5;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
  gap: 8px;
}
.demo-object .demo-line { height: 9px; background: #e3e3e3; border-radius: 2px; }
.demo-object .demo-line.short { width: 55%; }
.demo-object .demo-line.dark { background: #b9b9b9; width: 38%; height: 11px; }

/* ═══ Bench sliders ═══ */
.bench-slider { display: grid; grid-template-columns: 1fr; gap: 6px; min-width: 190px; }
.bench-slider .bench-slider-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.bench-slider .bench-slider-head .val { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.bench-slider input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ═══ Studio modal (export etc.) ═══ */
.studio-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 17, 14, 0.45);
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.studio-modal-overlay.open { display: flex; }
.studio-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.studio-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
}
.studio-modal-head h3 { font-family: var(--font-serif); font-weight: 500; font-size: 22px; margin: 0; }
.studio-modal-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 22px 0; }
.studio-modal-body { padding: 14px 22px; overflow: auto; }
.studio-modal-body pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 160px;
  color: var(--text-secondary);
}
.studio-modal-foot { display: flex; align-items: center; gap: 10px; padding: 4px 22px 20px; }

/* ═══ Neutral-page mode — achromatic token override ═══
   Applied by studio.js as <html data-studio-extent="page">.
   Piggybacks the token system, so the entire chrome follows. */
html[data-studio-extent="page"] {
  --bg-primary:   #ececec;
  --bg-secondary: #e1e1e1;
  --bg-tertiary:  #d3d3d3;
  --bg-tool:      #f7f7f7;
  --bg-input:     #fafafa;
  --bg-glass:     rgba(236, 236, 236, 0.82);
  --bg-card:      #f7f7f7;
  --text-primary:   #1c1c1c;
  --text-secondary: #555555;
  --text-tertiary:  #888888;
  --accent:       #1c1c1c;
  --accent-hover: #000000;
  --accent-light: rgba(28, 28, 28, 0.12);
  --accent-bg:    #e4e4e4;
  --border:       rgba(0, 0, 0, 0.14);
  --border-light: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.40);
  --shadow-xs: 0 1px 1px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03), 0 8px 18px -12px rgba(0,0,0,0.10);
  --shadow-md: 0 1px 2px rgba(0,0,0,0.04), 0 12px 26px -14px rgba(0,0,0,0.14);
  --shadow-lg: 0 2px 4px rgba(0,0,0,0.04), 0 18px 38px -16px rgba(0,0,0,0.20);
  --shadow-xl: 0 4px 8px rgba(0,0,0,0.05), 0 28px 56px -20px rgba(0,0,0,0.26);
}
html[data-studio-extent="page"][data-theme="dark"] {
  --bg-primary:   #161616;
  --bg-secondary: #1d1d1d;
  --bg-tertiary:  #282828;
  --bg-tool:      #1c1c1c;
  --bg-input:     #1c1c1c;
  --bg-glass:     rgba(22, 22, 22, 0.82);
  --bg-card:      #1c1c1c;
  --text-primary:   #ededed;
  --text-secondary: #b3b3b3;
  --text-tertiary:  #878787;
  --accent:       #e5e5e5;
  --accent-hover: #ffffff;
  --accent-light: rgba(229, 229, 229, 0.16);
  --accent-bg:    #2a2a2a;
  --border:       rgba(255, 255, 255, 0.12);
  --border-light: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.40);
}
/* .btn-primary hardcodes color:#faf7ef in redesign.css — fix both modes */
html[data-studio-extent="page"] .btn-primary { color: #f5f5f5; }
html[data-studio-extent="page"][data-theme="dark"] .btn-primary { color: #161616; }
html[data-studio-extent="page"] ::selection { background: #1c1c1c; color: #f5f5f5; }
html[data-studio-extent="page"][data-theme="dark"] ::selection { background: #e5e5e5; color: #161616; }
