/* ==========================================================================
   COLLAGE / GEN — editor chrome. Shared tokens: ../tokens.css
   Cyber-futurist / terminal-chic. No particle libs or animation frameworks.
   ========================================================================== */
:root {
  --header-h: 56px;
  --footer-h: 54px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
}

::selection { background: var(--accent-dim); color: var(--heading); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent), transparent 55%); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ==========================================================================
   Header — brand + horizontal section nav. The nav-link underline grow is
   the same interaction as the personal site's `.navmenu` desktop nav:
   a hidden accent underline that widens from 0 on hover/active.
   ========================================================================== */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.suite-nav {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
  flex: none;
}
.suite-link {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--dim);
  transition: color .15s ease;
}
.suite-link:hover { color: var(--accent); }
.suite-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
  color: var(--accent);
}
.suite-sep {
  color: var(--line);
  font-family: var(--mono);
  font-size: 12px;
  user-select: none;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
  transition: opacity .15s ease;
}
.brand:hover { opacity: .85; }
.brand:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}
.brand-mark { color: var(--accent); font-family: var(--mono); letter-spacing: 2px; }
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--heading);
  text-transform: uppercase;
  font-size: 14px;
}
.brand-name em { color: var(--accent); font-style: normal; margin: 0 2px; }

.section-nav {
  display: flex;
  align-items: center;
  gap: 30px;
  height: 100%;
  margin-left: 8px;
}
.nav-item {
  position: relative;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: .2px;
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  height: 2px; width: 0;
  background: var(--accent);
  transition: width .25s ease, box-shadow .25s ease;
}
.nav-item:hover { color: var(--heading); }
.nav-item:hover::before { width: 100%; box-shadow: 0 0 8px var(--copper-glow); }
.nav-item.active { color: var(--accent); }
.nav-item.active::before { width: 100%; box-shadow: 0 0 8px var(--copper-glow); }
.nav-item .led {
  width: 6px; height: 6px; border-radius: 50%;
  background: #333; flex: none;
  transition: background .2s, box-shadow .2s;
}
.nav-item.layer-on .led { background: var(--accent); box-shadow: 0 0 6px var(--accent-dim); }

/* ==========================================================================
   Layout — canvas stage on the left (primary focus), single-section
   control panel on the right.
   ========================================================================== */
.workspace { display: flex; height: calc(100% - var(--header-h) - var(--footer-h)); }

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent), transparent 96%), transparent 60%),
    var(--bg);
}
.stage.drag::after {
  content: 'DROP IMAGE';
  position: absolute;
  inset: 14px;
  border: 2px dashed var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: var(--mono);
  letter-spacing: 3px;
  font-size: 12px;
  background: rgba(10, 10, 10, .72);
  pointer-events: none;
}
#preview {
  background: #fff;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .65), 0 0 0 1px var(--line);
}

.panel-rail {
  width: 306px;
  min-width: 306px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  padding: 14px;
}

/* ==========================================================================
   Uploader + pinned Frame block (apply regardless of which section is open)
   ========================================================================== */
.uploader {
  border: 1px dashed #313131;
  border-radius: 3px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  letter-spacing: 1px;
  font-size: 10px;
  font-family: var(--mono);
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 12px;
  transition: border-color .15s, color .15s;
}
.uploader:hover, .uploader.drag, .uploader:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
  box-shadow: 0 0 24px var(--copper-glow);
}
.uploader-meta { margin-top: 8px; font-size: 9px; color: var(--accent); letter-spacing: 1px; }

.pinned-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.pinned-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
  position: relative;
  display: inline-block;
}
/* short accent underline following the label — the personal site's
   section-title signature, scaled down for a sidebar heading */
.pinned-title::after {
  content: '';
  display: block;
  width: 34px;
  height: 1px;
  margin-top: 5px;
  background: var(--accent);
}

/* ==========================================================================
   Section panels — one visible at a time, selected via the header nav
   (tabs), not a stacked accordion.
   ========================================================================== */
.layer-group { display: none; }
.layer-group.active-section { display: block; animation: panelIn .18s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.layer-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.layer-group-head h3 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--heading);
  display: flex;
  align-items: center;
  gap: 6px;
}
.layer-group-head h3 .tick { color: var(--accent); font-size: 9px; }

.switch-wrap { display: flex; align-items: center; gap: 8px; flex: none; }
.switch-state {
  font-family: var(--mono); font-size: 8.5px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--dim); width: 22px; text-align: right;
}
.layer-group:not(.layer-off) .switch-state { color: var(--accent); }

.switch { position: relative; width: 30px; height: 16px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: #2c2c2c; border-radius: 9px;
  transition: background .15s; cursor: pointer;
}
.switch span::before {
  content: ''; position: absolute; width: 10px; height: 10px; left: 3px; top: 3px;
  background: #7c7a72; border-radius: 50%; transition: transform .15s, background .15s;
}
.switch input:checked + span { background: var(--accent-dim); }
.switch input:checked + span::before { transform: translateX(14px); background: var(--accent); }

/* Layers stay visible while their tab is open even when disabled — dim the
   fields and surface an explicit way back to "on" instead of leaving it to
   a small header switch. */
