/*
 * SPDX-FileCopyrightText: 2026 University of Manchester
 *
 * SPDX-License-Identifier: apache-2.0
 */

/* --------------------------
 Global styles
--------------------------- */
body {
    font-family: "Open Sans", sans-serif;
    font-weight: 400;
    color: #333;
    font-size: clamp(32px, 3vw, 60px);
}

h1 {
    font-size: clamp(36px, 4vw, 74px);
    color: #6b2c91;
    line-height: 1.1;
    font-weight: 300;
    margin: 0;
}

h2 {
    font-size: clamp(32px, 3.5vw, 64px);
    color: #6b2c91;
    line-height: 1.1;
    font-weight: 300;
    margin: 0 0 0.5em;
}


/* --------------------------
 Page styles
--------------------------- */
.page-background {
    min-height: 100vh;
    width: 100%;
    background-image: url("/assets/solar-farm.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: clamp(10px, 3vw, 25px);
}

.page-background .dash-container {
    /* limit dash-container + page-background padding to 1920x1080 */
    max-width: 1870px;
    max-height: 1030px;
    padding: clamp(10px, 3vw, 25px);
    margin: auto;
    background-color: rgba(255, 255, 255, 0.97);
    border-radius: 2px;
}

/* --------------------------
 Header layout
--------------------------- */
.dashboard-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "uom heading enviromena";
    align-items: first-baseline;
    gap: clamp(15px, 3vw, 40px);
}

.dashboard-uom-logo {
    grid-area: uom;
    height: clamp(60px, 5vw, 90px);
    object-fit: contain;
}

.dashboard-enviromena-logo {
    grid-area: enviromena;
    height: clamp(24px, 2.5vw, 36px);
    object-fit: contain;
}

.dashboard-header .header-text {
    grid-area: heading;
    text-align: center;
    max-width: clamp(560px, 65vw, 1800px);
    margin: 0 auto;
}

.dashboard-uom-logo,
.dashboard-enviromena-logo {
    align-self: first-baseline;
    display: inline-block;
}

h2.dashboard-subtitle {
    color: #333;
    font-weight: 400;
}

@media (max-width: 1400px) {
    .dashboard-header {
        grid-template-columns: 1fr auto 1fr;
    }

    .page-background .dash-container {
        max-height: none;
    }
}

@media (max-width: 1100px) {
    /* Stack logos and heading vertically */
    .dashboard-header {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "uom enviromena"
            "heading heading";
        row-gap: 10px;
    }

    .dashboard-uom-logo {
        justify-self: start;
    }

    .dashboard-enviromena-logo {
        justify-self: end;
    }

    .dashboard-header .header-text {
        justify-self: centre;
        max-width: 90%;
        text-align: centre;
    }
}


/* --------------------------
 Panel layout
--------------------------- */
.dashboard-panels {
    width: 100%;
}

.dashboard-pair {
    display: grid;
    /* Fluid responsive column behaviour */
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(560px, 100%), 1fr)
    );
    /* Smooth vertical scaling */
    grid-auto-rows: minmax(clamp(360px, 30vw, 650px), auto);
    align-items: stretch;
}

/* Prevent overflow */
#bottom-panel-pair .grid-panel,
#top-panel-pair .grid-panel {
    min-width: 0;
}

.grid-panel {
    background: rgba(255, 255, 255, 0);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    container-type: inline-size;
    container-name: panel;
    text-align: center;
    padding: clamp(14px, 1vw, 18px);
}

.grid-panel h2 {
    text-align: center;
}

/* Make graph fill its panel */
.grid-panel .js-plotly-plot {
    width: 100% !important;
    height: 100% !important;
}

.solar-fact-wrapper {
    padding: 10px clamp(20px, 2vw, 40px);
}

/* --------------------------
 About panel
--------------------------- */
.dashboard-about-media {
    height: 100%;
    text-align: left;
}

.dashboard-about-photo {
    width: 100%;
    object-fit: cover;
    border-radius: 2px;
}

.dashboard-about-qr {
    width: clamp(200px, 20vw, 340px);
    object-fit: contain;
    flex-shrink: 0;
    margin: clamp(20px, 3vw, 40px);
}

@container panel (max-width: 560px) {
    .dashboard-about-media {
        grid-template-columns: 1fr;
        justify-items: start;
    }
}


/* --------------------------
 Plotly font size adjustments
--------------------------- */

/* Responsive font size for axis tick labels in all graphs */
.js-plotly-plot .plotly .xtick text,
.js-plotly-plot .plotly .ytick text {
    font-size: clamp(16px, 1.875vw, 38px) !important;
}

/* Responsive font size for text traces in the sun pie chart */
#last-generation-day-chart .js-plotly-plot .plotly .scatterlayer .textpoint text {
    font-size: clamp(16px, 2.083vw, 40px) !important;
}

/* --------------------------
 Maintain graph aspect ratio
--------------------------- */
.graph-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 500px;
    flex-shrink: 0;
}

.graph-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 fallback for older browsers */
}

.graph-wrapper > * {
    position: absolute;
    inset: 0;
}
