/* ==========================================================================
   Base Theme
   ========================================================================== */
:root {
    --np-body-bg: #f0f2f5;
    --np-card-bg: #ffffff;
    --np-card-shadow: 0 6px 8px rgba(0, 0, 0, 0.1);
    --np-text: rgba(51, 51, 51, 0.9);
    --np-muted: #666666;
    --np-heading: rgba(102, 102, 102, 0.8);
    --np-link: #000000;
    --np-link-hover: #000000;
    --np-disclaimer-text: #666666;
    --np-control-bg: #f0f2f5;
    --np-control-border: #dddddd;
    --np-control-hover: #dddddd;
    --np-control-text: #666666;
    --np-input-bg: rgba(255, 255, 255, 0.9);
    --np-input-border: rgba(0, 0, 0, 0.2);
    --np-input-outline: rgba(65, 131, 215, 0.35);
    --np-table-header: rgba(0, 0, 0, 0.5);
    --np-table-divider: rgba(0, 0, 0, 0.08);
    --np-table-empty: rgba(0, 0, 0, 0.6);
    --np-mobile-label: rgba(31, 61, 117, 0.6);
    --np-calendar-status: rgba(51, 51, 51, 0.66);
    --np-calendar-legend: rgba(31, 35, 40, 0.72);
    --np-calendar-swatch-border: rgba(31, 35, 40, 0.08);
    --np-llm-text: rgba(102, 102, 102, 0.7);
    --np-topbar-text: #666666;
    --np-topbar-border: rgba(0, 0, 0, 0.08);
    --np-theme-button-bg: #f0f2f5;
    --np-theme-button-border: #dddddd;
    --np-theme-button-text: #666666;
    --np-theme-button-active: #ffffff;
    --np-theme-button-active-text: #000000;
    --np-pulse-a: rgba(135, 206, 235, 0.1);
    --np-pulse-b: rgba(135, 206, 235, 0.25);
    --np-price-calendar-border: #ffffff;
    --np-price-calendar-empty: rgba(255, 255, 255, 0);
    --np-price-calendar-null: rgba(0, 0, 0, 0);
    --np-theme-chip-shadow: none;
    --np-topbar-bg: transparent;
    --np-github-logo-opacity: 0.5;
    --np-github-logo-opacity-hover: 0.8;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 20px;
    color: var(--np-text);
    background-color: var(--np-body-bg);
    transition: background-color 0.333s ease, color 0.333s ease;
}

#predictionText,
#narration,
#llm,
.price-calendar,
.price-calendar-legend,
.cheapest-table {
    transition: background-color 0.333s ease, color 0.333s ease, border-color 0.333s ease;
}

@media (prefers-reduced-motion: reduce) {
    body,
    #predictionText,
    #narration,
    #llm,
    .price-calendar,
    .price-calendar-legend,
    .cheapest-table {
        transition: none;
    }

    .np-weather-icon * {
        animation: none !important;
    }

    .np-windsock-fabric {
        transition: none !important;
    }

    .np-weather-rays,
    .np-weather-cloud,
    .np-weather-rain,
    .np-weather-snow,
    .np-weather-lightning {
        transition: none !important;
    }
}

/* ==========================================================================
   Typography & Links
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 200;
    color: var(--np-heading);
    margin-bottom: 0;
    line-height: 1.3;
}

p {
    margin-bottom: 1em;
    margin-left: 2px;
}

li {
    line-height: 1.6;
    margin-bottom: 8px;
    position: relative;
}

a {
    color: var(--np-link);
    text-decoration: underline;
    opacity: 0.6;
    border-bottom: 1px solid transparent;
    font-weight: 400;
    transition: opacity 0.15s ease-in-out;
}

a:hover {
    text-decoration: underline;
    color: var(--np-link-hover);
    opacity: 1;
    font-weight: 500;
}

a:source-code-link {
    text-decoration: none;
}

table {
    width: 100%;
    font-size: 1em;
    border-collapse: separate;
    border-spacing: 2px;
    margin: auto;
}

th,
td {
    vertical-align: middle;
    padding: 2px;
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */
.page-title {
    padding-top: 16px;
}

.section-title {
    padding-top: 32px;
}

#predictionText {
    max-width: 1080px;
    line-height: 1.6;
    box-sizing: border-box;
    margin: auto;
    margin-top: 16px;
    box-shadow: var(--np-card-shadow);
    background-color: var(--np-card-bg);
    padding: 24px 60px;
}

