@charset "UTF-8";

/* ========== Base ========== */

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
}

body {
    min-height: 100vh;
    background-attachment: fixed;
    padding: 2em 2.5em;
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    text-shadow: 0 0 20px #242424;
}

.text-button {
    background: none;
    border: none;
    color: white;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
    font: inherit;
}

/* Small uppercase labels: "LOCATION", "RIGHT NOW", "NEXT 6 DAYS" */
.location-label,
#forecast-container h3 {
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.75;
}


/* ========== Layout ========== */

/* Wide: three columns; weather never narrower than 30rem */
main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(30rem, 1fr);
    grid-template-areas: "sites moon weather";
    gap: 2em 4em;
}

.layout-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.left-col {
    grid-area: sites;
    justify-content: space-between;
}

.mid-col {
    grid-area: moon;
    justify-content: flex-start;
    gap: 1em;
}

.right-col {
    grid-area: weather;
    width: 100%;
    max-width: 32rem;
    justify-self: end;
}

.section-heading {
    font-size: 1.5rem;
}


/* ========== Title ========== */

.app-title {
    margin-top: 0.25em;
    font-size: clamp(1.75rem, 2.2vw, 2.75rem);
    white-space: nowrap;
}


/* ========== Top sites ========== */

.frequent-website-list-item {
    margin: 0.75em 0;
    font-size: 1rem;
    white-space: nowrap;
}

.frequent-website-link {
    color: white;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    max-width: calc(100% - 2.5em);
    vertical-align: middle;
}

.frequent-website-link:hover,
.frequent-website-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.frequent-website-icon {
    width: 16px;
    height: 16px;
}

.frequent-website-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* Smaller glow, so overflow: hidden doesn't cut it off into a dark box */
    text-shadow: 0 0 4px #242424;
}

/* The ✕ is invisible until you hover over its row */
.hide-site-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0 0.25em;
    margin-left: 0.5em;
    vertical-align: middle;
    opacity: 0;
}

.frequent-website-list-item:hover .hide-site-btn,
.hide-site-btn:focus-visible {
    opacity: 0.7;
}

.hide-site-btn:hover {
    opacity: 1;
}


/* ========== Moon ========== */

#moon-section {
    display: none;
    padding: 1em;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.moon-container {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: #333;
    overflow: hidden;
    box-shadow:
        0 0 30px rgba(255, 255, 255, 0.4),
        inset 0 0 15px rgba(0, 0, 0, 0.8);
}

.moon-light {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #f0f0f0;
    z-index: 1;
}

.moon-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #333;
    z-index: 2;
}

.moon-timeline {
    display: flex;
    justify-content: center;
    gap: 1.25em;
    margin: 0.5em 0;
}

.moon-timeline-phase {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.25em;
    font-size: 0.85rem;
}

.moon-timeline-emoji {
    font-size: 1.25em;
    line-height: 1;
}

.moon-timeline-date {
    white-space: nowrap;
}

.moon-timeline-phase.is-past {
    opacity: 0.6;
}

.moon-timeline-phase.is-today {
    font-weight: bold;
    opacity: 1;
}


/* ========== Time ========== */

#time-text {
    text-align: center;
    /* 5% of the window's width, but never smaller than 2.5rem or bigger than 4.25rem */
    font-size: clamp(2.5rem, 5vw, 4.25rem);
    white-space: nowrap;
    margin-bottom: 0;
}

#date-text {
    text-align: center;
    font-size: 1.5rem;
    margin-top: 0.25em;
}


/* ========== Location (top of the weather column) ========== */

.current-location-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
}

.location-label {
    margin: 0;
}

/* Places + "+ Add" on one line */
.location-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5em 1.5em;
}

.location-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em 1em;
    font-size: 1.25rem;
}

.pinned-location {
    display: inline-flex;
    align-items: center;
}

/* Each place: faded, unless it's the current one */
.pinned-location-btn {
    background: none;
    border: none;
    color: white;
    font: inherit;
    cursor: pointer;
    padding: 0;
    opacity: 0.75;
}

.pinned-location-btn:hover {
    opacity: 1;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.pinned-location-btn.is-current {
    opacity: 1;
    font-weight: bold;
}

/* Same hover-to-show pattern as the top sites ✕ */
.unpin-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0 0.25em;
    opacity: 0;
}

.pinned-location:hover .unpin-btn,
.unpin-btn:focus-visible {
    opacity: 0.7;
}

.unpin-btn:hover {
    opacity: 1;
}

/* ZIP form (first visit, or after clicking "+ Add") */
.zip-form {
    display: flex;
    align-items: center;
    gap: 1em;
}

.zip-form input {
    width: 11em;
    padding: 0.45em 0.75em;
    font: inherit;
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    text-shadow: none;
}

.zip-form input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.zip-form input:focus {
    outline: none;
    border-color: white;
    background: rgba(255, 255, 255, 0.25);
}

