/* ---------------------------------------------------------
   SONG FRONTEND RENDERER STYLES
   --------------------------------------------------------- */

#tfp-song-renderer-wrapper {
    width: 100%;
    margin-bottom: 40px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.tfp-renderer-flex-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Row Container */
.tfp-renderer-row {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Timeline */
/* Row Play Button */
.tfp-play-row-btn {
    background: #ddd;
    color: #000;
    border: none;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s, transform 0.1s;
    text-transform: uppercase;
    line-height: 1;
}

.tfp-play-row-btn:hover {
    background: #000;
    color: #fff;
}

.tfp-play-row-btn:active {
    transform: scale(0.95);
}

.tfp-play-row-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.tfp-renderer-timeline {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    height: 24px;
    align-items: center;
}

.tfp-timeline-spacer {
    width: 30px;
    /* Aligns with track labels */
    flex-shrink: 0;
    border-right: 1px solid #ddd;
    height: 100%;
}

.tfp-renderer-measure-num {
    flex: 1;
    text-align: left;
    padding-left: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #6c757d;
    border-right: 1px dashed #dee2e6;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Track Wrapper */
.tfp-renderer-track-wrapper {
    display: flex;
    border-bottom: 1px solid #eee;
}

.tfp-renderer-track-wrapper:last-child {
    border-bottom: none;
}

.tfp-track-label {
    width: 30px;
    flex-shrink: 0;
    background: #f1f3f5;
    color: #495057;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #ddd;
    font-size: 14px;
}

.tfp-track-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Layers / Rows inside track */
.tfp-renderer-layer {
    display: grid;
    min-height: 55px;
    border-bottom: 1px solid #f1f1f1;
    background-image: linear-gradient(to right, #eee 1px, transparent 1px);
    background-size: calc(100% / var(--tfp-grid-total, 16)) 100%;
}

.tfp-renderer-layer:last-child {
    border-bottom: none;
}

/* Slots */
.tfp-renderer-slot {
    display: flex;
    flex-direction: column;
    position: relative;
    /* Removed border-right to use container grid instead */
    box-sizing: border-box;
    min-width: 0;
    /* Important for grid cells */
    transition: background-color 0.2s;
}

.tfp-renderer-slot.measure-start {
    border-left: 3px solid #333;
}

.tfp-renderer-slot.beat-marker {
    border-left: 1px solid #aaa;
}

.tfp-slot-inner {
    flex: 1;
    padding: 2px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent notes from expanding slot width */
}

/* Notes */
.tfp-renderer-note {
    flex: 1;
    border-radius: 4px;
    background: #ccc;
    /* Fallback */
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    line-height: 1.1;

    /* Variable color hook */
    background: var(--tfp-note-color, #f47c31);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.note-name {
    font-size: 18px;
}

.note-finger {
    font-size: 14px;
    opacity: 0.8;
}

/* Octave Colors */
.tfp-renderer-note[data-octave="1"] {
    --tfp-note-color: #f9bd3e;
}

.tfp-renderer-note[data-octave="2"] {
    --tfp-note-color: #a69b91;
}

.tfp-renderer-note[data-octave="3"] {
    --tfp-note-color: #5bb663;
}

.tfp-renderer-note[data-octave="4"] {
    --tfp-note-color: #8c629e;
}

.tfp-renderer-note[data-octave="5"] {
    --tfp-note-color: #f47c31;
}

.tfp-renderer-note[data-octave="6"] {
    --tfp-note-color: #00878e;
}

.tfp-renderer-note[data-octave="7"] {
    --tfp-note-color: #c1373d;
}

/* Ties & Continuations (Visual Shapes) */

/* Parent (Pointing Right) */
.tfp-renderer-note[data-continue="true"] {
    clip-path: polygon(0% 0%, calc(100% - 8px) 0%, 100% 50%, calc(100% - 8px) 100%, 0% 100%);
    padding-right: 10px;
}

/* Child (Dovetail Left) */
.tfp-renderer-note[data-is-tied="true"] {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 8px 50%);
    padding-left: 10px;
    opacity: 0.9;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    /* Visual subtle hint */
}

/* Both */
.tfp-renderer-note[data-is-tied="true"][data-continue="true"] {
    clip-path: polygon(0% 0%, calc(100% - 8px) 0%, 100% 50%, calc(100% - 8px) 100%, 0% 100%, 8px 50%);
}

/* Arpeggio */
.tfp-renderer-note[data-is-arpeggio="true"] {
    padding-left: 10px;
}

.tfp-renderer-note[data-is-arpeggio="true"]::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 3px;
    bottom: 3px;
    width: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 20'%3E%3Cpath d='M3 0 Q6 5 3 10 Q0 15 3 20' stroke='%23000' fill='none' stroke-width='2.5'/%3E%3C/svg%3E");
    background-repeat: repeat-y;
    background-size: 100% 10px;
}

/* Responsive */
@media (max-width: 600px) {
    .tfp-renderer-layer {
        height: 40px;
    }

    .tfp-renderer-measure-num {
        font-size: 8px;
    }

    .note-name {
        font-size: 12px;
    }

    .note-finger {
        display: none;
    }
}

/* ---------------------------------------------------------
   SONG PLAYER & GHOST HANDS
   --------------------------------------------------------- */

/* ---------------------------------------------------------
   WEB3 CONTAINER & HEADER
   --------------------------------------------------------- */
.tfp-web3-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

.tfp-web3-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 20px;
}

.tfp-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.tfp-section-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, #FF6B6B 0%, #d45d79 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

/* Badges */
.tfp-meta-badges {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tfp-badge {
    padding: 0 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    /* Fixed height for equality */
}

.tfp-badge .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tfp-badge-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
    margin-left: -6px;
}

.tfp-badge-icon-fallback {
    font-size: 24px !important;
    width: 24px !important;
    height: 24px !important;
}

/* Force Right Alignment in transport container if flex settings allow */
.tfp-meta-badges {
    margin-left: auto;
}

.tfp-song-description {
    width: 100%;
    margin-top: 15px;
    color: #444;
    /* Dark grey/black for better contrast on white, user asked for black so using #000 or very dark */
    color: #000;
    font-size: 0.95em;
    line-height: 1.5;
}

.tfp-song-description p {
    margin: 0;
}

.tfp-badge-diff {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.tfp-badge-style {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #000;
}

.tfp-badge-artist {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #444;
}

/* Controls (Header context removed, now generic) */
.tfp-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#tfp-player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Specific spacing when inside the Web3 container */
.tfp-web3-container #tfp-player-controls {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tfp-btn-play {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.tfp-btn-play:hover {
    background: #000;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.tfp-bpm-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #444;
    background: rgba(255, 255, 255, 0.5);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.tfp-bpm-adj {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: none;
    background: #fff;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.tfp-bpm-adj:hover {
    transform: scale(1.1);
}

#tfp-bpm-input {
    width: 45px;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: 800;
    font-size: 1.1em;
    color: #333;
    padding: 0;
    margin: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .tfp-web3-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tfp-header-right {
        width: 100%;
        justify-content: space-between;
    }

    #tfp-player-controls {
        width: 100%;
        justify-content: space-between;
    }
}