#narration {
    max-width: 1080px;
    margin: auto;
    line-height: 1.6;
    padding-bottom: 24px;
    box-sizing: border-box;
}

#llm {
    max-width: 1080px;
    margin: auto;
    text-align: left;
    color: var(--np-llm-text);
    padding-top: 8px;
    line-height: 1.5;
    box-sizing: border-box;
    font-size: 0.9em;
}

#priceCalendarSection {
    margin: 28px 0 8px 0;
}

#cheapestWindows {
    margin: 24px 0 32px 0;
}

#predictionChart,
#windPowerChart,
#chart,
#pastPredictions,
#historyChart {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    min-height: 400px;
    height: 50vh;
}

#predictionChart {
    max-width: none;
    min-height: 488px;
    height: calc(50vh + 88px);
    padding-top: 0;
}

.prediction-chart-shell {
    --np-prediction-grid-top: 56px;
    --np-prediction-grid-bottom: 96px;
    --np-weather-bottom: 12px;
    position: relative;
    width: 100%;
    padding-top: 24px;
}

.prediction-weather {
    position: absolute;
    z-index: 2;
    top: auto;
    bottom: var(--np-weather-bottom);
    left: 0;
    width: 100%;
    height: 64px;
    overflow: hidden;
    pointer-events: none;
}

.prediction-weather[hidden],
.np-weather-mark[hidden],
.np-weather-separator[hidden] {
    display: none;
}

.np-weather-separator {
    position: absolute;
    top: 6px;
    bottom: 6px;
    width: 0;
    border-left: 1px dashed var(--np-weather-separator-color, silver);
    pointer-events: none;
}

.np-weather-tooltip {
    position: fixed;
    z-index: 10000;
    display: none;
    width: max-content;
    max-width: min(360px, calc(100vw - 16px));
    padding: 10px;
    border: 1px solid var(--np-weather-tooltip-border, rgba(31, 35, 40, 0.12));
    border-radius: 4px;
    background: var(--np-weather-tooltip-bg, #ffffff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: var(--np-weather-tooltip-text, rgba(51, 51, 51, 0.9));
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    pointer-events: none;
}

.np-weather-tooltip.is-visible {
    display: grid;
    gap: 8px;
}

.np-weather-tooltip strong {
    font-weight: 600;
}

.np-weather-tooltip-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 16px;
    margin: 0;
}

.np-weather-tooltip-list dt,
.np-weather-tooltip-list dd {
    margin: 0;
}

.np-weather-tooltip-list dd {
    text-align: right;
    white-space: nowrap;
}

.np-weather-tooltip-section {
    display: grid;
    gap: 2px;
    padding-top: 6px;
    border-top: 1px solid var(--np-weather-tooltip-border, rgba(31, 35, 40, 0.12));
}

.np-weather-mark {
    position: absolute;
    top: 4px;
    width: 52px;
    height: 52px;
    overflow: visible;
    transform: translateX(-50%);
    pointer-events: auto;
}

.np-weather-icon {
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: translateX(-10%);
}

.np-weather-condition {
    transform: scale(0.736);
    transform-box: view-box;
    transform-origin: 48px 50px;
}

