/* problem-input.css - compact "segment stack" problem input (see js/problem-input.js) */

.pi {
    position: relative;
    display: block;
    margin-top: 3px;
}
.pi [hidden] { display: none !important; }

/* ---- committed rows ---- */
.pi-rows {
    list-style: none;
    margin: 0;
    padding: 0;
}
.pi-row { margin: 0; padding: 0; }
.pi-row-main {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 44px;
}
.pi .pi-text {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 6px 8px;
    border: 0;
    border-radius: calc(var(--radius, 16px) * 0.5);
    background: transparent;
    color: var(--text, #e6edf6);
    font: inherit;
    font-size: 16px;
    line-height: 1.35;
    text-align: left;
    cursor: text;
    box-shadow: none;
    transform: none;
}
.pi .pi-text:hover { background: var(--card2, rgba(12, 18, 34, 0.85)); }
.pi-tx {
    display: block;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.pi .pi-x {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted, #8a98ae);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
}
.pi .pi-x:hover { color: var(--text, #e6edf6); background: var(--card2, rgba(12, 18, 34, 0.85)); }

/* ---- divider + number badge between problems ---- */
.pi-div {
    position: relative;
    height: 14px;
    margin: 0 4px;
    pointer-events: none;
}
.pi-div::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px dashed var(--border-strong, rgba(148, 163, 184, 0.24));
}
.pi-num {
    position: absolute;
    left: 6px;
    top: 50%;
    min-width: 18px;
    height: 18px;
    margin-top: -9px;
    padding: 0 5px;
    border-radius: 9px;
    background: #0e1526; /* solid on purpose: the page behind is busy */
    background-color: var(--pi-list-bg, #0e1526);
    border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.24));
    color: var(--muted, #8a98ae);
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-sizing: border-box;
}

/* ---- live input + "+" ---- */
.pi-field {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 6px;
}
.pi input.pi-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    margin: 0;
    font-size: 16px;
    box-sizing: border-box;
}
.pi input.pi-input:focus-visible,
.pi input.pi-input:focus { outline: none; box-shadow: var(--focus-ring); }
.pi .pi-row-main input.pi-edit { flex: 1 1 auto; }
.pi .pi-add {
    flex: 0 0 auto;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    align-self: center;
    border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.24));
    border-radius: calc(var(--radius, 16px) * 0.6);
    background: var(--card2, rgba(12, 18, 34, 0.85));
    color: var(--accent, #38bdf8);
    font-size: 24px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.12s ease, opacity 0.12s ease;
}
.pi .pi-add:active { transform: scale(0.94); }
.pi .pi-add:focus-visible,
.pi .pi-text:focus-visible,
.pi .pi-x:focus-visible,
.pi .pi-undo:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---- suggestion dropdown (absolute: never pushes the page) ---- */
.pi-list {
    position: absolute;
    left: 0;
    right: 50px;
    top: 100%;
    z-index: 40;
    list-style: none;
    margin: 4px 0 0;
    padding: 4px;
    background: var(--card-solid, #111827);
    border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.24));
    border-radius: calc(var(--radius, 16px) * 0.6);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform-origin: top center;
    animation: pi-pop 0.12s ease-out;
}
.pi-opt {
    min-height: 44px;
    display: block; /* inline children (highlight spans) keep their spaces; flex collapsed them ("Printnotclear") */
    padding: 12px 10px;
    border-radius: calc(var(--radius, 16px) * 0.4);
    color: var(--text, #e6edf6);
    font-size: 15px;
    line-height: 1.3;
    cursor: pointer;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    -webkit-tap-highlight-color: transparent;
}
.pi-opt:hover,
.pi-opt.is-hi {
    background: rgba(56, 189, 248, 0.16);
    background: rgb(var(--pa-rgb) / 0.16);
}
.pi-opt.is-hi { box-shadow: inset 2px 0 0 var(--accent, #38bdf8); }
.pi-hl { color: var(--accent, #38bdf8); font-weight: 700; }

/* ---- status line (corrections / undo) ---- */
.pi-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 8px;
    min-height: 0;
    padding: 2px 4px 0;
    color: var(--muted, #8a98ae);
    font-size: 13px;
    line-height: 1.3;
    animation: pi-fade 0.15s ease-out;
}
.pi-status-text { overflow-wrap: anywhere; }
.pi .pi-undo {
    min-height: 44px;
    min-width: 44px;
    margin: -10px 0;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--accent, #38bdf8);
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    box-shadow: none;
}

@keyframes pi-pop {
    from { opacity: 0; transform: translateY(-4px) scaleY(0.96); }
    to   { opacity: 1; transform: none; }
}
@keyframes pi-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (max-width: 379px) {
    .pi-list { max-height: 192px; right: 0; }
}

@media (pointer: fine) {
    .pi .pi-x { width: 44px; height: 44px; min-height: 44px; font-size: 20px; }
    .pi-row-main { min-height: 44px; }
    .pi .pi-text { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .pi-list, .pi-status { animation: none; }
    .pi .pi-add { transition: none; }
    .pi .pi-add:active { transform: none; }
}

/* picked problem: green tick at the start of its row */
.pi .pi-tick {
    flex: none;
    width: 22px;
    height: 22px;
    margin-left: 6px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.18);
    color: #22c55e;
    font-size: 14px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
