/* /features/accounting/ only: the body of the hero's live instrument (supplier invoices beside
   the invoice they're reading, with the PO match, approval stamp and Xero status;
   js/pages/accounting.js). The instrument's shell (stage, board header, activity footer) is
   .site-instrument in css/public-site.css. */

.ap-board {
    /* One colour per invoice status, on the list's chips and the invoice's status. */
    --ap-new: #6B6680;
    --ap-new-bg: #EFEDF3;
    --ap-reading: #6D28D9;
    --ap-reading-bg: #F1EAFE;
    --ap-matched: #1D4ED8;
    --ap-matched-bg: #E8EFFE;
    --ap-approved: #146C43;
    --ap-approved-bg: #E7F5EC;
}

.ap-board__body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; height: 400px; }

/* ---------- Status chip (list and invoice) ---------- */
.ap-chip {
    flex: none;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--ap-new-bg);
    color: var(--ap-new);
    font-family: var(--site-font-mono);
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.ap-chip:empty { display: none; }
.ap-chip--reading  { background: var(--ap-reading-bg);  color: var(--ap-reading); }
.ap-chip--matched  { background: var(--ap-matched-bg);  color: var(--ap-matched); }
.ap-chip--approved { background: var(--ap-approved-bg); color: var(--ap-approved); }
.ap-chip.is-popped { animation: ap-pop .45s cubic-bezier(.34, 1.5, .64, 1); }
@keyframes ap-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } }

