/* ============================================================
   Catalunya Oculta — audio (narration + soundtrack)
   Hero "Listen" pill · persistent dock · soundtrack card · home strip.
   One engine (coc-audio.js); state is mirrored in aria-pressed.
   ============================================================ */

[data-coc-bind], .coc-dock { --p: 0; }

/* Play/pause glyph swap, driven by data-playing (buttons carry an action label, not aria-pressed). */
.coc-song__play .i-pause,
.coc-listen .i-pause { display: none; }
[data-playing] .i-play { display: none; }
[data-playing] .i-pause { display: block; }

/* One focus ring for every audio control: white + dark halo, visible on light and dark. */
.coc-listen:focus-visible,
.coc-song__play:focus-visible,
.coc-dock__icon:focus-visible,
.coc-dock__rate:focus-visible,
.coc-dock__scrub:focus-visible,
.coc-song__wave:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px #141417; }

/* Keep focused elements clear of the fixed dock when tabbing (WCAG 2.4.11). */
html.coc-dock-on { scroll-padding-bottom: 96px; }
html.coc-dock-on.coc-dock-exp { scroll-padding-bottom: 260px; }

/* ---------- Hero "Listen" pill (narration) ---------- */
.coc-listen-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1rem;
    margin-top: 1.5rem;
}
.coc-listen {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    min-height: 52px;
    padding: 0 1.25rem 0 .4rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .9);
    color: #141414;
    font: 600 1rem/1 var(--coc-sans);
    letter-spacing: -.005em;
    cursor: pointer;
    transition: background-color .25s ease, transform .25s cubic-bezier(.2, .7, .2, 1);
}
.coc-listen__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #141414;
    color: #fff;
}
.coc-listen__icon svg { width: 16px; height: 16px; display: block; }
.coc-listen__meta {
    font-weight: 500;
    color: #3d3d3d;
    font-variant-numeric: tabular-nums;
}
.coc-listen__meta::before { content: "·"; margin-right: .75rem; color: rgba(20, 20, 20, .35); }
.coc-listen-row__note {
    font-size: .8rem;
    letter-spacing: .02em;
    color: rgba(255, 255, 255, .9);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .65);
}
@media (min-width: 768px) {
    .coc-listen { background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2); }
}
@media (hover: hover) {
    .coc-listen:hover { background: rgba(255, 255, 255, .96); }
}
.coc-listen:active { transform: scale(.97); }
/* Hero without image (light). */
.coc-article-hero--plain .coc-listen { background: #141414; color: #fff; }
.coc-article-hero--plain .coc-listen__icon { background: #fff; color: #141414; }
.coc-article-hero--plain .coc-listen__meta { color: rgba(255, 255, 255, .7); }
.coc-article-hero--plain .coc-listen__meta::before { color: rgba(255, 255, 255, .4); }
.coc-article-hero--plain .coc-listen-row__note { color: rgba(20, 20, 23, .72); text-shadow: none; }

/* ---------- Shared round play button (dock, card, strip) ---------- */
.coc-song__play {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #141417;
    cursor: pointer;
    transition: transform .2s cubic-bezier(.2, .7, .2, 1), box-shadow .25s ease;
}
.coc-song__play svg { width: 22px; height: 22px; display: block; }
.coc-song__play:hover { transform: scale(1.05); box-shadow: 0 10px 26px -12px rgba(255, 255, 255, .55); }
.coc-song__play:active { transform: scale(.95); }
.coc-song__kicker {
    display: block;
    font-family: var(--coc-sans);
    font-size: .64rem;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    opacity: .6;
}

/* ---------- Persistent dock ---------- */
.coc-dock {
    position: fixed;
    right: 15px;
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    width: min(340px, calc(100vw - 90px)); /* leaves the cookie button (bottom-left) free */
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 30px;
    background: rgba(14, 14, 18, .88);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
            backdrop-filter: blur(16px) saturate(1.2);
    color: #fff;
    box-shadow: 0 18px 44px -16px rgba(0, 0, 0, .75);
    font-family: var(--coc-sans);
    transition: width .3s cubic-bezier(.2, .7, .2, 1), border-radius .3s ease;
}
.coc-dock[hidden] { display: none; }
/* Movable: grab anywhere but the controls; it snaps to the nearest side on release. */
.coc-dock { touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.coc-dock.is-moving { cursor: grabbing; transition: none; box-shadow: 0 26px 60px -18px rgba(0, 0, 0, .85); }
.coc-dock button, .coc-dock a { cursor: pointer; }
.coc-dock[data-side="left"] { right: auto; left: 15px; }
.coc-dock[data-expanded="1"] { width: min(380px, calc(100vw - 90px)); border-radius: 24px; }
.coc-dock__row { display: flex; align-items: center; gap: .7rem; padding: 6px; }
.coc-dock .coc-dock__play { width: 44px; height: 44px; }
.coc-dock .coc-dock__play svg { width: 18px; height: 18px; }
/* Progress ring around the play button. */
.coc-dock__play::before {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: conic-gradient(#fff calc(var(--p) * 1turn), rgba(255, 255, 255, .16) 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
            mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
    pointer-events: none;
}
.coc-dock__meta { flex: 1; min-width: 0; line-height: 1.2; }
.coc-dock__kicker {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .7);
}
.coc-dock__title {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--coc-serif);
    font-size: .98rem;
    color: #fff !important;
    text-decoration: none;
}
.coc-dock__title:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Expanded: the full title gets two lines instead of an ellipsis. */
.coc-dock[data-expanded="1"] .coc-dock__title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.coc-dock__title:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 3px; box-shadow: 0 0 0 5px #141417; }
.coc-dock__icon {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    opacity: .62;
    cursor: pointer;
    transition: opacity .2s ease, background-color .2s ease, transform .3s cubic-bezier(.2, .7, .2, 1);
}
.coc-dock__icon::after { content: ""; position: absolute; inset: -5px; } /* 44px touch target */
.coc-dock__icon svg { width: 17px; height: 17px; display: block; }
.coc-dock__icon:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.coc-dock__icon:focus-visible { opacity: 1; }
.coc-dock[data-expanded="1"] .coc-dock__expand svg { transform: rotate(180deg); }

/* Expanded panel: scrubber, times, transport. */
.coc-dock__panel { display: none; padding: 2px 18px 14px; }
.coc-dock[data-expanded="1"] .coc-dock__panel { display: block; }
.coc-dock__scrub {
    position: relative;
    height: 44px;
    margin: -4px 0 2px;
    cursor: pointer;
    touch-action: none;
    border-radius: 6px;
}
.coc-dock__track {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .18);
    overflow: hidden;
}
.coc-dock__fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 100%); background: #fff; border-radius: 2px; }
.coc-dock__thumb {
    position: absolute;
    top: 50%;
    left: calc(var(--p) * 100%);
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .12);
    transition: transform .2s ease;
}
.coc-dock__scrub:hover .coc-dock__thumb,
.coc-dock__scrub.is-dragging .coc-dock__thumb { transform: scale(1.25); }
.coc-dock__times {
    display: flex;
    justify-content: space-between;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, .7);
}
/* Narration | Soundtrack switch (only on stories with both). */
.coc-dock__switch { display: flex; gap: 4px; margin: 2px 0 10px; padding: 3px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; }
.coc-dock__switch[hidden] { display: none; }
.coc-dock__switch button { flex: 1; min-height: 36px; border: 0; border-radius: 999px; background: transparent; color: rgba(255, 255, 255, .72); font: 600 .78rem/1 var(--coc-sans); letter-spacing: .02em; cursor: pointer; transition: background-color .2s ease, color .2s ease; }
.coc-dock__switch button[aria-pressed="true"] { background: #fff; color: #141417; }
.coc-dock__switch button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px #141417; }
.coc-dock__controls { display: flex; align-items: center; justify-content: center; gap: 1.4rem; margin-top: .55rem; }
.coc-dock__skip { width: 44px; height: 44px; opacity: .9; }
.coc-dock__skip::after { inset: 0; }
.coc-dock__skip svg { width: 32px; height: 32px; }
.coc-dock__rate {
    min-width: 62px;
    min-height: 44px;
    padding: 0 .9rem;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font: 600 .82rem/1 var(--coc-sans);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease;
}
.coc-dock__rate:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .45); }
.coc-dock__note { margin: .65rem 0 0; text-align: center; font-size: .78rem; letter-spacing: .02em; color: rgba(255, 255, 255, .66); }
/* Music needs no transport or voice disclosure: just the scrubber. */
.coc-dock[data-kind="soundtrack"] .coc-dock__controls,
.coc-dock[data-kind="soundtrack"] .coc-dock__note { display: none; }

