/**
 * JavocSoft Portfolio - "Pagefy this page" widget
 *
 * A floating panel with the soundtrack of the current page or of a project, in the
 * style of Pagefy's popup. Uses the theme variables from styles.css (and their dark
 * values from dark.css).
 */

.st-panel {
    --st-green: #148a3b;
    position: fixed;
    top: 106px;
    right: 16px;
    z-index: 940;
    display: flex;
    flex-direction: column;
    width: min(410px, calc(100vw - 32px));
    max-height: calc(100vh - 122px);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--color-light-gray);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: st-in 0.2s ease-out;
}

html[data-theme="dark"] .st-panel {
    --st-green: #1ed760;
}

.st-panel[hidden] {
    display: none;
}

.st-panel:focus {
    outline: none;
}

@keyframes st-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* Header */
.st-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--color-light-gray);
}

.st-logo {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: #ffffff;
    background: linear-gradient(135deg, #1db954 0%, #0f7a3a 100%);
}

.st-heading {
    flex: 1;
    min-width: 0;
}

.st-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.02rem;
    line-height: 1.25;
    color: var(--text);
}

.st-sub {
    margin: 0.1rem 0 0;
    font-size: 0.8rem;
    color: var(--color-gray);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-close {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--color-light-gray);
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base);
}

.st-close:hover {
    background: var(--color-bg);
    color: var(--text);
}

/* Body */
.st-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
}

.st-message {
    margin: 0 0 0.9rem;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-2);
}

.st-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--st-green);
    border-radius: 20px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.st-retry:hover {
    background: color-mix(in srgb, var(--st-green) 14%, transparent);
}

/* Steps while it works: the same path the extension follows */
.st-steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.st-steps li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0;
    font-size: 0.92rem;
    color: var(--color-gray);
}

.st-steps li i {
    width: 1.1rem;
    text-align: center;
}

.st-steps li.is-active {
    color: var(--text);
    font-weight: 600;
}

.st-steps li.is-active i {
    color: var(--st-green);
    animation: st-pulse 1.1s ease-in-out infinite;
}

.st-steps li.is-done {
    color: var(--text-2);
}

.st-steps li.is-done i {
    color: var(--st-green);
}

@keyframes st-pulse {
    50% { opacity: 0.35; }
}

/* Result */
.st-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.st-chip {
    padding: 0.22rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    background: var(--color-bg);
    border: 1px solid var(--color-light-gray);
}

.st-chip.is-mood {
    background: color-mix(in srgb, var(--st-green) 16%, transparent);
    border-color: color-mix(in srgb, var(--st-green) 40%, transparent);
}

.st-meters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.st-meter-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--color-gray);
}

.st-meter-bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--color-light-gray);
    overflow: hidden;
}

.st-meter-bar i {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--st-green);
}

.st-tracks {
    list-style: none;
    margin: 0;
    padding: 0;
}

.st-track {
    border-radius: var(--border-radius);
}

.st-track + .st-track {
    margin-top: 0.15rem;
}

.st-track.is-playing {
    background: color-mix(in srgb, var(--st-green) 9%, transparent);
}

.st-track-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.4rem 0.45rem;
}

.st-cover {
    flex: none;
    width: 46px;
    height: 46px;
    border-radius: 6px;
    background: var(--color-light-gray);
    object-fit: cover;
}

.st-cover.is-empty {
    display: grid;
    place-items: center;
    color: var(--color-gray);
    font-size: 1rem;
}

.st-track-text {
    flex: 1;
    min-width: 0;
}

.st-track-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-track-artists {
    display: block;
    font-size: 0.8rem;
    color: var(--color-gray);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.st-play {
    flex: none;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: #1db954;
    color: #0b1a10;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform var(--transition-base), background var(--transition-base);
}

.st-play:hover {
    transform: scale(1.08);
    background: #1ed760;
}

.st-play[aria-pressed="true"] {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--color-gray);
}

.st-embed {
    padding: 0 0.45rem 0.5rem;
}

.st-embed iframe {
    display: block;
    width: 100%;
    height: 80px;
    border: 0;
    border-radius: 12px;
    color-scheme: normal;
}

/* Footer */
.st-foot {
    padding: 0.8rem 1rem;
    border-top: 1px solid var(--color-light-gray);
    font-size: 0.76rem;
    line-height: 1.55;
    text-align: center;
    color: var(--color-gray);
}

.st-foot p {
    margin: 0;
}

.st-foot p + p {
    margin-top: 0.35rem;
}

.st-foot a {
    color: var(--text-2);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.st-foot a:hover {
    color: var(--text);
}

.st-more {
    margin-top: 0.35rem;
}

.st-more summary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.st-more summary::-webkit-details-marker {
    display: none;
}

.st-more summary::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--transition-base);
}

.st-more[open] summary::after {
    margin-top: 3px;
    transform: rotate(-135deg);
}

.st-more summary:hover {
    color: var(--text);
}

.st-more p {
    margin-top: 0.4rem;
}

/* Triggers inside the catalog and the case studies */
.soundtrack-link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.5rem;
}

.cs-links button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--color-light-gray);
    background: transparent;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition-base), transform var(--transition-base);
}

.cs-links button:hover {
    border-color: var(--cs-accent, var(--color-primary));
    transform: translateY(-1px);
}

/* The music button is a fourth button in the header: up to 560px the tagline under
   the logo gives way (below 480px styles.css already hides it), so the header
   keeps to one row */
@media (max-width: 560px) {
    .tagline {
        display: none;
    }
}

/* ...and on the smallest phones the logo shrinks a little too */
@media (max-width: 340px) {
    .logo-image {
        width: 28px;
        height: auto;
    }

    .logo h1 {
        font-size: 1.02rem;
    }

    .header-tools {
        gap: 0.15rem;
    }
}

/* Phones: a sheet from the bottom */
@media (max-width: 640px) {
    .st-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-height: 82vh;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        border-bottom: 0;
        animation-name: st-up;
    }

    .st-meters {
        grid-template-columns: 1fr;
    }
}

@keyframes st-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .st-panel {
        animation: none;
    }

    .st-steps li.is-active i {
        animation: none;
    }
}
