/**
 * Toggle Track — Base Structural CSS
 *
 * Layout-only styles shared by ALL skins. No decorative visuals here.
 * Colors come from CSS custom properties that skins override.
 *
 * @package ToggleTrack
 * @since   1.0.0
 */

/* ---------- Custom Property Defaults ---------- */

.toggle-track-player {
    --tt-bg: #1a1a1a;
    --tt-text: #e0e0e0;
    --tt-active: #ffffff;
    --tt-controls: #2a2a2a;
    --tt-progress: #333333;
    --tt-accent: #ff4400;
}

/* ---------- Container ---------- */

.toggle-track-player {
    background: var(--tt-bg);
    color: var(--tt-text);
    box-sizing: border-box;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 800px;
    overflow: hidden;
    line-height: 1.4;
}

.toggle-track-player *,
.toggle-track-player *::before,
.toggle-track-player *::after {
    box-sizing: border-box;
}

/* ---------- Wrapper ---------- */

.tt-wrapper {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}

/* ---------- Track Selector ---------- */

.tt-track-selector {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
}

.tt-track-btn {
    background: var(--tt-controls);
    color: var(--tt-text);
    border: none;
    padding: 6px 14px;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    transition: background-color 0.15s ease, color 0.15s ease;
    line-height: 1.4;
}

.tt-track-btn.tt-active {
    background: var(--tt-accent);
    color: var(--tt-active);
}

/* ---------- Transport ---------- */

.tt-transport {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

/* ---------- Play Button ---------- */

.tt-play-btn {
    background: var(--tt-controls);
    color: var(--tt-text);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-family: inherit;
    transition: background-color 0.15s ease;
    padding: 0;
}

/* ---------- Progress Wrap ---------- */

.tt-progress-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* ---------- Progress Bar ---------- */

.tt-progress-bar {
    position: relative;
    height: 8px;
    background: var(--tt-progress);
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
}

.tt-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--tt-accent);
    border-radius: 4px;
    width: 0%;
    transition: width 50ms linear;
    pointer-events: none;
}

/* ---------- Time Display ---------- */

.tt-time {
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Extras Row ---------- */

.tt-extras {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ---------- Volume ---------- */

.tt-volume-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.tt-volume-label {
    font-size: 0.8em;
    white-space: nowrap;
}

.tt-volume {
    width: 80px;
    accent-color: var(--tt-accent);
    cursor: pointer;
}

/* ---------- Control Buttons (Loop, Loudness, AB) ---------- */

.tt-loop-btn,
.tt-loudness-btn,
.tt-ab-btn {
    background: var(--tt-controls);
    color: var(--tt-text);
    border: none;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: inherit;
    transition: background-color 0.15s ease, color 0.15s ease;
    line-height: 1.4;
}

.tt-loop-btn.tt-active,
.tt-loudness-btn.tt-active,
.tt-ab-btn.tt-active {
    background: var(--tt-accent);
    color: var(--tt-active);
}

/* ---------- AB Wrap ---------- */

.tt-ab-wrap {
    display: flex;
    flex-direction: row;
    gap: 4px;
}

/* ---------- Speed ---------- */

.tt-speed-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.tt-speed {
    accent-color: var(--tt-accent);
    cursor: pointer;
}

.tt-speed-label {
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Meter ---------- */

.tt-meter-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tt-meter {
    display: block;
}

.tt-meter-label {
    font-size: 0.75em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Loading Overlay ---------- */

.tt-loading {
    position: absolute;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.8);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 10;
}

.tt-loading.tt-visible,
.tt-loading[style*="display: flex"],
.tt-loading:not([style*="display: none"]):not([style*="display:"]) {
    /* The JS toggles display via inline style; this provides a hook
       for skins that want to use the class-based approach. */
}

.tt-loading-bar {
    width: 60%;
    height: 4px;
    background: var(--tt-progress);
    border-radius: 2px;
    overflow: hidden;
}

.tt-loading-fill {
    height: 100%;
    background: var(--tt-accent);
    width: 0%;
    transition: width 200ms ease;
    border-radius: 2px;
}

.tt-loading-text {
    font-size: 0.85em;
    color: var(--tt-text);
}

/* ---------- Loop Markers ---------- */

.tt-loop-marker {
    position: absolute;
    top: 0;
    height: 100%;
    width: 2px;
    background: var(--tt-accent);
    opacity: 0.7;
    pointer-events: none;
    z-index: 2;
}

/* ---------- Icon Spans ---------- */

.tt-icon-play,
.tt-icon-pause {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------- Focus Styles ---------- */

.toggle-track-player *:focus-visible {
    outline: 2px solid var(--tt-accent);
    outline-offset: 2px;
}

/* ---------- Responsive ---------- */

@media (max-width: 400px) {
    .tt-wrapper {
        padding: 10px;
        gap: 10px;
    }

    .tt-transport {
        flex-direction: column;
        align-items: stretch;
    }

    .tt-play-btn {
        align-self: center;
    }

    .tt-extras {
        flex-direction: column;
        align-items: stretch;
    }

    .tt-volume-wrap {
        justify-content: center;
    }

    .tt-speed-wrap {
        justify-content: center;
    }

    .tt-meter-wrap {
        display: none;
    }

    .tt-ab-wrap {
        justify-content: center;
    }
}
