/* ==========================================================================
   DSA problem page — the split-pane judge (lc layout).
   Left: problem description / editorial / discuss / submissions.
   Right: CodeMirror editor + test console + action bar.
   Chrome and tokens come from core.css; this is the IDE shell only.
   ========================================================================== */

/* The judge owns the viewport: panes scroll independently, the page does not. */
html, body { height: 100%; }
body { overflow: hidden; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.lc-shell { display: flex; height: calc(100vh - var(--header-h)); width: 100%; }

.lc-left { width: 42%; min-width: 260px; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.lc-left-tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--sp-3);
    border-bottom: 1px solid var(--border);
    background: var(--panel-2);
    flex-shrink: 0;
    overflow-x: auto;
}
.lc-ltab {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    padding: 0.65rem 0.75rem;
    min-height: 40px;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease);
}
.lc-ltab:hover { color: var(--text); }
.lc-ltab.active { color: var(--accent); border-bottom-color: var(--accent); }
.lc-left-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-5) var(--sp-8); }

.lc-divider { width: 6px; cursor: col-resize; background: var(--border); flex-shrink: 0; transition: background var(--dur-fast) var(--ease); }
.lc-divider:hover { background: var(--accent); }

.lc-right { flex: 1; min-width: 320px; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   Problem description (left pane)
   -------------------------------------------------------------------------- */
.lc-left h1 { font-size: var(--fs-2xl); font-weight: 800; margin-bottom: var(--sp-3); letter-spacing: -0.025em; line-height: 1.2; }
.lc-left h2 { font-size: var(--fs-md); font-weight: 700; margin: var(--sp-5) 0 var(--sp-3); color: var(--text); }
.lc-left p { color: var(--text-muted); line-height: 1.7; margin-bottom: var(--sp-3); font-size: var(--fs-base); }
.lc-left ul { margin: 0 0 var(--sp-4) 1.2rem; color: var(--text-muted); font-size: var(--fs-base); line-height: 1.7; }
.lc-left strong { color: var(--text); }
.lc-left code { background: var(--code-bg); padding: 0.1rem 0.4rem; border-radius: var(--r-xs); font-family: var(--font-mono); font-size: 0.85em; }
.lc-left pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); overflow-x: auto; margin-bottom: var(--sp-4); }
.lc-left pre code { background: none; padding: 0; font-size: var(--fs-sm); line-height: 1.6; }

.lc-diff { display: inline-block; font-size: var(--fs-xs); font-weight: 700; padding: 3px 11px; border-radius: var(--r-full); margin-bottom: var(--sp-4); }
.lc-diff.easy { background: color-mix(in srgb, var(--easy) 14%, transparent); color: var(--easy); }
.lc-diff.medium { background: color-mix(in srgb, var(--medium) 14%, transparent); color: var(--medium); }
.lc-diff.hard { background: color-mix(in srgb, var(--hard) 14%, transparent); color: var(--hard); }

.lc-solved-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--success);
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
    padding: 2px 9px;
    border-radius: var(--r-full);
    margin-left: var(--sp-3);
    vertical-align: middle;
}

.lc-tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-2) 0 var(--sp-5); }
.lc-tag { font-size: var(--fs-xs); color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--border-accent); padding: 3px 10px; border-radius: var(--r-full); }

/* Collapsible topic tags — hidden by default so they can't spoil the approach */
.lc-topics { margin: var(--sp-2) 0 var(--sp-5); }
.lc-topics summary {
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    user-select: none;
}
.lc-topics summary::-webkit-details-marker { display: none; }
.lc-topics[open] summary { color: var(--text); }
.lc-topics .lc-tags { margin-top: var(--sp-3); }

/* --------------------------------------------------------------------------
   Submissions & discuss tabs
   -------------------------------------------------------------------------- */
.lc-sub-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: var(--fs-sm);
    transition: background var(--dur-fast) var(--ease);
}
.lc-sub-row:hover { background: var(--accent-subtle); }
.lc-sub-status { font-weight: 700; min-width: 120px; }
.lc-sub-status.ac { color: var(--success); }
.lc-sub-status.wa { color: var(--danger); }
.lc-sub-meta { color: var(--text-dim); font-size: var(--fs-xs); }
.lc-sub-code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-3) var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    white-space: pre;
    overflow-x: auto;
    margin: var(--sp-3) 0;
}
.lc-empty { color: var(--text-dim); font-size: var(--fs-base); padding: var(--sp-5) 0; text-align: center; }

