﻿:root {
    --page-background: #edf1f4;
    --card-background: #ffffff;
    --header-background: #18222c;
    --header-text: #ffffff;
    --accent: #2b7a78;
    --text: #1f2933;
    --muted: #6b7782;
    --border: #d6dde2;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--page-background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

/* Header and navigation */

.site-header {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 76px;
    padding: 8px 24px;
    background: var(--header-background);
    color: var(--header-text);
}

.site-title {
    flex: 0 0 auto;
    color: var(--header-text);
    font-size: 1.75rem;
    font-weight: bold;
    text-decoration: none;
}

    .site-title:hover {
        text-decoration: underline;
    }

.main-navigation {
    flex: 1 1 auto;
    min-width: 0;
}

#nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

    #nav li {
        margin: 0;
        padding: 0;
    }

    #nav a {
        display: flex;
        align-items: center;
        min-height: 58px;
        padding: 8px 12px;
        color: #ffffff;
        text-decoration: none;
        border-radius: 6px;
    }

        #nav a:hover,
        #nav a:focus-visible {
            background: rgba(255, 255, 255, 0.12);
        }

    #nav img {
        width: 32px;
        height: 32px;
    }

.menu-button {
    display: none;
    width: 44px;
    height: 40px;
    padding: 9px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    cursor: pointer;
}

.menu-button-line {
    display: block;
    height: 2px;
    margin: 4px 0;
    background: #ffffff;
}

/* Wallboard switch */

.wallboard-control {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    margin-left: auto;
    white-space: nowrap;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

    .switch input {
        width: 0;
        height: 0;
        opacity: 0;
    }

.switch-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: #71808e;
    border-radius: 28px;
    transition: background 0.2s;
}

    .switch-slider::before {
        position: absolute;
        bottom: 4px;
        left: 4px;
        width: 20px;
        height: 20px;
        content: "";
        background: #ffffff;
        border-radius: 50%;
        transition: transform 0.2s;
    }

.switch input:checked + .switch-slider {
    background: var(--accent);
}

    .switch input:checked + .switch-slider::before {
        transform: translateX(22px);
    }

/* Dashboard */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 28px;
}

.dashboard-module {
    grid-column: span 4;
    min-width: 0;
    overflow: hidden;
    background: var(--card-background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

    .dashboard-module.module-wide {
        grid-column: span 8;
    }

.module-header {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 10px 16px;
    background: #f6f8f9;
    border-bottom: 1px solid var(--border);
}

    .module-header h2 {
        margin: 0;
        font-size: 1.15rem;
    }

.module-content {
    min-height: 180px;
    padding: 16px;
    color: var(--muted);
}

.module-content-large {
    min-height: 420px;
}

.module-error {
    margin-top: 12px;
    color: #a40000;
}

/* Weather periods */

.weather-periods {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.weather-period {
    min-width: 0;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

    .weather-period:last-child {
        padding-right: 0;
        border-right: 0;
    }

.weather-period-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}

.weather-period-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text);
}

.weather-period-time {
    font-size: 0.9rem;
    color: #c62828;
}

.weather-period-top {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 12px;
}

.weather-period-icon {
    flex: 0 0 auto;
    width: 74px;
    height: 74px;
    object-fit: contain;
}

.weather-period-value-block {
    min-width: 0;
}

.weather-period-value-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.weather-period-value {
    font-size: 1.05rem;
    font-weight: bold;
    color: var(--text);
}

.weather-period-summary {
    margin-bottom: 8px;
    font-size: 1rem;
    color: var(--text);
    overflow-wrap: anywhere;
}

.weather-period-wind {
    color: var(--text);
    overflow-wrap: anywhere;
}

/* Weather forecast */

.weather-forecast {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.weather-forecast-day {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 220px;
    padding: 10px 8px;
    text-align: center;
    background: #f6f8f9;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.weather-forecast-icon {
    width: 64px;
    height: 64px;
    margin: 8px auto 4px;
    object-fit: contain;
}

.weather-forecast-name {
    min-height: 42px;
    font-weight: bold;
    color: var(--text);
}

.weather-forecast-summary {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.weather-forecast-temperatures {
    margin-top: auto;
    padding-top: 10px;
    font-weight: bold;
    color: var(--text);
}

    .weather-forecast-temperatures span {
        color: var(--muted);
    }

.weather-forecast-rain {
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--muted);
}

.weather-issued {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--muted);
}


/* Tides module */

.tides-next {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px 16px;
    padding-bottom: 10px;
}

.tides-next-label {
    width: 100%;
    font-size: 0.9rem;
    color: var(--muted);
}

.tides-next-main {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text);
}

.tides-next-height {
    font-size: 1rem;
    color: var(--muted);
}

