/*
 * Pixs design system: tokens, base styles and components.
 * Source: Léo's app V2 handoff (pixs-hq/maquettes/app-v2/02-Tokens.png,
 * 03-Components.png and 10-handoff-app.md §2). Shared by every page of the app.
 *
 * One deliberate change from the mockups: the primary button is white on
 * #CC4B14 (4.6:1, WCAG AA), as decided with Léo for the landing V4 on 12/11.
 * #FA682E stays the brand orange for icons, bars and light fills, never under
 * white text (3:1).
 */

@font-face {
    font-family: "Onest";
    src: url("../fonts/onest-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Manrope";
    src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Colour */
    --px-ink: #140600;
    --px-ink-2: #3f3733;
    --px-muted: #6b625d;
    --px-bg: #f6f3ef;
    --px-bg-2: #fbf8f4;
    --px-surface: #ffffff;
    --px-border: rgba(20, 6, 0, 0.1);
    --px-border-input: rgba(20, 6, 0, 0.14);
    --px-track: #efe9e2;

    --px-accent: #fa682e;
    --px-accent-hover: #e55f2a;
    --px-accent-strong: #cc4b14;
    --px-accent-strong-hover: #b3410f;
    --px-accent-text: #c2501c;
    --px-accent-text-2: #a8461a;
    --px-accent-soft: #fff1ea;
    --px-accent-soft-2: #ffe3d6;
    --px-accent-deep: #9a3e12;
    --px-accent-line: #ffd9c6;

    --px-success: #15803d;
    --px-success-bg: #e8f6ee;
    --px-warning: #92400e;
    --px-warning-bg: #fef3c7;
    --px-warning-row: #fffbea;
    --px-danger: #b91c1c;
    --px-danger-bg: #fee2e2;
    --px-danger-row: #fef6f6;
    --px-neutral: #5c534e;
    --px-neutral-bg: #f3f1ee;

    /* Type */
    --px-font-display: "Onest", "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --px-font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --px-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    /* Radius */
    --px-radius-input: 8px;
    --px-radius-button: 9px;
    --px-radius-card: 14px;
    --px-radius-modal: 16px;
    --px-radius-pill: 999px;

    /* Elevation */
    --px-shadow-modal: 0 30px 60px rgba(20, 6, 0, 0.14);
    --px-shadow-toast: 0 12px 30px rgba(20, 6, 0, 0.12);
    --px-overlay: rgba(246, 243, 239, 0.78);
    --px-focus: 0 0 0 2px var(--px-surface), 0 0 0 4px var(--px-accent);

    /* Layout */
    --px-sidebar: 232px;
    --px-main-pad-y: 28px;
    --px-main-pad-x: 40px;
    --px-bottom-bar: 72px;
}

/* ----- Base ------------------------------------------------------------ */

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

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

body {
    margin: 0;
    background: var(--px-bg);
    color: var(--px-ink-2);
    font-family: var(--px-font-body);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: var(--px-ink);
    font-family: var(--px-font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 22px;
}

h3 {
    font-family: var(--px-font-body);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0;
}

p {
    margin: 0;
}

a {
    color: var(--px-accent-text);
    font-weight: 700;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img,
video {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: none;
    box-shadow: var(--px-focus);
}

[hidden] {
    display: none !important;
}

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

.mono {
    font-family: var(--px-font-mono);
    font-size: 13px;
    font-weight: 700;
}

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

.label {
    color: var(--px-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.icon--sm {
    width: 14px;
    height: 14px;
}

.icon--lg {
    width: 22px;
    height: 22px;
}

.spin {
    animation: px-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .spin {
        animation-duration: 2.4s;
    }
}

/* ----- Buttons --------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--px-border-input);
    border-radius: var(--px-radius-button);
    background: var(--px-surface);
    color: var(--px-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    border-color: rgba(20, 6, 0, 0.28);
    text-decoration: none;
}

.btn--primary {
    border-color: var(--px-accent-strong);
    background: var(--px-accent-strong);
    color: #fff;
}

.btn--primary:hover {
    border-color: var(--px-accent-strong-hover);
    background: var(--px-accent-strong-hover);
}

.btn--danger {
    border-color: #f3c4c4;
    color: var(--px-danger);
}

.btn--danger:hover {
    border-color: var(--px-danger);
}

.btn--link {
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--px-accent-text);
}

.btn--link:hover {
    text-decoration: underline;
}

.btn--lg {
    min-height: 46px;
    padding: 0 22px;
    font-size: 15px;
}

.btn--sm {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.btn--block {
    width: 100%;
}

.btn--icon {
    width: 40px;
    padding: 0;
}

.btn--icon.btn--sm {
    width: 32px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.45;
}

.btn--primary[disabled],
.btn--primary[aria-disabled="true"] {
    opacity: 1;
    border-color: #f1b496;
    background: #f1b496;
}

.btn[aria-busy="true"] {
    cursor: progress;
}

/* Busy is disabled too, but its label says what is happening: keep it
   readable (white on the pale disabled orange is about 1.8:1). */
.btn--primary[aria-busy="true"] {
    border-color: var(--px-accent-strong);
    background: var(--px-accent-strong);
}

/* A copy button once its text is in the clipboard (J5.29, Dom.copyButton): the
   success pair of pill--ready, #15803d on #e8f6ee (4.5:1), and a check. */
.btn.is-copied,
.btn.is-copied:hover {
    border-color: var(--px-success);
    background: var(--px-success-bg);
    color: var(--px-success);
}

/* The button and its live region (Dom.copyButton). */
.copy-button {
    display: inline-flex;
}

/* ----- Form fields ----------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field__label {
    color: var(--px-ink-2);
    font-size: 13px;
    font-weight: 700;
}

.field__counter {
    color: var(--px-muted);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.field__counter.is-warning {
    color: var(--px-warning);
}

.field__hint {
    color: var(--px-muted);
    font-size: 12px;
}

.field__error {
    color: var(--px-danger);
    font-size: 13px;
    font-weight: 700;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--px-border-input);
    border-radius: var(--px-radius-input);
    background: var(--px-surface);
    color: var(--px-ink);
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
    min-height: 88px;
    resize: vertical;
    line-height: 1.5;
}

.select {
    padding-right: 36px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23140600' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    cursor: pointer;
}

.input::placeholder,
.textarea::placeholder {
    color: #8c837e;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--px-accent);
    box-shadow: 0 0 0 3px var(--px-accent-soft-2);
}

.input.is-invalid,
.textarea.is-invalid {
    border-color: var(--px-danger);
}

.input[readonly],
.input:disabled,
.select:disabled,
.textarea[readonly] {
    background: var(--px-bg-2);
    color: var(--px-ink-2);
}

.input.mono {
    font-size: 13px;
}

.check {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--px-ink-2);
    font-size: 14px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--px-accent-strong);
    cursor: pointer;
}

/* ----- Status pills, chips, tags --------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 10px;
    border-radius: var(--px-radius-pill);
    background: var(--px-neutral-bg);
    color: var(--px-neutral);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.pill .icon {
    width: 12px;
    height: 12px;
}

.pill--ready,
.pill--success {
    background: var(--px-success-bg);
    color: var(--px-success);
}

.pill--analyzing,
.pill--processing {
    background: var(--px-accent-soft);
    color: var(--px-accent-text);
}

.pill--review,
.pill--warning {
    background: var(--px-warning-bg);
    color: var(--px-warning);
}

.pill--failed,
.pill--danger {
    background: var(--px-danger-bg);
    color: var(--px-danger);
}

.pill--expired {
    color: var(--px-muted);
}

.pill--soon {
    background: var(--px-accent-soft);
    color: var(--px-accent-text-2);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--px-border-input);
    border-radius: var(--px-radius-pill);
    background: var(--px-surface);
    color: var(--px-ink);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.chip:hover {
    border-color: rgba(20, 6, 0, 0.28);
}

.chip[aria-pressed="true"],
.chip.is-active {
    border-color: transparent;
    background: var(--px-accent-soft-2);
    color: var(--px-accent-deep);
}

.keyword {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 10px;
    border-radius: var(--px-radius-pill);
    background: var(--px-accent-soft-2);
    color: var(--px-accent-deep);
    font-size: 13px;
    font-weight: 700;
}

.counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ----- Cards, meter, progress ------------------------------------------ */

.card {
    border: 1px solid var(--px-border);
    border-radius: var(--px-radius-card);
    background: var(--px-surface);
}

.card__body {
    padding: 24px;
}

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

.card__head + .card__body {
    padding-top: 0;
}

.card__foot {
    display: flex;
    justify-content: center;
    padding: 16px 24px;
    border-top: 1px solid var(--px-border);
}

.card--soft {
    border-color: var(--px-accent-line);
    background: var(--px-accent-soft);
}

.bar {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: var(--px-radius-pill);
    background: var(--px-track);
}

.bar__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: var(--px-accent);
    transition: width 0.3s ease;
}

.bar--warning .bar__fill {
    background: var(--px-warning);
}

.meter {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meter__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    color: var(--px-ink);
    font-size: 14px;
    font-weight: 700;
}

.meter__value {
    color: var(--px-ink-2);
    font-variant-numeric: tabular-nums;
}

.meter__foot {
    color: var(--px-muted);
    font-size: 12px;
}

/* ----- Tables ---------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    padding: 14px 16px;
    border-bottom: 1px solid var(--px-border);
    background: var(--px-bg-2);
    color: var(--px-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--px-border);
    color: var(--px-ink-2);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table th:first-child,
.table td:first-child {
    padding-left: 24px;
}

.table th:last-child,
.table td:last-child {
    padding-right: 24px;
}

.table .num {
    font-variant-numeric: tabular-nums;
}

.table .strong {
    color: var(--px-ink);
    font-weight: 700;
}

.table .sub {
    color: var(--px-muted);
    font-size: 13px;
}

.table tr.is-review td {
    background: var(--px-warning-row);
}

.table tr.is-failed td {
    background: var(--px-danger-row);
}

.table tr.is-muted td {
    color: var(--px-muted);
}

/* ----- Dropzone -------------------------------------------------------- */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 24px;
    border: 2px dashed #f7b79b;
    border-radius: var(--px-radius-modal);
    background: #fffaf6;
    text-align: center;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dropzone.is-over {
    border-style: solid;
    border-color: var(--px-accent);
    background: var(--px-accent-soft);
}

.dropzone__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--px-accent-soft-2);
    color: var(--px-accent);
}

.dropzone__title {
    color: var(--px-ink);
    font-family: var(--px-font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.dropzone__text {
    max-width: 520px;
    color: var(--px-muted);
    font-size: 15px;
}

.dropzone__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

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

.dropzone__release {
    color: var(--px-accent-text-2);
    font-size: 17px;
    font-weight: 700;
}

/* ----- Toasts ---------------------------------------------------------- */

.toasts {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(440px, calc(100vw - 32px));
    padding: 14px 16px;
    border: 1px solid var(--px-border);
    border-radius: 12px;
    background: var(--px-surface);
    box-shadow: var(--px-shadow-toast);
    color: var(--px-ink-2);
    pointer-events: auto;
    animation: px-toast-in 0.2s ease;
}

.toast__title {
    color: var(--px-ink);
    font-weight: 700;
}

.toast__body {
    flex: 1;
    min-width: 0;
}

.toast .icon {
    color: var(--px-success);
}

.toast--error {
    border-color: #f3c4c4;
}

.toast--error .icon,
.toast--error .toast__title {
    color: var(--px-danger);
}

.toast--warning .icon {
    color: var(--px-warning);
}

@keyframes px-toast-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
}

/* ----- Empty state ----------------------------------------------------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 24px;
    text-align: center;
}

.empty__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 4px;
    border-radius: 14px;
    background: var(--px-accent-soft);
    color: var(--px-accent);
}

.empty__title {
    color: var(--px-ink);
    font-size: 17px;
    font-weight: 700;
}

.empty__text {
    max-width: 420px;
    color: var(--px-muted);
}

/* An address the app does not know (J4.16): app.js shows this, not the app. */
.unknown-host {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.unknown-host .card {
    width: 100%;
    max-width: 480px;
}

.unknown-host__langs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ----- Modal, drawer, bottom sheet ------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--px-overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: px-fade-in 0.15s ease;
}

.modal {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: calc(100vh - 48px);
    border: 1px solid var(--px-border);
    border-radius: var(--px-radius-modal);
    background: var(--px-surface);
    box-shadow: var(--px-shadow-modal);
}

.modal--wide {
    width: min(620px, 100%);
}

.modal__content {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 32px 0;
}

.modal__title {
    font-size: 24px;
}

.modal__subtitle {
    margin-top: 4px;
    color: var(--px-muted);
}

.modal__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 32px;
    overflow-y: auto;
}

.modal__foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 32px 24px;
    border-top: 1px solid var(--px-border);
}

.modal__foot-note {
    margin-right: auto;
    color: var(--px-muted);
    font-size: 13px;
}

.overlay--drawer {
    justify-content: flex-end;
    padding: 0;
}

.drawer {
    display: flex;
    flex-direction: column;
    width: min(520px, 100%);
    height: 100%;
    border-left: 1px solid var(--px-border);
    background: var(--px-surface);
    box-shadow: var(--px-shadow-modal);
    animation: px-drawer-in 0.2s ease;
}

.drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--px-border);
}

