/* CoCreate Square document studio. Brand colours and fonts come from /brand/tokens.css.
   The document is the hero: the preview stage is a dark Brick field so the pages read as paper,
   and the form stays quiet on the brand's cream surface. */

:root {
  --stage: #2A2321;
  --field: #FFFFFF;
  --line: var(--divider);
  --muted: rgb(59 30 26 / 0.66);
  --on-stage: rgb(250 250 250 / 0.8);
  --on-stage-dim: rgb(250 250 250 / 0.46);
  --radius: 6px;
  --panel: 440px;
  --bar: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 14px/1.5 var(--text);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
code { font: 600 0.92em/1 var(--text); background: rgb(84 41 34 / 0.08); padding: 1px 5px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brick); outline-offset: 2px; }

/* ---------- top bar ---------- */

.bar {
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--brick);
  color: var(--white);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; margin-right: auto; }
.brand img { height: 24px; display: block; }
.brand span { font: 700 18px/1 var(--display); letter-spacing: -0.01em; }
.passcode { display: flex; align-items: center; gap: 10px; }
.passcode label { margin: 0; font-size: 13px; font-weight: 500; white-space: nowrap; color: rgb(250 250 250 / 0.78); }
.bar .passcode input {
  width: 160px;
  padding: 6px 10px;
  border: 1px solid rgb(250 250 250 / 0.28);
  border-radius: var(--radius);
  background: rgb(250 250 250 / 0.1);
  color: var(--white);
}
.bar .passcode input:focus { outline: none; border-color: var(--salmon); box-shadow: none; }

/* ---------- layout ---------- */

.studio { display: grid; grid-template-columns: var(--panel) minmax(0, 1fr); height: calc(100vh - var(--bar)); }
/* positioned, so visually hidden labels and inputs stay inside the scrolling panel instead of stretching the page */
.panel { position: relative; overflow-y: auto; padding: 28px 28px 0; border-right: 1px solid var(--line); }
.stage { position: relative; overflow-y: auto; background: var(--stage); color: var(--on-stage); }

/* ---------- form ---------- */

fieldset { border: 0; margin: 0 0 34px; padding: 0; min-width: 0; }
legend, .review h2 {
  padding: 0;
  margin: 0 0 6px;
  font: 600 20px/1.2 var(--display);
  letter-spacing: -0.01em;
  color: var(--brick);
}
.help { margin: 0 0 12px; font-size: 13px; color: var(--muted); }

/* the markup guide: open on a first visit, folded away once there is copy */
.guide { margin: 0 0 14px; font-size: 13px; }
.guide summary { cursor: pointer; font-weight: 600; color: var(--brick); }
.guide dl { margin: 10px 0 8px; padding: 12px 14px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); }
.guide dl div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 6px 0; }
.guide dl div + div { border-top: 1px solid rgb(214 203 197 / 0.6); }
.guide dt { margin: 0; font-weight: 600; }
.guide dd { margin: 0; color: var(--muted); }
.guide p { margin: 0; color: var(--muted); }

/* Claude-only controls appear only when the studio has a Claude key and the team chooses it */
.claude-only { display: none; }
.with-claude .claude-only { display: block; }
.editor-choice .help { margin-top: 10px; }
label, .label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; }
.opt { font-weight: 400; color: var(--muted); }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--brick);
  box-shadow: 0 0 0 3px rgb(255 143 145 / 0.5);
}
textarea { resize: vertical; line-height: 1.55; }
#copy { min-height: 360px; font-size: 13.5px; line-height: 1.65; }
.count { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }

.paper { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--field); overflow: hidden; }
.paper label { margin: 0; font-weight: 500; cursor: pointer; }
.paper input { position: absolute; opacity: 0; pointer-events: none; }
.paper span { display: block; padding: 7px 16px; }
.paper label + label span { border-left: 1px solid var(--line); }
.paper input:checked + span { background: var(--brick); color: var(--white); }
.paper input:focus-visible + span { outline: 2px solid var(--brick); outline-offset: -4px; }

.images { list-style: none; margin: 0 0 12px; padding: 0; }
.images li {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.images img { grid-row: span 3; width: 76px; height: 76px; object-fit: cover; border-radius: 3px; }
.images .name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--muted); }
.images .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.images input { padding: 6px 9px; font-size: 13px; }
.images .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.remove { background: none; border: 0; padding: 0; font-size: 12.5px; font-weight: 600; color: var(--brick); text-decoration: underline; cursor: pointer; }