.tides-state {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text);
}

.tides-state-separator {
    color: var(--muted);
}

.tides-cycle {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tides-cycle-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.tides-cycle-chart {
    width: 100%;
}

.tides-cycle-svg {
    display: block;
    width: 100%;
    height: 120px;
    overflow: visible;
}

.tides-cycle-curve {
    fill: none;
    stroke: #4aa3df;
    stroke-width: 12;
    stroke-linecap: round;
}

.tides-cycle-endpoint,
.tides-cycle-highpoint {
    fill: #1b4f72;
}

.tides-cycle-position {
    fill: #1b4f72;
    stroke: #ffffff;
    stroke-width: 5;
    transform: translate( calc(var(--tide-marker-x) * 1px), calc(var(--tide-marker-y) * 1px) );
}

.tides-today-heading {
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--text);
}

.tides-today {
    display: grid;
    gap: 8px;
}

.tides-time {
    display: grid;
    grid-template-columns: 34px 58px 70px 1fr;
    gap: 8px;
    align-items: baseline;
    padding: 10px 12px;
    background: #f6f8f9;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.tides-time-type {
    font-weight: bold;
    color: var(--text);
}

.tides-time-clock {
    font-weight: bold;
    color: var(--text);
}

.tides-time-height {
    color: var(--text);
}

.tides-time-long {
    color: var(--muted);
}

body.wallboard-mode .tides-next-main {
    font-size: 1.7rem;
}


/* Sunrise and sunset module */

.daylight-times {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.daylight-time {
    padding: 18px 14px;
    text-align: center;
    background: #f6f8f9;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.daylight-time-label {
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--muted);
}

.daylight-time-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text);
}

.daylight-summary {
    margin-top: 16px;
    padding-top: 16px;
    text-align: center;
    font-size: 1.05rem;
    color: var(--text);
    border-top: 1px solid var(--border);
}

body.wallboard-mode .daylight-time-value {
    font-size: 2.4rem;
}


/* Daylight progress */