.np-weather-sun-core { fill: #fbbf24; }
.np-weather-rays { fill: none; stroke: #f59e0b; stroke-width: 3.5; stroke-linecap: round; transform-origin: 34px 32px; }
.np-weather-cloud-back { fill: #94a3b8; }
.np-weather-cloud-front { fill: #e2e8f0; stroke: #cbd5e1; stroke-width: 1.2; }
.np-weather-rain { fill: none; stroke: #3b82f6; stroke-width: 3.2; stroke-linecap: round; }
.np-weather-snow { fill: #60a5fa; }
.np-weather-lightning { fill: #facc15; stroke: #eab308; stroke-width: 1; stroke-linejoin: round; }
.np-weather-rays,
.np-weather-cloud,
.np-weather-rain,
.np-weather-snow,
.np-weather-lightning {
    transform-box: fill-box;
}
.np-weather-rays { transform-box: view-box; }
.np-icon-motion-active .np-weather-rays { animation: npWeatherSun 8s linear infinite; }
.np-icon-motion-active .np-weather-cloud { animation: npWeatherCloud 3.2s ease-in-out infinite; }
.np-icon-motion-active .np-weather-rain { animation: npWeatherRain 0.9s ease-in infinite; }
.np-icon-motion-active .np-weather-snow { animation: npWeatherSnow 1.8s ease-in-out infinite; }
.np-icon-motion-active .np-weather-lightning { animation: npWeatherLightning 2.6s ease-in-out infinite; }
.np-icon-motion-active .np-weather-delay-1 { animation-delay: -0.6s; }
.np-icon-motion-active .np-weather-delay-2 { animation-delay: -1.2s; }

@keyframes npWeatherSun {
    to { transform: rotate(360deg); }
}

@keyframes npWeatherCloud {
    0%, 100% { transform: translateX(-1px); }
    50% { transform: translateX(2px); }
}

@keyframes npWeatherRain {
    0% { transform: translateY(-2px); opacity: 0; }
    30% { opacity: 1; }
    100% { transform: translateY(5px); opacity: 0; }
}

@keyframes npWeatherSnow {
    0%, 100% { transform: translate(-1px, -1px); opacity: 0.35; }
    50% { transform: translate(2px, 4px); opacity: 1; }
}

@keyframes npWeatherLightning {
    0%, 42%, 50%, 100% { opacity: 1; }
    45%, 48% { opacity: 0.12; }
}
.np-windsock-pole {
    fill: none;
    stroke: #64748b;
    stroke-width: 2.4;
    stroke-linecap: round;
}
.np-windsock-fabric-scale {
    transform: scale(1.21);
    transform-box: view-box;
    transform-origin: 80px 9px;
}
.np-windsock-body { fill: #f97316; stroke: #c2410c; stroke-width: 1.2; stroke-linejoin: round; }
.np-windsock-stripe { fill: #fff7ed; opacity: 0.95; }
.np-windsock-fabric {
    transform-box: view-box;
    transform-origin: 80px 9px;
}

.np-weather-mark[data-wind="calm"] .np-windsock-fabric { transform: rotate(72deg) scaleX(0.58); }
.np-weather-mark[data-wind="weak"] .np-windsock-fabric { transform: rotate(40deg) scaleX(0.72); }
.np-weather-mark[data-wind="normal"] .np-windsock-fabric { transform: rotate(14deg) scaleX(0.88); }
.np-weather-mark[data-wind="strong"] .np-windsock-fabric { transform: rotate(3deg) scaleX(1); }
.np-icon-motion-active .np-weather-mark[data-wind="weak"] .np-windsock-fabric {
    animation: npWindsockWeak 1.8s ease-in-out infinite;
}
.np-icon-motion-active .np-weather-mark[data-wind="normal"] .np-windsock-fabric {
    animation: npWindsockNormal 1.15s ease-in-out infinite;
}
.np-icon-motion-active .np-weather-mark[data-wind="strong"] .np-windsock-fabric {
    animation: npWindsockStrong 0.7s ease-in-out infinite;
}

@keyframes npWindsockWeak {
    0%, 100% { transform: rotate(40deg) scaleX(0.72); }
    50% { transform: rotate(31deg) scaleX(0.78); }
}

@keyframes npWindsockNormal {
    0%, 100% { transform: rotate(14deg) scaleX(0.88); }
    50% { transform: rotate(6deg) scaleX(0.96); }
}

@keyframes npWindsockStrong {
    0%, 100% { transform: rotate(3deg) scaleX(1); }
    50% { transform: rotate(-5deg) scaleX(1.05); }
}

#windPowerChart {
    padding-top: 24px;
}

#chart {
    padding-top: 12px;
}

#pastPredictions {
    padding: 24px 0;
}

#historyChart {
    /* already sized above */
}

#featureEmbeddingChart {
    height: 720px;
    min-height: 420px;
    width: 100%;
    max-width: 1080px;
    margin: 24px auto;
    box-sizing: border-box;
}

#disclaimer {
    position: relative;
    max-width: 512px;
    line-height: 1.6;
    margin: 16px auto 0;
    color: var(--np-disclaimer-text);
    font-size: 0.8em;
    opacity: 0.6;
    width: 100%;
    padding: 4px 0;
    text-align: center;
}

#source-code-text {
    color: var(--np-muted);
    text-decoration: none;
    font-size: 0.8em;
    opacity: 0.5;
    transition: opacity 0.15s ease-in-out;
    text-align: center;
    margin-bottom: 32px;
}

#github-logo-container {
    text-align: center;
    width: 100%;
    padding-top: 16px;
    margin: 16px 0 4px 0;
}

#github-logo {
    height: 32px;
    opacity: var(--np-github-logo-opacity);
    transition: opacity 0.15s ease-in-out;
}

