/* ── PAGE SECTIONS ──
   Sections an admin added from the browser, and the chrome that appears
   around them in edit mode.

   A built section has to be indistinguishable from a shipped one — same
   rules, same indices, same type scale — or the page starts to look like
   two websites stacked. So everything here leans on the tokens and the
   patterns already defined in layout.css and components.css.
*/

/* A zone that sits directly in a panel carries the page measure itself,
   because builder.js hides this one node when there is nothing in it —
   a wrapper around it would leave an empty ruled band behind. */
.blocks.zone {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 40px var(--gutter);
  border-top: 1px solid var(--line);
}
.blocks.zone[data-zone="top"] { border-top: 0; border-bottom: 1px solid var(--line); }

/* A page an admin made is nothing but its zone, so it opens like a page
   rather than continuing one. */
.tab-panel[data-custom] .blocks.zone { border-top: 0; padding-top: 48px; padding-bottom: 60px; }

/* Zones inside a page's own section only need the gap. */
.blocks:not(.zone):not(:empty) { margin-top: 40px; }

.blocks > .block { padding: 34px 0; }
.blocks > .block:first-child { padding-top: 0; }
.blocks > .block:last-child { padding-bottom: 0; }
.blocks > .block + .block { border-top: 1px solid var(--line); }

/* ── Text ─────────────────────────────────────────────────── */

.blk-text p {
  max-width: 66ch;
  color: var(--text-2);
  font-size: 14px;
}
.blk-text p + p { margin-top: 14px; }
.blk-text code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
}

/* Two columns of running text, which is what a long paragraph block
   wants at this measure. */
.blk-text-2 {
  columns: 2;
  column-gap: 44px;
  max-width: none;
}
.blk-text-2 p { max-width: none; break-inside: avoid; }
@media (max-width: 760px) { .blk-text-2 { columns: 1; } }

/* ── Steps ────────────────────────────────────────────────── */

.blk-steps { list-style: none; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; }
.blk-steps li {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
}
.blk-step-n {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
  padding-top: 3px;
  flex: none;
}
.blk-steps h3 { margin-bottom: 5px; }
.blk-steps p { color: var(--text-2); font-size: 13px; max-width: 62ch; }

/* ── Facts ────────────────────────────────────────────────── */

.blk-spec { max-width: 620px; }

/* ── Questions ────────────────────────────────────────────── */

.blk-faq {
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface);
  overflow: hidden;
}
.blk-faq details + details { border-top: 1px solid var(--line); }
.blk-faq summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  transition: background var(--fast);
}
.blk-faq summary::-webkit-details-marker { display: none; }
.blk-faq summary::after {
  content: "+";
  margin-left: auto;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-3);
}
.blk-faq details[open] summary::after { content: "−"; color: var(--accent); }
.blk-faq summary:hover { background: var(--surface-2); }
.blk-faq-body {
  padding: 0 18px 16px;
  color: var(--text-2);
  font-size: 13.5px;
  max-width: 70ch;
}
.blk-faq-body p + p { margin-top: 10px; }

/* ── Call to action ───────────────────────────────────────── */

.blk-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 26px;
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-3);
  background: var(--surface);
}
.blk-cta > div:first-child { flex: 1; min-width: 260px; }
.blk-cta h2 { margin-bottom: 8px; }
.blk-cta .hero-actions { margin-top: 0; }

/* ── Notice ───────────────────────────────────────────────── */

.blk-notice {
  padding: 16px 18px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-3);
  background: var(--accent-soft);
  font-size: 13.5px;
  max-width: 72ch;
}
.blk-notice strong {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}
.blk-notice p { color: var(--text-2); }
.blk-notice p + p { margin-top: 9px; }
.blk-notice-info { border-color: var(--info-line); background: var(--info-soft); }
.blk-notice-ok   { border-color: var(--ok-line);   background: var(--ok-soft); }
.blk-notice-warn { border-color: var(--warn-line); background: var(--warn-soft); }

/* ── Quote ────────────────────────────────────────────────── */

