/* =============================================================================
   THE PAPERS WINDOW (Session 14b phase 1, docs/handover/accounts/, Accounts.dc.html frames 2 and 3)
   features/papersWindow.js. Loaded in the head beside account.css, so the splash has it; the
   fonts are intro-flow.css's. The frame is the app-wide one (README Part 2): the close 36 px,
   16 px from the top and right; the title 24 px down, 20 px to the header rule, 24 px to the
   content; content 32 px in and 32 px clear of the bottom. 1296 px wide at 1440. Sizes from the
   window tokens (peelback-design-system.css), each with its value as the fallback (Session 15b phase 4).
   ============================================================================= */

dialog.pw {
    position: fixed; inset: 0; margin: 88px auto 24px;
    width: min(1296px, calc(100vw - 32px)); max-height: calc(100vh - 112px); height: fit-content;
    box-sizing: border-box; padding: 0; border: 0; border-radius: 14px; overflow: hidden;
    background: #fff; color: #1A1A2E; text-align: left;
    box-shadow: 0 30px 80px rgba(26,26,46,.3), 0 0 0 1px rgba(26,26,46,.08);
    font: 400 14px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif;
}
dialog.pw[open] { display: flex; flex-direction: column; }
dialog.pw::backdrop { background: rgba(26,26,46,.42); }
@media (max-height: 720px) { dialog.pw { margin-top: 16px; max-height: calc(100vh - 32px); } }

