/* The Photo button and its menu: js/photo-menu.js.
   One button per home, each shown only in its own layout:
     header      touch layouts (phone and iPad rail) and Classic
     workspace   beside File, in the project strip above the parts list
   The menu follows the editor's own menus (the workspace File menu and the
   account menu): small capital group headings, rows of icon and name, the
   same surface, line and focus ring. Rows are 44 px for fingers everywhere. */
.photo-menu-btn { display: none; position: relative; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto; box-sizing: border-box;
    margin: 0; font: inherit; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.photo-menu-btn svg { flex: 0 0 auto; width: 16px; height: 16px; }
.photo-menu-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
/* A sheet photo is on the canvas. */
.photo-menu-btn.has-photo::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent, #ff7a18); }
/* The desktop app has its own file handling; the photo project file is a browser and iPad feature for now. */
.offline-mode .photo-menu-btn { display: none !important; }

/* Header: right after the title. 32 px tall like the header's other buttons, so
   the header keeps its height; the ::before makes 44 px of it answer a finger. */
body:not(.workspace-beta) .app-header > .photo-menu-btn { display: inline-flex; height: 32px; margin-left: var(--spacing-sm); padding: 0 12px 0 10px;
    border: 1px solid var(--border-color); border-radius: 999px; background: var(--surface-light); color: var(--text-primary); font-size: .85rem; }
/* Offsets are measured from inside the 1 px border: -7 px reaches 6 px beyond the 32 px box each way, 44 px in all. */
body:not(.workspace-beta) .app-header > .photo-menu-btn::before { content: ""; position: absolute; left: -1px; right: -1px; top: -7px; bottom: -7px; }
body:not(.workspace-beta) .app-header > .photo-menu-btn:hover { border-color: var(--text-secondary); }
body:not(.workspace-beta) .app-header > .photo-menu-btn[aria-expanded="true"] { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
/* Classic in a narrow mouse-driven window: the header is full, so the button keeps its icon and its name is read from the label. */
@media (min-width: 700.02px) and (max-width: 1099.98px) and (pointer: fine) {
    body:not(.workspace-beta):not(.layout-touch) .app-header > .photo-menu-btn { width: 36px; padding: 0; }
    body:not(.workspace-beta):not(.layout-touch) .app-header > .photo-menu-btn > span { display: none; }
}
/* iPad rail: an open side panel lies over the header's left end (the title). The title's box
   takes the panel's width while it is open, so the button stays beside the panel, not under it. */
body.layout-rail.touch-sheet-open .app-header > .app-title { flex: 0 0 calc(var(--rail-panel-w, 320px) - var(--spacing-md)); min-width: 0; }

/* Workspace: a sibling of File, same size and look. */
#workspace-project > .photo-menu-btn { display: inline-flex; height: var(--ws-control-h); min-width: var(--ws-control-h); padding: 0 10px 0 8px;
    border: 1px solid var(--border-color); border-radius: var(--ws-radius-input); background: var(--surface-light); color: var(--text-primary); font-size: 12.5px; }
#workspace-project > .photo-menu-btn svg { width: 14px; height: 14px; color: var(--ws-text-label); }
#workspace-project > .photo-menu-btn:hover, #workspace-project > .photo-menu-btn[aria-expanded="true"] { border-color: var(--ws-primary-ring); }
#workspace-project > .photo-menu-btn:hover svg, #workspace-project > .photo-menu-btn[aria-expanded="true"] svg { color: var(--text-primary); }
#workspace-project > .photo-menu-btn:focus-visible { outline-color: var(--ws-primary-ring); }

/* ---- The menu ---- */
/* Above the toasts (z 2000): the notice shown after a photo is placed lasts 8 s at the top right, and on a
   phone or beside an open iPad panel it would lie over the rows the person opens this menu for. */
.photo-menu { position: fixed; z-index: 2100; box-sizing: border-box; display: flex; flex-direction: column; padding: 6px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    color: var(--text-primary); background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-pop, 0 12px 32px rgba(0, 0, 0, .45)); touch-action: manipulation; }
.photo-menu[hidden] { display: none; }
.photo-menu-heading { display: flex; align-items: center; gap: 6px; margin: 10px 8px 2px; font-family: 'Barlow', sans-serif; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.photo-menu-heading:first-child { margin-top: 4px; }
.photo-menu-tag, .photo-menu-badge { flex: 0 0 auto; padding: 1px 6px; border: 1px solid var(--border-color); border-radius: 999px; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: none; color: var(--text-secondary); white-space: nowrap; }
.photo-menu-badge { border-color: var(--accent, #ff7a18); color: var(--accent, #ff7a18); }
.photo-menu-group { display: flex; flex-direction: column; }
/* After the first group, a rule separates the groups, as in the File menu. */
.photo-menu-group + .photo-menu-heading { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border-color); }
.photo-menu-item { display: flex; align-items: center; gap: 10px; box-sizing: border-box; width: 100%; min-height: 44px; margin: 0; padding: 5px 8px; border: 0; border-radius: 6px;
    background: transparent; box-shadow: none; color: var(--text-primary); font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.photo-menu-item > svg { flex: 0 0 18px; width: 18px; height: 18px; color: var(--text-secondary); }
.photo-menu-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.photo-menu-item small { font-size: 11.5px; font-weight: 400; color: var(--text-secondary); }
.photo-menu-item small:empty { display: none; }
.photo-menu-item:hover, .photo-menu-item:focus { background: var(--surface-light); outline: none; }
.photo-menu-item:hover > svg, .photo-menu-item:focus > svg { color: var(--text-primary); }
.photo-menu-item:focus-visible, .photo-menu-keyboard .photo-menu-item:focus { outline: 2px solid #60a5fa; outline-offset: -2px; }
.photo-menu-item[aria-disabled="true"] { cursor: default; }
.photo-menu-item[aria-disabled="true"] .photo-menu-label, .photo-menu-item[aria-disabled="true"] > svg { opacity: .45; }
.photo-menu-item[aria-disabled="true"]:hover { background: transparent; }
/* Show sheet photo: a tick when it is shown. */
.photo-menu-check { flex: 0 0 18px; width: 18px; height: 18px; border: 1.5px solid var(--text-secondary); border-radius: 4px; position: relative; }
.photo-menu-item[aria-checked="true"] .photo-menu-check { background: var(--primary-color); border-color: var(--primary-color); }
.photo-menu-item[aria-checked="true"] .photo-menu-check::after { content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.photo-menu-note { margin: 8px 2px 2px; padding: 8px 8px 4px; border-top: 1px solid var(--border-color); font-size: 11.5px; line-height: 1.4; color: var(--text-secondary); }

/* Never printed. */
@media print { .photo-menu { display: none !important; } }
