@font-face {
    font-family: "Space Grotesk";
    src: url("fonts/SpaceGrotesk-Variable.ttf") format("truetype");
    font-weight: 300 700;
    font-display: swap;
}

/* Colours and sizes used across the site, so they are changed in one place. */
:root {
    /* Earthy terracotta: plant-pot, sand and olive colours */
    --background: #fbf5ee;
    --surface: #ffffff;
    --field: #fffcf8;
    --panel-border: #eadbcb;
    --border: #d4bfa8;
    --forest: #3a2a20;          /* main text */
    --forest-hover: #2a1e17;
    --primary: #b5553a;         /* terracotta: buttons, links, chart lines */
    --primary-hover: #964530;
    --olive: #6b8e23;
    --muted: #7a6656;
    --focus: #6b8e23;
    --burgundy: #b5553a;        /* dry soil, too cold or hot */
    --burgundy-soft: #f6e3db;
    --teal-soft: #eef3e2;       /* olive tint: comfortable range */
    --blue: #2f6f8f;            /* wet soil */
    --light-on: #d64933;        /* the red LED */
    --radius-card: 1.5rem;
    --radius-input: 0.85rem;
}

body {
    font-family: "Space Grotesk", system-ui, sans-serif;
    margin: 0;
    color: var(--forest);
    background: var(--background);
    line-height: 1.5;
}

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.brand {
    font-size: 20px;
    font-weight: bold;
    color: var(--forest);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 20px;
}

nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

nav a[aria-current="page"] {
    color: var(--forest);
    font-weight: bold;
    text-decoration: none;
}

.sim-note {
    max-width: 900px;
    margin: 0 auto;
    padding: 8px 16px;
    color: var(--muted);
    font-size: 14px;
}

h1 {
    margin: 16px 0 4px;
    font-size: 28px;
}

h2 {
    font-size: 18px;
    margin-top: 32px;
}

.note {
    color: var(--muted);
    font-size: 14px;
}

.panel,
.current,
.form {
    padding: 24px;
    margin-top: 16px;
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-card);
}

.panel h2 {
    margin-top: 0;
}

.dashboard-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.label {
    margin: 0;
    color: var(--muted);
}

.value {
    font-size: 40px;
    margin: 4px 0;
}

.status {
    font-weight: bold;
    margin: 0;
}

.dry {
    color: var(--burgundy);
}

.normal {
    color: var(--focus);
}

.wet {
    color: var(--blue);
}

.ok {
    color: var(--olive);
}

.cold,
.hot {
    color: var(--burgundy);
}

.offline {
    color: var(--burgundy);
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.cards .current {
    margin-top: 0;
}

@media (max-width: 760px) {
    .cards {
        grid-template-columns: 1fr 1fr;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 6px 8px 6px 0;
    border-bottom: 1px solid var(--panel-border);
}

.message {
    min-height: 24px;
    margin: 8px 0;
}

.message.error {
    color: var(--burgundy);
}

.chart {
    position: relative;
}

.chart svg {
    display: block;
}

.band-dry {
    fill: var(--burgundy-soft);
}

.band-wet {
    fill: var(--teal-soft);
}

.band-ok {
    fill: var(--teal-soft);
}

.band-label {
    fill: var(--muted);
    font-size: 12px;
}

.grid {
    stroke: var(--panel-border);
}

.axis {
    fill: var(--muted);
    font-size: 12px;
}

.value-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.latest-point {
    fill: var(--primary);
    stroke: var(--surface);
    stroke-width: 2;
}

.latest-label {
    fill: var(--primary);
    font-size: 13px;
    font-weight: bold;
}

.crosshair {
    stroke: var(--border);
}

.tooltip {
    position: absolute;
    top: 0;
    padding: 4px 8px;
    background: var(--forest);
    color: var(--field);
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
}

input,
select {
    min-height: 44px;
    padding: 6px 12px;
    box-sizing: border-box;
    font: inherit;
    color: var(--forest);
    background: var(--field);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
}

button {
    min-height: 44px;
    padding: 8px 18px;
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius-input);
    cursor: pointer;
}

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

button:disabled {
    background: var(--muted);
    border-color: var(--muted);
    cursor: default;
}

.table-scroll {
    max-height: 420px;
    overflow: auto;
}

.table-scroll th {
    position: sticky;
    top: 0;
    background: var(--surface);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 12px 0;
}

.form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: 360px;
}

.form input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
}


@media (max-width: 700px) {
    main {
        padding-bottom: 104px;
    }

    .dashboard-top {
        grid-template-columns: 1fr;
    }

    .panel,
    .current,
    .form {
        padding: 16px;
    }

    /* The navigation becomes a bar along the bottom of the screen */
    nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        justify-content: space-around;
        gap: 0;
        padding: 8px 4px;
        background: var(--surface);
        border-top: 1px solid var(--panel-border);
        z-index: 10;
    }

    nav a {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        font-size: 12px;
        text-align: center;
    }

    .value {
        font-size: 32px;
    }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: -999px;
}

.skip-link:focus {
    left: 16px;
    top: 8px;
    background: var(--surface);
    padding: 4px 8px;
}

.light-state {
    display: flex;
    align-items: center;
    gap: 10px;
}

.light-dot {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--field);
}

.light-dot.on {
    border-color: var(--forest);
    background: var(--light-on);
}

/* Brand, links and the active page in terracotta */
.brand,
nav a[aria-current="page"],
main a {
    color: var(--primary);
}

/* Plant illustrations */
.plant-hero {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 20px;
    align-items: center;
    margin-top: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-card);
}

.plant-hero img {
    width: 140px;
    height: 140px;
}

.plant-hero h2 {
    margin: 0 0 4px;
}

.auth-illustration {
    display: block;
    width: 160px;
    height: 160px;
    margin: 8px auto 0;
}

@media (max-width: 560px) {
    .plant-hero {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .plant-hero img {
        margin: 0 auto;
    }
}
