/* prices.eu.org: main stylesheet
 *
 * Light, clean design system built on CSS custom properties.
 * Layout: responsive grid of cards; data shown in tables.
 * Keep this file framework-free; it is the base later agents extend.
 */

:root {
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-border: #e3e6ea;
    --color-text: #1a1f24;
    --color-muted: #5c6670;
    --color-accent: #0b57d0;
    --color-accent-hover: #0948ad;
    --color-accent-soft: #e8effc;
    --color-up: #1a7f37;   /* price went up */
    --color-down: #b42318; /* price went down */
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 32, 0.08);
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --max-width: 1080px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ---------- layout ---------- */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1rem;
}

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.site-header .container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}
.brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-text);
    text-decoration: none;
}
.site-nav a {
    color: var(--color-muted);
    text-decoration: none;
    margin-right: 1rem;
}
.site-nav a:hover,
.site-nav a:focus,
.site-nav a[aria-current="page"] { color: var(--color-accent); }

main { padding: 1.5rem 0 3rem; }

.site-footer {
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
    font-size: 0.875rem;
    padding: 1.25rem 0;
    background: var(--color-surface);
}

/* ---------- grid and cards ---------- */

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
}
.card h2, .card h3 { margin-top: 0.25rem; }
.card .meta { color: var(--color-muted); font-size: 0.85rem; }

/* ---------- typography ---------- */

h1, h2, h3 { line-height: 1.25; }
a { color: var(--color-accent); }
a:hover, a:focus { color: var(--color-accent-hover); }
.muted { color: var(--color-muted); }

/* ---------- tables ---------- */

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

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
table.data th, table.data td {
    text-align: left;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
table.data th {
    background: var(--color-accent-soft);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--color-up); }
.down { color: var(--color-down); }

/* ---------- misc ---------- */

.badge {
    display: inline-block;
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: 0.75rem;
    padding: 0.1rem 0.6rem;
}
.badge.fresh-today { background: #dcfce7; color: #166534; }
.badge.fresh-yesterday { background: #fef9c3; color: #854d0e; }
.badge.fresh-date { background: var(--color-border); color: var(--color-muted); }
.updated { color: var(--color-muted); font-size: 0.85rem; }

/* ---------- header / nav ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand span { color: var(--color-accent); }
.site-nav a[aria-current="page"] { font-weight: 600; }
.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--color-surface);
    color: var(--color-accent);
    padding: 0.5rem 1rem;
    z-index: 50;
}
.skip-link:focus { left: 0; }

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- page furniture ---------- */

.hero h1 { font-size: 1.9rem; margin-bottom: 0.25rem; }
.lede { max-width: 46rem; color: var(--color-muted); font-size: 1.05rem; }
.crumbs { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 0.75rem; }
.crumbs a { text-decoration: none; }
.page-head { margin-bottom: 1.25rem; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.5rem 0 0.75rem;
}
.two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.link-card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s ease, transform .15s ease; }
.link-card:hover, .link-card:focus-visible { box-shadow: 0 4px 14px rgba(16,24,32,.12); transform: translateY(-2px); }
.link-card .more { display: block; margin-top: 0.5rem; color: var(--color-accent); font-weight: 600; }
.stat { font-size: 2rem; font-weight: 700; margin: 0.25rem 0; font-variant-numeric: tabular-nums; }
.stat small { font-size: 1rem; font-weight: 400; color: var(--color-muted); }
.stat-card .stat { line-height: 1.2; }
.stats-grid { margin-top: 1rem; }

/* ---------- segmented toggle (JS only) ---------- */

.segmented { display: none; gap: 0; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; background: var(--color-surface); }
.js-enabled .segmented { display: inline-flex; }
.segmented button {
    border: none;
    background: transparent;
    padding: 0.4rem 1rem;
    font: inherit;
    cursor: pointer;
    color: var(--color-muted);
}
.segmented button + button { border-left: 1px solid var(--color-border); }
.segmented button[aria-pressed="true"] { background: var(--color-accent); color: #fff; }

/* ---------- tables ---------- */

table.data tbody tr:nth-child(even) td { background: #fbfcfe; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover { color: var(--color-accent); }
table.data th[aria-sort="ascending"]::after { content: " ▲"; }
table.data th[aria-sort="descending"]::after { content: " ▼"; }

/* ---------- EU choropleth ---------- */

.map-wrap { margin: 0.5rem 0 1rem; }
.eu-map { width: 100%; height: auto; max-height: 78vh; display: block; }
.map-context path { fill: #e6eaf0; stroke: #ffffff; stroke-width: 0.8; }
.map-countries path { stroke: #ffffff; stroke-width: 0.8; transition: filter .12s ease; cursor: pointer; }
.map-countries a:hover path, .map-countries a:focus-visible path { filter: brightness(0.82); stroke: #334155; stroke-width: 1.4; }
.map-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-muted);
    max-width: 420px;
}
.map-legend svg { flex: 1; height: 10px; }
.note-box {
    border-left: 4px solid var(--color-accent);
    background: var(--color-accent-soft);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    font-size: 0.92rem;
}

/* ---------- charts ---------- */

.chart-card svg.sparkline { width: 100%; height: auto; }
svg.spark-inline { width: 110px; height: 26px; display: block; }
.spark-line { stroke: var(--color-accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--color-accent-soft); }
.spark-dot { fill: var(--color-accent); }
.chart-scale { display: flex; justify-content: space-between; margin: 0.25rem 0 0; }

/* ---------- sources / status ---------- */

.status { display: inline-block; padding: 0 0.55rem; border-radius: 999px; font-size: 0.75rem; }
.status-ok { background: #dcfce7; color: #166534; }
.status-error { background: #fee2e2; color: #991b1b; }
.status::before { content: "● "; }
.sources-table td { white-space: normal; }
.intro { margin-bottom: 1.5rem; }
.source-group { margin-bottom: 1.75rem; }

/* ---------- calculator ---------- */

#calc { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
#calc label { font-size: 0.85rem; color: var(--color-muted); }
#calc input, #calc select {
    font: inherit;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: inherit;
}
#calc input { width: 9rem; }
#calc output { font-size: 1.2rem; font-weight: 600; margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- dark mode ---------- */

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #12161a;
        --color-surface: #1b2129;
        --color-border: #2c3540;
        --color-text: #e7ecf1;
        --color-muted: #97a3ae;
        --color-accent: #7cabf4;
        --color-accent-hover: #a3c4fa;
        --color-accent-soft: #223047;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    }
    table.data tbody tr:nth-child(even) td { background: #1e252d; }
    table.data tbody tr:hover { background: #232c36; }
    .map-context path { fill: #262f39; stroke: #12161a; }
    .badge.fresh-date { background: var(--color-border); }
}

@media print {
    .site-header, .site-footer, .segmented, .skip-link, .crumbs { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; break-inside: avoid; }
}

@media (max-width: 640px) {
    html { font-size: 15px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    #calc output { margin-left: 0; width: 100%; }
}
