/* tool.css - tool page styles */

/* Tool Pages */
.tool-page .navbar {
    margin-bottom: 1.25rem;
}

.tool-nav-actions {
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tool-shell {
    padding-bottom: 2rem;
}

.tool-hero {
    padding-bottom: 2rem;
}

.tool-band {
    padding: 0 0 2rem;
}

.tool-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: clamp(1.1rem, 2.4vw, 1.6rem);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    margin-bottom: 1.5rem;
}

.tool-section-head {
    margin-bottom: 1rem;
}

.tool-section h2 {
    font-size: 1.45rem;
    line-height: 1.2;
    margin-bottom: 0.55rem;
}

.tool-section p {
    color: var(--text-secondary);
    font-weight: 600;
    line-height: 1.65;
}

.tool-grid,
.solver-layout {
    display: grid;
    grid-template-columns: minmax(350px, 0.72fr) minmax(0, 1.28fr);
    gap: 1.25rem;
    align-items: stretch;
}

.tool-grid .tool-section {
    height: 100%;
    min-width: 0;
}

.solver-layout .tool-section {
    height: 100%;
    min-width: 0;
}

.solver-input-card {
    padding: clamp(0.95rem, 1.8vw, 1.25rem);
}

.solver-input-card .tool-section-head {
    margin-bottom: 0.75rem;
}

.solver-input-card .landing-kicker {
    margin-bottom: 0.45rem;
}

.solver-input-card h2 {
    font-size: clamp(1.18rem, 2vw, 1.35rem);
    margin-bottom: 0.45rem;
}

.solver-input-card .tool-section-head p:not(.landing-kicker) {
    font-size: 0.92rem;
    line-height: 1.38;
}

.solver-input-card .tool-button {
    min-height: 38px;
    padding: 0.48rem 0.82rem;
    font-size: 0.9rem;
}

.solver-input-card .solver-message {
    margin-top: 0.65rem;
    font-size: 0.9rem;
    line-height: 1.35;
}

.tool-steps {
    margin: 0;
    padding-left: 1.35rem;
    color: var(--text-primary);
    font-weight: 650;
    line-height: 1.75;
}

.tool-cta-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.tool-cta-card .btn-primary {
    margin-top: auto;
}

.editor-frame-wrap {
    width: 100%;
    min-height: 820px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    background: #0f172a;
    overflow: hidden;
}

.editor-frame {
    display: block;
    width: 100%;
    height: clamp(820px, 92vh, 1120px);
    border: 0;
    background: #111827;
}

.tool-empty-state {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    color: var(--text-secondary);
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-md);
    font-weight: 700;
    text-align: center;
}

.solver-textarea {
    width: 100%;
    min-height: 230px;
    resize: vertical;
    border: 2px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 0.85rem 0.9rem;
    background: #f8fafc;
    color: var(--text-primary);
    font: 650 0.9rem/1.48 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    outline: none;
}

.solver-textarea:focus {
    border-color: var(--accent-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 119, 182, 0.12);
}

.solver-example-wrap {
    position: relative;
}

.solver-example-help {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #93c5fd;
    border-radius: 50%;
    background: #eff6ff;
    color: #1d4ed8;
    font: 800 1rem/1 var(--font-main);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
    cursor: pointer;
}

.solver-example-help:hover,
.solver-example-help[aria-expanded="true"] {
    background: #dbeafe;
    border-color: #60a5fa;
}

.solver-example-help[hidden],
.solver-example-popover[hidden] {
    display: none;
}

.solver-example-popover {
    position: absolute;
    right: 12px;
    bottom: 54px;
    z-index: 2;
    width: min(360px, calc(100% - 24px));
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #ffffff;
    color: #1e3a8a;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.solver-example-popover p {
    margin: 0;
}

.solver-example-popover p + p {
    margin-top: 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.75rem;
}

.tool-button {
    min-height: 42px;
    padding: 0.58rem 1rem;
    font-size: 0.95rem;
    border-radius: var(--radius-full);
}

button.nav-link-pill {
    cursor: pointer;
}

button:disabled,
.tool-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.solver-message {
    min-height: 1.5rem;
    margin-top: 0.75rem;
    font-weight: 750;
}

.solver-message.is-success {
    color: #15803d;
}

.solver-message.is-error {
    color: #b91c1c;
}

.bottle-preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.8rem;
    align-items: end;
    min-height: 190px;
}

