/* ------------------------------------------------------------------
   iout.uk trade-in drop-off ticket
   Mobile-first. The code (Royal Mail QR / DPD barcode) is the page;
   everything else is a caption to it. Sized so the code clears the
   fold on a 375x667 phone with browser chrome.
   ------------------------------------------------------------------ */

:root {
    color-scheme: light;

    /* Page ground - warm paper */
    --paper:        #F3EFE8;
    --paper-edge:   #E1DACD;
    --on-paper:     #1A1713;
    --on-paper-dim: #6B6459;
    --chip:         rgba(26, 23, 19, .045);

    /* Ticket internals - fixed light so the code always scans */
    --card:  #FFFFFF;
    --ink:   #1A1713;
    --ink-2: #5C564C;
    --ink-3: #8B8479;
    --rule:  #E8E2D7;

    --ready:      #12704A;
    --ready-soft: #E7F1EC;
    --wait:       #94590A;
    --wait-soft:  #F9EFDD;
    --stop:       #A32B1E;
    --stop-soft:  #F9EBE8;

    --btn:     #1A1713;
    --btn-ink: #FFFFFF;

    --shadow: 0 1px 2px rgba(26, 23, 19, .06), 0 14px 34px -14px rgba(26, 23, 19, .28);
    --radius: 22px;

    --sans: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --paper:        #141210;
        --paper-edge:   #3A332B;
        --on-paper:     #EDE8E0;
        --on-paper-dim: #9A9287;
        --chip:         rgba(255, 255, 255, .055);
        --btn:     #F3EFE8;
        --btn-ink: #17140F;
        --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 20px 44px -16px rgba(0, 0, 0, .8);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    background: var(--paper);
    color: var(--on-paper);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.page {
    margin: auto;
    width: 100%;
    max-width: 460px;
    padding: 20px 20px 28px;
    padding-left:   max(20px, env(safe-area-inset-left));
    padding-right:  max(20px, env(safe-area-inset-right));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: rise .45s cubic-bezier(.22, 1, .36, 1) both;
}

/* ---------------------------------------------------------- ticket */

.ticket {
    position: relative;
    background: var(--card);
    color: var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.ticket__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 20px;
}

.ticket__brand {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
}

/* Vendor logos are mostly ~5:1 wordmarks. Capping height rather than setting
   it lets a square mark stay square, and max-width:100% lets the whole thing
   scale down instead of overflowing when the order ID is a long one. */
.ticket__logo {
    display: block;
    width: auto;
    height: auto;
    max-height: 28px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.ticket__wordmark {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket__order { text-align: right; flex: none; }

.ticket__order-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--ink-3);
    line-height: 1.2;
}

.ticket__order-value {
    display: block;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: -.01em;
    color: var(--ink);
    line-height: 1.35;
}

/* Perforation: two ground-coloured punches straddling a dashed rule */
.ticket__perf {
    position: relative;
    height: 1px;
    margin: 0 20px;
    border-top: 1px dashed var(--rule);
}

.ticket__perf::before,
.ticket__perf::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--paper);
    transform: translateY(-50%);
}

.ticket__perf::before { left:  -30px; }
.ticket__perf::after  { right: -30px; }

.ticket__body {
    padding: 20px 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

/* ------------------------------------------------------ status row */

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .01em;
    padding: 5px 11px 5px 9px;
    border-radius: 999px;
}

.status--ready { background: var(--ready-soft); color: var(--ready); }
.status--wait  { background: var(--wait-soft);  color: var(--wait);  }

.status__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.status--wait .status__dot { animation: blink 1.6s ease-in-out infinite; }

.status__sep { color: currentColor; opacity: .38; }
.status__carrier { font-weight: 500; opacity: .82; }

/* ----------------------------------------------------- the code */

.code {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #FFFFFF;
    border: 1px solid var(--rule);
    border-radius: 16px;
}

.code--square { aspect-ratio: 1 / 1; max-width: 296px; }
.code--wide   { min-height: 176px; }

.code__img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 300px;
    object-fit: contain;
}

.code--wide .code__img { height: auto; }

/* Pending placeholder: smaller than the real code, so the waiting
   message carries the eye instead of a big empty square */
.code--pending {
    max-width: 232px;
    border-style: dashed;
    background: linear-gradient(180deg, #FFFFFF, #FAF8F4);
    position: relative;
    overflow: hidden;
}

.code--pending::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(148, 89, 10, .09) 50%, transparent 65%);
    transform: translateX(-100%);
    animation: sweep 2.6s ease-in-out infinite;
}

.code__spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2.5px solid var(--rule);
    border-top-color: var(--wait);
    animation: spin 900ms linear infinite;
}

/* ---------------------------------------------------------- copy */

.copy { display: flex; flex-direction: column; gap: 6px; }

.copy h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -.021em;
    color: var(--ink);
    text-wrap: balance;
}

.copy p {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ink-2);
    text-wrap: pretty;
}

/* -------------------------------------------------------- actions */

.actions { display: flex; flex-direction: column; gap: 10px; }

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 54px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 15px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.008em;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}

.btn:active { transform: scale(.985); }

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

.btn--quiet {
    background: var(--chip);
    color: var(--on-paper);
    border-color: var(--paper-edge);
}

.btn--quiet:active { border-color: var(--on-paper-dim); }

.btn:disabled { opacity: .55; cursor: progress; }

.btn svg { width: 19px; height: 19px; flex: none; }

/* ----------------------------------------------------- side notes */

.note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 15px;
    background: var(--chip);
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--on-paper-dim);
    text-align: left;
}

.note svg {
    width: 18px;
    height: 18px;
    flex: none;
    margin-top: 1px;
    opacity: .75;
}

.feedback {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
    text-align: center;
    color: var(--on-paper-dim);
    min-height: 1.45em;
}

.feedback.is-error { color: var(--stop); }

.support {
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    color: var(--on-paper-dim);
    text-wrap: pretty;
}

.support a { color: inherit; text-decoration-color: var(--paper-edge); text-underline-offset: 2px; }
.support a:hover { color: var(--on-paper); }

/* -------------------------------------------------------- failure */

.ticket--stop .ticket__body { padding-top: 26px; }

.stop-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--stop-soft);
    color: var(--stop);
}

.stop-mark svg { width: 23px; height: 23px; }

.code-echo {
    align-self: center;
    margin-top: 4px;
    padding: 5px 12px;
    border-radius: 9px;
    background: rgba(26, 23, 19, .05);
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: .04em;
    color: var(--ink);
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------ animation */

@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

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

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: .3; }
}

@keyframes sweep {
    0%        { transform: translateX(-100%); }
    60%, 100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* Tiny phones (iPhone SE and friends): keep the code above the fold */
@media (max-height: 700px) {
    .page { padding-top: 14px; gap: 12px; }
    .ticket__head { padding: 14px 18px; }
    .ticket__body { padding: 18px 18px 20px; gap: 14px; }
    .code--square { max-width: 258px; }
    .copy h1 { font-size: 19px; }
}

@media (min-width: 480px) {
    .code--square { max-width: 320px; }
    .copy h1 { font-size: 22px; }
}

/* ---------------------------------------------------- mark as sent */

.sent {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--paper-edge);
    border-radius: 18px;
    text-align: left;
}

.sent__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--on-paper);
}

.sent__text {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--on-paper-dim);
}

.sent__confirm { display: flex; flex-direction: column; gap: 10px; }
.sent__confirm[hidden], .sent .btn[hidden] { display: none; }

.sent .feedback:empty { display: none; }