/* Ghost Hand Container */
.tfp-ghost-hand {
    position: absolute;
    top: 100%;
    /* Position below the keys */
    left: 0;
    width: 60px;
    /* Rough width of a hand span */
    height: 40px;
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: left 0.2s ease-out, transform 0.1s linear, opacity 0.2s;
    transform-origin: center center;
    margin-top: 10px;
    /* Slight gap below keys */
}

/* Fingers (Circles with Numbers) */
.tfp-gh-finger {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 2px solid transparent;
    transition: background 0.1s, transform 0.1s;
    /* Center Number */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

/* Palm Connection (Hidden as requested) */
.tfp-gh-palm {
    position: absolute;
    height: 4px;
    width: 100%;
    bottom: 5px;
    left: 0;
    background: currentColor;
    opacity: 0;
    display: none;
    border-radius: 4px;
}

/* Hand Specifics */
.tfp-ghost-hand.right {
    --hand-color: #4A90E2;
    color: var(--hand-color);
}

.tfp-ghost-hand.right .tfp-gh-finger {
    border-color: var(--hand-color);
}

.tfp-ghost-hand.left {
    --hand-color: #E24A4A;
    color: var(--hand-color);
}

.tfp-ghost-hand.left .tfp-gh-finger {
    border-color: var(--hand-color);
}

/* Finger Positions: RIGHT HAND (Thumb F1 is Leftmost) */
.right .tfp-gh-finger.f1 {
    left: 0px;
    bottom: 0px;
}

/* Thumb */
.right .tfp-gh-finger.f2 {
    left: 16px;
    bottom: 15px;
}

/* Index */
.right .tfp-gh-finger.f3 {
    left: 32px;
    bottom: 20px;
}

/* Middle */
.right .tfp-gh-finger.f4 {
    left: 48px;
    bottom: 12px;
}

/* Ring */
.right .tfp-gh-finger.f5 {
    left: 64px;
    bottom: 2px;
}

/* Pinky */

/* Finger Positions: LEFT HAND (Thumb F1 is Rightmost - Mirrored) */
.left .tfp-gh-finger.f5 {
    left: 0px;
    bottom: 2px;
}

/* Pinky */
.left .tfp-gh-finger.f4 {
    left: 16px;
    bottom: 12px;
}

/* Ring */
.left .tfp-gh-finger.f3 {
    left: 32px;
    bottom: 20px;
}

/* Middle */
.left .tfp-gh-finger.f2 {
    left: 48px;
    bottom: 15px;
}

/* Index */
.left .tfp-gh-finger.f1 {
    left: 64px;
    bottom: 0px;
}

/* Thumb */

/* Active Pressing State */
.tfp-gh-finger.pressing {
    background: var(--hand-color);
    color: #fff;
    transform: scale(1.2);
}

/* Active Piano Key Highlight */
.piano-key.active {
    filter: brightness(1.2);
    transform: translateY(2px);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4);
    background: var(--octave-color) !important;
}