.bottle-preview.position-row-preview {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.position-bottle-row {
    display: flex;
    align-items: end;
    justify-content: space-around;
    gap: clamp(0.55rem, 1.5vw, 1rem);
    width: 100%;
}

.position-bottle-row .bottle-card {
    flex: 0 0 52px;
}

.position-row-preview .bottle-card {
    gap: 0.3rem;
}

.position-row-preview .bottle-glass {
    width: 40px;
    height: 92px;
    border-width: 2px;
    border-radius: 0 0 0.8rem 0.8rem;
}

.position-row-preview .bottle-label {
    min-width: 22px;
    min-height: 20px;
    font-size: 0.78rem;
}

.bottle-card {
    display: grid;
    justify-items: center;
    gap: 0.38rem;
}

.bottle-glass {
    width: min(56px, 100%);
    height: 145px;
    display: grid;
    grid-template-rows: repeat(var(--capacity), minmax(0, 1fr));
    overflow: hidden;
    border: 3px solid #94a3b8;
    border-top: 0;
    border-radius: 0 0 1.25rem 1.25rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(241,245,249,0.92));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.75), 0 10px 20px rgba(15,23,42,0.08);
}

.bottle-layer {
    min-height: 0;
    border-top: 1px solid rgba(255,255,255,0.68);
}

.bottle-layer.is-liquid {
    cursor: pointer;
    transition: box-shadow .16s ease, filter .16s ease;
}

.bottle-layer.is-liquid:hover {
    filter: brightness(1.06);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.9);
}

.bottle-layer.is-selected-color {
    box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px #0ea5e9;
    z-index: 1;
}

.bottle-layer.empty {
    background: transparent;
}

.bottle-label {
    min-width: 28px;
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 800;
    font-size: 0.92rem;
}

.color-editor-tip {
    margin-top: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.45;
}

.share-solver-note {
    margin: 0.65rem 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.45;
}

.guide-replay-callout {
    margin-top: 1rem;
}

.guide-replay-callout .landing-actions {
    margin-top: 0.8rem;
}

.guide-replay-note {
    margin: 0.65rem 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.45;
}

.color-tool-details,
.color-count-check {
    margin-top: 0.7rem;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.65rem 0.75rem;
}

.color-tool-details summary,
.color-count-check summary {
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 850;
}

.color-count-check.has-warning {
    border-color: #fbbf24;
    background: #fffbeb;
}

.color-ids-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.65rem;
}

.color-tool-empty {
    min-height: 44px;
    padding: 0.6rem;
    font-size: 0.9rem;
}

.color-id-row {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 800;
    padding: 0.3rem 0.65rem;
}

.color-id-swatch {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 50%;
    border: 1px solid rgba(15,23,42,0.22);
}

.color-count-rows {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.65rem;
    color: var(--text-secondary);
    font-weight: 750;
}

.color-count-row.is-warning {
    color: #b45309;
}

.color-popover {
    position: absolute;
    z-index: 1000;
    width: min(270px, calc(100vw - 24px));
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
    padding: 0.85rem;
}

.color-popover[hidden] {
    display: none;
}

.color-popover h3 {
    margin: 0 0 0.25rem;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.25;
}

.color-popover p {
    margin: 0 0 0.7rem;
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 700;
}

.color-popover-input {
    width: 100%;
    height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    padding: 0.25rem;
}

.color-popover-swatches {
    display: grid;
    grid-template-columns: repeat(6, minmax(28px, 1fr));
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.color-swatch-button {
    width: 100%;
    min-width: 28px;
    min-height: 28px;
    border: 1px solid rgba(15,23,42,0.24);
    border-radius: 8px;
    cursor: pointer;
}

.share-solution-popover {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.36);
    padding: 1rem;
}

.share-solution-popover[hidden] {
    display: none;
}

.share-solution-panel {
    width: min(560px, 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
    padding: 1rem;
}

.share-solution-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.share-solution-head h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.15rem;
    line-height: 1.25;
}

.share-solution-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-full);
    background: #eef2f7;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 900;
}

.share-solution-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text-primary);
    font: 650 0.9rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 0.75rem;
}

.share-solution-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.share-solution-status {
    min-height: 1.2em;
    margin: 0.65rem 0 0;
    color: #b91c1c;
    font-weight: 750;
}

.share-replay-page .share-replay-hero {
    padding-bottom: 1.25rem;
}

.share-replay-shell {
    margin-top: 1.25rem;
}

.share-step-player {
    padding: 0;
}

.share-replay-actions {
    margin-top: 1rem;
    align-items: center;
}

.share-replay-actions .tool-button {
    min-width: 0;
}

.solution-output {
    min-height: 160px;
    margin-top: 1rem;
    padding: 1rem;
    white-space: pre-wrap;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid #cbd5e1;
    background: #0f172a;
    color: #e2e8f0;
    font: 650 0.95rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.solution-output.is-two-column {
    white-space: normal;
}

.solution-output.has-visual-player {
    padding: 0;
    white-space: normal;
    overflow: visible;
    border-color: #dbe3ef;
    background: #ffffff;
    color: var(--text-primary);
    font: inherit;
}

.solution-output.share-solution-output {
    min-height: 240px;
    white-space: normal;
    overflow: visible;
    border-color: #dbe3ef;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
}

.share-solution-output .move-list-title {
    color: #0f172a;
}

.visual-step-player {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    overflow-anchor: none;
}

.visual-step-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
}

