/*
############################################################################
# Full d'estils de les gràfiques meteorològiques
############################################################################
*/

:root {
    --bg: #f3f5f8;
    --card: #ffffff;
    --text: #1f2a37;
    --muted: #64748b;
    --line: #dfe5ec;
    --grid: #e6ebf1;
    --head-bg: #e9eef4;
    --head-text: #2c3e50;
    --accent: #11557c;
    --accent-dark: #0b3a57;
    --accent-soft: #e4f0f7;
    --radius: 12px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--accent); }

.wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------- Capçalera i peu ---------- */

.site-header {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent) 60%, #1f7aa8);
    color: #fff;
    padding: 18px 0;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(11, 58, 87, .25);
}
.site-header .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 14px;
}
.site-header .brand { font-size: 1.35rem; font-weight: 700; letter-spacing: .01em; }
.site-header .brand-sub { font-size: .95rem; opacity: .8; }

body.embedded { padding-top: 16px; }

.site-footer {
    color: var(--muted);
    font-size: .78rem;
    text-align: right;
    padding: 20px 0 32px;
}
.site-footer a { color: inherit; }

/* ---------- Targeta ---------- */

#main-copy {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    padding: 24px;
}

#report h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-dark);
}

#report .report-head {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
}
#report .report-head p { margin: 0; }

#report .note {
    font-size: .8rem;
    color: var(--muted);
    text-align: center;
    margin: 14px 0 0;
}

#report .message {
    margin: 24px auto;
    max-width: 520px;
    text-align: center;
    background: #fdf1ef;
    border-left: 4px solid #c93d2f;
    border-radius: 6px;
    padding: 14px 18px;
}

/* ---------- Navegació ---------- */

.report-nav {
    margin: 16px 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.report-nav .view-switch {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--head-bg);
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
}
.report-nav .view-switch a,
.report-nav .view-switch span {
    padding: 6px 16px;
    border-radius: 999px;
    font-size: .9rem;
    text-decoration: none;
    color: var(--head-text);
}
.report-nav .view-switch a:hover { background: #d8e1ea; }
.report-nav .view-switch .active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(11, 58, 87, .3);
}

.report-nav .var-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}
.report-nav .var-buttons a,
.report-nav .var-buttons span {
    padding: 5px 12px;
    border: 1px solid #cdd7e1;
    border-radius: 999px;
    font-size: .82rem;
    text-decoration: none;
    color: var(--head-text);
    background: #fff;
}
.report-nav .var-buttons a:hover,
.report-nav .var-buttons .active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
}
.report-nav .var-buttons .active { font-weight: 600; }

/* ---------- Gràfica ---------- */

.wxchart {
    position: relative;
    margin: 8px 0 0;
}
.wxchart svg {
    display: block;
    width: 100%;
    height: auto;
    touch-action: pan-y;
    font-family: inherit;
}

.wxchart .grid line { stroke: var(--grid); stroke-width: 1; }
.wxchart .grid line.zero { stroke: #b8c4d1; }
.wxchart .grid .vgrid { stroke: var(--grid); stroke-dasharray: 2 3; }
.wxchart .ylabel { font-size: 12px; fill: var(--muted); text-anchor: end; }
.wxchart .xlabel { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.wxchart .axis-title { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.wxchart .vlabel {
    font-size: 10.5px;
    font-weight: 600;
    text-anchor: middle;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
    fill: var(--text);
}
.wxchart .series .vlabel { fill: currentColor; }
.wxchart .bars .vlabel { fill: var(--text); }
.wxchart .series { transition: opacity .2s; }
.wxchart .series.off { opacity: 0; pointer-events: none; }
.wxchart .guide { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }

.wxchart .chart-tip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .15);
    padding: 8px 10px;
    font-size: .8rem;
    white-space: nowrap;
}
.wxchart .chart-tip strong { display: block; margin-bottom: 4px; color: var(--accent-dark); }
.wxchart .chart-tip .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 6px;
}

.wxchart .legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    margin-top: 6px;
}
.wxchart .legend button {
    font: inherit;
    font-size: .82rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: none;
    color: var(--text);
    cursor: pointer;
}
.wxchart .legend button:hover { background: var(--head-bg); }
.wxchart .legend button[aria-pressed="false"] { opacity: .4; text-decoration: line-through; }
.wxchart .legend .swatch {
    display: inline-block;
    width: 18px;
    height: 4px;
    border-radius: 2px;
}
.wxchart .legend .swatch.bar { height: 12px; width: 12px; border-radius: 3px; }

/* ---------- Mòbil i impressió ---------- */

.wxchart .chart-scroll { overflow-x: auto; }

@media (max-width: 700px) {
    body { font-size: 14px; }
    .wxchart svg { min-width: 760px; }   /* manté els textos llegibles; es desplaça en horitzontal */
    #main-copy { padding: 14px; border-radius: 0; margin: 0 -16px; border-left: none; border-right: none; }
    #report h1 { font-size: 1.3rem; }
}

@media print {
    body { background: #fff; }
    .site-header, .report-nav, .chart-tip { display: none !important; }
    #main-copy { border: none; box-shadow: none; padding: 0; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
