/* Sections: a tinted area with a title bar. Only the bar, the edges and the corners take
   the pointer, so clicks, box selection and double-clicks inside reach the board. */
.card.section-card {
  --section-fill: color-mix(in srgb, var(--section-color, #dbe8ff) 38%, transparent);
  --section-bar: color-mix(in srgb, var(--section-color, #dbe8ff) 72%, transparent);
  --section-line: color-mix(in srgb, var(--section-color, #dbe8ff) 62%, #56606b);
  --section-ink: #2d3640;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  background: var(--section-fill) !important;
  border: 1.5px solid var(--section-line) !important;
  border-radius: 14px !important;
  box-shadow: none !important;
  overflow: visible !important;
  pointer-events: none;
  cursor: default;
}
.card.section-card:hover { box-shadow: none !important; }
.card.section-card > .drag-handle { display: none !important; }
.card.section-card > .card-body { padding: 0 !important; height: 100%; }
.card.section-card > :is(.resize-handle, .connection-handle) { pointer-events: auto; }
.card.section-card.collapsed > .resize-handle { display: none !important; }

.section-bar {
  pointer-events: auto;
  position: absolute;
  inset: 0 0 auto 0;
  height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 10px;
  border-radius: 12.5px 12.5px 0 0;
  background: var(--section-bar);
  color: var(--section-ink);
  cursor: grab;
  direction: rtl;
  touch-action: none;
}
html[lang=en] .section-bar { direction: ltr; padding: 0 10px 0 12px; }
.section-card.collapsed .section-bar { border-radius: 12.5px; }
.card.section-card.dragging .section-bar { cursor: grabbing; }

.section-fold {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.section-fold:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.section-fold svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .14s ease; }
/* Folded, the arrow points the way the interface reads. */
.section-card.collapsed .section-fold svg { transform: rotate(90deg); }
html[lang=en] .section-card.collapsed .section-fold svg { transform: rotate(-90deg); }

.section-title {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  /* The card's own --item-ink follows its pastel; the bar's ink follows the theme. */
  color: var(--section-ink) !important;
  font: 650 16px/30px var(--ui-font, Arial), sans-serif;
  text-align: right;
  text-overflow: ellipsis;
  cursor: inherit;
  outline: none;
}
html[lang=en] .section-title { text-align: left; }
/* The theme colours every text field in a card by the card's own colour; a section's name follows its bar. */
body.hn-themed .card.section-card[data-theme-surface] .section-bar .section-title { color: var(--section-ink) !important; }
body.hn-themed .card.section-card[data-theme-surface] .section-bar .section-title::placeholder { color: color-mix(in srgb, var(--section-ink) 52%, transparent) !important; }
.section-title::placeholder { color: color-mix(in srgb, currentColor 52%, transparent); }
.section-title:not([readonly]) { background: color-mix(in srgb, #fff 70%, transparent); cursor: text; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--section-line) 80%, transparent); }

.section-count {
  flex: none;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  box-sizing: border-box;
  border-radius: 11px;
  background: color-mix(in srgb, #fff 58%, transparent);
  font: 600 12px/22px var(--ui-font, Arial), sans-serif;
  text-align: center;
  color: var(--section-ink);
  direction: ltr;
}

/* Grab strips along the edges; the bar already covers the top. */
.section-edge { position: absolute; pointer-events: auto; cursor: grab; --edge: calc(10px * var(--hn-inverse-zoom, 1)); }
.section-edge-top { inset: calc(var(--edge) / -2) 0 auto 0; height: var(--edge); }
.section-edge-bottom { inset: auto 0 calc(var(--edge) / -2) 0; height: var(--edge); }
.section-edge-left { inset: 0 auto 0 calc(var(--edge) / -2); width: var(--edge); }
.section-edge-right { inset: 0 calc(var(--edge) / -2) 0 auto; width: var(--edge); }

/* Dark mode tints the saved colour toward the surface. View only: the saved colour stays. */
body.hn-dark .card.section-card {
  --section-fill: color-mix(in srgb, var(--section-color, #dbe8ff) 14%, transparent);
  --section-bar: color-mix(in srgb, var(--section-color, #dbe8ff) 26%, var(--theme-surface, #2b343a));
  --section-line: color-mix(in srgb, var(--section-color, #dbe8ff) 40%, var(--theme-border, #4f5a62));
  --section-ink: var(--theme-ink, #eef2f4);
}
body.hn-dark .section-count { background: color-mix(in srgb, var(--theme-raised, #3a444b) 80%, transparent); }
body.hn-dark .section-title:not([readonly]) { background: var(--theme-raised, #3a444b); }

/* Read-only links: sections still fold for the viewer; nothing moves or renames. */
body.hn-public-view .section-bar, body.hn-public-view .section-edge { cursor: default; }
body.hn-public-view .section-fold { cursor: pointer; }

/* Exports draw the open section as it is; the fold arrow is an editing control. */
.hn-pdf-page .section-fold { visibility: hidden; }
