/* The entity editor (js/panel.js, js/project.js through js/entityForm.js): a cover photo across
   the top, the name and type, quick actions, attributes, and the "On this chart" group. */

/* ---- cover ---- */

.photo-row { margin: 0 0 6px; min-width: 0; }
.cover {
  position: relative;
  height: 196px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
}
/* In the chart's side panel the cover runs edge to edge, like a profile's. */
.panel .entity-editor .cover { margin: -22px -24px 0; border-radius: 0; height: 208px; }
.cover:not(.has-photo) { height: 172px; }
.panel .entity-editor .cover:not(.has-photo) { height: 180px; }

.cover-media { position: absolute; inset: 0; }
.cover-blur {
  position: absolute; inset: -24px;
  background-size: cover; background-position: center;
  filter: blur(22px) saturate(1.15);
  opacity: .75;
}
/* The photo itself is never cropped: evidence stays whole. */
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cover.has-photo::after {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 64px;
  background: linear-gradient(rgba(20, 20, 20, .34), transparent);
  pointer-events: none;
  opacity: 0; transition: opacity .18s;
}

/* No photo: a quiet surface with the type glyph, and the ways to add one. */
.cover:not(.has-photo) .cover-media {
  cursor: pointer;
  background:
    radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 1.2px) 0 0 / 18px 18px,
    linear-gradient(160deg, var(--paper), var(--sky));
}
.cover-glyph { position: absolute; inset: 0 0 78px; display: grid; place-items: center; }
.cover-glyph svg { width: 56px; height: 56px; stroke: var(--wire); fill: none; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; opacity: .7; }
.cover-empty {
  position: absolute; inset: auto 0 14px 0;
  display: grid; justify-items: center; gap: 8px;
  pointer-events: none;
}
.cover-cta { display: flex; gap: 8px; pointer-events: auto; }
.cover-tip { margin: 0 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.35; }

.cover-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: rgba(251, 250, 249, .92);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: var(--navy);
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(36, 36, 36, .08);
  transition: background .15s, border-color .15s, transform .15s;
}
.cover-btn:hover { background: #fff; border-color: var(--navy); }
.cover-btn:active { transform: translateY(1px); }
.cover-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.cover-btn.primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.cover-btn.primary:hover { background: #000; }
.cover-btn.icon { width: 32px; padding: 0; justify-content: center; }
.cover-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.cover-btn svg, .chip-btn svg, .qa svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* With a photo, the tools wait in the top corner until the pointer or keyboard reaches the cover. */
.cover-tools {
  position: absolute; right: 12px; top: 12px;
  display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .18s, transform .18s;
}
.cover:hover .cover-tools, .cover:focus-within .cover-tools { opacity: 1; transform: none; }
.cover:hover::after, .cover:focus-within::after { opacity: 1; }
@media (hover: none) { .cover-tools { opacity: 1; transform: none; } .cover.has-photo::after { opacity: 1; } }

/* Dragging an image over the cover. */
.cover-drop {
  position: absolute; inset: 10px;
  display: grid; place-items: center;
  border: 2px dashed var(--blue);
  border-radius: 12px;
  background: color-mix(in srgb, var(--white) 82%, transparent);
  color: var(--blue); font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
}
.cover.dragging .cover-drop { opacity: 1; }

/* Fetching an image from a link. */
.cover-busy {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: color-mix(in srgb, var(--white) 78%, transparent);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  color: var(--navy); font-size: 13.5px;
}
.cover-busy[hidden] { display: none; }
.cover-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--blue);
  animation: cover-spin .8s linear infinite;
}
@keyframes cover-spin { to { transform: rotate(360deg); } }

/* ---- the other ways to a photo, and the link box when the clipboard is out of reach ---- */

