/* ---- Profile menu (menu.js): a bottom sheet on phones, a paper popover under the pill on wider screens ---- */

/* The pill now opens something: it says so with a small caret, and answers hover and focus. */
.profile-pill { min-height: 44px; border-radius: 22px; cursor: pointer; transition: color .2s; }
.profile-pill span { transition: border-color .2s, box-shadow .2s; }
.profile-pill:hover, .profile-pill[aria-expanded="true"] { color: var(--paper); }
.profile-pill:hover span, .profile-pill[aria-expanded="true"] span { border-color: var(--red); }
.profile-pill[aria-expanded="true"] span { box-shadow: 0 0 0 2px var(--night), 0 0 0 3px var(--red); }
.profile-pill:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.profile-pill::after { content: ''; flex: none; width: 6px; height: 6px; margin: -4px 2px 0 -3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.profile-pill[aria-expanded="true"]::after { transform: translateY(3px) rotate(225deg); }

@media (max-width: 760px) {
    /* Tonight · Notebook · Match share the bar evenly; Admin makes four (app.css has room for five). */
    .topbar nav:not(.hidden) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .topbar nav.has-admin:not(.hidden) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    /* Only the avatar shows on a phone: the whole 44 px square is the target (beats notices.css's min-width: 0). */
    .topbar .profile-pill { min-width: 44px; justify-content: center; }
    .profile-pill::after { display: none; }
}

/* ---- The sheet ---- */
.pm-sheet { position: fixed; inset: auto 0 0; width: 100%; max-width: 100%; max-height: min(90svh, 720px); margin: 0; padding: 0; overflow: visible; border: 0; border-top: 3px solid var(--red); color: var(--ink); background: var(--paper); box-shadow: 0 -14px 40px rgba(0, 0, 0, .5); }
.pm-sheet[open] { display: flex; flex-direction: column; }
.pm-sheet::backdrop { background: rgba(8, 8, 8, .66); animation: pm-dim .3s ease-out; }
@keyframes pm-dim { from { opacity: 0; } }

.pm-head { position: relative; flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 24px 14px 16px 20px; border-bottom: 1px solid #c9c4b4; touch-action: none; }
.pm-grip { position: absolute; top: 8px; left: 50%; width: 44px; height: 4px; margin-left: -22px; border-radius: 2px; background: #bdb8a8; }
/* The seal: the approved Match photo when there is one, otherwise the initial on red. */
.pm-avatar { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; color: var(--paper); background-color: var(--red); background-position: center; background-size: cover; background-repeat: no-repeat; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--ink); font: 400 26px/1 Georgia, serif; }
.pm-avatar.has-photo { color: transparent; }
.pm-who { min-width: 0; }
.pm-who small { display: block; color: #77736a; font: 800 10px/1.2 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
.pm-name { margin: 4px 0 0; overflow: hidden; font: italic 400 26px/1.08 Georgia, serif; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.pm-title { display: flex; align-items: baseline; gap: 7px; min-width: 0; margin: 6px 0 0; color: #3b3832; font: 15px/1.3 Georgia, serif; }
/* Longer titles (de "Die Laternenhelle Kämpfernatur") take a second line rather than lose their noun. */
.pm-title span:last-child { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.pm-title-kanji { flex: none; color: var(--red); font: 400 17px/1 "Yu Mincho", "MS Mincho", serif; }
.pm-title.is-empty { color: #77736a; font-size: 14px; font-style: italic; }
.pm-close { display: grid; place-items: center; align-self: start; width: 44px; height: 44px; padding: 0; border: 1px solid #b0aa98; border-radius: 50%; color: var(--ink); background: transparent; font: 400 26px/1 Georgia, serif; cursor: pointer; }
.pm-close:hover { border-color: var(--red); color: var(--red); }
.pm-close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.pm-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 12px calc(16px + env(safe-area-inset-bottom)); }
.pm-list { margin: 0; padding: 0; list-style: none; }
.pm-list + .pm-list { margin-top: 6px; padding-top: 6px; border-top: 1px solid #d3cdbb; }

.pm-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) 12px; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 8px 10px 8px 8px; border: 0; color: var(--ink); background: transparent; text-align: left; cursor: pointer; transition: background-color .2s; }
.pm-item:hover { background: rgba(18, 18, 18, .055); }
.pm-item:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.pm-seal { display: grid; place-items: center; width: 38px; height: 38px; color: var(--paper); background: var(--ink); font: 400 20px/1 "Yu Mincho", "MS Mincho", serif; transition: background-color .2s, color .2s, box-shadow .2s; }
.pm-item:hover .pm-seal, .pm-item:focus-visible .pm-seal { background: var(--red); }
/* Install and Support are a step quieter: an outlined seal. */
.pm-list-quiet .pm-seal { color: var(--ink); background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink); }
.pm-list-quiet .pm-item:hover .pm-seal, .pm-list-quiet .pm-item:focus-visible .pm-seal { color: var(--paper); background: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }
.pm-copy { min-width: 0; }
.pm-copy b { display: block; font: 400 18px/1.2 Georgia, serif; letter-spacing: -.01em; }
.pm-copy small { display: block; margin-top: 3px; overflow: hidden; color: #6f6b62; font: 12px/1.3 Arial, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.pm-arrow { width: 8px; height: 8px; border-top: 1.5px solid #8d887c; border-right: 1.5px solid #8d887c; transform: rotate(45deg); transition: transform .2s, border-color .2s; }
.pm-item:hover .pm-arrow { border-color: var(--red); transform: translateX(2px) rotate(45deg); }
.pm-item[aria-expanded] .pm-arrow { transform: rotate(135deg); }
.pm-item[aria-expanded="true"] .pm-arrow { border-color: var(--red); transform: rotate(-45deg); }

.pm-hint { margin: 0 8px 8px 60px; padding: 10px 12px; border-left: 3px solid var(--red); color: #3b3832; background: rgba(18, 18, 18, .05); font: 14px/1.55 Georgia, serif; }
.pm-hint b { color: var(--ink); font-weight: 700; }
.pm-share-icon { width: 17px; height: 17px; margin: 0 1px; vertical-align: -3px; fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.pm-links { display: flex; justify-content: center; margin: 6px 0 0; padding-top: 4px; border-top: 1px solid #d3cdbb; }
.pm-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: #4f4b44; font: 700 11px/1 Arial, sans-serif; letter-spacing: .12em; text-decoration: none; text-transform: uppercase; }
.pm-links a + a::before { content: '·'; margin: 0 14px 0 -12px; color: #a29d8f; }
.pm-links a:hover { color: var(--red); }
.pm-links a:focus-visible { outline: 2px solid var(--red); outline-offset: -4px; }

.pm-signout { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 52px; margin-top: 6px; padding: 0 16px; border: 1px solid var(--ink); color: var(--ink); background: transparent; font: 800 11px/1 Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; transition: color .2s, background-color .2s; }
.pm-signout .pm-seal { width: 28px; height: 28px; background: var(--red); font-size: 16px; }
.pm-signout:hover { color: var(--paper); background: var(--ink); }
.pm-signout:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

@media (min-width: 761px) {
    .pm-sheet { inset: var(--pm-top, 78px) var(--pm-right, 24px) auto auto; width: min(360px, calc(100vw - 24px)); max-height: min(82vh, 700px); border: 1px solid var(--ink); border-top: 3px solid var(--red); box-shadow: 12px 12px 0 #080808; transform-origin: calc(100% - var(--pm-tab, 14px) - 8px) 0; }
    /* A small red tab points at the avatar. */
    .pm-sheet::before { content: ''; position: absolute; top: -11px; right: var(--pm-tab, 14px); border: 8px solid transparent; border-top: 0; border-bottom-color: var(--red); }
    .pm-sheet::backdrop { background: rgba(8, 8, 8, .3); }
    .pm-grip { display: none; }
    .pm-head { padding-top: 18px; touch-action: auto; }
    .pm-item { min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
    .pm-sheet::backdrop { animation: none; }
    .profile-pill, .profile-pill span, .profile-pill::after, .pm-item, .pm-seal, .pm-arrow, .pm-signout { transition: none; }
}
