/* Prism Dither Studio — dark creative-tool theme.
   Layout: fixed left sidebar of grouped controls, fluid canvas stage. */

:root {
  --bg: #0a0a0b;          /* Void */
  --bg-raised: #141416;   /* Obsidian */
  --bg-inset: #09090a;
  --line: #1e1e21;        /* Graphite */
  --text: #fafafa;
  --text-dim: #b4b4b8;
  --accent-a: #ff6b2c;    /* Spark */
  --accent-b: #ff8f5c;    /* Ember */
  --accent-c: #ffb088;    /* Glow */
  --grad: linear-gradient(120deg, var(--accent-a), var(--accent-b) 50%, var(--accent-c));
  --radius: 10px;
  --sidebar-w: 304px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------------ */
/* Sidebar                                                              */
/* ------------------------------------------------------------------ */

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #2c2c30 transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand .tagline {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* Breathing Spark mark — hue rotation is gone on purpose: cycling the
   brand orange around the colour wheel reads as off-brand. */
.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 9px;
  background: conic-gradient(from 210deg, var(--accent-a), var(--accent-b), var(--accent-c), var(--accent-a));
  animation: mark-breathe 6s ease-in-out infinite alternate;
  box-shadow: 0 0 18px rgba(255, 107, 44, 0.4);
}

@keyframes mark-breathe {
  from { box-shadow: 0 0 12px rgba(255, 107, 44, 0.3); }
  to { box-shadow: 0 0 26px rgba(255, 107, 44, 0.55); }
}

/* Accessibility: visible keyboard focus + reduced-motion */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 2px;
}

/* Skip-to-content link — off-screen until focused. (The lab loads its own
   stylesheet, not assets/landing.css, so these rules live here too.) */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--accent-a);
  color: #fff;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; text-decoration: none; color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .brand-mark { animation: none !important; }
}

.panel h2,
.group summary {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.panel h2 { margin: 0 0 8px; }

.panel { padding: 0 2px; }

/* Collapsible control groups */
.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-inset);
  padding: 0 10px;
}

.group + .group { margin-top: 10px; }

.group summary {
  cursor: pointer;
  padding: 9px 2px;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
}

.group summary::-webkit-details-marker { display: none; }

.group summary::after {
  content: "";
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.group[open] summary::after { transform: rotate(45deg); }

.group-body {
  padding: 2px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Compact control rows: label | input | value */
.ctl {
  display: grid;
  grid-template-columns: 96px 1fr 40px;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.ctl label {
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctl-value {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
  opacity: 0.85;
}

.ctl-select, .ctl-color, .ctl-checkbox { grid-template-columns: 96px 1fr; }
.ctl-button { grid-template-columns: 1fr; }
.ctl.hidden { display: none; }

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: #26262a;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid var(--bg-inset);
  box-shadow: 0 0 0 1px #38383d;
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: #26262a;
}

input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid var(--bg-inset);
  box-shadow: 0 0 0 1px #38383d;
}

/* Selects */
select {
  width: 100%;
  background: #19191c;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
  font-size: 11.5px;
}

select:focus { outline: 1px solid var(--accent-b); }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 17px;
  justify-self: start;
}

.toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.toggle i {
  position: absolute;
  inset: 0;
  border-radius: 17px;
  background: #26262a;
  transition: background 0.15s;
  pointer-events: none;
}

.toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #9b97ad;
  transition: transform 0.15s, background 0.15s;
}

.toggle input:checked + i { background: var(--accent-b); }
.toggle input:checked + i::after { transform: translateX(13px); background: #fff; }

/* Colour inputs */
input[type="color"] {
  width: 100%;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* Buttons */
.btn {
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  color: var(--text);
  background: #1b1b1e;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  flex: 1;
}

.btn:hover { background: #232328; border-color: #333338; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--grad);
  border: none;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover { background: var(--grad); filter: brightness(1.12); }

.btn-small { padding: 5px 9px; font-size: 11px; }

.btn-row { display: flex; gap: 7px; margin-bottom: 7px; }
.btn-row.center { justify-content: center; }
.btn-row.right { justify-content: flex-end; margin-bottom: 0; }
.btn-row select { flex: 1; width: auto; }

/* Segmented control (fit/fill/1:1) */
.seg {
  display: flex;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  flex: 1;
  font: inherit;
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
}

.seg button.active {
  color: var(--text);
  background: #222226;
}

/* Mode toggle (Simple / Advanced) */
.mode-toggle { flex: 0 0 auto; }

.mode-toggle button {
  padding: 7px 0;
  font-weight: 600;
}

/* Looks gallery (Simple mode) */
.looks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  /* Cap the gallery so Tweak + Export stay above the fold; it scrolls. */
  max-height: 330px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: #2c2c30 transparent;
}

.framing-seg { margin-top: 7px; }

.look-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px 5px 7px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 550;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  text-align: left;
}

.look-card:hover { border-color: #3a3a40; background: #151517; }

.look-card.active {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--bg-inset), var(--bg-inset)) padding-box,
    var(--grad) border-box;
}

