/**
 * SpendSnapper - Accountants page
 *
 * The page for accountants and bookkeepers. Its panels reuse the hero, step, price list and question styles
 * from site.css.
 */

/* The hero: the pitch on the left, the simulation on the right */
/* The small label above the headline, saying who the page is for */
.practice-label {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--muted);    /* quiet, so the blue stays with the headline's second half */
}

.practice-hero h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

/* Beside the simulation the headline has half the page, so it grows more slowly there and each half keeps
   to one line */
@media (min-width: 992px) {
    .practice-hero h1 {
        font-size: clamp(1.75rem, 3.1vw, 2.75rem);
    }
}

.practice-hero h1 span {
    display: block;         /* the second half always starts its own line */
    color: var(--secondary);
}

.practice-lead {
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.practice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.practice-hero .hero-note {
    margin-bottom: 0;
}

/* Once the hero stacks, the pitch and the simulation become two panels, so the pitch ends at its buttons and the
   simulation starts with its own caption. The hero's panel steps aside and each half takes the panel's look. */
@media (max-width: 991.98px) {
    .practice-hero {
        padding: 0;
        background: none;
        box-shadow: none;
    }

    .practice-hero > .row {
        margin: 0;
        gap: var(--spacing-lg);     /* the same space as between the page's panels */
    }

    .practice-hero > .row > * {
        margin-top: 0;
        padding: 2.5rem var(--spacing-lg);
        background: var(--bs-white);
        border-radius: var(--border-radius-lg);
        box-shadow: var(--card-shadow);
    }
}

@media (max-width: 575.98px) {
    .practice-hero > .row {
        gap: var(--spacing-md);
    }

    .practice-hero > .row > * {
        padding: 1.75rem var(--spacing-md);
    }
}

/* -----------------------------
 * The simulation: one invoice, from a client's upload to the client's accounts
 * -----------------------------
 * The app's own list and review table, in the app's styles, with no video. The script sets the scene (1 to 7)
 * and these rules show it. */
.sim-caption {
    display: grid;
    margin: 0 0 0.9rem;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;        /* each caption is short enough for one line, even on a phone */
}

/* The captions share one spot above the panel, and only the current scene's shows */
.sim-caption span {
    grid-area: 1 / 1;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.sim-caption span.is-on {
    opacity: 1;
}

.sim-caption em {
    font-style: normal;
    color: var(--secondary);
}

/* The list and the review page share one spot, and one shows at a time */
.sim {
    display: grid;
    max-width: 560px;
    margin: 0 auto;
    text-align: left;
}

.sim-view {
    grid-area: 1 / 1;
    align-self: start;      /* a shorter scene sits at the top of the panel, close to its caption */
    min-width: 0;           /* a table's widest words must not push the panel wider than its card */
    opacity: 0;
    transition: opacity 0.45s ease;
}

/* The app's toolbar */
.sim-bar {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--secondary) 20%, transparent);
    border-radius: 22px;
    background-color: color-mix(in srgb, var(--secondary) 15%, transparent);
}

.sim-bar .btn-icon {
    height: 32px;
    padding: 0 18px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.sim-submit {
    margin-left: auto;
}

/* The app's tables */
.sim-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
    background-color: #fff;
}

.sim-table th,
.sim-table td {
    padding: 6px 8px;
    border: 1px solid var(--grid-border);
    vertical-align: top;
    text-align: left;
}

.sim-table th {
    border-color: var(--table-header-bg);
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: 500;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.sim-money,
.sim-tax {
    white-space: nowrap;
}

/* Things that take turns in one spot: a placeholder and its value, the three statuses, a button's two labels */
.sim-cell {
    display: inline-grid;
    min-width: 100%;
}

.sim-cell > * {
    grid-area: 1 / 1;
    justify-self: start;
}

/* The shimmer the app shows in a cell whose value has not arrived yet */
.sim-skeleton {
    width: 70%;
    height: 1.1em;
    margin-top: 0.2em;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-shine) 37%, var(--skeleton) 63%);
    background-size: 400% 100%;
    opacity: 0;
}

.sim-value {
    transition: clip-path 0.5s ease-out, opacity 0.15s linear;
}