/* Equaliser: moves only while something plays. */
.coc-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.coc-eq i { width: 2px; height: 30%; background: currentColor; border-radius: 1px; }
.coc-audio-on .coc-eq i { animation: cocEq .9s ease-in-out infinite; }
.coc-audio-on .coc-eq i:nth-child(2) { animation-delay: -.3s; }
.coc-audio-on .coc-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes cocEq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
/* Was playing on the previous page but the browser wants a tap to continue. */
.coc-audio-resume .coc-dock__play { animation: cocPulse 1.8s ease-in-out infinite; }
@keyframes cocPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .45); }
    50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

/* ---------- Soundtrack card inside the article ---------- */
.coc-article__content .coc-song--article {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin: 0 0 2.4rem;
    padding: 1.15rem 1.3rem;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 16px;
    background: #111116;
    color: #f2f2f4;
    line-height: 1.3;
    box-shadow: 0 22px 44px -26px rgba(0, 0, 0, .6);
}
.coc-song__body { flex: 1; min-width: 0; }
.coc-song__title {
    display: block;
    margin: .15rem 0 .6rem;
    font-family: var(--coc-serif);
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.15;
}
.coc-song__wave { position: relative; height: 40px; cursor: pointer; touch-action: none; border-radius: 4px; }
.coc-song__bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.coc-song__bars i { flex: 1; height: var(--h); min-height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .22); }
.coc-song__bars--on { clip-path: inset(0 calc((1 - var(--p)) * 100%) 0 0); }
.coc-song__bars--on i { background: #fff; }
.coc-song__foot { display: flex; justify-content: space-between; margin-top: .45rem; font-size: .74rem; opacity: .6; font-variant-numeric: tabular-nums; }
.coc-song .coc-song__note { margin: .7rem 0 0; font-size: .88rem; line-height: 1.5; opacity: .72; }

/* ---------- Home strip under the featured story ---------- */
.coc-song--strip {
    display: flex;
    align-items: center;
    gap: .9rem;
    max-width: 580px;
    margin-top: 1rem;
    padding: .55rem 1.1rem .55rem .55rem;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .04);
    color: #ececf0;
}
.coc-song--strip .coc-song__play { width: 44px; height: 44px; }
.coc-song--strip .coc-song__play svg { width: 18px; height: 18px; }
.coc-song--strip p { flex: 1; min-width: 0; margin: 0; font-size: .9rem; line-height: 1.35; }
.coc-song--strip .coc-song__kicker { margin-bottom: .15rem; }
.coc-song--strip strong { font-family: var(--coc-serif); font-weight: 500; }
.coc-song--strip .coc-song__time { font-size: .76rem; opacity: .6; font-variant-numeric: tabular-nums; }
body:not(.dark-mode) .coc-song--strip { color: #141417; border-color: rgba(0, 0, 0, .12); background: rgba(0, 0, 0, .03); }
body:not(.dark-mode) .coc-song--strip .coc-song__kicker,
body:not(.dark-mode) .coc-song--strip .coc-song__time { opacity: .78; }
body:not(.dark-mode) .coc-song--strip .coc-song__play { background: #141417; color: #fff; }

/* ---------- Small screens ---------- */
@media (max-width: 575.98px) {
    .coc-dock { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 84px); -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(14, 14, 18, .96); }
    .coc-dock[data-expanded="1"] { width: calc(100vw - 84px); }
    .coc-dock[data-side="left"] { left: 12px; }
    .coc-dock__panel { padding: 0 14px 12px; }
    .coc-dock__controls { gap: 1rem; }
    .coc-listen { min-height: 50px; font-size: .96rem; }
    .coc-article__content .coc-song--article { gap: .9rem; padding: 1rem; }
    .coc-song--article .coc-song__play { width: 46px; height: 46px; }
    .coc-song__bars i:nth-child(2n) { display: none; } /* 48 bars: enough weight on a narrow screen */
}

@media (prefers-reduced-motion: reduce) {
    .coc-dock, .coc-dock__icon, .coc-dock__thumb, .coc-listen, .coc-song__play { transition: none; }
    .coc-audio-on .coc-eq i, .coc-audio-resume .coc-dock__play { animation: none; }
    .coc-eq i { height: 70%; }
    .coc-audio-resume .coc-dock__play { box-shadow: 0 0 0 4px rgba(255, 255, 255, .55); }
}
@media print {
    .coc-dock, .coc-listen-row, .coc-song { display: none !important; }
}

/* ---------- Bubble (X): play with its progress ring + ⋯ to bring the dock back; audio keeps playing.
   Kept last so it beats the expanded and phone rules; ⋯ restores the previous state. ---------- */
.coc-dock .coc-dock__more { display: none; }
.coc-dock[data-min="1"] { width: 104px; border-radius: 999px; }
.coc-dock[data-min="1"] .coc-dock__more { display: grid; }
.coc-dock[data-min="1"] .coc-dock__meta,
.coc-dock[data-min="1"] .coc-dock__expand,
.coc-dock[data-min="1"] .coc-dock__close,
.coc-dock[data-min="1"] .coc-dock__panel { display: none; }