.layer-off-hint {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: color-mix(in srgb, var(--copper), transparent 90%);
  border: 1px solid color-mix(in srgb, var(--copper), transparent 55%);
  border-radius: 3px;
  padding: 9px 10px;
  margin: 10px 0 4px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text);
}
.layer-group.layer-off .layer-off-hint { display: flex; }
.layer-group.layer-off .layer-group-body > *:not(.layer-off-hint) { opacity: .4; filter: saturate(.5); }
.enable-link {
  flex: none;
  background: var(--accent); color: #08150e; border: none; border-radius: 2px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 6px 10px; cursor: pointer;
}
.enable-link:hover { filter: brightness(1.08); }

.subhead {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}
.subhead:first-child { margin-top: 6px; padding-top: 2px; border-top: none; }

.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.field-label { font-size: 9.5px; letter-spacing: .6px; color: var(--dim); white-space: nowrap; text-transform: uppercase; }
.field .val { color: var(--accent); font-style: normal; margin-left: 4px; }

/* Custom range track: filled portion in accent green, the base/unfilled
   portion in a muted copper — same warmth as the button shimmer, applied
   as a solid track color here rather than a hover-only effect. `--pct` is
   kept in sync with the input's value by app.js. */
.field input[type=range] {
  flex: 1; max-width: 140px; height: 14px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.field input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--pct, 50%),
    var(--copper-track) var(--pct, 50%), var(--copper-track) 100%);
}
.field input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface-2);
  margin-top: -4.5px;
  box-shadow: 0 0 0 1px var(--line);
}
.field input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--copper-track); }
.field input[type=range]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
.field input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface-2);
  background: var(--accent); box-shadow: 0 0 0 1px var(--line);
}
.field select, .field input[type=text], .field input[type=number] {
  background: #0d0d0d; color: var(--text); border: 1px solid var(--line);
  font-family: var(--sans); font-size: 11px; padding: 5px 7px; border-radius: 2px; width: 140px;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--accent); }
.field input[type=number] { width: 84px; }
.field input[type=color] {
  width: 44px; height: 23px; padding: 0; border: 1px solid var(--line);
  background: #0d0d0d; border-radius: 2px; cursor: pointer;
}
.field.chk { justify-content: flex-start; }
.field.chk label {
  display: flex; align-items: center; gap: 8px; font-size: 10.5px;
  color: var(--text); cursor: pointer;
}
.field.chk input { accent-color: var(--accent); width: 14px; height: 14px; }

.hint {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: .3px;
  line-height: 1.6;
  margin-top: 12px;
}

#cellList .field select { width: 112px; }

.frame-custom, .custom-only, .split-only { display: none; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 13px;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-mini { padding: 6px 10px; font-size: 9px; margin-top: 10px; width: 100%; }

/* ==========================================================================
   Footer action bar — seed + transport controls live here instead of a
   top-right button row. Buttons reuse the personal site's corner-tick +
   shimmer-sweep hover treatment (see .footer .social-links a there).
   ========================================================================== */
.action-bar {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.action-left { display: flex; align-items: center; gap: 16px; }

.seed-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--dim);
  text-transform: uppercase;
  white-space: nowrap;
}
.seed-tag b { color: var(--accent); font-weight: 700; }

.action-group { display: flex; align-items: center; gap: 8px; }
.divider-v { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.sq-btn {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 9px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
.sq-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(120deg,
    transparent 30%,
    oklch(0.85 0.08 45 / .15) 45%,
    oklch(0.85 0.08 45 / .3) 50%,
    oklch(0.85 0.08 45 / .15) 55%,
    transparent 70%);
  background-size: 300% 100%;
  background-position: 100% 0;
  background-repeat: no-repeat;
  transition: background-position .5s ease;
  z-index: 0;
}
.sq-btn::after {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 6px; height: 6px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  opacity: 0;
  transition: opacity .25s ease;
}
.sq-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 20px var(--copper-glow); }
.sq-btn:hover::before { background-position: 0% 0; }
.sq-btn:hover::after { opacity: 1; }
.sq-btn > * { position: relative; z-index: 1; }
.sq-btn:disabled { opacity: .35; cursor: default; }
.sq-btn:disabled:hover { border-color: var(--line); color: var(--text); box-shadow: none; }
.sq-btn:disabled:hover::before { background-position: 100% 0; }
.sq-btn:disabled:hover::after { opacity: 0; }
.sq-btn-primary { background: var(--accent); color: #08150e; border-color: var(--accent); font-weight: 700; }
.sq-btn-primary:hover { filter: brightness(1.08); color: #08150e; }
.sq-btn-primary::after { border-color: #08150e; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  body { overflow: auto; height: auto; }
  :root { --header-h: 96px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px 0; }
  .section-nav { width: 100%; gap: 18px; height: 34px; overflow-x: auto; }
  .workspace { flex-direction: column; height: auto; }
  .stage { min-height: 60vh; }
  .panel-rail { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--line); max-height: none; }
  .action-bar { height: auto; flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .action-group { flex-wrap: wrap; }
}
