/* Cedilla Studio — Off Grid (/off-grid), experimental type playground.
   Loaded after /styles.css; everything is scoped under body.off-grid-page. */

body.off-grid-page {
  --blue: #5164F6;
  --pink: #FC5FAD;
  --cyan: #21D4FD;
  --ink: #000;
  --paper: #fff;
  --muted: rgba(255, 255, 255, 0.55);
  --faint: rgba(255, 255, 255, 0.32);
  --line: rgba(255, 255, 255, 0.14);
  --panel: #070707;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --nav: 54px;

  height: auto;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Open Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.off-grid-page button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.lab {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100vh - var(--nav));
  height: calc(100svh - var(--nav));
  min-height: 560px;
  margin-top: var(--nav);
  border-top: 1px solid var(--line);
}

.lab-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 20px 40px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.lab-section { padding: 18px 0 20px; border-bottom: 1px solid var(--line); }
.lab-section:last-child { border-bottom: 0; }

.off-grid-page .lab-label {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.off-grid-page .lab-label span { color: var(--blue); margin-right: 6px; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 14px; }
.field-name {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.field-name em { font-style: normal; color: var(--faint); font-family: var(--mono); font-size: 10px; }

.lab textarea,
.lab select,
.console input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
  font: 15px/1.35 'Open Sans', sans-serif;
  padding: 10px 12px;
  outline: none;
  transition: border-color .3s var(--ease), background-color .3s var(--ease);
}
.lab textarea { resize: vertical; min-height: 64px; text-transform: none; }
.lab textarea:focus, .lab select:focus, .console input:focus { border-color: var(--blue); background: rgba(81,100,246,.08); }
.lab select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #fff 50%), linear-gradient(135deg, #fff 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.lab select option { background: #111; color: #fff; }

.font-row { display: flex; gap: 8px; }
.font-row select { flex: 1; min-width: 0; }

.mini {
  flex: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  font-size: 12px !important;
  white-space: nowrap;
  transition: background-color .3s var(--ease), border-color .3s var(--ease);
}
.mini:hover { background: var(--blue); border-color: var(--blue); }

/* Range sliders */
.param { display: grid; grid-template-columns: 78px minmax(0,1fr) 38px; align-items: center; gap: 10px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.param output { font-family: var(--mono); font-size: 11px; color: var(--paper); text-align: right; }
.param input[type=range] { width: 100%; margin: 0; height: 18px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.param input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line); border-radius: 2px; }
.param input[type=range]::-moz-range-track { height: 2px; background: var(--line); border-radius: 2px; }
.param input[type=range]::-moz-range-progress { height: 2px; background: var(--blue); }
.param input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 3px rgba(81,100,246,.0); transition: box-shadow .2s; }
.param input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; }
.param input[type=range]:hover::-webkit-slider-thumb,
.param input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(81,100,246,.55); }