.drawer__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
    overflow-y: auto;
}

.drawer__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--px-border);
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border: 1px solid var(--px-border-input);
    border-radius: 12px;
    background: var(--px-surface);
    cursor: pointer;
}

.option input {
    /* Its 18 px, even next to a text of two lines (J5.31). */
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--px-accent-strong);
}

.option__title {
    color: var(--px-ink);
    font-size: 15px;
    font-weight: 700;
}

.option__text {
    color: var(--px-muted);
}

.option:has(input:checked) {
    border: 2px solid var(--px-accent);
    padding: 17px 19px;
    background: var(--px-accent-soft);
}

.option.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

@keyframes px-fade-in {
    from {
        opacity: 0;
    }
}

@keyframes px-drawer-in {
    from {
        transform: translateX(24px);
        opacity: 0;
    }
}

@keyframes px-sheet-in {
    from {
        transform: translateY(32px);
    }
}

@media (max-width: 899px) {
    body {
        font-size: 15px;
    }

    .input,
    .select,
    .textarea {
        min-height: 48px;
        font-size: 16px;
    }

    .btn {
        min-height: 44px;
    }

    .btn--lg {
        min-height: 52px;
    }

    .overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal,
    .modal--wide {
        width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        animation: px-sheet-in 0.2s ease;
    }

    .modal::before {
        content: "";
        align-self: center;
        width: 44px;
        height: 5px;
        margin-top: 10px;
        border-radius: var(--px-radius-pill);
        background: var(--px-track);
    }

    .modal__head {
        padding: 16px 20px 0;
    }

    .modal__title {
        font-size: 22px;
    }

    .modal__body {
        padding: 20px;
    }

    .modal__foot {
        flex-wrap: wrap;
        padding: 16px 20px 24px;
    }

    .modal__foot .btn {
        flex: 1;
    }

    .modal__foot-note {
        flex-basis: 100%;
    }

    .drawer {
        width: 100%;
        border-left: 0;
    }

    .toasts {
        right: 16px;
        bottom: calc(var(--px-bottom-bar) + 16px);
        left: 16px;
        align-items: stretch;
    }

    .toast {
        width: auto;
    }
}