/* The app's status badges */
.sim-badge {
    padding: 2px 8px;
    border-radius: var(--badge-radius);
    background-color: var(--success-light);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sim-badge.is-reading {
    background-color: color-mix(in srgb, var(--secondary) 15%, transparent);
    color: var(--secondary);
}

.sim-badge i {
    margin-right: 4px;
    animation: sim-spin 1s linear infinite;
}

/* The account or tax rate being pointed at, and its reason beneath, as in the app */
.sim-pick {
    position: relative;
    transition: background-color 0.3s ease;
}

.sim-tip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    z-index: 1;
    width: max-content;
    max-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--tip-border);
    border-radius: var(--border-radius-sm);
    background-color: #fff;
    box-shadow: var(--card-shadow);
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: normal;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 0.3s ease;
}

.sim-tip::before,
.sim-tip::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
}

.sim-tip::before {
    top: -8px;
    border-bottom: 8px solid var(--tip-border);
}

.sim-tip::after {
    top: -6px;
    border-left-width: 7px;
    border-right-width: 7px;
    border-bottom: 7px solid #fff;
}

/* The tax rate sits near the right edge, so its reason is lined up with the cell's right side */
.sim-tip-5 {
    right: 0;
    left: auto;
    transform: none;
}

.sim-tip-5::before,
.sim-tip-5::after {
    right: 24px;
    left: auto;
    transform: none;
}

.sim-tip-5::after {
    right: 25px;
}

/* Submit's icon and label while it waits, and while it is submitting */
.sim-submit .sim-cell {
    min-width: 0;
}

.sim-submit .sim-cell > * {
    justify-self: center;
}

.sim-submit .sim-cell > :last-child {
    opacity: 0;
}

.sim-submit i {
    margin-right: 6px;
}

.sim-submit .fa-spinner {
    animation: sim-spin 1s linear infinite;
}

/* The bill in the accounts package. FreeAgent's screen has its own colours and typeface, so they are named here
   and used nowhere else. */
.sim-ledger {
    --ledger-page: #f5f8ff;
    --ledger-link: #1565a8;
    --ledger-line: #ebebeb;
    --ledger-muted: #5f6466;
    --ledger-thumb: #5d6e78;
    display: grid;
    grid-template-columns: 1fr 112px;
    align-content: start;
    gap: 10px;
    padding: 10px;
    border-radius: var(--border-radius);
    background-color: var(--ledger-page);
    font-family: -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 0.8rem;
    line-height: 1.35;
}

.sim-ledger p {
    margin: 0;
}

.sim-ledger-bill,
.sim-ledger-attachment {
    align-self: start;
    padding: 10px 12px;
    border: 1px solid var(--ledger-line);
    border-radius: 4px;
    background-color: #fff;
}

.sim-ledger-ref {
    padding-bottom: 6px;
}

.sim-ledger-supplier {
    margin-left: 0.5em;
    color: var(--ledger-link);
    font-weight: 700;
}

.sim-ledger table {
    width: 100%;
    border-collapse: collapse;
}

.sim-ledger :is(th, td) {
    padding: 4px 6px;
    border-top: 1px solid var(--ledger-line);
    vertical-align: top;
    text-align: right;
    white-space: nowrap;
}

.sim-ledger :is(th, td):first-child {
    padding-left: 0;
    text-align: left;
    white-space: normal;
}

.sim-ledger td span {
    display: block;
    color: var(--ledger-muted);
}