.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 12px 0 0; min-width: 0; }
.chip-btn, .photo-actions .image-search-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: #fff;
  color: var(--navy);
  font-size: 12.5px;
  text-decoration: none;
  max-width: 100%;
}
.chip-btn:hover, .photo-actions .image-search-link:hover { border-color: var(--navy); background: #fff; text-decoration: none; }
.chip-btn:focus-visible, .photo-actions .image-search-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
/* A long entity name must wrap inside the panel instead of pushing it wider. */
.photo-actions .image-search-link { height: auto; min-height: 30px; padding: 5px 11px; overflow-wrap: anywhere; line-height: 1.3; }
.photo-actions .image-search-link::after { content: '↗'; color: var(--muted); }
.photo-actions .image-search-hint { flex-basis: 100%; margin: 0; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--muted); overflow-wrap: anywhere; }
.photo-actions .image-search-link[hidden], .photo-actions .image-search-hint[hidden] { display: none; }
.url-field .url-why { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }

/* ---- name, type and quick actions ---- */

.entity-head { margin: 14px 0 4px; }
.entity-head .name-input { font-size: 28px; }
.entity-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.type-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 26px 0 10px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='5'><path d='M0 0h8L4 5z' fill='%23242424'/></svg>") no-repeat right 11px center;
  color: var(--navy);
  cursor: pointer;
}
.type-chip:hover, .type-chip:focus-within { border-color: var(--navy); }
.type-glyph svg { width: 16px; height: 16px; display: block; stroke: var(--navy); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* The select covers the chip so the whole chip opens it, and shows its own label as the text. */
.type-chip select {
  -webkit-appearance: none; appearance: none;
  border: 0; background: transparent; padding: 0; margin: 0;
  font-size: 13px; color: var(--navy); cursor: pointer; outline: none;
}
.meta-dot { color: var(--line); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font-size: 12.5px;
  transition: border-color .15s, background .15s, color .15s;
}
.qa svg { width: 18px; height: 18px; }
.qa:hover:not(:disabled) { border-color: var(--navy); }
.qa:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.qa:disabled { opacity: .45; cursor: default; }
.qa[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--white); }

/* ---- "On this chart": per-chart looks, folded away with a one-line summary ---- */

.appearance > summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  list-style: none; cursor: pointer;
  padding: 2px 0;
}
.appearance > summary::-webkit-details-marker { display: none; }
.appearance-title { font: var(--weight-head) 17px/1.2 var(--font-head); letter-spacing: var(--tracking-display); color: var(--navy); }
.appearance-title::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 9px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-3px) rotate(45deg); transition: transform .15s; }
.appearance[open] .appearance-title::after { transform: translateY(0) rotate(-135deg); }
.appearance-sum { font-size: 12.5px; color: var(--muted); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appearance[open] .appearance-sum { visibility: hidden; }
.appearance-note { margin: 6px 0 0; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.appearance .swatches { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .cover-spinner { animation-duration: 2s; }
}

/* Empty-state hints in the editor read as sentences, not labels. */
.entity-editor .section .kind, .manager-editor .section .kind { text-transform: none; letter-spacing: 0; font-size: 13px; }

/* ---- attributes: named values, with the common ones for the type a click away ---- */

.attributes .kv { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.3fr) 24px; }
/* The name reads as a label beside its value, not as a second empty box. */
.attributes .kv [data-key] { background: var(--paper); border-color: transparent; color: var(--navy); font-weight: 500; }
.attributes .kv [data-key]::placeholder { font-weight: 400; color: #aaa5a2; }
.attributes .kv [data-key]:hover { border-color: var(--line); }
.attributes .kv [data-key]:focus { background: #fff; border-color: var(--blue); }
.kv-value { position: relative; min-width: 0; }
.kv-value input { width: 100%; }
.kv-value:has(.kv-open:not([hidden])) input { padding-right: 52px; }
.kv-open {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--sky);
  color: var(--navy);
  font-size: 11.5px;
  text-decoration: none;
}
.kv-open:hover { background: var(--navy); color: var(--white); }
.kv-open[hidden] { display: none; }

.attr-add { margin-top: 12px; }
.attr-empty { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.attr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.attr-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 11px 0 9px;
  border: 1px dashed var(--line);
  border-radius: 100px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  transition: border-color .15s, background .15s, color .15s;
}
.attr-chip span { color: var(--muted); font-weight: 600; }
.attr-chip:hover { border-style: solid; border-color: var(--navy); background: #fff; color: var(--navy); }
.attr-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.attr-chip.custom { border-style: solid; color: var(--blue); }
.attr-chip.custom span { color: var(--blue); }
