/* ==========================================================================
   Package tracking demo — stylesheet
   Fresh & minimal: white page, one centered column, soft cards,
   dark-red primary. All colors live in the custom properties below.
   ========================================================================== */

:root {
    /* Color system */
    --color-primary: #A31621;        /* dark red — brand + progress + delivered */
    --color-primary-hover: #C22833;  /* lighter tint for hovers */
    --color-primary-soft: #FBF1F1;   /* very light red-tinted background */
    --color-text: #1C1C1C;           /* near-black body text */
    --color-text-secondary: #6B7280; /* gray-500 secondary text */
    --color-border: #E5E7EB;
    --color-surface: #FFFFFF;
    --color-warning: #B45309;        /* amber — reserved for exceptions */
    --color-warning-soft: #FEF3C7;

    /* Shape + shadow */
    --radius-card: 18px;
    --radius-pill: 999px;
    --shadow-card: 0 1px 2px rgba(28, 28, 28, 0.04), 0 8px 24px rgba(28, 28, 28, 0.06);
    --shadow-card-hover: 0 2px 4px rgba(28, 28, 28, 0.05), 0 12px 32px rgba(28, 28, 28, 0.09);

    /* Type */
    --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

/* --- Reset / base --------------------------------------------------------- */

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-surface);
    -webkit-font-smoothing: antialiased;
}

button {
    font: inherit;
}

/* Visible keyboard focus everywhere */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 6px;
}

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

/* --- Layout: one centered column ------------------------------------------ */

.site-header,
.page,
.site-footer {
    width: min(100% - 2.5rem, 720px);
    margin-inline: auto;
}

.site-header {
    padding-block: 1.75rem;
}

.page {
    padding-block: 1rem 4rem;
}

/* --- Header / logo --------------------------------------------------------- */

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.logo-icon {
    width: 30px;
    height: 30px;
    color: var(--color-primary);
    flex-shrink: 0;
}

/* --- Hero ------------------------------------------------------------------ */

.hero {
    text-align: center;
    padding-block: 2.5rem 1.5rem;
}

.hero-title {
    margin: 0 0 0.5rem;
    font-size: clamp(2rem, 6vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.hero-subline {
    margin: 0 auto 2rem;
    max-width: 40ch;
    color: var(--color-text-secondary);
}

/* --- Tracking input (the hero of the page) --------------------------------- */

.track-form {
    max-width: 560px;
    margin-inline: auto;
}

.track-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.4rem 0.4rem 1.4rem;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Subtle focus ring in the primary color */
.track-field:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(163, 22, 33, 0.12), var(--shadow-card);
}

.track-input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 1.05rem;
    color: var(--color-text);
    padding-block: 0.65rem;
}

.track-input::placeholder {
    color: #9CA3AF;
    text-transform: none;
}

.track-input:focus {
    outline: none; /* the ring is drawn on .track-field instead */
}

.track-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.6rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.track-button:hover {
    background: var(--color-primary-hover);
}

.track-button:active {
    transform: scale(0.98);
}

/* Loading state: hide the label, show the spinner */
.track-button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.track-button.is-loading {
    pointer-events: none;
}

.track-button.is-loading .track-button-label {
    display: none;
}

.track-button.is-loading .track-button-spinner {
    display: block;
}

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

/* Inline validation error under the input */
.input-error {
    margin: 0.6rem 1.4rem 0;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* --- Results area ----------------------------------------------------------- */

.results {
    padding-top: 1.5rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: clamp(1.25rem, 4vw, 2rem);
}

/* Entrance: fade + slide up */
.card-enter {
    animation: card-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* "Not found" card */
.card-empty {
    text-align: center;
    color: var(--color-text-secondary);
}

.card-empty .card-empty-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 0.75rem;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-radius: 50%;
    padding: 10px;
}

.card-empty h2 {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
    color: var(--color-text);
}

.card-empty p {
    margin: 0;
}

/* --- Result card: header row ------------------------------------------------ */

.result-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.9rem;
    margin-bottom: 0.4rem;
}

