/* ============================================================
   styles.css — MatterMake Pattern Studio
   Based on the MatterMake Design System: stark black-on-white,
   one rust accent (#E45C44), stone hairlines, lines not shadows,
   near-square corners, Titling Gothic FB + Suisse Intl.
   ============================================================ */

@import url("assets/mm-fonts.css");

:root {
  --ink: #000000;
  --paper: #ffffff;
  --grey-900: #1a1a1a;
  --grey-700: #454e4d;   /* slate — secondary text */
  --grey-500: #7f7f7f;   /* mid grey — captions, meta */
  --grey-300: #d7d7cf;   /* stone — hairlines */
  --grey-100: #f2f1ec;   /* faint warm grey — alt surface */
  --rust: #e45c44;       /* THE accent */
  --rust-hover: #d44e38;
  --rust-deep: #854b4b;
  --rust-tint: #fff3e1;
  --slate: #454e4d;      /* detractor / secondary mark */
  --font-display: "Titling Gothic FB", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Suisse Intl", "Helvetica Neue", Arial, sans-serif;
  --radius: 3px;
  --ease: cubic-bezier(0.2, 0, 0.1, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 340px 1fr;
  grid-template-areas: "header header" "sidebar viewport";
  height: 100vh;
  overflow: hidden;
}

/* ---------- header ---------- */
header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 14px; width: auto; display: block; }
.brand-sub {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 400;
  color: var(--grey-500);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding-left: 14px;
  border-left: 1px solid var(--grey-300);
}

.header-spacer { flex: 1; }

.btn {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--rust); border-color: var(--rust); color: var(--paper); }
.btn.primary:hover { background: var(--rust-hover); border-color: var(--rust-hover); }
.btn.primary:active { background: var(--rust-deep); border-color: var(--rust-deep); }
.btn.small { font-size: 11px; padding: 5px 10px; }
.btn.active { background: var(--ink); color: var(--paper); }

#mode-toggle { border-color: var(--grey-300); color: var(--grey-700); }
#mode-toggle:hover { background: var(--grey-100); color: var(--ink); }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 1px;
}

/* ---------- sidebar ---------- */
#sidebar {
  grid-area: sidebar;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  padding-bottom: 60px;
}

.panel-section {
  padding: 20px 20px 22px;
  border-bottom: 1px solid var(--grey-300);
}
.panel-section > h2 {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.panel-section > h2::before {
  content: "";
  display: block;
  width: 18px;
  height: 2px;
  background: var(--rust);
  flex-shrink: 0;
}

.hint {
  font-size: 12.5px;
  color: var(--grey-700);
  line-height: 1.5;
  margin: 4px 0 10px;
}

/* controls */
.ctl { margin-bottom: 13px; }
.ctl-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  margin-bottom: 6px;
}
.ctl-val {
  font-family: var(--font-display);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--grey-700);
}
.ctl input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 1px;
  background: var(--grey-300);
  outline: none;
}
.ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  background: var(--ink);
  border-radius: 2px;
  cursor: pointer;
  border: none;
}
.ctl input[type="range"]:active::-webkit-slider-thumb { background: var(--rust); }
.ctl.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ctl-label-s { font-size: 13.5px; }
.ctl.check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.45;
  cursor: pointer;
  color: var(--grey-700);
}
.ctl.check input { margin-top: 2px; accent-color: var(--ink); }

select, input.dim {
  font-family: var(--font-display);
  font-size: 11.5px;
  padding: 5px 7px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
select:hover, input.dim:hover { border-color: var(--ink); }

/* panels list */
.panel-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.panel-idx {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--grey-500);
  width: 20px;
}
input.dim { width: 72px; }
input.dim.gap { width: 54px; color: var(--rust); }
.gap-spacer { display: inline-block; width: 54px; }
.grid-subhead {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-500);
  margin: 12px 0 6px;
}
.dim-x { color: var(--grey-500); font-size: 12px; }
.icon-btn {
  background: none;
  border: none;
  color: var(--grey-500);
  font-size: 17px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 120ms var(--ease);
}
.icon-btn:hover { color: var(--rust); }
.add-row { display: flex; gap: 8px; margin: 10px 0 14px; }
.add-row select { flex: 1; min-width: 0; }

/* pattern grid */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pat-thumb {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  background: none;
  border: 1px solid var(--grey-300);
  border-radius: 2px;
  padding: 8px 6px 7px;
  cursor: pointer;
  color: var(--grey-700);
  transition: border-color 120ms var(--ease), color 120ms var(--ease);
}
.pat-thumb svg { width: 80%; height: auto; display: block; }
.pat-thumb span {
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--grey-700);
}
.pat-thumb:hover { border-color: var(--ink); color: var(--ink); }
.pat-thumb:hover span { color: var(--ink); }
.pat-thumb.active { border-color: var(--rust); outline: 1px solid var(--rust); color: var(--rust); }
.pat-thumb.active span { color: var(--rust); }
.pattern-tier {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-500);
}

/* points */
.tool-row { display: flex; gap: 7px; margin-bottom: 8px; }
.point-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.point-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--grey-300);
  border-radius: 2px;
  padding: 9px 8px 2px 9px;
  cursor: pointer;
  transition: border-color 120ms var(--ease);
}
.point-row:hover { border-color: var(--ink); }
.point-row.selected { border-color: var(--rust); outline: 1px solid var(--rust); }
.pt-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  color: var(--paper);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  line-height: 1;
}
.pt-badge.att { background: var(--rust); }
.pt-badge.det { background: var(--slate); }
.pt-ctls { flex: 1; min-width: 0; }
.pt-ctls .ctl { margin-bottom: 7px; }
.pt-ctls .ctl-label { font-size: 12px; margin-bottom: 2px; }

/* materials */
.swatch-row { display: flex; flex-direction: column; gap: 6px; }
.swatch {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--grey-300);
  border-radius: 2px;
  padding: 7px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 120ms var(--ease);
}
.swatch:hover { border-color: var(--ink); }
.swatch.active { border-color: var(--rust); outline: 1px solid var(--rust); }
.chip {
  width: 26px; height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 2px;
  flex-shrink: 0;
}
.val-row {
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 10px;
  gap: 7px;
}
.val-chip {
  width: 28px; height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  cursor: pointer;
}
.val-chip.active { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- viewport ---------- */
#viewport {
  grid-area: viewport;
  position: relative;
  overflow: hidden;
}
#viewport canvas { display: block; }

.vp-overlay {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 16px;
  backdrop-filter: blur(6px);
}
.vp-overlay label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-700);
  display: flex;
  align-items: center;
  gap: 10px;
}
.vp-overlay input[type="range"] {
  width: 130px;
  -webkit-appearance: none;
  appearance: none;
  height: 1px;
  background: var(--grey-300);
}
.vp-overlay input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px;
  background: var(--ink);
  border-radius: 2px;
  cursor: pointer;
}

/* toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 11px 16px;
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  pointer-events: none;
  z-index: 50;
}
#toast.show { opacity: 1; transform: none; }

/* client mode hides studio-only chrome */
body.client .studio-only { display: none !important; }

/* demo mode (pitch deck embeds): no header, no toast, no overlay */
body.demo { grid-template-rows: 0 1fr; }
body.demo header, body.demo #toast, body.demo .vp-overlay { display: none !important; }

/* scrollbar */
#sidebar::-webkit-scrollbar { width: 10px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--grey-300); }
#sidebar::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
