/* KPOM-FM — shared styles for the player (index.html) and the Icecast XSL pages. */

:root {
    --bg: #0d0e12;
    --surface: rgb(255 255 255 / 0.05);
    --surface-hover: rgb(255 255 255 / 0.09);
    --border: rgb(255 255 255 / 0.09);
    --text: #f3f3f6;
    --muted: #a4a7b5;
    --faint: #6e7180;
    --accent-default: #ff5d8f;
    --accent: var(--accent-default); /* app.js overrides this from the cover art */
    --live: #3ddc97;
    --alert: #ff453a;
    --radius: 16px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
        "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

h1,
h2,
h3,
p {
    margin: 0;
}

img {
    display: block;
    max-width: 100%;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

/* --- Header / footer --------------------------------------------------------- */

.site-header {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    width: 26px;
    height: 26px;
    align-self: center;
    color: var(--accent);
    transition: color 0.8s ease;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.brand-sub {
    font-size: 0.85rem;
    color: var(--muted);
}

.site-nav {
    display: flex;
    gap: 4px;
}

.site-nav a {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.site-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.site-nav a[aria-current="page"] {
    background: var(--surface-hover);
    color: var(--text);
}

.site-nav .nav-quiet {
    color: var(--faint);
}

.site-footer {
    margin-top: auto;
    padding: 32px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--faint);
}

.site-footer a {
    color: var(--muted);
}

/* --- Pills / buttons / cards ------------------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.pill-live {
    color: var(--live);
    border-color: rgb(61 220 151 / 0.3);
    background: rgb(61 220 151 / 0.08);
}

.pill-off {
    color: var(--faint);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.pill-live .dot,
.onair[data-state="live"] .dot {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; }
    50% { box-shadow: 0 0 0 4px transparent; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--surface-hover);
}

.btn-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: #111;
}

.btn-primary:hover {
    background: var(--accent);
    filter: brightness(1.08);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.card + .card {
    margin-top: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.card.empty {
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
}

.muted {
    color: var(--muted);
    font-weight: 400;
}

/* --- XSL pages (status / server / auth) -------------------------------------- */

.page-main {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 8px 24px 24px;
}

.page-narrow {
    max-width: 640px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0 24px;
}

.page-head h1 {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mount-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 16px;
    align-items: start;
}

.mount-grid .card + .card {
    margin-top: 0;
}

.mount {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mount-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.mount-name {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    word-break: break-all;
}

.mount-desc {
    margin-top: 2px;
    font-size: 0.85rem;
    color: var(--muted);
}

.mount-now {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgb(0 0 0 / 0.25);
}

.label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
}

.mount-track b {
    font-weight: 600;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 0;
}

.stats div {
    min-width: 0;
}

.stats .wide {
    grid-column: 1 / -1;
}

.stats dt {
    font-size: 0.72rem;
    color: var(--faint);
}

.stats dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.stats small {
    font-weight: 400;
    color: var(--muted);
}

.mount audio {
    width: 100%;
    height: 40px;
}

.mount-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mount-offline {
    opacity: 0.6;
}

.kv {
    margin: 0;
}

.kv div {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.kv div:first-child {
    border-top: 0;
    padding-top: 0;
}

.kv div:last-child {
    padding-bottom: 0;
}

.kv dt {
    color: var(--muted);
}

.kv dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.link-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.link-list a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgb(0 0 0 / 0.2);
    text-decoration: none;
    font-weight: 500;
}

.link-list a:hover {
    background: var(--surface-hover);
}

.form {
    display: grid;
    gap: 14px;
}

.form label {
    display: grid;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.form input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgb(0 0 0 / 0.3);
    color: var(--text);
    font: inherit;
}

.form .btn {
    justify-self: start;
    padding: 10px 18px;
}

/* --- Player (index.html) ----------------------------------------------------- */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at top, transparent 0%, var(--bg) 85%),
        linear-gradient(to bottom, rgb(13 14 18 / 0.35), var(--bg) 90%);
}

.backdrop-layer {
    position: absolute;
    inset: -15%;
    background-size: cover;
    background-position: center;
    filter: blur(70px) saturate(1.4) brightness(0.55);
    opacity: 0;
    transition: opacity 1.2s ease;
}

.backdrop-layer.on {
    opacity: 1;
}

.player {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(260px, 440px) minmax(0, 1fr);
    grid-template-areas:
        "alert   alert"
        "cover   now"
        "history history";
    column-gap: 56px;
    row-gap: 40px;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 24px 56px;
}

.alert-banner {
    grid-area: alert;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: rgb(255 69 58 / 0.14);
    border: 1px solid rgb(255 69 58 / 0.5);
    color: #ffd5d2;
    font-weight: 700;
    animation: alert-glow 1.6s ease-in-out infinite;
}

.alert-banner svg {
    width: 24px;
    height: 24px;
    flex: none;
    color: var(--alert);
}

@keyframes alert-glow {
    50% { box-shadow: 0 0 0 4px rgb(255 69 58 / 0.18); }
}

body.is-alert {
    --accent: var(--alert);
}

.cover {
    grid-area: cover;
    margin: 0;
    aspect-ratio: 1;
    border-radius: 20px;
    overflow: hidden;
    background: var(--surface);
    box-shadow:
        0 30px 80px -20px rgb(0 0 0 / 0.75),
        0 0 0 1px rgb(255 255 255 / 0.06);
}

.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.is-alert .cover {
    box-shadow:
        0 30px 80px -20px rgb(0 0 0 / 0.75),
        0 0 0 3px var(--alert);
}

.now {
    grid-area: now;
    min-width: 0;
}

.eyebrow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 18px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.onair {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.onair[data-state="live"] {
    color: var(--live);
}

.onair[data-state="off"],
.onair[data-state="error"] {
    color: var(--faint);
}

.is-alert .onair[data-state="live"] {
    color: var(--alert);
}

#title {
    font-size: clamp(2rem, 5.2vw, 3.6rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.artist {
    margin-top: 10px;
    font-size: clamp(1.15rem, 2.4vw, 1.5rem);
    font-weight: 600;
    color: var(--accent);
    transition: color 0.8s ease;
}

.album {
    margin-top: 4px;
    min-height: 1.5em;
    color: var(--muted);
}

.controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 32px;
}

.play-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    flex: none;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #111;
    cursor: pointer;
    box-shadow: 0 10px 30px -8px var(--accent);
    transition: transform 0.15s ease, background 0.8s ease, box-shadow 0.8s ease;
}

.play-btn:hover {
    transform: scale(1.05);
}

.play-btn:active {
    transform: scale(0.97);
}

.play-btn svg {
    grid-area: 1 / 1;
    width: 30px;
    height: 30px;
}

.play-btn .i-stop,
.play-btn[data-state="loading"] .i-play,
.play-btn[data-state="playing"] .i-play {
    display: none;
}

.play-btn[data-state="loading"] .i-stop,
.play-btn[data-state="playing"] .i-stop {
    display: block;
}

.spinner {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent);
    opacity: 0;
}

