/* Böhmische Dörfer — the trophy shelf and its unlock note (achievements.js), in THE PAINTED CHEST.
 * Its own sheet, linked after polish.css. Same world as style.css: the shelf is a painted plate
 * (chamfered chest-blue panel, ochre band, vermilion hair line); every picture is cut from the
 * printed tiles and sits in a small ochre-framed cartouche like a drawer front; an earned row
 * carries the ochre roundel with the ink tick that marks a completed village on the table, an
 * open one a faint dashed ring. Lime-wash stays the one "you may act" signal: only the close
 * button and the note itself are lime-edged, because they are the things to press.
 */

/* ── The shelf ─────────────────────────────────────────────────────────────────────────── */
#bd-ach {
    position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 10px;
    background: rgba(8, 18, 30, 0.66);
    animation: ach-veil 0.22s ease-out both;
}
.ach-sheet {
    position: relative; width: min(860px, 100%); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px);
    display: flex; flex-direction: column; padding: 18px 22px 20px;
    animation: ach-rise 0.36s var(--ease-out) both;
}
.ach-head { position: relative; flex: none; text-align: center; padding: 0 48px 12px; }
.ach-head h2 { font-family: var(--f-display); font-weight: 700; font-size: 36px; line-height: 1.02; color: var(--lime); text-wrap: balance; }
.ach-count { display: block; margin-top: 2px; font-size: 15px; font-style: italic; color: var(--lime-soft); font-variant-numeric: tabular-nums lining-nums; }
.ach-x {
    position: absolute; right: -6px; top: -4px; width: 44px; height: 44px; display: grid; place-items: center;
    color: var(--lime); border-radius: 6px;
}
.ach-x svg { width: 22px; height: 22px; }
@media (hover: hover) { .ach-x:hover { background: var(--lime-faint); } }

.ach-list {
    list-style: none; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px;
    padding: 4px 4px 2px; border-top: 1px solid rgba(211, 154, 58, 0.45);
}
.ach-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
    padding: 12px 6px 12px 2px; border-bottom: 1px solid rgba(242, 234, 216, 0.12);
}
.ach-row-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ach-row-txt b { font-family: var(--f-display); font-weight: 700; font-size: 22px; line-height: 1.05; color: var(--lime); }
.ach-row-txt span { font-size: 14.5px; line-height: 1.32; color: var(--lime-soft); }
.ach-row:not(.got) .ach-row-txt b { color: rgba(242, 234, 216, 0.8); }

/* the mark: the completed-village roundel when earned, a faint dashed ring when not */
.ach-mark { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.ach-row:not(.got) .ach-mark { border: 2px dashed rgba(242, 234, 216, 0.28); }
.ach-row.got .ach-mark {
    background: var(--ochre); color: var(--ink);
    box-shadow: inset 0 0 0 2px var(--ochre-deep), 0 2px 4px rgba(3, 10, 20, 0.45);
}
.ach-mark svg { width: 20px; height: 20px; }

/* ── A picture: a crop of the printed art in an ochre-framed cartouche ──────────────────── */
.ach-pic {
    position: relative; flex: none; width: 64px; height: 64px; display: block;
    background: radial-gradient(90% 90% at 50% 40%, var(--chest-lift), var(--chest-deep));
    clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
    box-shadow: inset 0 0 0 2px var(--ochre), inset 0 0 0 3px var(--vermilion);
}
.ach-pic > img { position: absolute; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.ach-pic.art > img:first-child { inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; clip-path: inherit; }
/* figures: one, or three standing in a row (an online table) */
.ach-pic.figs > img { bottom: 9%; height: 66%; width: auto; filter: drop-shadow(1px 2px 1.5px rgba(0, 0, 0, 0.55)); }
.ach-pic.figs.n1 > img { left: 50%; transform: translateX(-50%); }
.ach-pic.figs.n3 > img { height: 52%; }
.ach-pic.figs.n3 > img:nth-of-type(1) { left: 10%; }
.ach-pic.figs.n3 > img:nth-of-type(2) { left: 50%; transform: translateX(-50%); bottom: 15%; z-index: 1; }
.ach-pic.figs.n3 > img:nth-of-type(3) { right: 10%; }
.ach-crown { position: absolute; left: 50%; top: 5%; width: 34%; transform: translateX(-50%); color: var(--ochre); z-index: 2; filter: drop-shadow(0 1px 0 rgba(13, 31, 51, 0.9)); }
.ach-pic.figs.n1 .ach-crown { top: 3%; }
.ach-crown svg { width: 100%; height: auto; display: block; }
/* a printed coin with the points struck on it */
.ach-pic.coin > img { inset: 14%; width: 72%; height: 72%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5)); }
.ach-pic.coin > b {
    position: absolute; inset: 0; display: grid; place-items: center;
    font: 700 21px/1 var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums lining-nums;
    text-shadow: 0 1px 0 rgba(255, 244, 205, 0.7);
}
/* the tile that goes with the building (bishop, glass, flour), pinned to the corner */
.ach-badge { right: 2px; bottom: 2px; width: 40%; height: auto; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); z-index: 2; }