.look-card canvas {
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #151517
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(255, 255, 255, 0.02) 6px 12px);
  display: block;
}

.look-card span {
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Headline overlay input */
.panel textarea {
  width: 100%;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 6px 8px;
  resize: vertical;
  margin-bottom: 7px;
}

.panel textarea:focus { outline: 1px solid var(--accent-b); }

.panel textarea::placeholder { color: var(--text-dim); opacity: 0.7; }

/* Brand kit status line */
.kit-status {
  margin: 0 0 8px;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-dim);
}

/* Privacy note in the footer */
.hints .privacy {
  flex-basis: 100%;
  margin: 0 0 6px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-dim);
}

/* Preset chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font: inherit;
  font-size: 11px;
  font-weight: 550;
  color: var(--text);
  background: #171719;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  position: relative;
}

.chip:hover { border-color: #3a3a40; background: #202024; }

.chip.active {
  border-color: transparent;
  background:
    linear-gradient(#171719, #171719) padding-box,
    var(--grad) border-box;
  border: 1px solid transparent;
}

/* Shortcut hints */
.hints {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 10.5px;
  color: var(--text-dim);
}

kbd {
  font: 10px/1 inherit;
  background: #1c1c1f;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1.5px 5px;
}

/* ------------------------------------------------------------------ */
/* Stage / canvas                                                       */
/* ------------------------------------------------------------------ */

#stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(255, 107, 44, 0.06), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(255, 176, 136, 0.05), transparent 60%),
    var(--bg);
}

#canvas-wrap {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#view { display: block; }

/* When the preview is locked to a placement aspect (Simple mode), the
   canvas floats letterboxed in the stage — frame it like an artboard. */
#stage.framed #view {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

#stage.dragging::after {
  content: "Drop to load";
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--accent-c);
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-c);
  background: rgba(8, 8, 14, 0.55);
  pointer-events: none;
  z-index: 5;
}

/* Split-view drag handle */
#split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  margin-left: -9px;
  cursor: col-resize;
  z-index: 4;
  touch-action: none;
}

#split-handle::after {
  content: "◂ ▸";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  letter-spacing: -1px;
  color: #0b0b10;
  background: #fff;
  border-radius: 999px;
  padding: 5px 7px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hidden { display: none !important; }

/* Empty state */
#empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
}

.drop-card {
  position: relative;
  text-align: center;
  padding: 44px 52px;
  border: 1px dashed #2e2e33;
  border-radius: 18px;
  background: rgba(14, 14, 21, 0.8);
  color: var(--accent-c);
  max-width: 420px;
}

.drop-card h3 {
  margin: 14px 0 4px;
  font-size: 17px;
  color: var(--text);
}

.drop-card p {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Soft animated gradient halo behind the empty state */
.drop-glow {
  position: absolute;
  inset: -40px;
  border-radius: 30px;
  background: var(--grad);
  opacity: 0.1;
  filter: blur(48px);
  animation: breathe 5s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes breathe {
  from { opacity: 0.06; transform: scale(0.96); }
  to { opacity: 0.16; transform: scale(1.03); }
}

/* Toast */
#toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  background: #1b1b1e;
  border: 1px solid #313136;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 6;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Dialog */
dialog {
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  width: min(440px, 90vw);
}

dialog::backdrop { background: rgba(4, 4, 8, 0.65); }

dialog h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

/* Pro unlock */
.pro-status {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-dim);
}

.pro-status.locked {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #3a3a40;
  text-underline-offset: 2px;
}

.pro-status.locked:hover { color: var(--text); }

.pro-pitch {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
}

.pro-error {
  margin: -6px 0 10px;
  font-size: 11px;
  color: #ff7b9d;
}

dialog input[type="email"] {
  width: 100%;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  padding: 8px 10px;
  margin-bottom: 12px;
}

dialog input[type="email"]:focus { outline: 1px solid var(--accent-b); }

dialog textarea {
  width: 100%;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 11px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  padding: 8px;
  resize: vertical;
  margin-bottom: 12px;
}

/* ------------------------------------------------------------------ */
/* Tablet                                                               */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
  #app { flex-direction: column-reverse; }

  #sidebar {
    width: 100%;
    flex: 0 0 42vh;
    border-right: none;
    border-top: 1px solid var(--line);
  }

  #stage { flex: 1; }
  .drop-card { padding: 30px 24px; margin: 0 16px; }
}
