/* Opening Library: a Linear-style row list. Flat rows split by 1px hairlines, no boxed panels. */

.openings-page {
    max-width: 1280px;
    padding: var(--space-6) var(--space-6) var(--space-10);
}

/* One header row: title, side toggle, summary, filter on the right */
.openings-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
}

.openings-header h1 {
    margin: 0;
    font-size: var(--fs-2xl);
}

.openings-header .openings-tabs {
    margin-bottom: 0;
}

.progress-row {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    min-width: 0;
    font-size: var(--fs-sm);
    color: var(--ink-2);
}

.progress-text {
    color: var(--ink-2);
    font-family: var(--font);
}

.progress-figure b {
    font-weight: 500;
    color: var(--ink);
}

.progress-figure + .progress-figure::before {
    content: "\00b7";
    margin-right: var(--space-3);
    color: var(--ink-3);
}

.progress-figure.due b {
    color: var(--yellow);
}

.openings-filter {
    flex: 0 1 260px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 32px;
    padding: 0 var(--space-3);
    border: 1px solid var(--hair-strong);
    border-radius: var(--radius-ctl);
    color: var(--ink-3);
}

.openings-filter:focus-within {
    border-color: var(--blue-line);
}

.openings-filter input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: var(--fs-sm);
    outline: none;
}

.openings-filter input::placeholder {
    color: var(--ink-3);
}

/* The list: each row is a hairline-separated strip */
.openings-grid {
    border-top: 1px solid var(--hair);
}

.opening-row {
    border-bottom: 1px solid var(--hair);
}

.row-main {
    display: grid;
    grid-template-columns: 24px 88px minmax(0, 1fr) 260px 32px 96px;
    align-items: center;
    column-gap: var(--space-3);
    padding: var(--space-3) var(--space-2);
}

.opening-row .row-main:hover {
    background: var(--surface);
}

.row-chevron {
    display: grid;
    place-items: center;
    width: 24px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-ctl);
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
}

.row-chevron:hover {
    color: var(--ink);
}

.row-chevron svg {
    transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.row-chevron[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

.row-chevron:focus-visible,
.track-toggle:focus-visible,
.cell-board-link:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* The board diagram opens the opening */
.cell-board-link {
    width: 88px;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

.cell-board-link:disabled {
    cursor: default;
}

.cell-board {
    width: 88px;
    border-width: 1px;
    transition: border-color 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cell-board .fc-sq {
    cursor: inherit;
}

.cell-board-link:hover:not(:disabled) .cell-board {
    border-color: var(--blue);
}

.cell-main {
    min-width: 0;
}

.cell-code {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    min-width: 0;
}

.opening-eco {
    flex: none;
    font-size: var(--fs-sm);
    color: var(--ink-2);
}

.opening-name {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recommended-badge {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--blue);
}

.opening-summary {
    margin: 2px 0 0;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Known / total bar, the due part in amber */
.cell-progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.known-bar {
    flex: 1 1 auto;
    display: flex;
    min-width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--hair-strong);
    overflow: hidden;
}

.known-fill {
    display: block;
    background: var(--ink-2);
}

.due-fill {
    display: block;
    background: var(--yellow);
}

.known-count {
    flex: none;
    font-size: var(--fs-xs);
    color: var(--ink-2);
    white-space: nowrap;
}

.progress-none {
    font-size: var(--fs-xs);
    color: var(--ink-3);
}

.due-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 999px;
    color: var(--yellow);
    font-size: var(--fs-xs);
    font-weight: 500;
    white-space: nowrap;
}

/* Track toggle: a star at the end of the row */
.track-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 0;
    color: var(--ink-3);
    cursor: pointer;
    transition: color 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.track-toggle svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linejoin: round;
}

.track-toggle:hover,
.track-toggle.tracked {
    color: var(--blue);
}

.track-toggle.tracked svg {
    fill: currentColor;
}

.row-main .open-button {
    width: 100%;
}

/* Inline lines: sub-rows under the opening */
.cell-lines {
    padding: 0 var(--space-2) var(--space-3) calc(24px + 88px + 2 * var(--space-3) + var(--space-2));
}

.lines-empty {
    margin: var(--space-3) 0 0;
    color: var(--ink-2);
}

.line-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.line-row {
    display: grid;
    grid-template-columns: minmax(160px, 300px) minmax(0, 1fr) 96px auto;
    align-items: center;
    column-gap: var(--space-4);
    min-height: 40px;
    padding: var(--space-1) 0;
    border-top: 1px solid var(--hair);
}

.line-info {
    display: contents;
}

.line-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-size: var(--fs-sm);
}

.line-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.line-idea {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
    font-size: var(--fs-xs);
}

.line-moves {
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-2);
    font-size: var(--fs-xs);
}

