/* === Guided Nomenclature Styles === */

/* --- Molecule Selector --- */
#molecule-selector {
    text-align: center;
    margin: 0.5em 0;
}

#molecule-select {
    font-size: 0.95rem;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    max-width: 300px;
}

/* --- Name Strip (progressive build) --- */
#name-strip {
    max-width: 400px;
    margin: 0.5em auto;
    height: 62px;
    padding: 6px 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

#name-strip-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    align-items: center;
    min-height: 28px;
}

#name-strip-tiles:empty::before {
    content: "Name builds here as you go";
    color: #adb5bd;
    font-style: italic;
    font-size: 0.85rem;
}

.name-tile {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1.5px solid transparent;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Tile appears with a pop animation */
.name-tile.entering {
    animation: tile-pop 0.4s ease;
}

@keyframes tile-pop {
    0% { opacity: 0; transform: scale(0.5); }
    60% { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

/* Tile colors — matched to Wong colorblind-safe step colors */
/* Vermillion (#D55E00) = step 0 FG (suffix) */
.name-tile[data-type="suffix"] { background: rgba(213, 94, 0, 0.12); border-color: #D55E00; color: #8a3c00; }
/* Blue (#0072B2) = step 1 parent (root, ring) */
.name-tile[data-type="root"] { background: rgba(0, 114, 178, 0.12); border-color: #0072B2; color: #004a75; }
.name-tile[data-type="ring"] { background: rgba(0, 114, 178, 0.12); border-color: #0072B2; color: #004a75; }
/* Orange (#E69F00) = step 2 substituents */
.name-tile[data-type="substituent"] { background: rgba(230, 159, 0, 0.12); border-color: #E69F00; color: #7a5400; }
.name-tile[data-type="multiplier"] { background: rgba(230, 159, 0, 0.12); border-color: #E69F00; color: #7a5400; }
/* Bluish green (#009E73) = step 3 numbering (locants, connectors) */
.name-tile[data-type="locant"] { background: rgba(0, 158, 115, 0.12); border-color: #009E73; color: #005c43; }
.name-tile[data-type="connector"] { background: rgba(0, 158, 115, 0.08); border-color: #009E73; color: #005c43; }

/* Placeholder tile (not yet revealed) */
.name-tile.placeholder {
    background: #f0f0f0;
    border-color: #ddd;
    color: #ccc;
}

/* Name complete state */
#name-strip.complete {
    border-color: #2a9d8f;
    background: #f0faf8;
}

/* --- Molecule Display Area (smaller) --- */
#molecule-area {
    position: relative;
    width: 380px;
    height: 300px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: white;
    margin: 0.5em auto;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
}

#mol-container {
    width: 100%;
    height: 100%;
}

#mol-container svg {
    width: 100%;
    height: 100%;
}

#selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* --- Atom hit targets --- */
.atom-hit-target {
    fill: transparent;
    stroke: none;
    pointer-events: all;
    cursor: pointer;
}

/* Per-step hover colors (Wong colorblind-safe) */
/* 0=FG (vermillion), 1=parent (blue), 2=substituents (orange), 3=numbering (green) */
#molecule-area[data-step="0"] .atom-hit-target:hover { fill: rgba(213, 94, 0, 0.12); }
#molecule-area[data-step="1"] .atom-hit-target:hover { fill: rgba(0, 114, 178, 0.12); }
#molecule-area[data-step="2"] .atom-hit-target:hover { fill: rgba(230, 159, 0, 0.12); }
#molecule-area[data-step="3"] .atom-hit-target:hover { fill: rgba(0, 158, 115, 0.12); }

/* --- Selection indicators (colors set inline per step) --- */
.selected-atom {
    pointer-events: none;
}

.confirmed-atom {
    stroke-width: 1.5;
    opacity: 0.35;
    pointer-events: none;
}

/* Bond highlighting */
.selected-bond {
    stroke: #6153cc;
    stroke-width: 3;
    stroke-opacity: 0.4;
    pointer-events: none;
}

/* Bond highlighting during selection (color set inline per step) */
.selected-bond {
    stroke-width: 12;
    stroke-opacity: 0.35;
    fill: none;
    pointer-events: none;
    stroke-linecap: round;
}

.confirmed-bond {
    stroke: #0072B2;  /* blue = parent framework */
    stroke-width: 12;
    stroke-opacity: 0.12;
    fill: none;
    pointer-events: none;
    stroke-linecap: round;
}

/* Direction choice pulsing indicators */
.direction-choice {
    fill: rgba(255, 165, 0, 0.25);
    stroke: #e67e22;
    stroke-width: 2.5;
    pointer-events: all;
    cursor: pointer;
    animation: pulse-direction 1.2s ease-in-out infinite;
}

@keyframes pulse-direction {
    0%, 100% { stroke-opacity: 0.5; fill-opacity: 0.15; }
    50% { stroke-opacity: 1; fill-opacity: 0.35; }
}

/* FG/substituent identification labels */
.fg-label {
    fill: #D55E00;
    font-family: 'Segoe UI', Arial, sans-serif;
    opacity: 0.7;
}

.subst-label {
    fill: #E69F00;
    font-family: 'Segoe UI', Arial, sans-serif;
    opacity: 0.7;
}

/* Numbering labels */
.ring-number-label, .chain-number-label {
    fill: #009E73;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-weight: 700;
    pointer-events: none;
}

/* --- Card Carousel --- */
#card-carousel {
    position: relative;
    width: 380px;
    margin: 0.5em auto;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1;
}

#arrow-left { left: -40px; }
#arrow-right { right: -40px; }

.carousel-arrow:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #999;
}

.carousel-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

#card-viewport {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.step-card {
    padding: 8px 12px;
    text-align: center;
    display: none;
}

.step-card.visible {
    display: block;
    animation: card-fade-in 0.3s ease;
}

@keyframes card-fade-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.step-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin-bottom: 2px;
}

.step-prompt {
    font-size: 0.95rem;
    font-weight: 600;
    color: #444;
    line-height: 1.4;
    white-space: normal;
}

/* Completed step cards */
.step-card.done .step-prompt {
    color: #2a9d8f;
}

.step-card.done .step-prompt::before {
    content: "\2713 ";
}

/* --- Next button (on mol-container) --- */
#next-btn {
    position: absolute;
    bottom: 8px;
    right: 10px;
    padding: 6px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    z-index: 2;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    background-color: #009E73;
    color: #fff;
}

#next-btn:disabled {
    opacity: 0.25;
    cursor: default;
    background-color: #999;
}