.lc-discuss-form textarea,
.lc-discuss-form input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    padding: var(--sp-3);
}
.lc-discuss-form textarea { min-height: 70px; font-size: var(--fs-base); resize: vertical; }
.lc-discuss-form input { font-size: var(--fs-sm); margin-bottom: var(--sp-2); padding: 0.5rem var(--sp-3); }
.lc-discuss-post {
    margin-top: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--accent-contrast);
    background: var(--accent);
    border-radius: var(--r-sm);
    padding: 0.5rem 1.1rem;
    min-height: 40px;
}
.lc-discuss-post:hover { background: var(--accent-hover); }
.lc-discuss-item { border-bottom: 1px solid var(--border); padding: var(--sp-3) 0.2rem; }
.lc-discuss-item .who { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.lc-discuss-item .when { font-size: var(--fs-xs); color: var(--text-dim); margin-left: var(--sp-2); }
.lc-discuss-item .txt { font-size: var(--fs-base); color: var(--text-muted); margin-top: 0.3rem; white-space: pre-wrap; line-height: 1.65; }

/* --------------------------------------------------------------------------
   Editorial
   -------------------------------------------------------------------------- */
.lc-editorial h3 { font-size: var(--fs-md); font-weight: 700; margin: var(--sp-5) 0 var(--sp-3); color: var(--text); }
.lc-editorial h3:first-child { margin-top: var(--sp-2); }
.lc-editorial p { color: var(--text-muted); line-height: 1.7; margin-bottom: var(--sp-3); font-size: var(--fs-base); }
.lc-editorial ol, .lc-editorial ul { margin: 0 0 var(--sp-4) 1.2rem; color: var(--text-muted); font-size: var(--fs-base); line-height: 1.7; }
.lc-editorial li { margin-bottom: 0.3rem; }
.lc-editorial pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); overflow-x: auto; margin-bottom: var(--sp-4); }
.lc-editorial pre code { font-size: var(--fs-sm); line-height: 1.6; }
.lc-editorial code { background: var(--code-bg); padding: 0.1rem 0.4rem; border-radius: var(--r-xs); font-family: var(--font-mono); font-size: 0.85em; }
.lc-editorial .ed-note {
    font-size: var(--fs-sm);
    color: var(--text-dim);
    border-left: 3px solid var(--accent);
    padding: var(--sp-2) var(--sp-4);
    margin: var(--sp-3) 0;
    background: var(--accent-subtle);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* --------------------------------------------------------------------------
   Editor toolbar
   -------------------------------------------------------------------------- */
.lc-editor-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.lc-editor-bar .lc-spacer { margin-left: auto; }
.lc-lang {
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.5rem;
    min-height: 34px;
    cursor: pointer;
    outline: none;
}
.lc-reset, .lc-timer {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.65rem;
    min-height: 34px;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.lc-reset:hover, .lc-timer:hover { color: var(--text); border-color: var(--accent); }
.lc-timer { font-family: var(--font-mono); font-weight: 600; min-width: 58px; }
.lc-timer::before { content: '\23F1 '; }
.lc-timer.paused { color: var(--text-dim); opacity: 0.65; }
.lc-editor-bar .lc-btn { padding: 0.35rem 1rem; font-size: var(--fs-sm); }
.lc-kbd { font-size: var(--fs-xs); color: var(--text-dim); }
.lc-kbd b { font-family: var(--font-mono); font-weight: 600; color: var(--text-muted); }

.lc-editor-wrap { flex: 1; min-height: 0; position: relative; }
.lc-editor-wrap .CodeMirror { height: 100%; font-family: var(--font-mono); font-size: 0.85rem; }

/* Autocomplete popup — !important overrides the addon's own stylesheet, which
   loads dynamically after this file. */
.CodeMirror-hints {
    position: absolute;
    z-index: 1000;
    max-height: 18em;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    border-radius: var(--r-sm) !important;
    border: 1px solid var(--border) !important;
    background: var(--panel-2) !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    list-style: none;
}
.CodeMirror-hint { padding: 3px 10px !important; border-radius: var(--r-xs); color: var(--text) !important; white-space: pre; cursor: pointer; }
li.CodeMirror-hint-active { background: var(--accent) !important; color: var(--accent-contrast) !important; }

/* Disable programming ligatures so "!=" stays "!=" rather than rendering "≠" */
.CodeMirror, .CodeMirror-line, .lc-sol-code, .lc-sub-code, .lc-io-box,
.lc-left code, .lc-editorial code, .lc-fmt-note code, pre, code {
    font-variant-ligatures: none !important;
    -webkit-font-feature-settings: "liga" 0, "calt" 0 !important;
    font-feature-settings: "liga" 0, "calt" 0 !important;
}

/* --------------------------------------------------------------------------
   Console
   -------------------------------------------------------------------------- */
.lc-console { border-top: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; max-height: 46%; }
.lc-console-tabs { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.lc-console-tab {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    padding: 0.4rem 0.5rem 0.5rem;
    transition: color var(--dur-fast) var(--ease);
}
.lc-console-tab:hover { color: var(--text); }
.lc-console-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.lc-console-body { overflow-y: auto; padding: var(--sp-3) var(--sp-4); min-height: 90px; }

.lc-case-tabs { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.lc-case-tab {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.7rem;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.lc-case-tab:hover { color: var(--text); }
.lc-case-tab.active { color: var(--text); border-color: var(--accent); }
.lc-case-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.lc-case-dot.pass { background: var(--success); }
.lc-case-dot.fail { background: var(--danger); }

.lc-io-label { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: var(--sp-3) 0 0.25rem; }
.lc-io-box {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-2) var(--sp-3);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}
.lc-io-box.bad { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.lc-fmt-note { font-size: var(--fs-xs); color: var(--text-muted); margin: var(--sp-2) 0 0.1rem; line-height: 1.5; }
.lc-fmt-note code { font-family: var(--font-mono); font-size: 0.68rem; background: var(--panel-2); padding: 0.02rem 0.28rem; border-radius: var(--r-xs); }

.lc-verdict { font-size: var(--fs-md); font-weight: 800; margin-bottom: var(--sp-2); display: flex; align-items: center; gap: var(--sp-3); }
.lc-verdict.ac { color: var(--success); }
.lc-verdict.wa { color: var(--danger); }
.lc-verdict.run { color: var(--text-muted); font-weight: 600; }
.lc-verdict small { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.lc-spinner {
    display: inline-block;
    width: 15px; height: 15px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: lc-spin 0.7s linear infinite;
}
@keyframes lc-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Inline diagrams & reference solutions
   -------------------------------------------------------------------------- */
.lc-diagram { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3); margin: var(--sp-2) 0 0.3rem; overflow-x: auto; text-align: center; }
.lc-diagram .lc-dg { max-width: 100%; height: auto; }
.lc-dg-node { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.lc-dg-edge { stroke: var(--text-dim); stroke-width: 2; }
.lc-dg-arrow { fill: var(--text-dim); }
.lc-dg-text { fill: var(--text); font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.lc-dg-cell { fill: var(--panel); stroke: var(--border); stroke-width: 1; }
.lc-dg-empty { color: var(--text-muted); font-style: italic; font-size: var(--fs-sm); padding: var(--sp-2); }
.lc-dg-bar { fill: var(--accent); opacity: 0.85; }
.lc-dg-water { fill: var(--info); opacity: 0.5; }

.lc-vis { margin-top: var(--sp-5); }
.lc-vis h2 { font-size: var(--fs-base); margin: 0 0 var(--sp-2); }
.lc-ex-dg { margin-bottom: var(--sp-3); }
.lc-ex-cap { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.25rem; }
.lc-fmt-desc { margin-top: var(--sp-3); }

.lc-sol { margin-top: var(--sp-5); }
.lc-sol h3 { font-size: var(--fs-base); margin: 0 0 var(--sp-2); }
.lc-sol-tabs { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.lc-sol-tab {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 0.3rem 0.7rem;
    min-height: 30px;
    border-radius: var(--r-xs);
    font-family: inherit;
}
.lc-sol-tab:hover { color: var(--text); }
.lc-sol-tab.active { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.lc-sol-code {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-3) var(--sp-4);
    overflow-x: auto;
    white-space: pre;
    color: var(--text);
    margin: 0;
}
.lc-sol-code code { background: none; padding: 0; }

/* --------------------------------------------------------------------------
   Action bar
   -------------------------------------------------------------------------- */
.lc-actions { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); background: var(--panel-2); }
.lc-actions .lc-spacer { margin-left: auto; }
.lc-btn {
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
    border-radius: var(--r-sm);
    padding: 0.5rem 1.2rem;
    min-height: 38px;
    border: 1px solid transparent;
    transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.lc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lc-run { color: var(--text); background: var(--surface); border-color: var(--border); }
.lc-run:hover:not(:disabled) { border-color: var(--accent); }
.lc-submit { color: #fff; background: linear-gradient(135deg, var(--success), color-mix(in srgb, var(--success) 75%, #000)); }
.lc-submit:hover:not(:disabled) { transform: translateY(-1px); }
.lc-status { font-size: var(--fs-xs); color: var(--text-dim); }

/* --------------------------------------------------------------------------
   Responsive — below 860px the panes stack and the page scrolls normally
   -------------------------------------------------------------------------- */
@media (max-width: 860px) {
    body { overflow: auto; }
    .lc-shell { flex-direction: column; height: auto; }
    .lc-left { width: 100%; }
    .lc-left-body { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
    .lc-divider { display: none; }
    .lc-right { min-height: 80vh; border-left: none; border-top: 1px solid var(--border); }
}
/* Declutter the editor toolbar so it stays on one row on phones */
@media (max-width: 600px) {
    .lc-editor-bar { gap: var(--sp-2); }
    .lc-editor-bar .lc-reset, .lc-editor-bar .lc-btn { padding: 0.4rem 0.6rem; }
    #lc-autosuggest, #lc-timer { display: none; }
}