#github-logo:hover {
    opacity: var(--np-github-logo-opacity-hover);
}

#topdisclaimer {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
    color: var(--np-topbar-text);
    gap: 48px;
    background-color: var(--np-topbar-bg);
    position: relative;
}

#topdisclaimer::before,
#topdisclaimer::after {
    content: '';
    flex: 1 1 0;
    min-width: 0;
}

#topdisclaimer .lang-option {
    color: var(--np-topbar-text);
    opacity: 0.4;
    text-decoration: none;
    border-bottom: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

#topdisclaimer .lang-option:hover,
#topdisclaimer .lang-option:focus-visible {
    opacity: 0.9;
    text-decoration: underline;
}

#topdisclaimer .lang-option[aria-current="true"] {
    opacity: 1;
    font-weight: 600;
}

.topbar-links,
.theme-switch {
    flex-shrink: 0;
}

.topbar-links {
    flex: 0 0 auto;
    text-align: left;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

:root[data-theme="dark"] .theme-switch [data-theme-option="dark"] {
    color: #bcbd22;
    text-shadow: 0 0 8px rgba(188, 189, 34, 0.9);
    opacity: 1;
}

:root[data-theme="dark"] #topdisclaimer .lang-option[aria-current="true"] {
    color: #f0f0f0;
    text-shadow: 0 0 10px rgba(192, 192, 192, 0.95);
}

:root[data-theme="dark"] #disclaimer,
:root[data-theme="dark"] #source-code-text {
    opacity: 1;
}

:root[data-theme="dark"] #disclaimer a,
:root[data-theme="dark"] #source-code-text a {
    opacity: 1;
}

#disclaimer a,
#source-code-text a {
    text-decoration: none;
}

#disclaimer a:hover,
#source-code-text a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Components
   ========================================================================== */
#predictionChart {
    /* sizing defined in layout */
}

.price-calendar {
    width: 100%;
    height: 256px;
    margin-top: 12px;
}

.price-calendar-status {
    font-size: 0.9rem;
    color: var(--np-calendar-status);
    margin-top: 8px;
}

.price-calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--np-calendar-legend);
    justify-content: flex-end;
}

.price-calendar-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.price-calendar-legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px var(--np-calendar-swatch-border);
}

#cheapestWindows.cheapest-refresh .cheapest-table {
    animation: cheapestPulseBackground 0.96s ease-in-out;
}

@keyframes cheapestPulseBackground {
    0% {
        background-color: transparent;
    }
    25% {
        background-color: rgba(135, 206, 235, 0.1);
    }
    50% {
        background-color: rgba(135, 206, 235, 0.25);
    }
    75% {
        background-color: rgba(135, 206, 235, 0.1);
    }
    100% {
        background-color: transparent;
    }
}

#cheapestWindows h2 {
    margin: 0;
    font-size: 1.2em;
}

.cheapest-sentence {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 1em 2px;
    font-size: 1em;
    line-height: 1.6;
    color: var(--np-text);
}

.cheapest-sentence span {
    display: inline-flex;
    align-items: center;
}

.cheapest-wrap {
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.cheapest-field {
    display: inline-flex;
}

.cheapest-field input,
.cheapest-field select {
    border-radius: 4px;
    border: 1px solid var(--np-input-border);
    padding: 3px 8px;
    font: inherit;
    min-width: 3.4ch;
    text-align: center;
    background-color: var(--np-input-bg);
    color: var(--np-text);
}

.cheapest-field input:focus,
.cheapest-field select:focus {
    outline: 2px solid var(--np-input-outline);
    outline-offset: 1px;
}

.cheapest-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    table-layout: fixed;
}

.cheapest-table thead th {
    text-align: left;
    padding: 6px 6px 10px;
    font-weight: 600;
    color: var(--np-table-header);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cheapest-row {
    border-top: 1px solid var(--np-table-divider);
}

.cheapest-row:first-child {
    border-top: none;
}

.cheapest-cell {
    padding: 12px 6px;
    vertical-align: middle;
}

.cheapest-cell-average,
.cheapest-cell-countdown {
    font-weight: 600;
    font-size: 1.05em;
}

.cheapest-row-empty td {
    padding: 20px 6px;
    text-align: center;
    color: var(--np-table-empty);
}

.cheapest-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.cheapest-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-flex;
}

