/* ---------------------------------------------------------------------------
   World Radio — app shell styles.

   This file holds only shell chrome: the page body, the top navigation, and the
   bottom player bar. Feature-specific CSS lives in a <style> block at the bottom
   of the owning .razor file.

   It is a real stylesheet rather than inline <style> for one concrete reason:
   Razor parses '@media' inside a .razor <style> block as a C# transition and
   fails the build. Keeping media queries here sidesteps that, and the shell
   styles are global by nature anyway (they style :root and MudMainContent).

   All colours come from the --mud-palette-* custom properties that
   MudThemeProvider emits, so nothing here needs to know which mode is active.
   --------------------------------------------------------------------------- */

:root {
    /* Single source of truth for the player bar's height. PlayerBar sizes its own
       box from this; .app-main-content uses it for the gap that keeps the last row
       of page content clear of the bar. */
    --wr-player-height: 72px;
}

@media (max-width: 600px) {
    :root {
        /* One row on phones too (no volume slider there), just a smaller play knob.
           Measured at 390px: 68px. */
        --wr-player-height: 68px;
    }
}

html, body {
    font-family: var(--mud-typography-body1-family, 'Nunito Sans', 'Segoe UI', Arial, sans-serif);
}

/* Routes.razor's FocusOnNavigate moves focus to the page's h1 after every navigation.
   That programmatic focus draws a box around a full-width block element on each page
   change, which is noise rather than an affordance. A heading is not in the tab order,
   so nothing is lost; every interactive control keeps its own :focus-visible ring. */
h1:focus,
h1:focus-visible {
    outline: none;
}

/* Let the browser paint its canvas in the active scheme before Blazor boots,
   which avoids a white flash on the dark default. */
body {
    background-color: var(--mud-palette-background, #2A1D16);
}

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */

.app-main-content {
    padding-bottom: calc(var(--wr-player-height) + 24px);
}

/* Shared by Search's loading grid and Home's StationGrid skeletons. Inline
   <style> blocks are global in Razor, so a class used by two features has to live in a
   real stylesheet rather than in one feature's component. */
.station-card-skeleton {
    border-radius: var(--mud-default-borderradius);
}

/* Station logo avatar, shared by StationCard and the PlayerBar. It lives here rather than
   in StationCard's inline <style> because that block is only in the DOM while a card is
   rendered, and the player bar is visible on pages with no cards (empty Favorites,
   Not Found, Error, Search while loading). */
/* Station avatars are ivory knobs, the same in both modes (they are "objects", like the set). */
.station-avatar {
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.station-avatar.mud-avatar-filled {
    background: radial-gradient(circle at 35% 30%, #FFF8EA, #F1E6D2 50%, #CDBFA6);
    box-shadow: 0 2px 4px rgba(42, 29, 22, 0.35);
}

.station-avatar-initials {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6A4A30;
}

/* Stacked above the initials, so a load failure (which hides this element) falls
   back to them without any interop. */
.station-avatar-logo {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--mud-palette-surface);
}

/* Flag + country line, shared by StationCard and the PlayerBar for the same reason. */
.station-country {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 4px;
    min-width: 0;
}

.station-country .fi {
    border-radius: 2px;
    flex-shrink: 0;
}

.station-country-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Top navigation
   -------------------------------------------------------------------------- */

/* A hairline instead of MudBlazor's drop shadow: the bar should sit on the page like
   the top of a shelf, not float above it. */
.app-bar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.app-brand:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 4px;
    border-radius: 6px;
}

.app-brand-body {
    fill: color-mix(in srgb, var(--mud-palette-secondary) 25%, var(--mud-palette-surface));
    stroke: var(--mud-palette-secondary);
    stroke-width: 1.5;
}

.app-brand-cloth {
    fill: var(--mud-palette-secondary);
}

.app-brand-knob {
    fill: var(--mud-palette-primary);
}

.app-brand-antenna {
    stroke: var(--mud-palette-secondary);
    stroke-width: 1.5;
    stroke-linecap: round;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--mud-default-borderradius);
    transition: background-color 0.15s, color 0.15s;
}

.top-nav a:hover {
    background-color: color-mix(in srgb, var(--mud-palette-action-default) 10%, transparent);
    color: var(--mud-palette-text-primary);
}

.top-nav a:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.top-nav a.top-nav-link--active {
    background-color: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
    color: var(--mud-palette-primary);
}

.top-nav-icon {
    font-size: 1.05rem;
}

.app-brand-name {
    white-space: nowrap;
}