/* not yet earned: the picture is painted over, still readable */
.ach-row:not(.got) .ach-pic > img,
.ach-row:not(.got) .ach-pic .ach-crown { filter: grayscale(0.85) brightness(0.62); }
.ach-row:not(.got) .ach-pic > b { opacity: 0.55; }
.ach-row:not(.got) .ach-pic { box-shadow: inset 0 0 0 2px rgba(211, 154, 58, 0.45), inset 0 0 0 3px rgba(194, 74, 51, 0.4); }

/* ── The unlock note: small, top centre, a beat; a tap sends it away ────────────────────── */
.ach-note {
    position: fixed; z-index: 1300; left: 50%; top: calc(var(--head-h) + 10px);
    width: max-content; max-width: min(380px, calc(100vw - 16px));
    display: flex; align-items: center; gap: 12px; padding: 9px 18px 9px 10px; text-align: left;
    background: linear-gradient(180deg, var(--panel-hi), var(--panel)); color: var(--lime);
    clip-path: polygon(var(--cham) 0, calc(100% - var(--cham)) 0, 100% var(--cham), 100% calc(100% - var(--cham)), calc(100% - var(--cham)) 100%, var(--cham) 100%, 0 calc(100% - var(--cham)), 0 var(--cham));
    box-shadow: inset 0 0 0 3px var(--ochre), inset 0 0 0 4px var(--vermilion), inset 0 0 0 7px rgba(13, 31, 51, 0.35);
    filter: drop-shadow(0 8px 14px rgba(3, 10, 20, 0.55));
    opacity: 0; transform: translate(-50%, -14px);
    transition: opacity 0.22s ease, transform 0.42s var(--ease-out);
    cursor: pointer;
}
.ach-note.on { opacity: 1; transform: translate(-50%, 0); }
.ach-note .ach-pic { width: 50px; height: 50px; }
.ach-note .ach-pic.coin > b { font-size: 17px; }
.ach-note-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ach-note-txt b { font-family: var(--f-display); font-weight: 700; font-size: 23px; line-height: 1.05; }
.ach-note-kicker { font-size: 13.5px; font-style: italic; color: var(--lime-soft); }
.ach-note:focus-visible { outline: 2px dashed var(--ochre); outline-offset: -9px; }

/* ── The end sheet's quiet way to the shelf ─────────────────────────────────────────────── */
.end-ach {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px auto 0;
    min-height: 44px; padding: 0 14px; color: var(--lime-soft); font-size: 15px;
    border-radius: 6px;
}
.end-ach svg { width: 22px; height: 22px; color: var(--ochre); }
.end-ach span { text-decoration: underline; text-decoration-color: rgba(211, 154, 58, 0.6); text-underline-offset: 4px; }
.end-ach small { font-size: 14px; font-style: italic; font-variant-numeric: tabular-nums lining-nums; }
@media (hover: hover) { .end-ach:hover { color: var(--lime); background: var(--lime-faint); } }

/* ── Narrow, short and phone ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .ach-list { grid-template-columns: 1fr; }
}
@media (max-height: 520px), (pointer: coarse) and (max-height: 560px) {
    #bd-ach { padding: 6px; }
    .ach-sheet { max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); padding: 10px 14px 10px; }
    .ach-head { padding: 0 44px 6px; text-align: left; display: flex; align-items: baseline; gap: 12px; }
    .ach-head h2 { font-size: 26px; }
    .ach-count { margin: 0; font-size: 14px; }
    .ach-x { right: -8px; top: -8px; }
    .ach-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
    .ach-row { gap: 10px; padding: 7px 2px; }
    .ach-pic { width: 46px; height: 46px; }
    .ach-pic.coin > b { font-size: 16px; }
    .ach-row-txt b { font-size: 18px; }
    .ach-row-txt span { font-size: 12.5px; line-height: 1.25; }
    .ach-mark { width: 24px; height: 24px; }
    .ach-mark svg { width: 16px; height: 16px; }
    .end-ach { margin-top: 2px; min-height: 40px; }
}
/* the trophy is a fifth tool in the phone header: at the 640 floor the two-line name gives up a
   little size so it never runs under the first tool */
@media (max-width: 700px) { body.phone .bd-name { font-size: 14.5px; } }
/* phone table: the note sits over the villages (left), never over the right column's controls */
body.phone .ach-note { left: 8px; top: 8px; transform: translate(0, -14px); max-width: min(330px, calc(100vw - 340px)); padding: 7px 14px 7px 8px; gap: 10px; }
body.phone .ach-note.on { transform: none; }
body.phone .ach-note .ach-pic { width: 42px; height: 42px; }
body.phone .ach-note-txt b { font-size: 19px; }
body.phone .ach-note-kicker { font-size: 12.5px; }

@keyframes ach-veil { from { opacity: 0; } }
@keyframes ach-rise { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) {
    #bd-ach, .ach-sheet { animation: none; }
    .ach-note { transition: opacity 0.15s linear; transform: translate(-50%, 0); }
    body.phone .ach-note { transform: none; }
}