.visual-step-head h3,
.move-list-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.15rem;
    line-height: 1.25;
}

.visual-step-progress {
    display: none;
    flex: 0 0 auto;
    border-radius: var(--radius-full);
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 850;
    padding: 0.28rem 0.7rem;
}

.visual-step-preview {
    min-height: 180px;
    overflow-anchor: none;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #f8fafc;
    padding: 1rem;
}

.visual-current-move {
    height: 72px;
    display: flex;
    align-items: center;
    overflow: auto;
    overflow-anchor: none;
    border-left: 4px solid #38bdf8;
    background: #f0f9ff;
    border-radius: 8px;
    color: #075985;
    font-weight: 850;
    line-height: 1.45;
    padding: 0.75rem 0.85rem;
}

.visual-player-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
}

.visual-player-controls .tool-button {
    margin-top: 0;
}

.visual-invalid-message {
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-weight: 850;
    padding: 0.7rem 0.85rem;
}

.visual-move-list {
    display: grid;
    gap: 0.45rem;
    max-height: 300px;
    overflow-y: auto;
    overflow-anchor: none;
    overscroll-behavior: contain;
    padding-right: 0.25rem;
}

.visual-move-row {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
    font: 750 0.94rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-align: left;
    padding: 0.6rem 0.75rem;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.visual-move-row:hover {
    border-color: #60a5fa;
    background: #e0f2fe;
    color: #082f49;
}

.visual-move-row.is-active {
    border-color: #1d4ed8;
    background: #bfdbfe;
    color: #0f172a;
    box-shadow: inset 4px 0 0 #1d4ed8;
}

.visual-move-row.is-invalid {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #991b1b;
}

.visual-move-row:disabled {
    cursor: not-allowed;
    opacity: 0.75;
}

.solution-header {
    margin-bottom: 1.1rem;
    white-space: pre-wrap;
}

.solution-steps-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 2rem;
}

.solution-steps-column {
    display: grid;
    gap: 0.36rem;
    min-width: 0;
}

.solution-step-row {
    white-space: nowrap;
}

.solver-faq {
    display: grid;
    gap: 0.8rem;
}

.solver-faq details {
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.9rem 1rem;
}

.solver-faq summary {
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 800;
}

.solver-faq p {
    margin: 0.65rem 0 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.tool-links-panel {
    margin-top: 0;
}

.home-structured-modules {
    display: grid;
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.home-link-module {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.home-link-module .section-heading-row {
    margin-bottom: 0.6rem;
}

.home-link-module-desc {
    color: var(--text-secondary);
    margin-bottom: 0.9rem;
}

.home-link-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.home-link-card {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 14px;
    padding: 0.65rem;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.home-link-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
    transform: translateY(-1px);
}

.home-link-card-media {
    width: 64px;
    height: 64px;
    flex: 0 0 64px;
    border-radius: 12px;
    overflow: hidden;
    background: #e2e8f0;
}

.home-link-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.home-link-card-type {
    display: inline-block;
    font-size: .74rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #1d4ed8;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    margin-bottom: 0.28rem;
}

.home-link-card h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.home-link-card p {
    color: var(--text-secondary);
    font-size: .88rem;
    line-height: 1.35;
}

@media (max-width: 900px) {
    .tool-nav-actions {
        display: none;
    }

    .tool-grid,
    .solver-layout {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .solver-layout .tool-section {
        height: auto;
    }

    .solution-steps-grid {
        grid-template-columns: 1fr;
    }

    .solution-step-row {
        white-space: pre-wrap;
    }

    .visual-step-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .editor-frame-wrap {
        min-height: 760px;
        margin-left: -0.35rem;
        margin-right: -0.35rem;
    }

    .editor-frame {
        height: 760px;
    }

    .home-link-card-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 520px) {
    .tool-section {
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    .tool-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .tool-button,
    .tool-actions .nav-link-pill,
    .tool-actions .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .visual-player-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .visual-player-controls .tool-button,
    .visual-player-controls .nav-link-pill,
    .visual-player-controls .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .solver-textarea {
        min-height: 220px;
        font-size: 0.88rem;
    }

    .bottle-preview {
        grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
        gap: 0.6rem;
    }

    .bottle-preview.position-row-preview {
        overflow-x: auto;
        padding-bottom: 0.35rem;
    }

    .position-bottle-row {
        min-width: 360px;
        gap: 0.55rem;
    }

    .position-bottle-row .bottle-card {
        flex-basis: 44px;
    }

    .position-row-preview .bottle-glass {
        width: 36px;
        height: 82px;
    }

    .position-row-preview .bottle-label {
        min-width: 20px;
        min-height: 18px;
        font-size: 0.74rem;
    }

    .bottle-glass {
        width: 46px;
        height: 122px;
    }

    .editor-frame-wrap {
        min-height: 720px;
    }

    .editor-frame {
        height: 720px;
    }
}

