/* ══════════════════════════════════════════════════════════════
   DIALOGUE BOX - 1930s cartoon style with character portraits
   ══════════════════════════════════════════════════════════════ */

.dialogue-container {
    position: absolute;
    bottom: 3%;
    left: 3%;
    right: 3%;
    z-index: 100;
    pointer-events: none;
    overflow: visible; /* Allow portrait to overflow */
}

.dialogue-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: linear-gradient(180deg, #f8f0e0 0%, #ece0c8 100%);
    border: 4px solid #4a3728;
    border-radius: 16px;
    padding: 14px 16px 14px 70px; /* Left padding for text after portrait */
    margin-left: 55px; /* Space for portrait overflow */
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.4),
        0 6px 20px rgba(40, 30, 20, 0.4);
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
    pointer-events: none;
    position: relative;
    overflow: visible; /* Allow portrait to overflow */
}

.dialogue-box.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Character portrait - large, overlapping outside the dialogue box */
.dialogue-portrait {
    position: absolute;
    left: -55px;
    top: 50%;
    transform: translateY(-50%);
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 5px solid #4a3728;
    background: linear-gradient(180deg, #fffbe6 0%, #f0e4c8 100%);
    overflow: hidden;
    box-shadow:
        inset 0 3px 6px rgba(255,255,255,0.4),
        0 6px 16px rgba(40, 30, 20, 0.4),
        0 0 0 3px rgba(255,248,220,0.5);
    z-index: 15;
}

.dialogue-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
}

/* Text content area */
.dialogue-content {
    flex: 1;
    min-width: 0;
}

/* Art deco corner accents */
.dialogue-box::before,
.dialogue-box::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #8b7355;
    border-radius: 2px;
}

.dialogue-box::before {
    top: 5px;
    right: 5px;
    border-left: none;
    border-bottom: none;
}

.dialogue-box::after {
    bottom: 5px;
    right: 5px;
    border-left: none;
    border-top: none;
}

.dialogue-speaker {
    font-weight: bold;
    font-size: 13px;
    color: #4a3728;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dialogue-text {
    font-size: 13px;
    color: #5a4738;
    line-height: 1.45;
    font-style: italic;
}

.tap-hint {
    text-align: right;
    font-size: 13px;
    color: #a08060;
    margin-top: 6px;
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   SILENT FILM INTERTITLE STYLE - Alternative dialogue look
   Add class "silent-film" to dialogue-box for this style
   ══════════════════════════════════════════════════════════════ */

.dialogue-box.silent-film {
    background: linear-gradient(180deg, #1a1612 0%, #2a2420 50%, #1a1612 100%);
    border: 6px solid #3a3025;
    border-radius: 8px;
    padding: 20px 24px 16px 80px;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.5),
        0 8px 24px rgba(0, 0, 0, 0.6);
}

/* Film sprocket holes on sides */
.dialogue-box.silent-film::before,
.dialogue-box.silent-film::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 100%;
    top: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 8px,
        #0a0806 8px,
        #0a0806 16px,
        transparent 16px,
        transparent 24px
    );
    border: none;
    border-radius: 0;
}

.dialogue-box.silent-film::before {
    left: 4px;
}

.dialogue-box.silent-film::after {
    right: 4px;
    bottom: auto;
}

/* Decorative inner frame */
.dialogue-box.silent-film .dialogue-content {
    border: 2px solid #5a4a3a;
    border-radius: 4px;
    padding: 12px 16px;
    background: linear-gradient(180deg, #1e1a16 0%, #242018 100%);
}

.dialogue-box.silent-film .dialogue-speaker {
    color: #e8dcc0;
    font-size: 13px;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 8px;
    border-bottom: 1px solid #4a3a2a;
    padding-bottom: 6px;
}

.dialogue-box.silent-film .dialogue-text {
    color: #f0e8d8;
    font-size: 14px;
    font-style: normal;
    text-align: center;
    line-height: 1.6;
    font-family: 'Times New Roman', Georgia, serif;
}

.dialogue-box.silent-film .tap-hint {
    color: #8a7a60;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

/* Portrait adjustments for silent film style */
.dialogue-box.silent-film .dialogue-portrait {
    border-color: #3a3025;
    background: #1a1612;
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.5),
        0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ══════════════════════════════════════════════════════════════
   SPEECH BUBBLE INDICATORS - Cuphead-style PNG thought bubbles
   Positioned right next to character faces
   ══════════════════════════════════════════════════════════════ */

/* Speech indicators: NEVER fully hidden after init. Two visual states:
   .has-new  = animated pulse, full opacity (unseen lines exist)
   .resting  = static, smaller, muted (all lines seen, still tappable)
   .visible  = base visibility (always applied after init) */

.speech-indicator {
    position: absolute;
    width: 40px !important;
    max-width: 40px !important;
    height: auto;
    z-index: 25;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    cursor: pointer;
}

/* Base visible state - always tappable once initialized */
.speech-indicator.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* New dialogue available - animated pulse, full brightness */
.speech-indicator.visible.has-new {
    opacity: 1;
    transform: scale(1);
    animation: thought-pulse-gentle 2.5s ease-in-out infinite;
}

/* Resting state - static, smaller, muted but still tappable */
.speech-indicator.visible.resting {
    opacity: 0.45;
    transform: scale(0.75);
    animation: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1)) grayscale(0.3);
}

/* Locked characters: faint speech bubble hinting at future unlock */
.speech-indicator.locked {
    visibility: visible;
    opacity: 0.2;
    transform: scale(0.6);
    animation: none;
    filter: grayscale(1) brightness(0.7);
    pointer-events: auto;
    cursor: pointer;
}

@keyframes thought-pulse-gentle {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

/* Per-stage speech indicator positions
   HEAD CENTER positions (from screenshot_grid_overlay.png):
   - Worm head: 26%, 53%
   - Sunny head: 37%, 25%
   - Crow head: 51%, 32%
   Bubbles: bottom 3% above head, left edge 4% right of head center */

/* Worm - head at (26%, 53%), bubble bottom 50%, left 30% */
.stage-1 .worm-speech,
.stage-2 .worm-speech { top: 31%; left: 29%; }
.stage-3 .worm-speech,
.stage-4 .worm-speech { top: 33%; left: 30%; }

/* Sunny - head at (37%, 25%), bubble bottom 22%, left 41% */
.stage-1 .sunny-speech,
.stage-2 .sunny-speech { top: 3%; left: 40%; }
.stage-3 .sunny-speech,
.stage-4 .sunny-speech { top: 5%; left: 41%; }

/* Crow - head at (51%, 32%), bubble bottom 29%, left 55% */
.stage-1 .crow-speech,
.stage-2 .crow-speech { top: 10%; left: 54%; }
.stage-3 .crow-speech,
.stage-4 .crow-speech { top: 12%; left: 55%; }

/* Stage 3-4 zoom-out: scale speech bubbles to match smaller characters */
.stage-3 .speech-indicator.visible,
.stage-4 .speech-indicator.visible {
    transform: scale(0.7);
}
.stage-3 .speech-indicator.visible.has-new,
.stage-4 .speech-indicator.visible.has-new {
    animation: thought-pulse-gentle-small 2.5s ease-in-out infinite;
}
.stage-3 .speech-indicator.visible.resting,
.stage-4 .speech-indicator.visible.resting {
    transform: scale(0.55);
}
.stage-3 .speech-indicator.locked,
.stage-4 .speech-indicator.locked {
    transform: scale(0.45);
}

@keyframes thought-pulse-gentle-small {
    0%, 100% { transform: scale(0.7); }
    50% { transform: scale(0.76); }
}
