/* === RESET === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === BASE === */
/* Font and color variables are set via inline <style> in the template */

html {
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    color: var(--fg);
    background-color: var(--bg);
    line-height: 1.5;
    position: relative;
    transition: background-color 0.3s, color 0.3s;
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_cursor.png'), auto;
}

p, dt, dl {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_cursor_flip.png'), auto;
}

details {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_cursor_hat.png'), auto;
}

a, button, audio, .cell-btn, .links-toggle-btn, .mini-btn {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
}

/* Photocopy noise overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

/* === SKIP LINK === */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
    padding: 0.5rem 1rem;
    background: var(--highlight);
    color: var(--bg);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

/* === SCREEN READER ONLY === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === FOCUS VISIBLE === */
:focus-visible {
    outline: 2px solid var(--highlight);
    outline-offset: 2px;
}

/* === TABLE LAYOUT === */
#site-table {
    display: table;
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

.row {
    display: table-row;
}

.cell {
    display: table-cell;
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    vertical-align: middle;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cell:first-child {
    border-left: none;
}

.cell:last-child {
    border-right: none;
}

.cell-narrow {
    width: 24%;
    white-space: nowrap;
}

.cell-label {
    width: 24%;
    white-space: nowrap;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    vertical-align: top;
    padding-top: 1.25rem;
}

/* === HEADER === */
#header-row {
    border-bottom: 2px solid var(--border);
}

#header-logo {
    text-align: center;
    width: 24%;
}

#logo {
    width: 70px;
    height: auto;
}

:root[data-theme="dark"] #logo {
    filter: invert(1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #logo {
        filter: invert(1);
    }
}

#header-title {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    user-select: none;
    touch-action: manipulation;
}

#header-title h1 {
    font-family: var(--font-logo);
    font-size: 2rem;
    letter-spacing: 0.15em;
    font-weight: 400;
}

@keyframes bpm-pulse {
    0% { background-color: var(--highlight); color: var(--bg); }
    30% { background-color: transparent; color: var(--fg); }
    100% { background-color: transparent; color: var(--fg); }
}

#header-title.bpm-beat {
    animation: bpm-pulse var(--beat-ms) ease-out;
}

#header-counter {
    text-align: center;
    width: 24%;
}

#day-counter {
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.counter-link {
    color: inherit;
    text-decoration: none;
}

/* === PLAYER === */
#player-row {
    border-bottom: 2px solid var(--border);
}

/* Button-style cells */
.cell-btn {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    transition: background 0.15s, color 0.15s;
    text-align: center;
    user-select: none;
    text-decoration: none;
    touch-action: manipulation;
}

.cell-btn:hover {
    background: var(--highlight);
    color: var(--bg);
}

.cell-btn:hover .cell-btn-label {
    font-weight: 900;
}

.cell-btn-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.15em;
}

#player-section {
    display: table-cell;
    vertical-align: middle;
    padding: 1.25rem 1.5rem;
}

/* Play/Stop text with rotated letters */
.play-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.play-text span {
    display: inline-block;
}

@keyframes slow-spin-letter {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinning-letter {
    animation: slow-spin-letter 600s linear infinite;
}

.rotated-letter {
    transform: rotate(90deg);
    translate: 0 0.15em;
}

.player-dot {
    display: inline-block;
    width: 1.3em;
    height: 1.3em;
    vertical-align: middle;
    position: relative;
    top: -0.22em;
    margin-right: 0.5rem;
    font-size: inherit;
    background: transparent;
}

.player-dot::after,
.mini-vol-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--fg);
    transition: transform 0.15s ease;
    transform: scale(var(--vol-scale, 1));
}

.player-dot,
.mini-vol-dot {
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
}

.player-dot:active,
.mini-vol-dot:active {
    cursor: ns-resize;
}

#player-section:hover .player-dot::after {
    background: var(--bg);
}

#player-section.playing .player-dot::after {
    background: var(--bg);
}

/* Playing state */
#player-section.playing {
    background: var(--highlight);
    color: var(--bg);
}

/* Loading state */
@keyframes pulse-bg {
    0%, 100% { background-color: var(--bg); }
    50% { background-color: var(--highlight); }
}

#player-section.loading {
    animation: pulse-bg 1.5s ease-in-out infinite;
}

/* Jukebox mode */
#site-title.jukebox {
    text-decoration: line-through;
}

#jukebox-label {
    display: none;
    color: var(--highlight);
    font-family: var(--font-logo);
    font-size: 2rem;
    letter-spacing: 0.15em;
    font-weight: 400;
    margin-left: 0.75rem;
}

#jukebox-label.active {
    display: inline;
}

#chat-cell {
    color: var(--fg);
}

#chat-cell:hover {
    color: var(--bg);
}

/* Pulse animation on load */
@keyframes pulse-border {
    0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
    50% { box-shadow: inset 0 0 0 3px var(--highlight); }
}