.result-number {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.8rem;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.status-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Delivered: filled dark-red pill with a check (success uses red, not green) */
.status-badge--delivered {
    background: var(--color-primary);
    color: #fff;
}

/* Exception: the one amber tone in the UI */
.status-badge--exception {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.result-route {
    margin: 0 0 0.2rem;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.result-route .route-arrow {
    color: var(--color-primary);
    padding-inline: 0.25rem;
}

.result-service {
    margin: 0;
    font-size: 0.88rem;
    color: var(--color-text-secondary);
}

/* --- Progress bar + milestones ----------------------------------------------- */

.progress-section {
    margin-block: 1.75rem 2rem;
}

.progress-track {
    height: 10px;
    background: var(--color-primary-soft);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0; /* animated to the real % by JS after render */
    background: var(--color-primary);
    border-radius: var(--radius-pill);
    transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.milestones {
    display: flex;
    justify-content: space-between;
    margin: 0.6rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.milestones li {
    flex: 1;
    text-align: center;
}

.milestones li:first-child { text-align: left; }
.milestones li:last-child  { text-align: right; }

.milestones li.is-reached {
    color: var(--color-primary);
}

/* --- Vertical timeline --------------------------------------------------------- */

.timeline-heading {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline-item {
    position: relative;
    padding-left: 2rem;
    padding-bottom: 1.5rem;
}

/* Connecting vertical line between dots */
.timeline-item::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 20px;
    bottom: -2px;
    width: 2px;
    background: var(--color-primary-soft);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item:last-child::before {
    display: none;
}

/* Dots: past events solid dark red, current event pulses */
.timeline-dot {
    position: absolute;
    left: 0;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
}

.timeline-item.is-current .timeline-dot {
    animation: pulse 1.8s ease-out infinite;
}

.timeline-item.is-exception .timeline-dot {
    background: var(--color-warning);
}

.timeline-item.is-exception.is-current .timeline-dot {
    animation-name: pulse-warning;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(163, 22, 33, 0.35); }
    70%  { box-shadow: 0 0 0 10px rgba(163, 22, 33, 0); }
    100% { box-shadow: 0 0 0 0 rgba(163, 22, 33, 0); }
}

@keyframes pulse-warning {
    0%   { box-shadow: 0 0 0 0 rgba(180, 83, 9, 0.35); }
    70%  { box-shadow: 0 0 0 10px rgba(180, 83, 9, 0); }
    100% { box-shadow: 0 0 0 0 rgba(180, 83, 9, 0); }
}

.timeline-status {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.timeline-item.is-exception .timeline-status {
    color: var(--color-warning);
}

.timeline-description {
    margin: 0.15rem 0 0.3rem;
    color: var(--color-text-secondary);
    font-size: 0.92rem;
}

.timeline-meta {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.timeline-meta .meta-sep {
    padding-inline: 0.4rem;
    color: var(--color-border);
}

/* --- Footer ---------------------------------------------------------------------- */

.site-footer {
    padding-block: 2rem 3rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.88rem;
}

.footer-note {
    margin: 0;
}

/* --- Mobile: stack the Track button below the input -------------------------------- */

@media (max-width: 480px) {
    .track-field {
        flex-direction: column;
        align-items: stretch;
        border-radius: 24px;
        padding: 0.5rem 0.5rem 0.5rem;
    }

    .track-input {
        padding: 0.65rem 0.9rem;
        text-align: center;
    }

    .track-button {
        width: 100%;
        padding-block: 0.85rem;
    }

    .input-error {
        text-align: center;
        margin-inline: 0.5rem;
    }

    .milestones {
        font-size: 0.62rem;
    }
}

/* --- Reduced motion: disable all animation --------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .card-enter {
        animation: none;
    }

    .progress-fill {
        transition: none;
    }

    .timeline-item.is-current .timeline-dot {
        animation: none;
    }

    .track-button-spinner {
        animation-duration: 1.5s; /* keep a slow spinner so loading is still visible */
    }
}