.sim-ledger-attachment {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

/* The original, as the small picture of the page that FreeAgent shows */
.sim-ledger-thumb {
    display: grid;
    place-items: center;
    padding: 6px 0;
    border-radius: 3px;
    background-color: var(--ledger-thumb);
}

.sim-ledger-thumb span {
    width: 46%;
    aspect-ratio: 210 / 297;
    background: repeating-linear-gradient(to bottom, #fff 0 5px, var(--ledger-line) 5px 6px) content-box #fff;
    padding: 6px 4px;
}

.sim-ledger-button {
    justify-self: start;
    padding: 2px 8px;
    border: 1px solid var(--ledger-line);
    border-radius: 3px;
    color: var(--ledger-link);
    font-weight: 700;
}

/* Which package the bill is shown in, as a quiet label under the attachment */
.sim-ledger-note {
    color: var(--ledger-muted);
    font-size: 0.72rem;
    font-weight: 400;
}

/* Scenes 1 and 2: the list. The upload arrives and is read, then its details write in. */
.sim:is([data-scene="1"], [data-scene="2"]) .sim-list { opacity: 1; }
.sim[data-scene="1"] .sim-upload { animation: sim-press 3.4s ease-out both; }
.sim[data-scene="1"] .sim-list tbody { animation: sim-arrive 0.5s ease-out 0.7s both; }
.sim[data-scene="1"] .sim-skeleton { opacity: 1; animation: review-shimmer 1.4s linear infinite; }
.sim[data-scene="1"] .sim-value { clip-path: inset(0 100% 0 0); opacity: 0; transition: none; }
.sim[data-scene="1"] .is-reading { opacity: 1; }
.sim[data-scene="2"] td:nth-child(2) .sim-value { transition-delay: 0.3s; }
.sim[data-scene="2"] .is-reading { transition-delay: 0.9s; }
.sim[data-scene="2"] .is-ready { opacity: 1; transition-delay: 0.9s; }

/* Scenes 3 to 5: the review page, then a reason for an account and a reason for a tax rate */
.sim:is([data-scene="3"], [data-scene="4"], [data-scene="5"]) .sim-review { opacity: 1; }
.sim[data-scene="4"] tr:nth-child(1) .sim-account,
.sim[data-scene="5"] tr:nth-child(2) .sim-tax { background-color: var(--secondary-ultra-light); }
.sim[data-scene="4"] .sim-tip-4,
.sim[data-scene="5"] .sim-tip-5 { opacity: 1; }

/* Scene 6: Submit is pressed on the review page, then the list shows the document as submitted */
.sim[data-scene="6"] .sim-review { animation: sim-leave 4.8s linear both; }
.sim[data-scene="6"] .sim-list { animation: sim-enter 4.8s linear both; }
.sim[data-scene="6"] .sim-submit { animation: sim-press 4.8s ease-out both; }
.sim[data-scene="6"] .sim-submit .sim-cell > :first-child { animation: sim-first 4.8s linear both; }
.sim[data-scene="6"] .sim-submit .sim-cell > :last-child { animation: sim-second 4.8s linear both; }
.sim[data-scene="6"] .is-submitted { opacity: 1; }

/* Scene 7: the bill in the client's accounts, and a ring around the attached original */
.sim[data-scene="7"] .sim-ledger { opacity: 1; }
.sim[data-scene="7"] .sim-ledger-attachment { animation: sim-ring 5s ease-out both; }

@keyframes sim-ring {
    0%, 22% { box-shadow: 0 0 0 0 var(--secondary-light); }
    30% { box-shadow: 0 0 0 4px var(--secondary-light); }
    70% { box-shadow: 0 0 0 4px var(--secondary-light); }
    85%, 100% { box-shadow: 0 0 0 4px transparent; }
}

@keyframes sim-arrive {
    from { opacity: 0; transform: translateY(-6px); }
}

@keyframes sim-spin {
    to { transform: rotate(360deg); }
}

/* A press on a button: it dips and a ring spreads from it */
@keyframes sim-press {
    0%, 12% { transform: scale(1); box-shadow: 0 0 0 0 var(--secondary-light); }
    16% { transform: scale(0.93); }
    22% { transform: scale(1); }
    34%, 100% { box-shadow: 0 0 0 12px transparent; }
}

/* The first of a pair gives way to the second once the button has been pressed */
@keyframes sim-first {
    0%, 17% { opacity: 1; }
    18%, 100% { opacity: 0; }
}

@keyframes sim-second {
    0%, 17% { opacity: 0; }
    18%, 100% { opacity: 1; }
}

@keyframes sim-leave {
    0%, 36% { opacity: 1; }
    44%, 100% { opacity: 0; }
}

@keyframes sim-enter {
    0%, 36% { opacity: 0; }
    44%, 100% { opacity: 1; }
}

@media (max-width: 575.98px) {
    .sim-table {
        font-size: 0.75rem;
    }

    .sim-table th,
    .sim-table td {
        padding: 5px 6px;
    }

    .sim-tax {
        white-space: normal;
    }

    /* The line totals make way for the description, account and tax rate */
    .sim-lines :is(th, td):nth-child(4) {
        display: none;
    }

    .sim-tip {
        max-width: 200px;
    }

    .sim-caption {
        font-size: 1.05rem;
    }

    /* The attachment moves beneath the bill, as one row */
    .sim-ledger {
        grid-template-columns: 1fr;
        gap: 8px;
        font-size: 0.75rem;
    }

    /* Each description keeps to one line, as it was shown in full on the review page */
    .sim-ledger td:first-child {
        width: 100%;
        max-width: 0;
    }

    .sim-ledger th:last-child {
        white-space: normal;    /* the heading wraps, which leaves the descriptions more room */
    }

    .sim-ledger td:first-child span {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .sim-ledger-note {
        margin-left: auto;
    }

    .sim-ledger-attachment {
        padding: 6px 12px;
        grid-template-columns: auto 44px auto 1fr;
        align-items: center;
        justify-content: start;
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sim *,
    .sim-caption span {
        animation: none !important;
        transition: none !important;
    }
}

/* The control cards' lead line sits close to the cards it introduces */
#control .section-lead {
    margin-bottom: 0;
}

/* Each step's number has its own colour: slate, then the logo's blue, red and green */
.step-icon.step-c1 { background-color: var(--primary); }
.step-icon.step-c2 { background-color: var(--facet-blue); }
.step-icon.step-c3 { background-color: var(--facet-red); }
.step-icon.step-c4 { background-color: var(--facet-green); }

/* The step cards sit a little below their heading */
.practice-steps {
    margin-top: 1rem;
}

/* Two steps to a row (or one on a phone), the number sits beside its heading and text, so the cards stay short.
   Four to a row on wide screens, the cards are narrow and keep the number above. */
@media (max-width: 1199.98px) {
    #how .step {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 1rem;
        align-items: start;
        align-content: start;   /* a card stretched to match its neighbour keeps its text under the heading */
        padding: 1.25rem;
    }

    #how .step .step-icon {
        grid-row: span 2;
        width: 40px;
        height: 40px;
        margin-bottom: 0;
    }

    #how .step h3 {
        margin-top: 0.45rem;
    }
}