.line-status {
    grid-column: 3;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 1px var(--space-2);
    border: 1px solid var(--hair-strong);
    border-radius: 999px;
    color: var(--ink-2);
    font-size: var(--fs-xs);
}

/* One status language: a small dot plus a word, coloured by state */
.status-dot {
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.line-status.unseen {
    color: var(--ink-3);
}

.line-status.due {
    color: var(--yellow);
    border-color: rgba(251, 191, 36, 0.35);
}

.line-status.learning {
    color: var(--blue);
    border-color: var(--blue-line);
}

.line-status.learned {
    color: var(--green);
    border-color: rgba(74, 222, 128, 0.35);
}

.line-actions {
    grid-column: 4;
    display: flex;
    gap: var(--space-3);
}

.line-btn {
    padding: 6px var(--space-1);
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
}

.line-btn:hover {
    color: var(--ink);
}

.line-btn.practice {
    color: var(--blue);
}

.line-btn.practice:hover {
    color: var(--ink);
}

.line-btn:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.hint-line {
    margin-top: var(--space-1);
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 400;
}

.lines-hints {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--hair);
}

.lines-hints h3 {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-md);
}

/* Empty state for a new user: a flat section above the list */
.openings-empty {
    margin-bottom: var(--space-4);
    padding: 0 0 var(--space-4);
    border-bottom: 1px solid var(--hair);
}

.openings-empty h2 {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-lg);
}

.openings-empty p {
    margin: 0 0 var(--space-3);
    max-width: 40rem;
    color: var(--ink-2);
}

.openings-no-match {
    margin: var(--space-4) var(--space-2);
    color: var(--ink-2);
}

/* Narrow laptop and tablet: the sidebar is the 56px rail (nav-rail.css), so no top padding for a Menu button.
   The progress bar gives up some width so the row still fits. */
@media (max-width: 1100px) {
    .row-main {
        grid-template-columns: 24px 88px minmax(0, 1fr) 190px 32px 96px;
    }
}

/* Phone: board and name on the first line, progress and actions under them */
@media (max-width: 760px) {
    .openings-page {
        padding: var(--space-4) var(--space-4) var(--space-6);
    }

    .openings-header .openings-tabs {
        display: flex;
        flex: 1 1 100%;
        order: 2;
    }

    .openings-header .openings-tabs .tab {
        flex: 1;
    }

    .progress-row {
        flex: 1 1 100%;
        order: 3;
    }

    .openings-filter {
        flex: 1 1 100%;
        order: 4;
        height: 40px;
    }

    .row-main {
        grid-template-columns: 24px 88px minmax(0, 1fr) 32px;
        grid-template-areas:
            "chev board main track"
            ". progress progress progress"
            ". action action action";
        row-gap: var(--space-3);
        padding: var(--space-3) 0;
    }

    .row-main .row-chevron { grid-area: chev; }
    .row-main .cell-board-link { grid-area: board; }
    .row-main .cell-main { grid-area: main; }
    .row-main .track-toggle { grid-area: track; }
    .row-main .cell-progress { grid-area: progress; }
    .row-main .open-button { grid-area: action; min-height: 40px; }

    .opening-summary {
        white-space: normal;
    }

    .cell-lines {
        padding-left: 0;
    }

    .line-row {
        grid-template-columns: minmax(0, 1fr) auto;
        row-gap: var(--space-1);
        padding: var(--space-2) 0;
    }

    .line-name { grid-column: 1; }
    .line-detail { grid-column: 1 / 3; grid-row: 2; }
    .line-status { grid-column: 2; grid-row: 1; }
    .line-actions { grid-column: 1 / 3; grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
    .cell-board,
    .track-toggle,
    .row-chevron svg { transition: none; }
}