.pw button { font: inherit; color: inherit; border: 0; margin: 0; padding: 0; background: none; cursor: pointer; }
.pw :focus-visible { outline: 2px solid #544FF0; outline-offset: 2px; }
.pw-vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Header ── */
.pw-hd { position: relative; flex: none; padding: 24px 68px 20px 32px; border-bottom: 1px solid rgba(26,26,46,.08); }
.pw-hd h2 { margin: 0; font: 600 24px/30px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; letter-spacing: -0.01em; }
.pw-hd h2:focus { outline: none; }
.pw-count { margin-left: 8px; font: 400 15px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; letter-spacing: 0; color: #6B6B72; }
.pw .pw-x {
    position: absolute; top: var(--pb-close-inset, 16px); right: var(--pb-close-inset, 16px); width: var(--pb-close, 36px); height: var(--pb-close, 36px); display: grid; place-items: center;
    color: #4B4B55; border-radius: var(--pb-win-btn-r, 6px); background: #fff;
    box-shadow: 0 0 0 1px rgba(26,26,46,.07), 0 1px 1px rgba(26,26,46,.06);
}

/* ── Body and toolbar ── */
.pw-bd { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 24px 32px 32px; }
.pw-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.pw .pw-new {
    display: inline-flex; align-items: center; gap: 8px; flex: none; height: var(--pb-win-btn-h, 40px); padding: 0 16px 0 14px;
    border-radius: var(--pb-win-btn-r, 6px); background: #544FF0; color: #fff; box-shadow: 0 1px 2px rgba(84,79,240,.3);
    font: var(--pb-win-btn-font, 700 11px/14px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif); letter-spacing: var(--pb-btn-track, .08em); text-transform: uppercase; white-space: nowrap;
}
.pw .pw-new:hover { background: #4743D8; }
.pw-search {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: var(--pb-field-h, 40px); box-sizing: border-box; padding: 0 14px;
    border-radius: var(--pb-field-r, 6px); background: #fff; box-shadow: 0 0 0 1px rgba(26,26,46,.14); color: #6B6B72;
}
.pw-search svg { flex: none; }
.pw-search:focus-within { box-shadow: 0 0 0 2px #544FF0; }
/* One ring, on the rounded field: the window's :focus-visible outline is taken off the input inside it */
.pw .pw-search input:focus, .pw .pw-search input:focus-visible { outline: none; }
.pw-search input {
    flex: 1; min-width: 0; height: calc(var(--pb-field-h, 40px) - 2px); border: 0; padding: 0; margin: 0; background: none; outline: none; -webkit-appearance: none; appearance: none;
    font: 400 14px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #1A1A2E;
}
.pw-search input::placeholder { color: #6B6B72; opacity: 1; }
.pw-search input::-webkit-search-decoration { -webkit-appearance: none; }
.pw .pw-sort {
    display: inline-flex; align-items: center; gap: 8px; flex: none; height: var(--pb-win-btn-h, 40px); padding: 0 12px;
    border-radius: var(--pb-win-btn-r, 6px); background: #fff; box-shadow: 0 0 0 1px rgba(26,26,46,.14);
    font: 600 14px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #1A1A2E; white-space: nowrap;
}
.pw-sort svg { color: #6B6B72; flex: none; }
.pw-view { display: inline-flex; flex: none; border-radius: var(--pb-win-btn-r, 6px); overflow: hidden; box-shadow: 0 0 0 1px rgba(26,26,46,.14); }
.pw .pw-view button { width: var(--pb-win-btn-h, 40px); height: var(--pb-win-btn-h, 40px); display: grid; place-items: center; color: #6B6B72; background: #fff; }
.pw .pw-view button + button { border-left: 1px solid rgba(26,26,46,.1); }
.pw .pw-view button[aria-pressed="true"] { background: #1A1A2E; color: #fff; }
.pw .pw-view button:focus-visible { outline-offset: -4px; outline-color: #fff; box-shadow: inset 0 0 0 2px #544FF0; }
.pw .pw-view button[aria-pressed="false"]:focus-visible { outline-color: #544FF0; box-shadow: none; }

.pw-msg { margin: 8px 0 0; font: 400 15px/22px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #6B6B72; }

/* ── Tiles (frame 2): five across at 1440 ── */
.pw-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; align-items: start; }
.pw-tile {
    position: relative; border-radius: 12px; overflow: hidden; background: #fff;
    box-shadow: 0 0 0 1px rgba(26,26,46,.1), 0 2px 6px rgba(26,26,46,.05);
}
.pw-tile:hover { box-shadow: 0 0 0 1px rgba(26,26,46,.2), 0 4px 12px rgba(26,26,46,.08); }
.pw-tile:has(.pw-open:focus-visible) { outline: 2px solid #544FF0; outline-offset: 2px; }
.pw-th { height: 104px; display: flex; align-items: flex-end; box-sizing: border-box; padding: 0 16px 12px; background: #544FF0; color: #E7FD7D; }
.pw-th .nm { font-size: 44px; }
.nm { display: inline-flex; align-items: flex-start; font-family: 'Saira', 'Helvetica Neue', Arial, sans-serif; font-weight: 524; line-height: .9; letter-spacing: -0.02em; white-space: nowrap; }
.nm .nm-p { font-size: .6em; font-weight: 130; margin-top: .08em; }
.pw-tb { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; }
.pw-tt { margin: 0; font: 700 14px/19px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; }
/* The title is the tile's link: stretched over the whole tile; the lozenge and … sit above it */
/* Safari won't clamp or ellipsise a <button> itself, so the cut is on the span inside it (.pw-ot) */
.pw .pw-open { display: block; width: 100%; max-width: 100%; text-align: left; font-weight: 700; }
.pw .pw-open .pw-ot { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pw-tile .pw-open::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.pw-tile .pw-open:focus-visible { outline: none; }
.pw-src { margin: -2px 0 0; font: 400 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #6B6B72; }
.pw-auds { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.pw-aud {
    display: inline-flex; align-items: center; box-sizing: border-box; height: var(--pb-pill-h, 24px); padding: 0 9px; border-radius: 999px;
    background: #F3F4F9; color: #1A1A2E; font: 600 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif;
}
/* Each audience pill opens its own version (Session 16a), so it sits above the stretched title */
.pw .pw-aud {
    position: relative; z-index: 2; padding: 0 9px; border: 0; background: #F3F4F9; color: #1A1A2E;
    font: 600 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; cursor: pointer;
}
.pw .pw-aud:hover { background: #E6E7EF; }
.pw .pw-aud:focus-visible { outline: 2px solid #544FF0; outline-offset: 2px; }
.pw-ver { margin-top: 8px; padding-top: 16px; border-top: 1px solid rgba(26,26,46,.08); }
.pw-ver-h { margin: 0 0 10px; font: 400 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #767676; }
.pw-outs { display: flex; flex-wrap: wrap; gap: 6px; }
.pw-none { display: block; margin: -3px 0 -4px; font: 400 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #767676; }
/* Output lozenges are links (light purple): resting 7.6:1; hover white on purple, 5.6:1; focus adds the ring */
.pw .pw-out {
    position: relative; z-index: 2; display: inline-flex; align-items: center; box-sizing: border-box; height: var(--pb-pill-h, 24px); padding: 0 9px;
    border-radius: 999px; background: #F4F3FE; color: #3F3AB8; font: 600 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; white-space: nowrap;
}
.pw .pw-out:hover, .pw .pw-out:focus-visible { background: #544FF0; color: #fff; }
.pw-foot {
    display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(26,26,46,.07);
    font: 400 12px/16px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #6B6B72;
}
.pw-foot > span { flex: 1; }
.pw .pw-more { position: relative; z-index: 2; width: var(--pb-row-btn-h, 32px); height: var(--pb-row-btn-h, 32px); display: grid; place-items: center; border-radius: var(--pb-row-btn-r, 6px); color: #1A1A2E; }
.pw .pw-more:hover, .pw .pw-more[aria-expanded="true"] { background: #F3F4F9; }

/* ── The list (frame 3) ── */
.pw-tablewrap { overflow-x: auto; }
.pw-list { width: 100%; border-collapse: collapse; font: 400 14px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #1A1A2E; }
.pw-list th, .pw-list td { width: 1%; white-space: nowrap; padding: 10px 12px; text-align: left; vertical-align: middle; }
.pw-list th { padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(26,26,46,.14); font-weight: 400; }
.pw-list td { border-bottom: 1px solid rgba(26,26,46,.07); }
.pw-list .pw-c-name { width: 100%; max-width: 0; padding-left: 0; }
.pw-list tbody tr { cursor: pointer; }
.pw-list tbody tr:hover td { background: #FAFAFC; }
.pw-list .pw-c-more { padding-left: 0; padding-right: 0; text-align: center; }
/* Every heading sorts: light grey and regular at rest; hover darkens it and shows its arrow;
   the chosen one is ink and extra bold with its arrow */
.pw .pw-sth {
    display: inline-flex; align-items: center; gap: 4px; min-height: var(--pb-row-btn-h, 32px);
    font: 400 11px/14px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #767676;
}
.pw-sth svg { visibility: hidden; flex: none; }
.pw .pw-sth:hover, .pw .pw-sth:focus-visible { color: #3D3D46; }
.pw-sth:hover svg, .pw-sth:focus-visible svg { visibility: visible; opacity: .6; }
.pw .pw-sth.on { color: #1A1A2E; font-weight: 800; }
.pw-sth.on svg { visibility: visible; opacity: 1; }
.pw-nm { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pw-lth { flex: none; width: 52px; height: 40px; border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: #544FF0; color: #E7FD7D; }
.pw-lth .nm { font-size: 15px; }
.pw-ln { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pw-list .pw-open { font: 600 14px/19px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; }
.pw-list .pw-open .pw-ot { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-ln small { font-size: 12px; line-height: 16px; color: #6B6B72; overflow: hidden; text-overflow: ellipsis; }
.pw-list .pw-none { display: inline; margin: 0; font-size: 14px; line-height: 20px; color: #6B6B72; }

/* ── Menus: the sort menu and each paper's … ── */
/* Fixed, placed by papersWindow.js against the browser window, so the dialog's
   overflow: hidden never clips it; it scrolls only if the browser window is too short for it */
.pw-menu {
    position: fixed; z-index: 5; min-width: 220px; box-sizing: border-box; padding: 6px; overflow-y: auto;
    border-radius: 10px; background: #fff; box-shadow: 0 16px 40px rgba(26,26,46,.2), 0 0 0 1px rgba(26,26,46,.08);
}
.pw-menu[hidden] { display: none; }
.pw .pw-mi {
    display: flex; align-items: center; width: 100%; min-height: var(--pb-win-btn-h, 40px); box-sizing: border-box; padding: 0 12px; border-radius: var(--pb-win-btn-r, 6px);
    font: 400 14px/20px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif; color: #1A1A2E; text-align: left; white-space: nowrap;
}
.pw .pw-mi:hover, .pw .pw-mi:focus-visible { background: #F4F3FE; outline: none; }
.pw .pw-mi[aria-checked="true"] { font-weight: 700; }
.pw .pw-mi[aria-checked]::before { content: ""; width: 16px; margin-right: 6px; flex: none; }
.pw .pw-mi[aria-checked="true"]::before { content: "✓"; }

/* ── Rename and Delete: account.css's window frame, with a secondary and a danger button ── */
.pw-sub .pw-sub-name { color: #1A1A2E; font-weight: 700; overflow-wrap: anywhere; }
.pw-sub-acts { display: flex; gap: var(--pb-btn-gap, 10px); margin-top: var(--pb-btn-gap, 10px); }
.aw .pw-sub-acts .aw-btn { flex: 1; margin-top: 0; }
.aw .aw-btn2 {
    flex: 1; display: flex; align-items: center; justify-content: center; height: var(--pb-win-btn-h, 40px); border-radius: var(--pb-win-btn-r, 6px);
    background: #fff; color: #544FF0; box-shadow: 0 0 0 1px rgba(26,26,46,.14), 0 1px 2px rgba(26,26,46,.06);
    font: var(--pb-win-btn-font, 700 11px/14px 'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif); letter-spacing: var(--pb-btn-track, .08em); text-transform: uppercase;
}
.aw .aw-btn2:hover { background: #F4F3FE; }
.aw .aw-btn.aw-btn--danger { background: #B42318; box-shadow: 0 1px 2px rgba(180,35,24,.3); }
.aw .aw-btn.aw-btn--danger:hover { background: #912018; }

/* ── Narrow windows: not drawn (the launch pass); it stacks and scrolls and stays usable ── */
@media (max-width: 719px) {
    dialog.pw { margin: 16px auto; max-height: calc(100vh - 32px); }
    .pw-hd { padding: 20px 60px 16px 20px; }
    .pw-bd { padding: 20px 20px 24px; }
    .pw-tools { flex-wrap: wrap; }
    .pw-search { order: 5; flex-basis: 100%; }
    .pw-grid { grid-template-columns: 1fr; }
    .pw-sub-acts { flex-direction: column; }
}