.drop {
  display: block;
  margin: 0;
  padding: 16px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 400;
}
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop span { display: block; font-weight: 600; color: var(--brick); }
.drop small { color: var(--muted); font-size: 12.5px; }
.drop:hover, .drop.over { border-color: var(--brick); background: var(--field); }
.drop:focus-within { outline: 2px solid var(--brick); outline-offset: 2px; }

/* the action stays in reach however long the copy is */
.make {
  position: sticky;
  bottom: 0;
  margin: 0 -28px;
  padding: 16px 28px 20px;
  background: var(--cream);
  border-top: 1px solid var(--line);
}
.primary {
  width: 100%;
  padding: 13px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brick);
  color: var(--white);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.primary:hover { background: #6B352C; }
.primary:disabled { opacity: 0.6; cursor: progress; }
.status { font-size: 13px; color: var(--muted); }
.status:not(:empty) { margin-top: 10px; }
.status.error { color: var(--brick); font-weight: 500; }
.status ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

.notice { margin: 0 0 24px; padding: 12px 14px; border-radius: var(--radius); background: rgb(255 143 145 / 0.28); color: var(--brick); font-weight: 500; }

/* ---------- editor review ---------- */

.review { padding: 28px 0 40px; }
.review h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 600; }
.checks, .notes { list-style: none; margin: 0; padding: 0; }
.checks li, .notes li { position: relative; padding-left: 20px; margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.checks li::before, .notes li::before { content: ''; position: absolute; left: 2px; top: 0.5em; width: 7px; height: 7px; }
.checks li::before { background: var(--orange); }
.notes li::before { background: var(--salmon); transform: rotate(11.17deg); }

/* ---------- stage ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--stage);
  border-bottom: 1px solid rgb(250 250 250 / 0.08);
}
.toolbar p { margin: 0; font-size: 13px; }
.save {
  padding: 9px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--salmon);
  color: var(--brick);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.save:hover { background: #FFA3A5; }
.save:focus-visible { outline-color: var(--salmon); }

.sheet-wrap { display: flex; justify-content: center; padding: 56px 32px; }
.sheet {
  width: min(400px, 100%);
  aspect-ratio: 210 / 297;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 36px;
  border: 1.5px dashed rgb(250 250 250 / 0.2);
  border-radius: 2px;
}
.sheet p { margin: 0 0 14px; }
.lede { font: 600 26px/1.15 var(--display); letter-spacing: -0.01em; color: var(--white); }
.ghost {
  align-self: flex-start;
  margin-top: 8px;
  padding: 8px 14px;
  border: 1px solid rgb(250 250 250 / 0.35);
  border-radius: var(--radius);
  background: none;
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
}
.ghost:hover { border-color: var(--salmon); }
.ghost:focus-visible { outline-color: var(--salmon); }

.steps { list-style: none; margin: 0 0 18px; padding: 0; }
.steps li { position: relative; padding-left: 26px; margin-bottom: 14px; color: var(--on-stage-dim); }
.steps li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.45em;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
}
.steps li.done { color: var(--on-stage); }
.steps li.done::before { background: var(--salmon); border-color: var(--salmon); }
.steps li.active { color: var(--white); font-weight: 600; }
.steps li.active::before { background: var(--salmon); border-color: var(--salmon); animation: tilt 1.6s ease-in-out infinite; }
@keyframes tilt { 50% { transform: rotate(11.17deg) scale(1.15); } }
.elapsed { font-size: 13px; color: var(--on-stage-dim); }

.pages { display: flex; justify-content: center; padding: 28px 24px 72px; }
.veiled { position: absolute; left: 0; right: 0; top: 0; visibility: hidden; pointer-events: none; }
.fit { position: relative; }
.fit iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: transparent; }
.pages.reveal { animation: reveal 420ms ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .steps li.active::before, .pages.reveal { animation: none; }
}

/* ---------- small screens: form first, preview below ---------- */

@media (max-width: 900px) {
  .studio { display: block; height: auto; }
  .panel { overflow: visible; border-right: 0; padding: 22px 16px 0; }
  .make { margin: 0 -16px; padding: 14px 16px 16px; }
  .stage { min-height: 70vh; overflow: visible; }
  .bar { height: auto; min-height: var(--bar); flex-wrap: wrap; row-gap: 8px; column-gap: 12px; padding: 10px 16px; }
  .brand span { font-size: 16px; white-space: nowrap; }
  .passcode label { display: none; }
  .bar .passcode input { width: 112px; }
}
@media (max-width: 480px) {
  .pair, .images .two { grid-template-columns: 1fr; }
  .guide dl div { grid-template-columns: 1fr; gap: 2px; }
}
