/* Stonemason — shared tokens, header and controls.
   Montserrat (titles) + Atkinson Hyperlegible (body). Dark is the default;
   [data-theme="light"] on <html> switches to the warm light palette. */

:root {
  --bg: #0e1216;
  --canvas: #0b0f13;
  --header: #12171d;
  --surface: #161d25;
  --panel: #1b232c;
  --well: #10151b;
  --field: #0a0e12;
  --ink: #e9edf2;
  --ink-2: #93a0ae;
  --ink-3: #6f7c8a;
  --ink-soft: #c6cdd6;
  --line: rgba(255, 255, 255, 0.08);
  --chip: rgba(147, 160, 174, 0.12);
  --hover: rgba(255, 255, 255, 0.06);
  --accent: #c4646a;
  --accent-hover: #d17378;
  --on-accent: #0b0f13;
  --accent-soft: rgba(196, 100, 106, 0.16);
  --accent-faint: rgba(196, 100, 106, 0.07);
  --amber: #ffc46b;
  --ok-soft: rgba(122, 220, 143, 0.12);
  --danger: #ff8a8a;
  --dots: rgba(134, 150, 170, 0.08);
  --scrim: rgba(7, 10, 13, 0.55);
  --track-off: #d4cec4;
  --knob: #0e1216;
  --shadow-header: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-pop-filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.4)); /* the same, for filter chains */
  --shadow-dialog: 0 40px 100px rgba(0, 0, 0, 0.6);
  --shadow-board: 0 24px 70px rgba(0, 0, 0, 0.55);
  --font-title: "Montserrat", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f4f0;
  --canvas: #ebe9e3;
  --header: #ffffff;
  --surface: #ffffff;
  --panel: #ffffff;
  --well: #f5f4f0;
  --field: #f1efea;
  --ink: #1c2229;
  --ink-2: #5d6873;
  --ink-3: #66707a;
  --ink-soft: #3a434c;
  --line: rgba(28, 34, 41, 0.1);
  --chip: rgba(28, 34, 41, 0.07);
  --hover: rgba(28, 34, 41, 0.05);
  --accent: #a8474d;
  --accent-hover: #93393f;
  --on-accent: #ffffff;
  --accent-soft: rgba(168, 71, 77, 0.12);
  --accent-faint: rgba(168, 71, 77, 0.06);
  --amber: #b86e00;
  --ok-soft: rgba(40, 150, 80, 0.12);
  --danger: #b3261e;
  --dots: rgba(60, 50, 40, 0.13);
  --scrim: rgba(40, 34, 28, 0.32);
  --knob: #ffffff;
  --shadow-header: 0 6px 20px rgba(60, 50, 40, 0.18);
  --shadow-pop: 0 8px 24px rgba(60, 50, 40, 0.16);
  --shadow-pop-filter: drop-shadow(0 8px 18px rgba(60, 50, 40, 0.16));
  --shadow-dialog: 0 40px 100px rgba(60, 50, 40, 0.28);
  --shadow-board: 0 24px 70px rgba(60, 50, 40, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.site-header {
  background: var(--header);
  box-shadow: var(--shadow-header);
  position: relative;
  z-index: 20;
  flex: none;
}
.site-header nav {
  padding: 0 32px;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { display: block; width: 54px; height: 54px; }
.brand span {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
}
:root[data-theme="light"] .brand span { letter-spacing: 0.02em; }
.logo-light { display: none !important; }
:root[data-theme="light"] .logo-dark { display: none !important; }
:root[data-theme="light"] .logo-light { display: block !important; }
.nav-spacer { flex: 1; }

/* theme switch: sun · track · moon */
.theme-switch { display: inline-flex; align-items: center; gap: 0; }
.theme-switch svg { flex: none; }
.theme-switch .sun { margin-right: 6px; stroke: var(--ink-2); color: var(--ink-2); }
.theme-switch .moon { margin-left: 6px; color: var(--ink); }
:root[data-theme="light"] .theme-switch .sun { stroke: var(--ink); color: var(--ink); }
:root[data-theme="light"] .theme-switch .moon { color: var(--ink-2); }
.switch {
  width: 48px; height: 28px;
  border-radius: 999px; border: 0;
  background: var(--accent);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: flex-end;
  padding: 3px;
}
.switch span {
  display: block; width: 22px; height: 22px; border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}
:root[data-theme="light"] .switch { background: var(--track-off); justify-content: flex-start; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-body);
  font-size: 14px; font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 0; border-radius: 999px;
  padding: 11px 22px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { color: var(--on-accent); background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { font-size: 13px; padding: 9px 18px; }
.btn.large { font-size: 16px; padding: 14px 28px; gap: 10px; }
.btn.quiet { color: var(--ink-2); background: var(--chip); font-weight: 500; padding: 11px 18px; }
.btn.quiet:hover { color: var(--ink); background: var(--hover); }
.btn.soft { color: var(--ink); background: rgba(233, 237, 242, 0.08); font-weight: 500; }
:root[data-theme="light"] .btn.soft { background: rgba(28, 34, 41, 0.08); }
.btn.soft:hover { color: var(--ink); background: var(--hover); }

.icon-btn {
  width: 38px; height: 38px;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { color: var(--ink-3); cursor: default; opacity: 0.7; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.chip { background: var(--chip); }

@media (max-width: 640px) {
  .site-header nav { padding: 0 16px; gap: 14px; }
  .brand img { width: 42px; height: 42px; }
}
@media (max-width: 480px) {
  .site-header nav { gap: 10px; }
  .brand { gap: 8px; }
  .brand img { width: 36px; height: 36px; }
  .brand span { font-size: 14px; letter-spacing: 0.04em; }
  .theme-switch .sun, .theme-switch .moon { display: none; }
  .site-header .btn.small { padding: 8px 12px; font-size: 12.5px; }
}