.pulse-on-load {
    animation: pulse-border 1.5s ease-in-out 3;
}

/* === LINKS CELL === */
#links-cell {
    text-align: center;
    vertical-align: middle;
    overflow: hidden;
}

#links-collapsed {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#links-collapsed .nav-link {
    padding: 0;
}

.links-toggle-btn {
    display: block;
    margin: 0 auto;
    background: none;
    border: none;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: var(--fg);
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    padding: 0.25rem 0;
}

#links-collapse {
    font-size: 1rem;
}

.links-toggle-btn:hover {
    text-decoration: underline;
}

.nav-link-inline {
    display: inline;
}

.links-separator {
    border-top: 1px solid var(--fg);
    opacity: 0.15;
    margin: 0.3rem 0;
}

.links-quote {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.15rem 0;
    display: block;
    opacity: 0.4;
    white-space: normal;
}

#links-expanded {
    padding: 0.5rem 0;
}

#links-expanded .nav-link {
    padding: 0.6rem 0;
}

#links-expanded .drawer-email {
    display: block;
    font-family: var(--font-body);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--fg);
    opacity: 0.7;
    padding: 0.6rem 0;
}

/* === SWUP TRANSITIONS === */
.transition-main {
    opacity: 1;
    transition: opacity 0.2s ease;
}

html.is-changing .transition-main {
    opacity: 0;
}

/* === CONTENT TABLE (schedule rows inside swappable area) === */
#content-table {
    display: table;
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

.col-group {
    display: table-column-group;
}

.col-narrow {
    display: table-column;
    width: 24%;
}

.col-body {
    display: table-column;
}

/* === SUBPAGE CONTENT === */
.page-content {
    padding: 2rem 1.25rem;
}

.page-content h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

/* === ROW BORDER VARIANTS === */

/* "label" borders: merge body + spacer (border between col1 and col2 only) */
.cell-merge-right {
    border-right: none;
}

.cell-merge-left {
    border-left: none;
}

/* "none" borders: no vertical borders at all */
.cell-no-vborder {
    border-left: none;
    border-right: none;
}

.nav-link {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: var(--fg);
    text-decoration: none;
    padding: 0.25rem 0;
}

.nav-link:hover {
    text-decoration: underline;
}

/* === UTILITY ROW (full-width single cell, no borders) === */
.utility-row {
    border-bottom: none;
}

.utility-cell {
    padding: 0.4rem 1.25rem;
    border: none;
    white-space: nowrap;
}

/* === TIMEZONE TOGGLE === */

.tz-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}

.tz-switch input {
    display: none;
}

.tz-slider {
    display: inline-block;
    width: 28px;
    height: 14px;
    background: var(--fg);
    border-radius: 7px;
    position: relative;
    transition: background 0.2s;
}

.tz-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background: var(--bg);
    border-radius: 50%;
    transition: transform 0.2s;
}

.tz-switch input:checked ~ .tz-slider::after {
    transform: translateX(14px);
}

.tz-option {
    opacity: 0.4;
    transition: opacity 0.15s;
}

/* When checked (LOCAL mode): LOCAL label bright, UTC dim */
.tz-switch input:checked ~ #tz-local-label {
    opacity: 1;
}

.tz-switch input:checked ~ #tz-utc-label {
    opacity: 0.4;
}

/* When unchecked (UTC mode): UTC label bright, LOCAL dim */
.tz-switch input:not(:checked) ~ #tz-utc-label {
    opacity: 1;
}

.tz-switch input:not(:checked) ~ #tz-local-label {
    opacity: 0.4;
}

.tz-current {
    font-family: var(--font-body);
    font-size: 0.7rem;
    opacity: 0.5;
    margin-left: 0;
}

/* === SCHEDULE SECTIONS === */
.section-label {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
}

.placeholder {
    opacity: 0.5;
    font-style: italic;
    font-size: 0.9rem;
}

.day-heading {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.5;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--fg);
    border-bottom-color: color-mix(in srgb, var(--fg) 15%, transparent);
    padding-bottom: 0.15rem;
}

.day-heading:first-child {
    margin-top: 0;
}

.show-entry {
    margin-bottom: 0.5rem;
}

.show-entry:last-child {
    margin-bottom: 0;
}

.show-time {
    font-size: 0.8rem;
    opacity: 0.6;
}

.show-title {
    font-weight: 700;
}

.show-description {
    font-size: 0.95rem;
    opacity: 0.6;
    margin-top: 0.15rem;
}

.restream-label {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    opacity: 0.5;
    text-transform: uppercase;
}

.restream-link {
    font-size: 0.8rem;
    color: var(--highlight);
    text-decoration: none;
}

.restream-link:hover {
    text-decoration: underline;
}

#previous-body {
    max-height: 200px;
    overflow-y: auto;
}