.history-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    max-width: 1080px;
    margin: 48px auto 0 auto;
}

.history-toggle {
    display: flex;
    justify-content: center;
}

.history-prune select {
    background-color: var(--np-control-bg);
    border: 1px solid var(--np-control-border);
    color: var(--np-control-text);
    padding: 5px 12px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
    transition: all 0.2s ease;
    border-radius: 4px;
    height: 31.6px;
}

.history-prune select:hover {
    background-color: var(--np-control-hover);
}

.history-toggle button {
    background-color: var(--np-control-bg);
    border: 1px solid var(--np-control-border);
    color: var(--np-control-text);
    padding: 5px 12px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.history-toggle button:first-child {
    border-radius: 4px 0 0 4px;
}

.history-toggle button:last-child {
    border-radius: 0 4px 4px 0;
}

.history-toggle button.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
    font-weight: 500;
}

.history-toggle button:hover:not(.active) {
    background-color: var(--np-control-hover);
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    font-size: 1em;
    color: var(--np-topbar-text);
    gap: 12px;
    white-space: nowrap;
}

.theme-switch [data-theme-option] {
    cursor: pointer;
    opacity: 0.4;
    text-decoration: none;
    padding: 2px 0;
    outline: none;
    font-size: 1.3em;
    line-height: 1;
}

.theme-switch [data-theme-option]:hover,
.theme-switch [data-theme-option]:focus-visible {
    opacity: 0.9;
    text-decoration: underline;
}

.theme-switch [data-theme-option].is-active {
    font-weight: 600;
    opacity: 1;
}

/* ==========================================================================
   Responsive Rules
   ========================================================================== */
@media (min-width: 640px) {
    .price-calendar {
        height: 256px;
    }
}

@media (min-width: 960px) {
    .price-calendar {
        height: 256px;
    }
}

@media (max-width: 720px) {
    .cheapest-table,
    .cheapest-table tbody,
    .cheapest-table tr,
    .cheapest-table td {
        display: block;
        width: 100%;
    }

    .cheapest-table thead {
        display: none;
    }

    .cheapest-row {
        padding: 12px 0;
    }

    .cheapest-cell {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        padding: 6px 0;
        gap: 12px;
    }

    .cheapest-cell::before {
        content: attr(data-label);
        font-size: 0.72em;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--np-mobile-label);
        font-weight: 600;
    }

    .cheapest-sentence {
        font-size: 0.9em;
        gap: 4px;
    }

    .cheapest-field input,
    .cheapest-field select {
        min-width: 3ch;
        padding: 2px 4px;
    }

    .cheapest-cell-average,
    .cheapest-cell-countdown {
        font-size: 1em;
    }

    .cheapest-row-empty td {
        padding: 12px 0;
    }
}

@media (max-width: 768px) {
    body {
        margin: 12px;
    }

    table {
        font-size: 0.85em;
    }

    #predictionText {
        padding-left: 16px;
        padding-right: 16px;
        padding-top: 12px;
    }

    #predictionText .page-title {
        margin-top: 0;
    }

    #predictionChart,
    #pastPredictions,
    #windPowerChart,
    #historyChart {
        height: 300px;
    }

    #predictionChart {
        min-height: 380px;
        height: 380px;
    }

    .prediction-chart-shell {
        --np-prediction-grid-top: 64px;
    }

    .prediction-weather {
        height: 56px;
    }

    .np-weather-mark {
        top: 2px;
        width: 44px;
        height: 44px;
    }

    #disclaimer {
        max-width: 320px;
    }

    .history-toggle button {
        padding: 4px 8px;
        font-size: 0.8em;
    }
}

@media (max-width: 620px) {
    .cheapest-wrap {
        flex-basis: 100%;
    }
}

@media (max-width: 480px) {
    .prediction-chart-shell {
        --np-prediction-grid-top: 72px;
        --np-prediction-grid-bottom: 64px;
        --np-weather-bottom: 8px;
        padding-top: 0;
    }

    .prediction-weather {
        height: 36px;
    }

    .np-weather-separator {
        top: 4px;
        bottom: 4px;
    }

    .np-weather-mark {
        top: 0;
    }

    .np-weather-icon {
        display: block;
        width: 28px;
        height: 28px;
        margin: 0 auto;
    }
}
