/* Tokens */
:root {
    color-scheme: light;
    --color-desk: #e5e7e6;
    --color-paper: #fff9e9;
    --color-ink: #202320;
    --color-muted: #555c58;
    --color-accent: #294f68;
    --color-line: #b8beb9;
    --color-error: #8b2929;
    --font-sans: Calibri, Candara, "Segoe UI", sans-serif;
    --font-receipt: "Courier New", Courier, monospace;
    --receipt-width: 430px;
    --receipt-padding-inline: 28px;
    --focus-ring: 3px solid var(--color-accent);
    font-family: var(--font-sans);
    color: var(--color-ink);
    background: var(--color-desk);
}

/* Reset / base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

button,
input {
    font: inherit;
}

button,
a,
input,
summary {
    -webkit-tap-highlight-color: transparent;
}

button,
a,
summary {
    touch-action: manipulation;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

button[aria-disabled="true"] {
    cursor: not-allowed;
}

a {
    color: inherit;
    text-underline-offset: 4px;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
[tabindex="-1"]:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 5px;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.site-head {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 1100px;
    margin: auto;
    padding: 28px 32px;
    font: 700 14px var(--font-receipt);
    letter-spacing: 0.06em;
}

.mark {
    width: 17px;
    height: 23px;
    border: 2px solid currentColor;
    background:
        repeating-linear-gradient(
            transparent 0 4px,
            currentColor 4px 5px,
            transparent 5px 8px
        );
    background-position: center;
    background-repeat: no-repeat;
    background-size: 9px 12px;
}

main {
    max-width: 1000px;
    margin: 36px auto 0;
    padding: 0 32px;
}

.intro {
    max-width: 560px;
}

h1 {
    margin: 0 0 22px;
    font-size: clamp(38px, 5.4vw, 60px);
    font-weight: 600;
    line-height: 1.03;
    letter-spacing: -0.055em;
}

.intro p {
    max-width: 450px;
    margin: 0;
    color: var(--color-muted);
    font-size: 17px;
    line-height: 1.65;
}

.intro .intro-followup {
    margin-top: 16px;
}

/* Form */
.form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 76px;
    align-items: start;
}

form {
    padding-top: 3px;
}

.field {
    margin: 0 0 23px;
}

label {
    display: block;
    margin-bottom: 9px;
    font-size: 15px;
    font-weight: 600;
}

.input-shell {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 7px;
    border-bottom: 1px solid #828b85;
}

.input-shell:focus-within {
    border-color: var(--color-accent);
}

input {
    width: 100%;
    min-width: 0;
    padding: 3px 0;
    border: 0;
    border-radius: 0;
    color: var(--color-ink);
    background: transparent;
    font: 26px var(--font-receipt);
    font-variant-numeric: tabular-nums;
}

input::placeholder {
    color: var(--color-muted);
    opacity: 1;
}

.unit {
    color: var(--color-muted);
    font-size: 13px;
    white-space: nowrap;
}

.hint,
.error {
    margin: 7px 0 0;
    font-size: 12px;
    line-height: 1.5;
}

.hint {
    color: var(--color-muted);
}

.error {
    color: var(--color-error);
    font-size: 13px;
}

.primary,
.secondary {
    width: 100%;
    min-height: 52px;
    padding: 15px 12px;
    border: 1px solid var(--color-ink);
    font: 700 13px var(--font-receipt);
    letter-spacing: 0.04em;
}

.primary {
    color: var(--color-paper);
    background: var(--color-ink);
}

.primary:hover {
    background: #39433c;
}

.secondary {
    color: var(--color-ink);
    background: transparent;
}

.secondary:hover {
    background: #d9ddd9;
}

.exits {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-top: 22px;
}

.text-button {
    min-height: 44px;
    padding: 12px 0;
    border: 0;
    color: var(--color-muted);
    background: none;
    font-size: 13px;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.privacy {
    max-width: 460px;
    margin: 28px 0 0;
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.6;
}

/* Receipt */
.result-wrap {
    max-width: var(--receipt-width);
    margin: 0 auto;
}

.printer-slot {
    height: 9px;
    margin: 0 -9px -3px;
    border-radius: 5px;
    background: #303832;
    box-shadow: 0 2px 0 #9da69e;
}

.receipt {
    position: relative;
    padding: 34px var(--receipt-padding-inline) 32px;
    overflow-wrap: break-word;
    color: var(--color-ink);
    background: var(--color-paper);
    box-shadow: 0 8px 19px #26302a20;
    font-family: var(--font-receipt);
    font-variant-numeric: tabular-nums;
}

.receipt::after {
    position: absolute;
    right: 0;
    bottom: -7px;
    left: 0;
    height: 8px;
    background:
        linear-gradient(135deg, var(--color-paper) 25%, transparent 25%) -4px 0 / 8px 8px,
        linear-gradient(225deg, var(--color-paper) 25%, transparent 25%) -4px 0 / 8px 8px;
    content: "";
}

.receipt h2 {
    margin: 0 0 7px;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -1.4px;
    text-align: center;
}

.receipt .subtitle {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-align: center;
}

.receipt hr {
    margin: 24px 0;
    border: 0;
    border-top: 1px dashed #66685d;
}

.receipt h3 {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.35;
}

.receipt .context {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
}

.total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 9px 0 26px;
    white-space: nowrap;
}

