/* Synthesis — shares simonsure.com's type & layout system.
   Base tokens/structure mirror the site; the box zoom-on-hover is intentionally
   dropped (this view is interactive/editable), and editor affordances are added. */

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

:root {
  --color-bg: #fff;
  --color-text: #0a0a0a;
  --color-muted: #767676;
  --color-soft: #4b4b4b;
  --color-border: #c4c4c4;
  --color-faint: #eef0f3;
  --color-accent: #2f6fed;
  --font: "Space Grotesk", sans-serif;
  --font-mono: "Space Mono", monospace;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; }

/* ---- HEADER ---- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 2.5rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.logo {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-text);
  transition: color 0.2s;
}

.logo:hover { color: var(--color-muted); }

.logo-dot {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-muted);
  user-select: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.header-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
}

.header-btn:hover { color: var(--color-text); }

/* ---- GRID ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding: 0 2.5rem 2.5rem;
}

/* ---- BOX ---- */

.box {
  border: 1px solid var(--color-border);
  padding: 2.2rem;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 260px;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.25s, box-shadow 0.25s;
  margin-top: -1px;
  margin-left: -1px;
}

a.box { cursor: pointer; }

/* no scale zoom — just a crisp border + soft shadow */
.box:hover {
  border-color: var(--color-text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  z-index: 5;
}

.box-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.box-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.box-footer {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-muted);
  letter-spacing: 0.06em;
  margin-top: 1.5rem;
  text-transform: uppercase;
}

.topic-card .box-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topic-card .box-body p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-muted);
  margin-top: 0.6rem;
}

