/*
 * Site-wide styles shared by every page (alongside Tailwind). Loaded as
 * css/site.css?v=N with the same N as js/site.js; bump both together.
 */

/* ---- Design tokens (also exposed to Tailwind in each page's config) ---- */

:root {
    /* Greys */
    --grey-muted: #888888;  /* secondary text: dates, back links, player times */
    --grey-dot: #333333;    /* dot grids */

    /* Spacing */
    --gutter: 1rem;               /* page padding on mobile */
    --space-section: 2rem;        /* between page sections: buttons, post text, lyrics, newsletter */
    --space-dots: 0.5rem;         /* between dot grids and the artwork/cards beside them */
    --space-header: 6px;          /* above and below post titles */
}
@media (min-width: 768px) {
    :root { --space-header: 8px; }
}

/* ---- Floating audio player (js/site.js) ---- */

body { padding-bottom: var(--player-h, 0px); }

#rooms-player {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(23, 23, 23, 0.96);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
#rooms-player[hidden] { display: none; }
#rooms-player .rp-inner {
    max-width: 900px; margin: 0 auto;
    display: flex; align-items: center; gap: 14px;
}
#rooms-player button {
    flex: none; width: 40px; height: 40px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0; border: 0; cursor: pointer; color: inherit; background: transparent;
    transition: background-color .15s, opacity .15s;
}
#rooms-player .rp-play { background: #fff; color: #0E100D; }
#rooms-player .rp-play i { font-size: 15px; }
#rooms-player .rp-play .fa-play { margin-left: 2px; }
#rooms-player .rp-mute { opacity: .7; }
#rooms-player .rp-middle { flex: 1; min-width: 0; }
#rooms-player .rp-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 13px; line-height: 1.2; margin-bottom: 6px;
}
/* On mobile 'up next' sits under the title; from 640px it shares the line. */
#rooms-player .rp-meta-left {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
}
#rooms-player .rp-meta-left > * { max-width: 100%; }
#rooms-player .rp-title {
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    color: var(--grey-muted); text-decoration: none;
}
#rooms-player .rp-name { color: #fff; }
#rooms-player .rp-next {
    min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    color: var(--grey-muted);
}
#rooms-player .rp-next[hidden] { display: none; }
#rooms-player .rp-next a { color: #fff; text-decoration: none; }
#rooms-player .rp-time { flex: none; color: var(--grey-muted); font-variant-numeric: tabular-nums; }
#rooms-player .rp-right { flex: none; display: flex; align-items: center; gap: 6px; }
#rooms-player .rp-seek { display: block; }
#rooms-player .rp-volume { display: none; width: 80px; }

@media (min-width: 640px) {
    #rooms-player .rp-meta-left { flex-direction: row; justify-content: space-between; gap: 12px; }
    #rooms-player .rp-volume { display: block; }
}

/* Hover styles only for devices with a real pointer, so they don't stick after a tap. */
@media (hover: hover) and (pointer: fine) {
    #rooms-player .rp-play:hover { opacity: .85; }
    #rooms-player .rp-mute:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
    #rooms-player a.rp-title:hover { text-decoration: underline; }
    #rooms-player .rp-next a:hover { text-decoration: underline; }
}

#rooms-player input[type=range] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer;
    --fill: 0%;
}
#rooms-player input[type=range]:disabled { cursor: default; }
#rooms-player input[type=range]::-webkit-slider-runnable-track {
    height: 4px; border-radius: 9999px;
    background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, .2) var(--fill));
}
#rooms-player input[type=range]::-moz-range-track {
    height: 4px; border-radius: 9999px;
    background: linear-gradient(to right, #fff var(--fill), rgba(255, 255, 255, .2) var(--fill));
}
#rooms-player input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 9999px;
    background: #fff;
}
#rooms-player input[type=range]::-moz-range-thumb {
    width: 12px; height: 12px; border: 0; border-radius: 9999px; background: #fff;
}
#rooms-player input[type=range]:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---- Artwork lightbox (js/site.js) ---- */

@media (min-width: 768px) {
    img[data-lightbox] { cursor: zoom-in; }
}
#rooms-lightbox {
    position: fixed; inset: 0; z-index: 70;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; background: rgba(14, 16, 13, .95); cursor: zoom-out;
}
#rooms-lightbox[hidden] { display: none; }
#rooms-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }

/* ---- Dot grids: js/site.js fills these with evenly spaced 4px dots ---- */

.dot-grid { position: relative; min-width: 0; }
.dot-grid-dots {
    position: absolute; inset: 0; overflow: hidden;
    display: grid; justify-content: space-between; align-content: space-between;
}
.dot-grid-dots > i { width: 4px; height: 4px; border-radius: 9999px; background: var(--grey-dot); }
/* Full-width bands of dots: 15 rows (15 dots + 14 gaps of 4px), or 10. */
.dot-strip { height: 116px; }
.dot-strip-short { height: 76px; }

/* ---- Typewriter text: lyrics, and the homepage smiley ---- */

