/*
 * Stage 5 stylesheet for the Barbados Fuel Price website.
 * It preserves the Stage 2.5 current-price cards and adds responsive history.
 */

/* Use border-box sizing so padding does not unexpectedly increase widths. */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Basic page typography and neutral background. */
body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #17212b;
}

/* Constrain the content while retaining comfortable mobile padding. */
.site-shell {
    width: min(100% - 2rem, 1100px);
    margin: 0 auto;
    padding: 3rem 0;
}

.page-header {
    margin-bottom: 1.75rem;
}

.eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 3rem);
    line-height: 1.05;
}

.intro {
    margin: 0.75rem 0 0;
    color: #5b6670;
}

/* One column by default keeps the current-price cards readable on phones. */
.price-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.price-card {
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #dfe4e8;
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.06);
}

.price-card h2 {
    margin: 0;
    font-size: 1.15rem;
}

.price {
    margin: 0.75rem 0;
    font-size: clamp(2.25rem, 12vw, 3.5rem);
    font-weight: 700;
    line-height: 1;
}

/* Price-change details are grouped together beneath the current price. */
.price-change {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.65rem;
    margin: 0 0 0.9rem;
    font-weight: 700;
}

.change-direction {
    font-size: 0.95rem;
}

.change-values {
    font-size: 1rem;
}

/* Requirement: increases are red and decreases are green. */
.price-change.increase,
.change-increase,
.history-increase {
    color: #c62828 !important;
}

.price-change.decrease,
.change-decrease,
.history-decrease {
    color: #218739 !important;
}

/* A price that has not changed uses a neutral colour. */
.price-change.no-change,
.change-neutral,
.history-no-change {
    color: #68737d !important;
}

.effective-date {
    margin: 0;
    color: #68737d;
    font-size: 0.95rem;
}

.empty-state {
    padding: 1.25rem;
    background: #ffffff;
    border-radius: 12px;
}

/* Stage 3 history begins below the current-price cards. */
.history-section {
    margin-top: 3rem;
}

.history-heading {
    margin-bottom: 1rem;
}

.history-heading h2 {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 2rem);
}

.history-heading p {
    margin: 0.5rem 0 0;
    color: #5b6670;
}

/* Keep all seven history columns available and allow mobile horizontal scroll. */
.history-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    border: 1px solid #dfe4e8;
    border-radius: 14px;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.05);
}

.history-table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e7ebee;
    text-align: left;
    white-space: nowrap;
}

.history-table th {
    background: #f8fafb;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

/* Numeric columns align right so prices and changes are easy to compare. */
.history-table .numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Historical increase/decrease figures are visually emphasized. */
.history-increase,
.history-decrease,
.history-no-change {
    font-weight: 700;
}

/* Source links point to the original announcement stored in source_url. */
.source-link {
    font-weight: 700;
    color: #245a8d;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.source-link:hover,
.source-link:focus-visible {
    text-decoration-thickness: 2px;
}

.source-unavailable {
    color: #7a858f;
}

/* On wider screens, display the current fuel cards side by side. */
@media (min-width: 600px) {
    .price-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/*
 * Stage 3.5: "About this data" notice.
 * This section is intentionally understated so it remains readable without
 * competing visually with the current-price cards and historical price table.
 */
.data-notice {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    background: #ffffff;
    border: 1px solid #dfe4e8;
    border-radius: 14px;
}

.data-notice h2 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
}

.data-notice p {
    margin: 0 0 0.75rem;
    color: #5b6670;
    font-size: 0.9rem;
    line-height: 1.55;
}

.data-notice p:last-child {
    margin-bottom: 0;
}


/*
 * Stage 4: Historical fuel-type filter.
 * The selector remains comfortable to use on phones and wider screens.
 */
.history-filter {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0 0 1rem;
}

.history-filter label {
    font-size: 0.9rem;
    font-weight: 700;
}

.history-filter select {
    width: 100%;
    max-width: 320px;
    padding: 0.7rem 0.8rem;
    border: 1px solid #cfd6dc;
    border-radius: 8px;
    background: #ffffff;
    color: #17212b;
    font: inherit;
}

.history-filter select:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* The hidden attribute must win over the table's normal row display rules. */
.history-table tr[hidden] {
    display: none !important;
}


/*
 * Stage 4.5: Previous price shown on each current-price card.
 * It is visually secondary to the current price but remains easy to scan.
 */
.previous-price {
    margin: -0.15rem 0 0.75rem;
    color: #5b6670;
    font-size: 0.95rem;
}

.previous-price strong {
    color: #17212b;
    font-variant-numeric: tabular-nums;
}


/*
 * Stage 5: Recorded high and low on each current-price card.
 * "Recorded" is intentional because historical data is still being backfilled.
 */
.recorded-range {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e7ebee;
}

.recorded-range p {
    margin: 0;
}

.recorded-range span,
.recorded-range small {
    display: block;
    color: #68737d;
}

.recorded-range span {
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.recorded-range strong {
    display: block;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.recorded-range small {
    margin-top: 0.15rem;
    font-size: 0.78rem;
}