#next-btn:not(:disabled):hover {
    background-color: #007a5a;
}

#next-btn.pulse {
    animation: next-pulse 0.8s ease 2;
}

@keyframes next-pulse {
    0%, 100% { transform: scale(1); box-shadow: none; }
    50% { transform: scale(1.1); box-shadow: 0 0 12px rgba(0, 158, 115, 0.5); }
}

/* Step-confirmed flash on mol-container */
#molecule-area.step-flash {
    animation: step-flash 0.6s ease;
}

@keyframes step-flash {
    0% { box-shadow: inset 0 0 0 4px rgba(0, 158, 115, 0.6); }
    100% { box-shadow: inset 0 0 0 4px rgba(0, 158, 115, 0); }
}

/* --- Controls --- */
#game-controls {
    margin: 0.5em 0;
    text-align: center;
}

#primary-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

#secondary-controls {
    margin-top: 4px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

#skip-btn {
    background-color: #bbc8ca;
    min-width: 100px;
}

#skip-btn.next-ready {
    background-color: #333;
}

#reveal-link {
    display: block;
    text-align: center;
    margin: 0.4em 0;
    font-size: 0.9rem;
    color: #6c757d;
}

#reveal-link.disabled {
    color: #ccc;
    pointer-events: none;
    text-decoration: none;
}

#compound-cid {
    display: block;
    text-align: center;
    color: #adb5bd;
    margin: 0.25em 0;
}

.score-container-local {
    text-align: center;
    margin: 0.5em 0;
}

/* --- Feedback (inside mol-container) --- */
#feedback-message {
    position: absolute;
    top: 6px;
    left: 10px;
    right: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    z-index: 2;
    pointer-events: none;
}

#feedback-message:empty {
    display: none;
}

/* --- Feedback indicators --- */
.atom-correct {
    fill: rgba(42, 157, 143, 0.2);
    stroke: #2a9d8f;
    stroke-width: 2.5;
    pointer-events: none;
}

.atom-missed {
    fill: none;
    stroke: #d32f2f;
    stroke-width: 2.5;
    stroke-dasharray: 5 3;
    pointer-events: none;
}

.atom-wrong {
    fill: rgba(211, 47, 47, 0.15);
    stroke: #d32f2f;
    stroke-width: 2.5;
    pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 500px) {
    #molecule-area {
        width: 100%;
        height: 240px;
    }

    #card-carousel {
        max-width: 100%;
    }

    .name-tile {
        padding: 2px 6px;
        font-size: 0.8rem;
    }
}