.typewriter {
    font-family: 'Courier New', Courier, monospace;
    /* Courier New is hairline-thin on iOS; a faint outline evens it out. */
    -webkit-text-stroke: 0.3px currentColor;
}
.lyrics { font-size: 0.9rem; line-height: 1.625; color: #fff; }
.lyrics > p { margin-bottom: 1.5rem; }
.lyrics > p:last-of-type { margin-bottom: 0; }

/* ---- Post 'next' link: hidden until js/site.js knows where it goes ---- */

a[data-next-post][hidden] { display: none; }

/* ---- Track list on multi-track posts (rows built by js/site.js) ---- */

/* Collapsed to a 'track list' toggle; the panel opens by easing its row from 0fr to 1fr. */
.tracklist-toggle {
    display: flex; align-items: center; gap: 16px; width: 100%; height: 44px; padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 0.5rem; background: rgba(255, 255, 255, .05);
    color: #fff; font-size: 0.875rem; text-align: left; cursor: pointer; transition: background-color .15s;
}
.tracklist-toggle-icon { width: 32px; flex: none; display: flex; justify-content: center; font-size: 0.875rem; }
.tracklist-panel {
    display: grid; grid-template-rows: 0fr; opacity: 0;
    transition: grid-template-rows .3s ease, opacity .3s ease;
}
.tracklist.is-open .tracklist-panel { grid-template-rows: 1fr; opacity: 1; }
.tracklist-rows { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 12px; }
/* An empty first item, so the gap above the first row collapses with the panel (padding wouldn't). */
.tracklist-rows::before { content: ''; }
@media (prefers-reduced-motion: reduce) { .tracklist-panel { transition: none; } }
.tracklist-row {
    display: flex; align-items: center; gap: 16px; width: 100%; height: 44px; padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 0.5rem; background: rgba(255, 255, 255, .05);
    color: #fff; font-size: 0.875rem; text-align: left; cursor: pointer; transition: background-color .15s;
}
.tracklist-row.is-current { background: rgba(255, 255, 255, .1); }
.tracklist-num, .tracklist-icon { width: 32px; flex: none; display: flex; justify-content: center; }
.tracklist-num { color: var(--grey-muted); font-variant-numeric: tabular-nums; }
.tracklist-icon { display: none; }
.tracklist-row.is-current .tracklist-num { display: none; }
.tracklist-row.is-current .tracklist-icon { display: flex; }
.tracklist-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracklist-time { color: var(--grey-muted); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) {
    .tracklist-row:hover, .tracklist-toggle:hover { background: rgba(255, 255, 255, .1); }
    .tracklist-row:hover .tracklist-num { display: none; }
    .tracklist-row:hover .tracklist-icon { display: flex; }
}

/* ---- 'Now playing' EQ: five bouncing bars (decorative, not driven by the audio) ---- */

.eq { display: none; align-items: stretch; gap: 2px; height: 14px; margin-left: auto; flex: none; }
.is-playing > .eq { display: flex; }
/* Bars are full height and squashed from the bottom with transform, which
   animates reliably everywhere (animating percentage heights stalled in Safari). */
.eq i { width: 3px; border-radius: 1px; background: currentColor; transform-origin: bottom; transform: scaleY(.3); animation: eq-bounce 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-duration: .8s; animation-delay: -.4s; }
.eq i:nth-child(3) { animation-duration: 1.15s; animation-delay: -.7s; }
.eq i:nth-child(4) { animation-duration: .9s; animation-delay: -.2s; }
.eq i:nth-child(5) { animation-duration: 1.05s; animation-delay: -.55s; }
/* The outer bars stay at or below half height. */
.eq i:first-child, .eq i:last-child { animation-name: eq-bounce-low; }
@keyframes eq-bounce {
    0%, 100% { transform: scaleY(.3); }
    25% { transform: scaleY(1); }
    50% { transform: scaleY(.55); }
    75% { transform: scaleY(.85); }
}
@keyframes eq-bounce-low {
    0%, 100% { transform: scaleY(.2); }
    25% { transform: scaleY(.5); }
    50% { transform: scaleY(.3); }
    75% { transform: scaleY(.45); }
}
/* In the Play button the bars are centred in a column as wide as the
   buy/play pills on the buttons below, so they all line up. */
[data-rooms-play] .eq { height: 16px; width: 4.5rem; justify-content: center; }
@media (prefers-reduced-motion: reduce) {
    .eq i { animation: none; }
    .eq i:nth-child(1) { transform: scaleY(.4); }
    .eq i:nth-child(2) { transform: scaleY(1); }
    .eq i:nth-child(3) { transform: scaleY(.4); }
    .eq i:nth-child(4) { transform: scaleY(.8); }
    .eq i:nth-child(5) { transform: scaleY(.5); }
}

/* ---- Newsletter form: js/site.js hides the email row after a sign-up, and
   Tailwind's .flex would otherwise override the hidden attribute ---- */
.newsletter-form [hidden] { display: none; }

/* ---- Newsletter prompt (js/site.js): a card just above the player ---- */

#rooms-prompt {
    position: fixed; z-index: 61;
    left: var(--gutter); right: var(--gutter);
    bottom: calc(var(--player-h, 0px) + 12px);
    padding: 20px;
    background: #171717;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    color: #fff;
}
#rooms-prompt[hidden] { display: none; }
#rooms-prompt .rooms-prompt-heading { font-weight: 700; font-size: 1.125rem; margin: 0 32px 6px 0; }
#rooms-prompt .rooms-prompt-close {
    position: absolute; top: 10px; right: 10px;
    width: 36px; height: 36px; border-radius: 9999px;
    display: flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--grey-muted); cursor: pointer;
}
@media (min-width: 768px) {
    #rooms-prompt { left: auto; right: 24px; width: 420px; }
}
@media (hover: hover) and (pointer: fine) {
    #rooms-prompt .rooms-prompt-close:hover { color: #fff; background: rgba(255, 255, 255, .08); }
}