.app-footer {
    margin-top: 48px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 10px;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

.app-footer a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.app-footer a:hover,
.app-footer a:focus-visible {
    color: var(--mud-palette-primary);
}

@media (max-width: 600px) {
    /* The two credits stack on phones; a separator dot would dangle at a line end. */
    .app-footer {
        flex-direction: column;
        align-items: center;
    }

    .app-footer-sep {
        display: none;
    }
}

@media (max-width: 600px) {
    /* At phone width the brand text, three nav labels and the theme toggle don't fit on
       one row. The brand mark stays (it is still the home link, and keeps its aria-label);
       the wordmark goes, and the toolbar gutters tighten from MudBlazor's 24px. */
    .app-bar .mud-toolbar {
        padding-left: 12px;
        padding-right: 4px;
    }

    .app-brand-name {
        display: none;
    }

    .top-nav-icon {
        display: none;
    }

    .top-nav a {
        padding: 6px 8px;
    }
}

/* --------------------------------------------------------------------------
   Player bar
   -------------------------------------------------------------------------- */

.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Sits above MudBlazor's Popover (1200) so a dropdown near the bottom edge is
       not occluded, and below Tooltip (1600) so tag tooltips still show. Matches
       MudThemeProvider's default AppBar z-index; the bar never overlaps the app
       bar, so there is no collision. */
    z-index: 1300;
    min-height: var(--wr-player-height);
    display: flex;
    align-items: center;
    /* The bottom rail of the set: the same walnut as Home's radio in both modes, so the
       text on it uses the fixed light tones below rather than palette text colours. */
    background: linear-gradient(#5C3B28, #4A2F20);
    color: #F1E6D2;
    /* Re-pointing the palette for everything inside the bar is simpler than overriding each
       MudBlazor colour class (they use !important), and it holds in both modes. */
    --mud-palette-primary: #FFB547;
    --mud-palette-tertiary: #D4BC94;
    --mud-palette-secondary: #D4BC94;
    --mud-palette-text-primary: #F1E6D2;
    --mud-palette-text-secondary: #D4BC94;
    border: 0;
    border-radius: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 -8px 24px rgba(42, 29, 22, 0.35);
}

/* The play button is an ivory knob ringed with valve glow. */
.player-bar .player-controls .mud-icon-button {
    background: radial-gradient(circle at 35% 30%, #FFF8EA, #F1E6D2 50%, #CDBFA6);
    color: #6A4A30;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 181, 71, 0.25);
}

.player-bar .mud-chip.mud-chip-text {
    color: #D4BC94;
    background-color: rgba(212, 188, 148, 0.14);
}

.player-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-station {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-station-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.player-station-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Country and tags share one line so the bar keeps its fixed height. Chips that do not
   fit are clipped rather than wrapped onto a second line. */
.player-station-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin-top: 2px;
}

.player-station-meta .station-country {
    margin-top: 0;
    flex-shrink: 1;
}

.player-station-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.player-station-tags .mud-chip {
    margin: 0;
    flex-shrink: 0;
}

/* The heart sits right after the station name, so it never gets squeezed out. */
.player-favorite {
    flex: 0 0 auto;
}

.player-controls {
    flex: 0 0 auto;
}

/* Station info and volume share the leftover space equally (flex 1 1 0) so the
   transport stays centred rather than drifting toward whichever side is longer. */
.player-volume {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.player-volume-slider {
    width: 100%;
    max-width: 160px;
}

/* --------------------------------------------------------------------------
   Home radio set (Home.razor) — media queries can't live in a .razor <style>
   -------------------------------------------------------------------------- */

/* Home's inline <style> block is in the DOM after this file, so an override here with the
   same specificity loses to it. Every selector below therefore carries one extra class
   (or an element) than its base rule in Home.razor. */
@media (max-width: 900px) {
    section.radio-set {
        grid-template-columns: 1fr;
        padding: 14px;
        margin-bottom: 32px;
        border-radius: 22px;
    }

    .radio-set .radio-cloth {
        padding: 26px 22px;
    }
}

@media (max-width: 600px) {
    .radio-title.mud-typography-h3 {
        font-size: 2.1rem;
    }

    .radio-set .radio-hint {
        display: none;
    }

    .radio-set .radio-controls {
        flex-wrap: nowrap;
    }

    .radio-set .radio-knob {
        width: 46px;
        height: 46px;
    }

    .radio-set .radio-surprise.mud-button-filled {
        flex: 1 1 auto;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .radio-needle {
        transition: none;
    }
}

/* Phones get a mini-player: station on the left, play/pause on the right, one row.
   The volume slider goes because it does nothing useful there: iOS Safari ignores
   HTMLMediaElement.volume (always 1), and Android users reach for the hardware keys. */
@media (max-width: 600px) {
    .player-inner {
        padding: 8px 12px 8px 16px;
        gap: 12px;
    }

    /* Tags don't fit beside the country at this width and get cut mid-chip; the card the
       station was played from already shows them. */
    .player-volume,
    .player-station-tags {
        display: none;
    }

    .player-bar .player-controls .mud-icon-button {
        padding: 8px;
    }
}