/* ---------- Effect toggles ---------- */
.fx { border-radius: 12px; margin: 0 -10px 2px; transition: background-color .3s var(--ease); }
.fx.is-on { background: rgba(81,100,246,.09); }
.fx-toggle {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  text-align: left;
}
.fx-switch {
  position: relative; width: 28px; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.14);
  transition: background-color .3s var(--ease);
}
.fx-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: transform .3s var(--ease);
}
.fx.is-on .fx-switch { background: var(--blue); box-shadow: 0 0 12px rgba(81,100,246,.6); }
.fx.is-on .fx-switch::after { transform: translateX(12px); }
.fx-name { font-size: 14px; line-height: 1.2; }
.fx-name small { display: block; font-size: 11px; color: var(--faint); margin-top: 2px; }
.fx-cmd { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.fx-params { display: none; padding: 0 10px 10px 50px; }
.fx.is-on .fx-params { display: block; }

/* ---------- Chips / swatches ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  font-size: 12px !important;
  transition: background-color .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}
.chip:hover { background: var(--blue); border-color: var(--blue); transform: translateY(-1px); }

.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); padding: 0; position: relative; overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch.is-on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px #fff; }
.swatch i { position: absolute; inset: 0; }

.colour-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.colour-row label { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); cursor: pointer; }
.colour-row input[type=color] { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: transparent; padding: 3px; cursor: pointer; }
.colour-row input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.colour-row input[type=color]::-webkit-color-swatch { border: 0; border-radius: 7px; }
.colour-row input[type=color]::-moz-color-swatch { border: 0; border-radius: 7px; }

/* ---------- Stage ---------- */
.lab-stage { position: relative; overflow: hidden; min-width: 0; background: #000; }
.lab-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.lab-stage.is-grabby canvas { touch-action: none; }
.lab-stage.is-editing canvas { cursor: crosshair; }
.lab-stage.is-dragging canvas { cursor: grabbing; }
.lab-stage.is-hovering canvas { cursor: grab; }

.stage-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px;
  pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
.off-grid-page .stage-title {
  margin: 0; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--paper);
  mix-blend-mode: difference;
}
.stage-title span { color: var(--blue); margin-left: 6px; mix-blend-mode: normal; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.lab .pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #fff;
  font-size: 12px;
  letter-spacing: .02em;
  transition: background-color .4s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease), transform .3s var(--ease);
}
.lab .pill:hover { background: var(--blue); border-color: var(--blue); transform: translateY(-1px); }
.lab .pill[aria-pressed="true"]#btnEdit { background: var(--pink); border-color: var(--pink); }
.lab .pill--glow {
  background: linear-gradient(135deg, var(--pink), var(--blue), var(--blue), var(--cyan));
  background-size: 300% 300%;
  border-color: transparent;
}
.lab .pill--glow:hover { animation: lab-gradient 5s ease infinite; box-shadow: 0 0 18px rgba(81,100,246,.6), 0 0 40px rgba(81,100,246,.35); }
@keyframes lab-gradient { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.stage-info, .stage-shop {
  position: absolute; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.75); mix-blend-mode: difference; pointer-events: none;
}
.stage-info { right: 18px; bottom: 140px; text-align: right; line-height: 1.7; }
.stage-shop {
  left: 18px; top: 60px; pointer-events: auto; text-decoration: none; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.4); padding-bottom: 2px; transition: border-color .3s;
}
.stage-shop:hover { border-color: #fff; }

.edit-bar {
  position: absolute; left: 50%; top: 64px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 32px);
  padding: 6px 6px 6px 16px; border-radius: 999px;
  background: var(--pink); color: #000; font-size: 12px;
  box-shadow: 0 10px 30px rgba(252,95,173,.3);
}
.edit-bar[hidden] { display: none; }
.edit-bar .mini { background: #000; color: #fff; border-color: #000; }

/* Console */
.console {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  margin: 0;
}
.console-log {
  font-family: var(--mono); font-size: 11px; line-height: 1.6; color: rgba(255,255,255,.85);
  padding: 0 4px 8px; max-height: 6.4em; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  mix-blend-mode: difference; pointer-events: none;
}
.console-log div { white-space: pre-wrap; animation: log-in .35s var(--ease); }
.console-log .is-err { color: var(--pink); mix-blend-mode: normal; }
@keyframes log-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.console-line { display: flex; align-items: center; position: relative; }
.console-caret { position: absolute; z-index: 1; left: 14px; font-family: var(--mono); color: var(--blue); pointer-events: none; }
.console input {
  font-family: var(--mono); font-size: 13px; padding: 12px 14px 12px 32px;
  background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-color: rgba(255,255,255,.18);
}
.console input::placeholder { color: rgba(255,255,255,.4); }

.drop-veil {
  position: absolute; inset: 12px; border: 2px dashed var(--blue); border-radius: 18px;
  display: grid; place-items: center; font-family: var(--mono); text-transform: uppercase; letter-spacing: .14em; font-size: 13px;
  background: rgba(81,100,246,.18); opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
.lab-stage.is-dropping .drop-veil { opacity: 1; }

/* ---------- Notes ---------- */
.lab-notes { border-top: 1px solid var(--line); padding: 64px clamp(16px, 4vw, 56px); }
.lab-notes-inner { max-width: 1200px; margin: 0 auto; }
.notes-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 32px; }
.off-grid-page .notes-grid h3 { margin: 0 0 10px; font-size: 18px; font-weight: 500; color: #fff; font-family: 'Open Sans', sans-serif; }
.notes-grid p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--muted); }
.notes-grid strong, .notes-grid em { color: #fff; font-weight: 500; }
.notes-grid code, .notes-grid kbd {
  font-family: var(--mono); font-size: 12px; color: #fff;
  background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}

/* ---------- Small screens ---------- */
@media (max-width: 1100px) {
  .notes-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 860px) {
  .lab { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .lab-stage { order: -1; height: 72vh; height: 72svh; min-height: 420px; }
  .lab-panel { overflow: visible; border-right: 0; border-top: 1px solid var(--line); padding: 4px 16px 32px; }
  .stage-top { padding: 12px; }
  .stage-actions { justify-content: flex-start; }
  .lab .pill { padding: 7px 12px; }
  .stage-shop { top: auto; bottom: 120px; left: 16px; }
  .stage-info { display: none; }
  .edit-bar { top: auto; bottom: 150px; font-size: 11px; }
  .console { left: 12px; right: 12px; bottom: 12px; }
  .console-log { max-height: 3.2em; }
  .console input { font-size: 16px; } /* stops iOS zooming on focus */
  .notes-grid { grid-template-columns: minmax(0,1fr); gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .lab .pill--glow:hover { animation: none; }
}
