/* ==========================================================================
   Global Weather Pro — Sidebar Widget (Dark)
   Layout model: centred readout + two-column instrument grid.
   Tokens are scoped to .weather-widget-sidebar so they never leak into the
   host theme. Keep the token block in sync with sidebar-light-mode.css.
   ========================================================================== */

.weather-widget-sidebar {
    /* --- tokens ------------------------------------------------------- */
    --gw-surface: #0f1724;
    --gw-inset: #17212f;
    --gw-ink: #eaf1fa;
    --gw-ink-2: #c3d2e5;
    --gw-muted: #8fa4bf;
    --gw-line: #24324a;
    --gw-accent: #57a8ff;
    --gw-accent-soft: rgba(87, 168, 255, 0.14);
    --gw-radius: 14px;
    --gw-pad: 18px;

    /* --- card --------------------------------------------------------- */
    background-color: var(--gw-surface);
    border: 1px solid var(--gw-line);
    border-radius: var(--gw-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.45);
    padding: var(--gw-pad);
    color: var(--gw-ink-2);
    max-width: 340px;
    margin: 0 auto;
    text-align: center;
    overflow: hidden;
    font-size: 16px; /* base for em calculations */

    /* The widget sits in a theme sidebar, so its width has nothing to do
       with the viewport. Make the card itself the query container. */
    container-type: inline-size;
    container-name: gwpro-sidebar;

    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.weather-widget-sidebar:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 38px rgba(0, 0, 0, 0.55);
    border-color: #33465f;
}

/* ==========================================================================
   Header
   ========================================================================== */

.weather-header-section {
    margin-bottom: 14px;
    border-bottom: 1px solid var(--gw-line);
    padding-bottom: 14px;
}

.weather-location {
    font-size: 1.25em;      /* 20px — was 25.6px, which forced wrapping */
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--gw-ink) !important;
    text-wrap: balance;
}

.weather-date {
    font-size: 0.75em;      /* 12px */
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gw-muted);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Current conditions readout
   ========================================================================== */

.weather-body {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.weather-current {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
    min-width: 0;
}

/* The icon is a background-image on #weather-icon-div, so CSS owns its size.
   Both selectors are listed everywhere it is sized, so the container-query
   overrides below tie on specificity and win on source order. */
.weather-icon-div,
#weather-icon-div {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: brightness(1.06);
}

/* Large, light numerals read as an instrument display rather than a badge. */
.weather-temperature {
    font-size: 2.75em;      /* 44px */
    font-weight: 300;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--gw-ink);
    font-variant-numeric: tabular-nums;
}

.weather-condition {
    font-size: 0.9375em;    /* 15px */
    font-weight: 500;
    color: var(--gw-ink-2);
    margin-top: 10px;
}

/* ==========================================================================
   Unit toggle (F / C)
   --------------------------------------------------------------------------
   Native <button>s with aria-pressed. The pressed state drives the styling,
   so the visible selection and the screen-reader state can never disagree.
   sidebarWidget.js still moves the active unit to the front of the group.
   ========================================================================== */

.gwpro-unit-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.unit-toggle-wrapper [data-role="unit-toggle"] {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;        /* WCAG 2.5.8 target size (24px minimum) */
    min-height: 28px;
    margin: 0;
    font-family: inherit;
    font-size: 0.75rem;     /* 12px — no longer inherits the 44px temp size */
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--gw-line);
    background: transparent;
    color: var(--gw-muted);
    text-decoration: none;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.unit-toggle-wrapper [data-role="unit-toggle"][aria-pressed="true"] {
    background: var(--gw-accent-soft);
    border-color: var(--gw-accent);
    color: var(--gw-ink);
}

.unit-toggle-wrapper [data-role="unit-toggle"]:hover {
    background: var(--gw-inset);
    color: var(--gw-ink);
}

#click-fahrenheit, #click-celsius,
#click-fahrenheit-sidebar, #click-celsius-sidebar {
    translate: no !important;   /* tell the browser not to machine-translate */
    cursor: pointer;
    user-select: none;
}