h1 {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---- SUBPAGE LAYOUT ---- */

.box-page-hero,
.box-page-section {
  grid-column: span 4;
  min-height: auto;
}

.box-page-hero:hover,
.box-page-section:hover,
.box-page-content:hover {
  box-shadow: none;
  border-color: var(--color-border);
}

.box-page-content {
  grid-column: span 4;
  min-height: auto;
  padding: 2rem 2.6rem 2.4rem;
}

.box-page-hero .box-footer a {
  color: var(--color-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  transition: color 0.2s;
}
.box-page-hero .box-footer a:hover { color: var(--color-text); }

/* ---- READING / CLAIMS ---- */

/* sections are stacked boxes that collapse borders (no gap between them) */
.sections { display: flex; flex-direction: column; }

.box-page-section {
  grid-column: span 4;
  min-height: auto;
  padding: 1.8rem 2.4rem 2rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-soft);
}

.section-note-wrap {
  margin: -0.1rem 0 0.9rem;
}
.section-note {
  font-size: 0.9rem;
  color: var(--color-soft);
  line-height: 1.5;
  font-style: italic;
  letter-spacing: 0.02em;
}

.claim {
  position: relative;
  margin-top: 1.1rem;
}
.claim.first { margin-top: 0.2rem; }

.claim-text {
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.claim-note {
  font-size: 0.9rem;
  color: var(--color-soft);
  line-height: 1.5;
  font-style: italic;
  letter-spacing: 0.02em;
  margin-bottom: 0.4rem;
}

.source-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.source-item {
  line-height: 1.7;
  position: relative;
}

.source-item .source-detail {
  font-size: 0.85rem;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

.source-item .source-title,
.source-item a.source-title {
  font-size: 0.85rem;
  color: var(--color-soft);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.source-item a.source-title:hover { color: var(--color-text); }

.source-item .source-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-muted);
  letter-spacing: 0.05em;
}

/* ================= EDITOR AFFORDANCES ================= */

/* inline editable fields */
.field {
  outline: none;
  border-radius: 2px;
  transition: background 0.15s, box-shadow 0.15s;
}
body.can-edit .field:hover { background: var(--color-faint); }
body.can-edit .field:focus {
  background: #fff;
  box-shadow: 0 0 0 1px var(--color-text);
}
body.can-edit .field.empty::before {
  content: attr(data-placeholder);
  color: var(--color-border);
}

/* insertion line ("+") between items */
.inserter {
  height: 0.55rem;
  position: relative;
  display: none;
  cursor: pointer;
}
body.can-edit .inserter { display: block; }
.inserter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.15s;
}
.inserter::before {
  content: "+";
  position: absolute;
  top: 50%;
  left: -1.3rem;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: transparent;
  transition: color 0.15s;
}
.inserter:hover::after { background: var(--color-accent); }
.inserter:hover::before { color: var(--color-accent); }

/* section add — sections touch (collapsed borders); an always-visible gray
   "+ section" label sits centered ON the separating line (masking it in the
   middle). Click to insert. Only the label is a hit target. */
.inserter.section-inserter {
  position: absolute;
  left: 50%;
  z-index: 8;
  display: none;
  margin: 0;
  height: auto;
  cursor: pointer;
}
body.can-edit .inserter.section-inserter { display: block; }
.inserter.section-inserter-top { top: 0; transform: translate(-50%, -50%); }
.inserter.section-inserter-bottom { bottom: 0; transform: translate(-50%, 50%); }
.inserter.section-inserter::after { display: none; }
.inserter.section-inserter::before {
  content: "+ section";
  display: block;
  color: #9b9b9b;
  background: var(--color-bg);
  padding: 0.15rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.inserter.section-inserter:hover::before { color: var(--color-accent); }

/* empty topic: a plain in-flow "+ section" (no box to anchor an overlay to) */
.inserter.section-inserter-empty {
  height: auto;
  padding: 1.2rem 0 0;
  cursor: pointer;
}
.inserter.section-inserter-empty::after { display: none; }
.inserter.section-inserter-empty::before {
  content: "+ section";
  position: static;
  left: auto;
  transform: none;
  color: #9b9b9b;
  background: none;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.inserter.section-inserter-empty:hover::before { color: var(--color-accent); }

/* drag handle in the left gutter, shown on row hover */
.row { position: relative; }
.handle {
  position: absolute;
  left: -1.5rem;
  top: 0.35rem;
  width: 1.2rem;
  text-align: center;
  color: transparent;
  cursor: grab;
  user-select: none;
  transition: color 0.15s;
}
.handle svg {
  width: 13px;
  height: 13px;
  display: block;
  margin: 0 auto;
  pointer-events: none;
}
body.can-edit .row:hover > .handle { color: var(--color-muted); }
body.can-edit .handle:hover { color: var(--color-text); }
.handle:active { cursor: grabbing; }

/* section boxes: handle sits inside the top-left corner (no negative gutter) */
.box-page-section > .handle { left: 0.9rem; top: 0.9rem; }

/* topic cards have no left gutter — put the handle inside the top-left corner */
.topic-card .handle {
  left: 0.8rem;
  right: auto;
  top: 0.8rem;
}

.row.dragging { opacity: 0.35; }

/* drop indicators — instant (override the .box box-shadow transition so they
   show on section/topic boxes too) and axis-aware (vertical bar for topics). */
.row.drop-before,
.row.drop-after,
.row.drop-left,
.row.drop-right { transition: none; }
.row.drop-before { box-shadow: inset 0 3px 0 0 var(--color-accent); }
.row.drop-after { box-shadow: inset 0 -3px 0 0 var(--color-accent); }
.row.drop-left { box-shadow: inset 3px 0 0 0 var(--color-accent); }
.row.drop-right { box-shadow: inset -3px 0 0 0 var(--color-accent); }

/* delete (x) sits inline at the end of the item's text (left-bound), on hover */
.del {
  display: inline-block;
  margin-left: 0.55rem;
  color: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  vertical-align: baseline;
  background: none;
  border: none;
  transition: color 0.15s;
}
body.can-edit .section-head:hover .del,
body.can-edit .claim-text:hover .del,
body.can-edit .source-item:hover .del { color: var(--color-muted); }
.del:hover { color: #c0392b; }

.link-del { color: #c0392b; cursor: pointer; }

/* "+ source" affordance (sources are added via this button only) */
.add-source {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-border);
  cursor: pointer;
  padding: 0.3rem 0 0;
  transition: color 0.15s;
}
body.can-edit .add-source { display: inline-block; }
.add-source:hover { color: var(--color-accent); }

/* small mono add buttons (sections, topics) */
.add-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  background: none;
  border: 1px dashed var(--color-border);
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  display: none;
}
body.can-edit .add-btn { display: inline-block; }
.add-btn:hover { color: var(--color-text); border-color: var(--color-text); }

.add-topic-box {
  border: 1px dashed var(--color-border);
  min-height: 260px;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
  cursor: pointer;
  margin-top: -1px;
  margin-left: -1px;
  transition: color 0.2s, border-color 0.2s;
}
body.can-edit .add-topic-box { display: flex; }
.add-topic-box:hover { color: var(--color-text); border-color: var(--color-text); }

.source-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.4rem;
  align-items: baseline;
}
.source-fields .field { display: inline; }

/* ---- MODAL (login / register) ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border: 1px solid var(--color-text);
  padding: 2.5rem;
  width: min(400px, 90vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}
.modal h2 { font-size: 1.3rem; margin-bottom: 1.2rem; }
.modal p { font-size: 0.85rem; color: var(--color-muted); line-height: 1.6; margin-bottom: 1.2rem; }
.modal input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.7rem;
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
}
.modal input:focus { outline: none; border-color: var(--color-text); }
.modal-actions { display: flex; gap: 0.8rem; }
.btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--color-text);
  background: var(--color-text);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.8; }
.btn.secondary { background: #fff; color: var(--color-text); }
.modal-error { color: #c0392b; font-size: 0.75rem; min-height: 1rem; margin-bottom: 0.5rem; }
.modal-note { font-size: 0.7rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 0.6rem 1.2rem;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 200;
}
.toast.show { opacity: 1; }

/* ---- RESPONSIVE ---- */

@media (max-width: 1024px) {
  header { padding: 1.5rem; }
  .grid { grid-template-columns: repeat(2, 1fr); padding: 0 1.5rem 1.5rem; }
}

@media (max-width: 600px) {
  header { padding: 1.2rem 1rem; }
  .grid { grid-template-columns: 1fr; padding: 0 1rem 1rem; }
  .box { min-height: 200px; }
  .box-page-hero, .box-page-section { min-height: auto; }
  h1 { font-size: 1.6rem; }
  .handle { left: -1.1rem; }
}