.blk-quote {
  max-width: 62ch;
  padding-left: 22px;
  border-left: 2px solid var(--accent);
}
.blk-quote blockquote p {
  font-size: 19px;
  line-height: 1.45;
  letter-spacing: -0.015em;
  color: var(--text);
}
.blk-quote blockquote p + p { margin-top: 12px; }
.blk-quote figcaption {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Image ────────────────────────────────────────────────── */

.blk-image { max-width: 720px; }
.blk-image-full { max-width: none; }
.blk-image img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--surface-2);
}
.blk-image figcaption {
  margin-top: 9px;
  font-size: 12px;
  color: var(--text-3);
}

/* ── Code ─────────────────────────────────────────────────── */

.blk-code-title { margin-bottom: 10px; }
.blk-code {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--bg-sunken);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

/* ── Rules and space ──────────────────────────────────────── */

.blk-rule { border: 0; border-top: 1px solid var(--line); }
.blk-space { height: 30px; }

/* ══ Edit mode ════════════════════════════════════════════════ */

/* Sections show their frame only while the page is being edited, so a
   visitor never sees a dashed box. */
body.building .blocks > .block {
  position: relative;
  outline: 1px dashed var(--accent-line);
  outline-offset: 10px;
  border-radius: 2px;
}
body.building .blocks > .block:hover { outline-color: var(--accent); }
body.building .block-hidden { opacity: 0.5; }

.block-tools {
  position: absolute;
  top: -30px; right: -10px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity var(--fast);
}
.block:hover > .block-tools,
.block:focus-within > .block-tools { opacity: 1; }
.bt-name {
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.block-tools .push { flex: 1; }
/* One chevron, pointed both ways. */
.bt-up svg { transform: rotate(180deg); }

.zone-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 26px;
  padding: 13px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-3);
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.zone-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.zone-add svg { width: 14px; height: 14px; fill: currentColor; }

.zone-empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: var(--r-3);
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}
.zone-empty .label { display: block; margin-bottom: 4px; }

/* ── The picker ───────────────────────────────────────────── */

.sec-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.sec-choice {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 4px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--fast), background var(--fast);
}
.sec-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.sec-choice svg { width: 15px; height: 15px; fill: var(--text-3); margin-top: 2px; }
.sec-choice:hover svg { fill: var(--accent); }
.sec-choice-name { font-size: 13px; font-weight: 600; }
.sec-choice-blurb {
  grid-column: 2;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}
@media (max-width: 540px) { .sec-picker { grid-template-columns: 1fr; } }

/* ── The form ─────────────────────────────────────────────── */

.sec-blurb { margin-bottom: 18px; }

.sec-list { display: grid; gap: 8px; margin-bottom: 10px; }
.sec-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
}
.sec-item-head { display: flex; align-items: center; gap: 8px; }

.sec-image { display: flex; gap: 12px; align-items: flex-start; }
.sec-image-preview {
  display: grid;
  place-items: center;
  width: 88px; height: 66px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--surface-2);
  overflow: hidden;
  flex: none;
}
.sec-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.sec-image-actions { flex: 1; display: grid; gap: 8px; justify-items: start; }
.sec-image-actions .input { width: 100%; }

/* ── The edit bar ─────────────────────────────────────────── */

/* LOAD-BEARING — content.js adds .show while edit mode is on */
.edit-bar {
  position: fixed;
  bottom: 18px; left: 50%;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  transform: translate(-50%, calc(100% + 30px));
  transition: transform var(--mid);
}
.edit-bar.show { transform: translate(-50%, 0); }
.eb-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

/* Editable copy, while it is being edited. */
body.editing [data-cms] {
  outline: 1px dashed var(--accent-line);
  outline-offset: 3px;
  border-radius: 2px;
  cursor: text;
}
body.editing [data-cms]:hover, body.editing [data-cms]:focus {
  outline-style: solid;
  outline-color: var(--accent);
}
body.editing [data-cms].dirty {
  outline-style: solid;
  outline-color: var(--accent);
  background: var(--accent-soft);
}
/* A link wrapping editable text would navigate on the first click. */
body.editing [data-cms] a,
body.editing a:has([data-cms]) { pointer-events: none; }