#click-celsius:focus-visible,
#click-fahrenheit:focus-visible,
#click-celsius-sidebar:focus-visible,
#click-fahrenheit-sidebar:focus-visible {
    outline: 2px solid var(--gw-accent);
    outline-offset: 2px;
}

/* ==========================================================================
   Measurements grid
   --------------------------------------------------------------------------
   This is the fix for the cramped labels. The old rule was a wrapping flex row
   with `min-width: 80px` per item, which gave "Precipitation" ~80px to live in
   and let it spill. A two-column grid with minmax(0, 1fr) gives each label the
   full half-width of the card and allows the cell to shrink instead of overflow.
   ========================================================================== */

.weather-footer {
    border-top: 1px solid var(--gw-line);
    padding-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 14px;
    text-align: left;
}

.weather-detail {
    display: block;
    min-width: 0;   /* lets the cell shrink below its content width */
}

/* The trailing hairline is the widget's signature: it absorbs whatever space
   the label doesn't use, so labels of very different lengths still resolve to
   an even column edge — and a long label simply squeezes the rule to nothing
   instead of pushing the layout around. */
.detail-label {
    display: flex;
    align-items: center;
    gap: 0.6em;
    font-size: 0.625rem;    /* 10px */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--gw-muted);
    margin-bottom: 5px;
    white-space: nowrap;
}

.detail-label::after {
    content: "";
    flex: 1 1 auto;
    min-width: 0;
    height: 1px;
    background: var(--gw-line);
}

.detail-value {
    font-size: 0.9375em;    /* 15px */
    font-weight: 600;
    color: var(--gw-ink);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.detail-value strong { font-weight: inherit; }

/* ==========================================================================
   Alert badge — keep it in the flow of the centred header
   ========================================================================== */

.weather-widget-sidebar .alert-icon-class {
    margin: 12px auto 0;
}

/* ==========================================================================
   Theme switcher (demo sidebar)
   ========================================================================== */

#light-dark-mode-toggle {
    height: 32px;
    width: 32px;
}

#select-theme-label-sidebar {
    display: block;
    font-size: 0.6875em;    /* 11px */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 0.5em;
    color: var(--gw-muted);
}

#gwpro-theme-mode-select-demo-sidebar {
    width: 100%;
    border-radius: 8px;
}

#btn-submit-theme-mode-sidebar {
    color: #0b1420;
    background-color: var(--gw-accent);
    border: none;
    border-radius: 8px;
    transition: background-color 0.18s ease;
}

#btn-submit-theme-mode-sidebar:hover {
    background-color: #7cbcff;
}

/* ==========================================================================
   Container queries — respond to the sidebar's width, not the viewport's
   ========================================================================== */

/* Narrow sidebars: one measurement per row. The cutoff is set so the longest
   label ("PRECIPITATION") always has room in a half-width cell. */
@container gwpro-sidebar (max-width: 264px) {
    .weather-footer { grid-template-columns: 1fr; row-gap: 11px; }
    .weather-temperature { font-size: 2.25em; }
    .weather-icon-div,
    #weather-icon-div { width: 58px; height: 58px; }
    .weather-location { font-size: 1.125em; }
}

/* Very narrow sidebars: tighten the readout so the unit toggle never clips. */
@container gwpro-sidebar (max-width: 208px) {
    .weather-current { gap: 6px; }
    .weather-icon-div,
    #weather-icon-div { width: 44px; height: 44px; }
    .weather-temperature { font-size: 1.75em; }
    .unit-toggle-wrapper [data-role="unit-toggle"] { padding: 3px 6px; font-size: 0.6875rem; min-width: 24px; min-height: 24px; }
    #click-fahrenheit-sidebar { margin-right: 2px; }
}

/* Roomy sidebars: let the readout breathe. */
@container gwpro-sidebar (min-width: 320px) {
    .weather-temperature { font-size: 3.125em; }
}

@media (prefers-reduced-motion: reduce) {
    .weather-widget-sidebar,
    .weather-widget-sidebar * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