.number {
    font-size: clamp(40px, 10vw, 58px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.065em;
}

.hedge,
.hours {
    flex: 0 0 auto;
    font-size: 13px;
}

.next {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--color-accent);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.8;
}

.caveat {
    margin: 24px 0 17px;
    font-size: 11px;
    line-height: 1.6;
}

.source,
.origin {
    margin: 0;
    font-size: 10px;
    line-height: 1.65;
}

.origin {
    margin-top: 10px;
    text-align: center;
}

.receipt-block {
    opacity: 1;
}

.printing {
    animation: feed 1.9s steps(36, end) both;
}

.printing .receipt-block {
    animation: ink 0.18s both;
    animation-delay: var(--delay, 0s);
}

@keyframes feed {
    from {
        clip-path: inset(0 0 100% 0);
    }

    to {
        clip-path: inset(0 0 -10px 0);
    }
}

@keyframes ink {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Actions */
.actions {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.actions .primary {
    border-color: var(--color-accent);
    background: var(--color-accent);
}

.edit {
    display: block;
    margin: 12px auto 0;
    text-align: center;
}

.status {
    min-height: 1.6em;
    margin: 10px 0;
    color: var(--color-muted);
    font-size: 13px;
    line-height: 1.6;
}

.message-fallback {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--color-line);
    font-size: 14px;
    line-height: 1.7;
    user-select: all;
}

/* Emotional exits */
.exit-view {
    max-width: 550px;
    margin: 60px auto 120px;
}

.exit-view h1 {
    font-size: 42px;
    line-height: 1.2;
}

.exit-view p {
    color: var(--color-muted);
    font-size: 17px;
    line-height: 1.7;
}

/* Methodology */
footer {
    max-width: 1000px;
    margin: 64px auto 0;
    padding: 0 32px 36px;
}

details {
    max-width: 100%;
    padding-top: 4px;
    border-top: 1px solid var(--color-line);
}

/* The padding keeps the label where it was while reaching a 44px target. */
summary {
    width: fit-content;
    min-height: 44px;
    padding: 14px 0;
    color: var(--color-muted);
    font-size: 13px;
    cursor: pointer;
}

.method-copy {
    max-width: 670px;
    color: var(--color-muted);
    font-size: 13px;
    line-height: 1.8;
}

.method-copy code {
    font-size: 12px;
}

.method-copy p {
    margin: 12px 0;
}

.noscript {
    max-width: 600px;
    margin: auto;
    padding: 24px;
}

/* Responsive */
@media (max-width: 700px) {
    :root {
        --receipt-padding-inline: 23px;
    }

    .site-head {
        padding: 22px 24px;
    }

    main {
        margin-top: 25px;
        padding: 0 24px;
    }

    .form-layout {
        grid-template-columns: 1fr;
        gap: 34px;
    }

    .intro p {
        font-size: 16px;
    }

    form {
        max-width: 480px;
    }

    .field {
        margin-bottom: 22px;
    }

    .result-wrap {
        max-width: 400px;
    }

    .receipt {
        padding-top: 30px;
    }

    .number {
        font-size: clamp(34px, 12vw, 50px);
    }

    .next {
        font-size: 12px;
    }

    .exit-view {
        margin: 32px auto 80px;
    }

    .exit-view h1 {
        font-size: 34px;
    }

    footer {
        margin-top: 42px;
        padding: 0 24px 28px;
    }
}

@media (max-width: 360px) {
    main {
        padding-inline: 18px;
    }

    .receipt {
        padding-inline: 18px;
    }

    .total {
        gap: 6px;
    }

    .number {
        font-size: 34px;
    }

    .hedge,
    .hours {
        font-size: 11px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation: none !important;
    }
}