/* The control cards do the same once they stack one to a row (three to a row, they keep the icon above) */
@media (max-width: 767.98px) {
    #control .step {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 1rem;
        align-items: start;
        align-content: start;
        padding: 1.25rem;
    }

    #control .step .step-icon {
        grid-row: span 2;
        width: 40px;
        height: 40px;
        margin-bottom: 0;
        font-size: 1rem;
    }

    #control .step h3 {
        margin-top: 0.45rem;
    }
}

/* Feature cards (not the numbered steps): on wide screens, where three to a row still leaves each card room, the
   icon sits on the left with the heading and text beside it, so the panel is shorter. Narrower, the icon goes back
   on top. Used by "You stay in control" here and "What's different" on the Dext page. */
@media (min-width: 1200px) {
    .cards-beside .step {
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: var(--spacing-md);
        align-items: start;
        align-content: start;
    }

    .cards-beside .step .step-icon {
        grid-row: span 2;
        margin-bottom: 0;
    }

    .cards-beside .step h3 {
        margin-top: 0.7rem;     /* the heading lines up with the middle of its icon */
    }
}

/* The numbered steps carry a digit where the other pages carry an icon */
.practice-steps .step-icon {
    font-weight: 700;
}

/* On wide screens the questions flow down two columns, each question directly under the one before. The shared
   grid (site.css) pairs them in rows instead, which leaves a gap beside any answer longer than its neighbour. */
@media (min-width: 768px) {
    .practice-faq .faq {
        display: block;
        columns: 2;
        column-gap: 2.5rem;
    }

    .practice-faq .faq-item {
        break-inside: avoid;
        margin-bottom: 1.5rem;
    }

    .practice-faq .faq-item:last-child {
        margin-bottom: 0;
    }
}

/* An answer in two paragraphs keeps a little space between them */
.practice-faq .faq-item p + p {
    margin-top: var(--spacing-sm);
}

/* The closing line reads as a heading on the slate band */
.closing .practice-closing {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 500;
}

@media (max-width: 575.98px) {
    /* The headline is a little smaller on a phone, so each half fits on one line and the page starts sooner */
    .practice-hero h1 {
        font-size: clamp(1.4rem, 6.6vw, 1.75rem);
    }

    /* The two hero buttons share one row on a phone, a little smaller */
    .practice-actions {
        gap: 0.5rem;
    }

    .practice-actions .btn-icon-lg {
        flex: 1 1 auto;
        height: 42px;
        padding: 0 12px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    /* On a phone the pitch is centred, as the home page's hero is, and so are the headings of the steps and the
       control cards (site.css already centres the prices and questions headings) */
    .practice-pitch,
    #how .section-title,
    #control .section-title,
    #control .section-lead {
        text-align: center;
    }

    /* The label, the lead and the note under the buttons break into even lines on a phone, so none leaves one
       word alone on its last line */
    .practice-label,
    .practice-lead,
    .practice-hero .hero-note {
        text-wrap: balance;
    }

    .practice-faq .section-title {
        text-align: center;
    }
}

/* Marks a step that practices can skip, eg. sharing when they upload everything themselves */
.step h3 .step-optional {
    font-weight: normal;
    font-size: 0.8em;
    color: var(--muted);
}