/* === ARCHIVE === */

#archive-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.archive-search-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    opacity: 0.4;
}

#archive-search-wrap:focus-within .archive-search-icon {
    opacity: 0.7;
}

#archive-search {
    width: 100%;
    background: transparent;
    border: none;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    color: var(--fg);
    padding: 0.3rem 0;
    outline: none;
}

#archive-search::placeholder {
    color: var(--fg);
    opacity: 0.4;
}

#archive-tags {
}

#archive-row .cell {
    vertical-align: top;
}

button.archive-tag {
    background: none;
    border: none;
    color: inherit;
    display: block;
}

.archive-tag {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.15rem 0;
    opacity: 0.5;
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    transition: opacity 0.15s;
}

.archive-tag:hover {
    opacity: 1;
}

.archive-tag.active {
    opacity: 1;
    color: var(--highlight);
    font-weight: 700;
}

.archive-tag-count {
    font-family: var(--font-body);
    font-size: 0.65rem;
    opacity: 0.5;
}

.archive-tag-clear {
    color: var(--highlight);
    font-weight: 700;
    opacity: 1;
    margin-bottom: 0.25rem;
}

.archive-tag-more {
    color: var(--highlight);
    font-weight: 700;
    opacity: 1;
    margin-top: 0.25rem;
}

.archive-count {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 0.75rem;
}

.archive-warning {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--highlight);
    margin-bottom: 0.75rem;
}

.archive-entry {
    margin-bottom: 0.5rem;
}

.archive-entry:last-child {
    margin-bottom: 0;
}

.archive-date {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    opacity: 0.5;
    display: block;
}

.archive-title {
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
}

.archive-title:hover {
    text-decoration: underline;
    color: var(--highlight);
}

.archive-duration {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-left: 0.5rem;
}

.archive-genres {
    display: block;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* === FOOTER === */
#site-footer {
    text-align: center;
    padding: 1.25rem 1.25rem 5rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    opacity: 0.4;
}

/* === MINI PLAYER === */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    background: var(--bg);
    border-top: 2px solid var(--border);
    padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 50;
    transform: translateY(0);
    transition: transform 0.3s ease, background-color 0.3s;
}

.mini-player.hidden {
    transform: translateY(100%);
}

button.mini-btn {
    background: none;
}

.mini-btn {
    touch-action: manipulation;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.mini-btn:hover {
    background: var(--highlight);
    color: var(--bg);
}

.mini-vol-dot {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    position: relative;
    flex-shrink: 0;
    vertical-align: middle;
    background: transparent;
}

#mini-now-playing {
    font-size: 0.9rem;
    font-weight: 700;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    transition: opacity 0.3s;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    padding: 0;
    cursor: url('https://assets.chunt.org/images/web/cursors/luigi_point.png'), pointer;
}

/* === MOBILE === */
@media (max-width: 1024px) {
    .cell-narrow,
    .cell-label,
    #header-logo,
    #header-counter {
        width: 21%;
    }

}

@media (max-width: 768px) {
    html {
        font-size: 18px;
    }

    #site-table,
    #content-table {
        display: block;
    }

    .row {
        display: block;
    }

    .cell {
        display: block;
        border: none;
        border-bottom: 1px solid var(--border);
    }

    .cell-narrow {
        width: auto;
        white-space: normal;
    }

    .cell-label {
        width: auto;
        white-space: normal;
        padding-bottom: 0.25rem;
        border-bottom: none;
    }

    #header-row {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        border-bottom: 2px solid var(--border);
    }

    #header-logo {
        border-bottom: none;
        flex-shrink: 0;
        padding: 0.5rem;
    }

    #logo {
        width: 50px;
    }

    #header-title {
        border-bottom: none;
        flex: 1;
        text-align: right;
        min-width: 0;
    }

    #header-title h1 {
        font-size: 1.3rem;
    }

    #jukebox-label {
        font-size: 1.3rem;
        margin-left: 0.4rem;
    }

    #header-counter {
        flex: 0 0 100%;
        text-align: center;
        border-bottom: none;
        padding: 0 1rem 0.5rem;
    }

    #player-row {
        display: block;
        border-bottom: 2px solid var(--border);
    }

    #player-section {
        display: block;
        text-align: center;
    }

    .play-text {
        font-size: 3rem;
    }

    .player-dot {
        width: 1em;
        height: 1em;
        font-size: 3rem;
    }

    #links-cell {
        display: block;
        width: auto;
    }

    .nav-link {
        display: inline;
    }


    #previous-body {
        max-height: none;
        overflow-y: visible;
    }

    .cell-spacer {
        display: none;
    }

    #archive-search {
        max-width: 100%;
    }

    #archive-tags {
        max-height: none;
        overflow-y: visible;
        display: flex;
        flex-wrap: wrap;
        gap: 0 0.75rem;
    }
}