.daylight-progress {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.daylight-progress-status {
    margin-bottom: 8px;
    text-align: center;
    font-weight: bold;
    color: var(--text);
}

.daylight-progress-chart {
    width: 100%;
}

.daylight-progress-svg {
    display: block;
    width: 100%;
    height: 150px;
    overflow: visible;
}

.daylight-progress-horizon {
    fill: none;
    stroke: var(--border);
    stroke-width: 3;
}

.daylight-progress-path {
    fill: none;
    stroke: #f4b400;
    stroke-width: 11;
    stroke-linecap: round;
}

.daylight-progress-point,
.daylight-progress-noon {
    fill: #d99500;
}

.daylight-progress-sun {
    transform: translate( calc(var(--sun-marker-x) * 1px), calc(var(--sun-marker-y) * 1px) );
}

    .daylight-progress-sun circle {
        fill: #ffd54f;
        stroke: #f4a900;
        stroke-width: 5;
    }

    .daylight-progress-sun line {
        stroke: #f4a900;
        stroke-width: 5;
        stroke-linecap: round;
    }

.daylight-progress-labels {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 2px;
    font-size: 0.85rem;
    color: var(--muted);
}

body.wallboard-mode .daylight-progress-status {
    font-size: 1.15rem;
}





/* Moon phase module */

.moon-phase-layout {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 24px;
    align-items: center;
}

.moon-visual {
    display: flex;
    align-items: center;
    justify-content: center;
}

.moon-disc {
    position: relative;
    width: 130px;
    height: 130px;
    overflow: hidden;
    background: #f5f1d0;
    border: 2px solid #c8c4aa;
    border-radius: 50%;
    box-shadow: inset -8px -8px 18px rgba(0, 0, 0, 0.14), 0 3px 10px rgba(0, 0, 0, 0.14);
}

.moon-shadow {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: #29333d;
}

/* Major phases */

.moon-new .moon-shadow {
    inset: -2px;
}

.moon-full .moon-shadow {
    display: none;
}

.moon-first-quarter .moon-shadow {
    left: -2px;
    right: 50%;
    border-radius: 65px 0 0 65px;
}

.moon-last-quarter .moon-shadow {
    left: 50%;
    right: -2px;
    border-radius: 0 65px 65px 0;
}

/* Waxing phases: illuminated on the right */

.moon-waxing-crescent .moon-shadow {
    left: -15%;
    right: 28%;
    border-radius: 50%;
}

.moon-waxing-gibbous .moon-shadow {
    left: -48%;
    right: 68%;
    border-radius: 50%;
}

/* Waning phases: illuminated on the left */

.moon-waning-gibbous .moon-shadow {
    left: 68%;
    right: -48%;
    border-radius: 50%;
}

.moon-waning-crescent .moon-shadow {
    left: 28%;
    right: -15%;
    border-radius: 50%;
}

.moon-details {
    min-width: 0;
}

.moon-phase-name {
    margin-bottom: 18px;
    font-size: 1.45rem;
    font-weight: bold;
    color: var(--text);
}

.moon-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

    .moon-detail-row strong {
        color: var(--text);
    }

.moon-next-phase {
    margin-top: 16px;
    line-height: 1.4;
    color: var(--text);
}

body.wallboard-mode .moon-disc {
    width: 155px;
    height: 155px;
}

body.wallboard-mode .moon-phase-name {
    font-size: 1.7rem;
}

@media (max-width: 600px) {
    .moon-phase-layout {
        grid-template-columns: 1fr;
    }

    .moon-details {
        width: 100%;
    }

    .moon-phase-name {
        text-align: center;
    }
}

.moon-disc {
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
}

body.wallboard-mode .module-moon .moon-phase-layout {
    grid-template-columns: 170px 1fr;
}

body.wallboard-mode .module-moon .moon-disc {
    width: 155px;
    height: 155px;
    min-width: 155px;
    min-height: 155px;
}




/* Bus on the left; daylight and Moon stacked on the right */

.module-buses {
    grid-column: 1 / span 8;
    grid-row: 2 / span 2;
}

.module-daylight {
    grid-column: 9 / span 4;
    grid-row: 2;
    align-self: start;
}

.module-moon {
    grid-column: 9 / span 4;
    grid-row: 3;
    align-self: stretch;
    margin-top: -20px;
}

    .module-daylight .module-content,
    .module-moon .module-content {
        min-height: 0;
    }

.module-daylight .daylight-time {
    padding: 12px 10px;
}

.module-daylight .daylight-time-value {
    font-size: 1.7rem;
}

.module-daylight .daylight-summary {
    margin-top: 10px;
    padding-top: 10px;
}

.module-daylight .daylight-progress {
    margin-top: 10px;
    padding-top: 10px;
}

.module-daylight .daylight-progress-status {
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.module-daylight .daylight-progress-svg {
    width: 100%;
    height: auto;
    aspect-ratio: 1000 / 225;
}

.module-daylight .daylight-progress-labels {
    margin-top: 0;
    font-size: 0.75rem;
}

.module-moon .moon-phase-layout {
    grid-template-columns: 105px 1fr;
    gap: 14px;
}

.module-moon .moon-disc {
    width: 92px;
    height: 92px;
}

.module-moon .moon-phase-name {
    margin-bottom: 8px;
    font-size: 1.15rem;
}

.module-moon .moon-detail-row {
    padding: 5px 0;
    font-size: 0.85rem;
}

.module-moon .moon-next-phase {
    margin-top: 8px;
    font-size: 0.82rem;
}



/* Live Jersey buses module */

.dashboard-bus-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 10px;
}

    .dashboard-bus-controls label {
        font-weight: bold;
        color: var(--text);
    }

    .dashboard-bus-controls select,
    .dashboard-bus-controls button {
        min-height: 38px;
        padding: 7px 10px;
        font: inherit;
        background: #ffffff;
        border: 1px solid #aeb7c0;
        border-radius: 5px;
    }

    .dashboard-bus-controls select {
        min-width: 170px;
    }

    .dashboard-bus-controls button {
        margin-left: auto;
        cursor: pointer;
    }

        .dashboard-bus-controls button:hover {
            background: #eef2f5;
        }

        .dashboard-bus-controls button:disabled {
            cursor: wait;
            opacity: 0.65;
        }

.dashboard-bus-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: normal !important;
}

    .dashboard-bus-checkbox input {
        width: 18px;
        height: 18px;
        margin: 0;
    }

.dashboard-bus-status {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--muted);
}

.dashboard-bus-map {
    width: 100%;
    height: 480px;
    min-height: 420px;
    background: #dce6eb;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.dashboard-bus-marker-wrapper {
    background: transparent;
    border: 0;
}

.dashboard-bus-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: 3px solid #1f6f8b;
    border-radius: 50%;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.32);
}

.dashboard-bus-marker--outbound {
    border-color: #a94f2c;
}

.dashboard-bus-marker--school {
    border-style: dashed;
}

.dashboard-bus-marker-route {
    font-size: 0.85rem;
    font-weight: bold;
    line-height: 1;
    color: var(--text);
}

.dashboard-bus-marker-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 0.65rem;
    line-height: 1;
    color: var(--text);
    transform: translate(-50%, -50%) rotate(var(--bus-bearing)) translateY(-23px);
    transform-origin: center;
}

.dashboard-bus-popup {
    min-width: 210px;
}