/* ---------- Supplier invoices (the list) ---------- */
.ap-list { display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden; }
.ap-list__head {
    flex: none;
    display: flex;
    justify-content: space-between;
    padding: 2px 2px 4px;
    font-family: var(--site-font-mono);
    font-size: 10.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--site-subtle);
}
.ap-item {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 8px;
    border: 1px solid var(--site-line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease;
}
.ap-item:hover { background: #F7F5FC; }
.ap-item.is-active { border-color: var(--site-accent); background: var(--site-panel); }
.ap-item.is-arriving { animation: ap-arrive .5s cubic-bezier(.34, 1.3, .64, 1) backwards; }
@keyframes ap-arrive { from { opacity: 0; transform: translateY(-10px); } }
.ap-item__mark { flex: none; width: 4px; align-self: stretch; border-radius: 2px; background: var(--ap-new-bg); transition: background-color .3s ease; }
.ap-item--reading .ap-item__mark  { background: var(--ap-reading); }
.ap-item--matched .ap-item__mark  { background: var(--ap-matched); }
.ap-item--approved .ap-item__mark { background: var(--ap-approved); }
.ap-item__info { flex: 1; min-width: 0; }
.ap-item__vendor { font-size: 13px; font-weight: 600; color: var(--site-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-item__meta { margin-top: 1px; font-family: var(--site-font-mono); font-size: 11px; color: var(--site-subtle); white-space: nowrap; }
.ap-list__note { flex: none; padding: 4px 2px; font-size: 12px; font-style: italic; color: var(--site-subtle); }

/* ---------- The invoice being read ---------- */
.ap-viewer {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 14px;
    border: 1px solid var(--site-line);
    border-radius: 10px;
    background: var(--site-paper);
    overflow: hidden;
}
.ap-paper {
    position: relative;
    width: min(440px, 100%);
    height: 100%;
    padding: 16px 20px 14px;
    display: flex;
    flex-direction: column;
    border: 1px solid #E4E1EA;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 14px 30px -16px rgba(23, 20, 31, .35);
    transition: opacity .22s ease, transform .22s ease;
    overflow: hidden;
}
/* No transform at rest: on the instrument's 3D stage Chrome stops hit-testing anything inside an
   element left with one (the Approve button went dead under a slight tilt of the page). */
.ap-paper.is-swapping { opacity: 0; transform: translateY(10px) scale(.98); }

/* Smart Match reading: a line passes over the page */
.ap-paper__scan { position: absolute; left: 0; right: 0; top: 4%; height: 2px; background: var(--ap-reading); opacity: 0; pointer-events: none; }
.ap-paper.is-reading .ap-paper__scan { opacity: .5; animation: ap-scan 1.6s ease-in-out infinite; }
@keyframes ap-scan { 50% { top: 94%; } }

.ap-paper__head {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--site-text);
}
.ap-paper__id { min-width: 0; }
.ap-paper__letterhead { font-family: var(--site-font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--site-subtle); }
.ap-paper__title { margin-top: 3px; font-family: var(--site-font-display); font-size: 17px; font-weight: 600; line-height: 1.2; color: var(--site-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-paper__ref { margin-top: 2px; font-size: 12px; color: var(--site-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-paper__label { flex: none; margin-bottom: 2px; font-family: var(--site-font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--site-accent); }

.ap-paper__rows { flex: none; }
.ap-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px solid #EFEDF3; font-size: 12.5px; }
.ap-row__label { color: var(--site-muted); }
.ap-row__value { font-weight: 600; color: var(--site-text); text-align: right; white-space: nowrap; }
.ap-row__value.is-pending { font-weight: 400; font-style: italic; color: #B4AEC6; }
.ap-row__value.is-read { animation: ap-read .5s ease; }
@keyframes ap-read { from { background: var(--ap-reading-bg); } }
.ap-row--total { border-bottom: 0; padding-top: 6px; }
.ap-row--total .ap-row__label { font-weight: 600; color: var(--site-text); }

.ap-paper__match {
    flex: none;
    min-height: 44px;
    margin-top: 10px;
    padding: 7px 10px;
    border: 1px solid #C9D8FC;
    border-radius: 8px;
    background: var(--ap-matched-bg);
    font-size: 12px;
    line-height: 1.45;
    color: var(--ap-matched);
    visibility: hidden;
}
.ap-paper__match.is-shown { visibility: visible; }
.ap-paper__match.is-new { animation: ap-match-in .4s cubic-bezier(.34, 1.3, .64, 1) backwards; }
@keyframes ap-match-in { from { opacity: 0; transform: translateY(6px); } }
.ap-paper__match strong, .ap-paper__match span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-paper__match strong { font-weight: 600; }

.ap-paper__foot { flex: none; margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; }
.ap-paper__xero { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12px; color: var(--site-text-2); white-space: nowrap; }
.ap-paper__xero [data-ap] { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ap-paper__xero-label { font-family: var(--site-font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--site-subtle); }
.ap-approve {
    flex: none;
    padding: 7px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--site-accent);
    color: #fff;
    font: 600 12.5px/1.2 var(--site-font-body);
    cursor: pointer;
    visibility: hidden;
}
.ap-approve:hover { background: var(--site-accent-hover); }
.ap-approve.is-shown { visibility: visible; }

/* The approval stamp */
.ap-paper__stamps { position: absolute; inset: 0; pointer-events: none; }
.ap-stamp {
    position: absolute;
    left: 56%;
    top: 52%;
    width: max-content;   /* not squeezed by the paper's right edge */
    padding: 4px 12px 5px;
    border: 3px solid var(--ap-approved);
    border-radius: 8px;
    color: var(--ap-approved);
    font-family: var(--site-font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-align: center;
    opacity: .85;
    transform: translate(-50%, -50%) rotate(-9deg);
}
.ap-stamp small { display: block; margin-top: -2px; font-family: var(--site-font-mono); font-size: 9px; font-weight: 500; letter-spacing: .06em; white-space: nowrap; }
.ap-stamp.is-slammed { animation: ap-slam .4s cubic-bezier(.22, 1.3, .36, 1) backwards; }
@keyframes ap-slam {
    0%  { opacity: 0; transform: translate(-50%, -50%) rotate(-9deg) scale(2.4); }
    55% { opacity: .9; transform: translate(-50%, -50%) rotate(-9deg) scale(.95); }
}

/* The Xero figure flashes on each push (kit.bump with is-flash, the shell's animation). */
.ap-xero-value { color: var(--ap-approved); }

/* ---------- Narrow: the list above the invoice ---------- */
@media (max-width: 760px) {
    .ap-board__body { grid-template-columns: minmax(0, 1fr); height: auto; }
    /* Exactly three one-line invoices: a new one lands on top and the oldest drops off the
       bottom, so nothing below moves. */
    .ap-list { height: 160px; }        /* heading 22 + three of (6 gap + 40) */
    .ap-list__head { height: 22px; padding-top: 0; padding-bottom: 0; align-items: center; }
    .ap-list__note, .ap-item__meta, .ap-paper__label { display: none; }
    .ap-item { height: 40px; padding-top: 0; padding-bottom: 0; }
    .ap-viewer { height: 354px; padding: 8px; }
    .ap-paper { padding: 12px 14px 10px; }
    .ap-paper__title { font-size: 16px; }
    .ap-row { font-size: 12px; }
    .ap-stamp { left: 50%; font-size: 15px; }
    .ap-paper__match { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .ap-paper, .ap-item, .ap-item__mark { transition: none; }
    .ap-paper.is-reading .ap-paper__scan { animation: none; opacity: 0; }
}
