/* Menus, popovers and dialogs (Board 2's Menus board): projects, devices, Auto size, the app
   menu, screen and overlay options, History, Reset, Export, Import and the small dialogs. */

/* Popovers that drop from a button */
.pop {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 60;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: pop-open 140ms ease-out both;
}
:root[data-skin="clean"] .pop { padding: 6px; }
.pop-left { left: 0; }
.pop-right { right: 0; }
.pop-below { top: calc(100% + 6px); }
@keyframes pop-open { from { opacity: 0; transform: translateY(-4px); } }

.pop-item {
  width: 100%;
  min-height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  font-family: var(--ui);
  font-size: 13.5px;
  line-height: 1.3;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}
:root[data-skin="clean"] .pop-item { padding: 0 10px; border-radius: 8px; }
button.pop-item:hover:not(:disabled), button.pop-item:focus-visible { background: var(--surface2); outline: 0; }
:root[data-skin="clean"] button.pop-item:hover:not(:disabled), :root[data-skin="clean"] button.pop-item:focus-visible { background: #f7f1e3; }
.pop-item.is-on, button.pop-item.is-on:hover { font-weight: 700; background: var(--surface2); }
:root[data-skin="clean"] .pop-item.is-on, :root[data-skin="clean"] button.pop-item.is-on:hover { color: var(--accent-ink); background: var(--tint); }
.pop-item .i { flex: none; }
.pop-item:disabled { opacity: 0.45; cursor: default; }
.pop-item.is-danger { color: var(--danger); }
.pop-tall { min-height: 46px; padding-top: 4px; padding-bottom: 4px; }
.pop-short { min-height: 36px; }
.pop-static { cursor: default; padding-top: 6px; padding-bottom: 6px; }
.pop-between { justify-content: space-between; }
.pop-check { width: 18px; flex: none; display: flex; justify-content: center; }
.pop-check .i { stroke-width: 3.25; }
.pop-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pop-name { font-weight: 600; }
.is-on > .pop-text .pop-name { font-weight: 700; }
.pop-size { flex: none; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.pop-head { padding: 10px 12px 4px; font-family: var(--ui); font-size: var(--esz); font-weight: var(--ew); letter-spacing: var(--es); text-transform: var(--et); color: var(--muted); }
:root[data-skin="clean"] .pop-head { padding: 8px 10px 4px; }
.pop-sep { display: block; height: 2px; flex: none; background: #271813; }
:root[data-skin="clean"] .pop-sep { height: 1px; margin: 6px 4px; background: #e6dccb; }
.pop-foot {
  width: 100%;
  min-height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-family: var(--ui);
  font-size: var(--lsz);
  font-weight: var(--lw);
  letter-spacing: var(--ls);
  text-transform: var(--lt);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
}
:root[data-skin="clean"] .pop-foot { padding: 0 10px; color: var(--accent-ink); border-radius: 8px; }
.pop-foot:hover, .pop-foot:focus-visible { background: var(--surface2); outline: 0; }
:root[data-skin="clean"] .pop-foot:hover, :root[data-skin="clean"] .pop-foot:focus-visible { background: #f7f1e3; }
.pop-new { min-height: 44px; font-size: var(--lsz); font-weight: var(--lw); letter-spacing: var(--ls); text-transform: var(--lt); background: #ffe9e3; border-bottom: 2px solid #271813; }
:root[data-skin="clean"] .pop-new { min-height: 42px; font-weight: 700; color: #9a3412; background: transparent; border-bottom: 0; }
.pop-plus { width: 22px; height: 22px; flex: none; display: flex; align-items: center; justify-content: center; color: #271813; background: #ff5f1f; border: 2px solid #271813; }
:root[data-skin="clean"] .pop-plus { color: #ffffff; background: #9a3412; border: 0; border-radius: 6px; }
.pop-group { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 10px; }
:root[data-skin="clean"] .pop-group { padding: 8px 10px 10px; }
.key-cap { padding: 0 5px; font-family: var(--mono); font-size: 11px; line-height: 16px; border: 2px solid #271813; }
:root[data-skin="clean"] .key-cap { padding: 1px 6px; color: #474e5f; background: #f1e9d8; border: 1px solid #e6dccb; border-radius: 5px; }

/* A popover that is a small dialog (Auto size) */
.pop-dialog, :root[data-skin="clean"] .pop-dialog { gap: 12px; padding: 16px; }
.pop-dialog .dlg-text { font-size: 13px; color: var(--muted); }
.size-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 40px; gap: 8px; }
.size-fields.no-rotate { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.size-fields .icon-btn { width: 40px; }
.field-off.field-pre input { font-size: 12.5px; }

/* Dialogs */
.dialog-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade-in 160ms ease both; }
.dlg {
  position: relative;
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  color: var(--ink);
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: dlg-open 180ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes dlg-open { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dlg-title { margin: 0; font-family: var(--display); font-size: 15px; font-weight: var(--hw); letter-spacing: var(--hs); text-transform: var(--ht); line-height: 1.2; }
:root[data-skin="clean"] .dlg-title { font-size: 19px; }
.dlg-text { margin: 0; font-size: 13.5px; line-height: 1.45; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.dlg-error { margin: 0; padding: 8px 10px; font-size: 12.5px; font-weight: 600; color: var(--danger); background: rgba(185, 28, 28, 0.07); border: 2px solid var(--danger); }
:root[data-skin="clean"] .dlg-error { border-width: 1px; border-radius: var(--rs); }

/* Export choices */
.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 10px; text-align: left; font-family: inherit; color: #271813; background: #ffffff; border: 2px solid #271813; border-radius: 0; }
.opt.is-on { background: #ffe9e3; box-shadow: 2px 2px 0 #271813; }
:root[data-skin="clean"] .opt { padding: 0 12px; color: #1c2230; background: #ffffff; border: 1px solid #e6dccb; border-radius: 10px; }
:root[data-skin="clean"] .opt.is-on { background: rgba(154, 52, 18, 0.07); border-color: #9a3412; box-shadow: none; }
.opt-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 6px 0; }
.opt-title { font-size: 13px; font-weight: 600; }
.opt.is-on .opt-title { font-weight: 700; }

/* Import */
.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 12px; text-align: center; color: var(--ink); background: var(--surface2); border: 3px dashed #271813; border-radius: var(--rc); cursor: pointer; transition: background-color 120ms ease; }
:root[data-skin="clean"] .drop-zone { border: 1.5px dashed #b9ab92; }
.drop-zone.is-over { background: var(--tint); border-color: var(--accent); }
.drop-zone:has(:focus-visible) { outline: 2px solid var(--sel); outline-offset: 2px; }
.drop-title { font-size: 14px; font-weight: 700; }

/* Your projects */
.proj-list { display: flex; flex-direction: column; gap: 6px; max-height: min(360px, calc(100dvh - 260px)); overflow-y: auto; }
.proj-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 0; background: #ffffff; border: 2px solid #271813; }
.proj-row.is-on { background: #ffe9e3; box-shadow: 2px 2px 0 #271813; }
:root[data-skin="clean"] .proj-row { border: 1px solid #e6dccb; border-radius: 10px; }
:root[data-skin="clean"] .proj-row.is-on { background: rgba(154, 52, 18, 0.07); border-color: #9a3412; box-shadow: none; }
.proj-open { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 4px 10px; text-align: left; color: var(--ink); background: transparent; border: 0; }
.proj-open .pop-name, .proj-open .sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keyboard shortcuts and help */
.keys { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; margin: 0; }
.keys dt { font-size: 13px; }
.keys dd { margin: 0; display: flex; justify-content: flex-end; gap: 4px; }
.keys-head { margin-top: 4px; }
.help-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; line-height: 1.45; }

/* History (bottom right, above the canvas tools) */
.history { position: fixed; right: 20px; bottom: 80px; z-index: 65; width: 330px; max-width: calc(100vw - 32px); max-height: min(520px, calc(100dvh - 160px)); display: flex; flex-direction: column; overflow: hidden; animation: dlg-open 180ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }
.history-head { height: 42px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 14px; }
.history-head .icon-sm { width: 28px; height: 28px; }
.history-list { position: relative; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 8px 0; }
.history-rail { position: absolute; left: 20px; top: 28px; bottom: 28px; width: 2px; background: var(--soft); }
.history-row { position: relative; min-height: 44px; flex: none; display: flex; align-items: center; gap: 12px; padding: 4px 14px; }
.history-row.is-here { background: var(--surface2); }
:root[data-skin="clean"] .history-row.is-here { background: var(--tint); }
.history-row:not(.is-here):hover, .history-row:focus-within { outline: 2px solid #271813; outline-offset: -2px; }
:root[data-skin="clean"] .history-row:not(.is-here):hover, :root[data-skin="clean"] .history-row:focus-within { outline: 0; background: #f7f1e3; }
.history-row.is-ahead .history-text { opacity: 0.6; }
.history-dot { position: relative; z-index: 1; width: 14px; height: 14px; flex: none; background: #ffffff; border: 2px solid #271813; border-radius: 50%; }
.history-dot.is-on { background: #ff5f1f; }
.history-dot.is-start { background: #271813; border-radius: 0; }
:root[data-skin="clean"] .history-dot { border: 1.5px solid #b9ab92; }
:root[data-skin="clean"] .history-dot.is-on { background: #ffffff; border: 4.5px solid #9a3412; }
:root[data-skin="clean"] .history-dot.is-start { background: #1c2230; border: 0; border-radius: 4px; }
.history-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.history-title { font-size: 13px; font-weight: 600; }
.is-here .history-title { font-weight: 700; }
.history-restore, .btn-sm.history-restore { height: 26px; padding: 0 8px; opacity: 0; }
.history-row:hover .history-restore, .history-row:focus-within .history-restore { opacity: 1; }
@media (hover: none) { .history-restore, .btn-sm.history-restore { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .pop, .dlg, .history, .dialog-scrim { animation: fade-in 120ms ease both; }
}