.dashboard-bus-popup-heading {
    display: block;
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.dashboard-bus-popup-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 8px;
    line-height: 1.4;
}

.dashboard-bus-popup-label {
    font-weight: bold;
}

body.wallboard-mode .dashboard-bus-map {
    height: 560px;
}

@media (max-width: 700px) {
    .dashboard-bus-controls {
        align-items: stretch;
    }

        .dashboard-bus-controls select {
            flex: 1 1 100%;
            width: 100%;
        }

        .dashboard-bus-controls button {
            width: 100%;
            margin-left: 0;
        }

    .dashboard-bus-status {
        flex-direction: column;
        gap: 3px;
    }

    .dashboard-bus-map {
        height: 65vh;
        min-height: 400px;
    }
}




/* Asynchronously loaded dashboard modules */

.dashboard-async-module {
    position: relative;
}

.dashboard-module-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 150px;
    color: var(--muted);
}

    .dashboard-module-loading::before {
        width: 22px;
        height: 22px;
        content: "";
        border: 3px solid var(--border);
        border-top-color: var(--accent);
        border-radius: 50%;
        animation: dashboard-loading-spin 0.8s linear infinite;
    }

@keyframes dashboard-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.dashboard-async-module-loaded {
    animation: dashboard-module-appear 0.2s ease-out;
}

@keyframes dashboard-module-appear {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}




 /** Media **/
@media (max-width: 600px) {
    .daylight-times {
        grid-template-columns: 1fr;
    }
}




@media (max-width: 600px) {
    .tides-time {
        grid-template-columns: 34px 58px 1fr;
    }

    .tides-time-long {
        grid-column: 1 / -1;
    }
}


/* Wallboard mode */

body.wallboard-mode {
    background: #0e151c;
}

    body.wallboard-mode .site-header {
        min-height: 50px;
        padding: 7px 14px;
    }

    body.wallboard-mode .site-title,
    body.wallboard-mode .main-navigation {
        display: none;
    }

    body.wallboard-mode .wallboard-control {
        margin-left: auto;
        opacity: 0.35;
    }

        body.wallboard-mode .wallboard-control:hover,
        body.wallboard-mode .wallboard-control:focus-within {
            opacity: 1;
        }

    body.wallboard-mode .dashboard-grid {
        max-width: none;
        gap: 14px;
        padding: 10px 14px 14px;
    }

    body.wallboard-mode .dashboard-module {
        font-size: 1.15rem;
    }

    body.wallboard-mode .module-header h2 {
        font-size: 1.4rem;
    }

    body.wallboard-mode .weather-period-title {
        font-size: 1.3rem;
    }

    body.wallboard-mode .weather-period-value {
        font-size: 1.25rem;
    }

    body.wallboard-mode .weather-forecast-name {
        font-size: 1.1rem;
    }

/* Tablet and smaller desktop */

@media (max-width: 1400px) {
    .module-buses,
    .module-daylight,
    .module-moon {
        grid-row: auto;
    }

    .module-moon {
        margin-top: 0;
    }

    .module-buses {
        grid-column: span 12;
    }

    .module-daylight,
    .module-moon {
        grid-column: span 6;
    }

    .site-header {
        position: relative;
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .menu-button {
        display: block;
        margin-left: auto;
    }

    .wallboard-control {
        margin-left: 0;
    }

    .main-navigation {
        display: none;
        flex: 0 0 100%;
        order: 4;
    }

        .main-navigation.menu-open {
            display: block;
        }

    #nav {
        align-items: stretch;
        flex-direction: column;
        padding: 8px 0;
    }

        #nav a {
            min-height: 48px;
            padding: 8px;
        }

    .dashboard-module.module-wide {
        grid-column: span 12;
    }

    .dashboard-module:not(.module-wide) {
        grid-column: span 6;
    }

    .weather-forecast {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 850px) {
    .dashboard-module,
    .dashboard-module.module-wide {
        grid-column: span 12;
    }

    .weather-periods {
        grid-template-columns: 1fr;
    }

    .weather-period {
        padding-right: 0;
        padding-bottom: 14px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

        .weather-period:last-child {
            padding-bottom: 0;
            border-bottom: 0;
        }

    .weather-forecast {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phone */

@media (max-width: 600px) {
    .wallboard-control span {
        display: none;
    }

    .dashboard-grid {
        display: block;
        padding: 14px 12px;
    }

    .dashboard-module {
        margin-bottom: 14px;
    }

    .weather-period-top {
        flex-wrap: wrap;
        gap: 12px;
    }

    .weather-forecast {
        grid-template-columns: 1fr;
    }

    .weather-forecast-day {
        min-height: 190px;
    }
}