.play-btn[data-state="loading"] .spinner {
    opacity: 1;
    animation: spin 0.9s linear infinite;
}

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

.volume {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(220px, 100%);
    color: var(--muted);
}

.volume svg {
    width: 22px;
    height: 22px;
    flex: none;
}

.volume input {
    --fill: 1;
    flex: 1;
    min-width: 0;
    height: 20px;
    margin: 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.volume input::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--text) calc(var(--fill) * 100%), rgb(255 255 255 / 0.18) 0);
}

.volume input::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--text) calc(var(--fill) * 100%), rgb(255 255 255 / 0.18) 0);
}

.volume input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 0;
    border-radius: 50%;
    background: var(--text);
}

.volume input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: var(--text);
}

.player-note {
    margin-top: 14px;
    min-height: 1.5em;
    font-size: 0.85rem;
    color: var(--muted);
}

.history {
    grid-area: history;
}

.history h2 {
    margin-bottom: 14px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--faint);
}

.history ol {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.history li {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 8px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.history img {
    width: 52px;
    height: 52px;
    flex: none;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface);
}

.history li div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.h-title,
.h-artist {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h-title {
    font-weight: 600;
    font-size: 0.92rem;
}

.h-artist {
    font-size: 0.82rem;
    color: var(--muted);
}

@media (max-width: 820px) {
    .player {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "alert"
            "cover"
            "now"
            "history";
        row-gap: 28px;
        padding-top: 8px;
        text-align: center;
    }

    .cover {
        width: min(100%, 380px);
        justify-self: center;
    }

    .eyebrow,
    .controls {
        justify-content: center;
    }

    .history {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 14px 16px;
        justify-content: center;
    }

    .brand-sub {
        display: none;
    }

    .page-main,
    .player {
        padding-left: 16px;
        padding-right: 16px;
    }

    .kv div {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

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