/* "Loading location..." and error messages */
.location-status {
    margin: 0;
    font-size: 0.9rem;
}

.location-status:empty {
    display: none;
}


/* ========== Weather ========== */

#weather-section {
    margin-top: 1em;
    display: none;
}

#forecast-container {
    display: flex;
    flex-direction: column;
}

/* "Forecast" label (font styles are in Base) */
#forecast-container h3 {
    margin: 1.5em 0 0.25em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* Each row: name | icon | wind | temperatures */
.weather-period-container {
    display: grid;
    grid-template-columns: 8.5rem minmax(7.5rem, 1fr) minmax(6.5em, 1fr) 6em;    
    gap: 0.75em;
    align-items: center;
    padding: 1.25em 0;
}

.weather-period-name {
    font-size: 1.05rem;
    margin: 0;
}

.weather-period-icon {
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.25em;
    white-space: nowrap;
}

.weather-arrow {
    font-size: 0.8rem;
    opacity: 0.7;
}

.weather-rain-chance {
    font-size: 0.75rem;
    font-weight: bold;
}

.weather-wind {
    font-size: 0.9rem;
    opacity: 0.85;
    text-align: left;
    white-space: nowrap;
}

.wind-arrow {
    display: inline-block;
    width: 1em;
    line-height: 1;
    text-align: center;
    transform-origin: center;
    font-weight: bold;
    margin-right: 0.25em;
}

.weather-period-temperature-text {
    font-size: 1.15rem;
    font-weight: bold;
    margin: 0;
    text-align: right;
}

#weather-last-updated {
    text-align: center;
}

/* Next 12 hours: Now, then every 3 hours */
.hourly-strip {
    display: flex;
    justify-content: space-between;
    padding: 1em 0;
}

.hourly-stop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35em;
}

.hourly-time {
    font-size: 0.85rem;
    opacity: 0.85;
}

.hourly-stop.is-now .hourly-time {
    font-weight: bold;
    opacity: 1;
}

.hourly-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.hourly-temp {
    font-size: 1.1rem;
    font-weight: bold;
}

/* Each day is a dropdown: click the row to show its hours */
.day-row summary {
    list-style: none;
    cursor: pointer;
}

/* When a day is open, its hours already show the weather, so hide the day's own emoji */
.day-row[open] .weather-period-icon {
    visibility: hidden;
}

/* No outline after a mouse click, but a soft one when using the keyboard (Tab) */
.day-row summary:focus {
    outline: none;
}

.day-row summary:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
    border-radius: 6px;
}

/* Hide the browser's built-in triangle */
.day-row summary::-webkit-details-marker {
    display: none;
}

/* Our own small arrow before the day name: ▸ closed, ▾ open */
.day-row .weather-period-name::before {
    content: "\25B8";
    display: inline-block;
    width: 1em;
    opacity: 0.6;
}

.day-row[open] .weather-period-name::before {
    content: "\25BE";
}

/* The hours sit just under the open row, indented to line up with the day name */
.day-row .hourly-strip {
    padding: 0 0 1.25em 1em;
}


/* ========== Smaller screens ========== */

/* Medium: moon and clock top left, top sites under them, weather on the right */
@media (max-width: 1300px) {
    main {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
        grid-template-areas:
            "moon  weather"
            "sites weather";
    }

    /* The big title takes up a lot of room for little benefit at this size */
    .app-title {
        display: none;
    }
}

/* Narrow: one column: time, weather, moon, top sites */
@media (max-width: 800px) {
    main {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "time"
            "weather"
            "moon"
            "sites";
    }

    /* Let the clock and the moon be placed separately */
    .mid-col {
        display: contents;
    }

    .time-container {
        grid-area: time;
    }

    /* The clock has the full width here, so let it be bigger */
    #time-text {
        font-size: clamp(3rem, 13vw, 5rem);
    }

    /* Center the weather in the single column */
    .right-col {
        justify-self: center;
    }

    #moon-section {
        grid-area: moon;
    }
}

/* ========== First visit (no location saved yet) ========== */

/* The intro line only shows before a location is saved */
.location-intro {
    display: none;
    margin: 0 0 0.5em;
    max-width: 22em;
    line-height: 1.4;
}

.needs-location .location-intro {
    display: block;
}

/* A bigger, friendlier form */
.needs-location .zip-form input {
    width: 9em;
    font-size: 1.25rem;
    padding: 0.5em 0.75em;
}

.needs-location .zip-form button[type="submit"] {
    padding: 0.55em 1.25em;
    font-size: 1.1rem;
    font-weight: bold;
    color: hsl(250, 40%, 25%);
    background: white;
    border-radius: 6px;
    text-decoration: none;
    text-shadow: none;
}

/* Wide screens: fill the window so the clock and the welcome sit in the middle */
@media (min-width: 1301px) {
    .needs-location main {
        min-height: calc(100vh - 4em);
    }

    .needs-location .mid-col,
    .needs-location .right-col {
        justify-content: center;
    }
}