.piano-key.black.active {
    filter: brightness(1.5);
    background: #333 !important;
}

/* --- Web3 / Glassmorphism Design System --- */
:root {
    --tfp-glass-bg: rgba(255, 255, 255, 0.65);
    --tfp-glass-border: rgba(255, 255, 255, 0.5);
    --tfp-glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --tfp-accent-primary: #4facfe;
    --tfp-accent-secondary: #00f2fe;
    --tfp-gradient-main: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --tfp-gradient-warm: linear-gradient(135deg, #fad961 0%, #f76b1c 100%);
    --tfp-text-dark: #1a1a1a;
    --tfp-text-muted: #666;
    --tfp-radius: 16px;
}

/* Container Layout */
#tfp-song-renderer-wrapper.tfp-web3-layout {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--tfp-text-dark);
}

/* Interactive Tab Container (Standardized Margin) */
.tfp-web3-container {
    margin-top: 40px !important;
    /* Ensure spacing matches blocks */
}

.tfp-web3-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    /* Equal spacing between grid items */
    margin-bottom: 40px;
    /* Equal spacing below grid */
}

@media (min-width: 768px) {
    .tfp-web3-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }

    .tfp-pdf-card,
    .tfp-media-split-row {
        grid-column: 1 / -1;
        /* PDF and Split Row take full width */
    }
}

/* Glass Card */
.tfp-glass-card {
    background: var(--tfp-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--tfp-glass-border);
    border-radius: var(--tfp-radius);
    box-shadow: var(--tfp-glass-shadow);
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tfp-glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.2);
}

.tfp-card-header {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 12px;
}

/* Custom Audio Player */
.tfp-custom-audio-player {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.tfp-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--tfp-gradient-main);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 242, 254, 0.3);
    transition: transform 0.2s;
}

.tfp-icon-btn:hover {
    transform: scale(1.05);
}

.tfp-icon-btn.small {
    width: 32px;
    height: 32px;
    background: #e0e0e0;
    color: #555;
    box-shadow: none;
}

.tfp-icon-btn.small:hover {
    background: #ccc;
}

.tfp-audio-progress-track {
    flex-grow: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

#tfp-audio-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--tfp-gradient-main);
    transition: width 0.1s linear;
}

#tfp-audio-time {
    font-size: 0.85em;
    font-variant-numeric: tabular-nums;
    color: var(--tfp-text-muted);
}

/* PDF Card & Viewport */
#tfp-flipbook-viewport {
    width: 100%;
    height: 600px;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    margin-bottom: 15px;
}

.tfp-flip-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.tfp-download-link {
    display: block;
    text-align: center;
    font-size: 0.9em;
    color: var(--tfp-accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.tfp-download-link:hover {
    text-decoration: underline;
}

/* Purchase Card */
.tfp-purchase-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.6);
    margin-bottom: 40px;
    /* Spacing below the unlock block */
}

.tfp-purchase-content {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.tfp-purchase-icon {
    font-size: 2.5em;
    color: #f76b1c;
    /* Orange accent */
    background: rgba(247, 107, 28, 0.1);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tfp-purchase-info {
    flex: 1;
    min-width: 200px;
}

.tfp-purchase-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.25em;
}

.tfp-purchase-info p {
    margin: 0;
    color: var(--tfp-text-muted);
    font-size: 0.95em;
}

.tfp-purchase-action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.tfp-cost-badge {
    font-weight: 700;
    font-size: 1.1em;
    color: #333;
}

.tfp-btn-gradient {
    background: var(--tfp-gradient-warm);
    border: none;
    padding: 12px 28px;
    border-radius: 30px;
    color: white;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(247, 107, 28, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tfp-btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 107, 28, 0.4);
}

/* Split Row Layout */
.tfp-media-split-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

@media (min-width: 768px) {
    .tfp-media-split-row {
        grid-template-columns: 2fr 1fr;
    }
}

/* Promo Card Styling */
.tfp-promo-card {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 255, 0.8));
    border: 1px solid rgba(79, 172, 254, 0.3);
    /* Subtle blue border */
}

.tfp-promo-content h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.2em;
}

.tfp-promo-content p {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.4;
}

.tfp-btn-gradient.small {
    padding: 8px 20px;
    font-size: 0.9em;
    text-decoration: none;
    display: inline-block;
}