/* ==========================================================================
   Code Coriander - Java 8+ Interactive Coding Portal (Non-Stepper)
   ========================================================================== */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef3;
  --surface-3: #dfe5ed;
  --ink: #16202b;
  --muted: #566273;
  --line: #d5dce5;
  --accent: #0a6a85;
  --accent-soft: #d3ebf2;
  --accent-hover: #08566b;
  
  --p1: #2c66cc;
  --p1-soft: #dce7fa;
  --p2: #b56f00;
  --p2-soft: #f8e8cc;
  --p3: #7d47bd;
  --p3-soft: #ece0f8;
  
  --ok: #1d7f46;
  --ok-soft: #d5f0df;
  --bad: #c2342a;
  --bad-soft: #f9dcd8;
  
  /* Light Theme Code Palette: Clean modern editor */
  --code-bg: #f8fafc;
  --code-ink: #1e293b;
  --code-gutter: #f1f5f9;
  --code-border: #cbd5e1;
  --code-line-no: #94a3b8;
  --code-line-hover: #eef2f6;
  
  --tk-k: #7c3aed;     /* keywords: vibrant purple */
  --tk-t: #0284c7;     /* types & classes: ocean sky blue */
  --tk-m: #d97706;     /* methods & stream operations: warm amber gold */
  --tk-s: #15803d;     /* strings & chars: forest emerald green */
  --tk-n: #c2410c;     /* numbers: rust orange */
  --tk-c: #64748b;     /* comments: slate gray italic */
  --tk-a: #be185d;     /* annotations: magenta */
  --tk-op: #e11d48;    /* operators & lambdas: rose crimson */
  --tk-b: #dc2626;     /* booleans & null: bright red */
  --tk-v: #0d9488;     /* variables/fields: teal */

  --f-ui: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

:root[data-theme="dark"],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1116;
    --surface: #141a21;
    --surface-2: #1b232c;
    --surface-3: #242e3a;
    --ink: #e3e8ee;
    --muted: #93a0af;
    --line: #2a3440;
    --accent: #4fb6d2;
    --accent-soft: #123540;
    --accent-hover: #63c6e2;
    
    --p1: #6f9fff;
    --p1-soft: #1a2b4a;
    --p2: #efa647;
    --p2-soft: #3a2a10;
    --p3: #b58cf0;
    --p3-soft: #2c1f42;
    
    --ok: #4fc283;
    --ok-soft: #133523;
    --bad: #ff6e62;
    --bad-soft: #401a17;
    
    /* Dark Theme Code Palette: VS Code / One Dark Pro modern IDE */
    --code-bg: #111827;
    --code-ink: #f1f5f9;
    --code-gutter: #0b0f17;
    --code-border: #1e293b;
    --code-line-no: #64748b;
    --code-line-hover: #1e293b;
    
    --tk-k: #c084fc;     /* keywords: bright lavender purple */
    --tk-t: #38bdf8;     /* types & classes: electric sky cyan */
    --tk-m: #fde047;     /* methods & stream operations: vibrant sunburst yellow */
    --tk-s: #4ade80;     /* strings & chars: bright emerald mint */
    --tk-n: #fb923c;     /* numbers: vivid orange */
    --tk-c: #94a3b8;     /* comments: elegant slate italic */
    --tk-a: #f472b6;     /* annotations: bright neon pink */
    --tk-op: #fb7185;    /* operators & lambdas: bright rose */
    --tk-b: #f87171;     /* booleans & null: coral red */
    --tk-v: #2dd4bf;     /* variables/fields: bright teal */
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-section a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}

.brand-logo {
  height: 32px;
  width: auto;
  vertical-align: middle;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-sub {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.badge-pill {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  transition: all 0.15s ease;
  user-select: none;
}

.btn:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Layout */
.app-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 60px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero / Filter Bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

.search-box svg {
  width: 16px;
  height: 16px;
  fill: var(--muted);
  flex-shrink: 0;
}

.search-box input {
  all: unset;
  width: 100%;
  font-family: var(--f-ui);
  font-size: 0.92rem;
  color: var(--ink);
}

.search-box input::placeholder {
  color: var(--muted);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  all: unset;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* Main Content Grid */
.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

/* Sidebar Problem List */
.problem-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}

.problem-card {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.problem-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.problem-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.problem-card.active .card-title {
  color: var(--accent);
}

.diff-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.diff-easy {
  background: var(--ok-soft);
  color: var(--ok);
}

.diff-medium {
  background: var(--p2-soft);
  color: var(--p2);
}

.diff-hard {
  background: var(--bad-soft);
  color: var(--bad);
}

.card-summary {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.company-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.comp-tag {
  font-size: 0.68rem;
  font-family: var(--f-mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--muted);
}

/* Detail Area */
.detail-area {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-title-group h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 6px 0;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.file-pill {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 4px;
}

.detail-summary {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

/* Stream Pipeline Highlights */
.pipeline-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.pipeline-step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pipeline-step-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.pipeline-step-val {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--accent);
  overflow-x: auto;
  white-space: nowrap;
}

/* Tab Bar */
.tabs-nav {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  gap: 4px;
}

.tab-btn {
  all: unset;
  cursor: pointer;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Code Panel */
.code-panel {
  display: flex;
  flex-direction: column;
}

.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.code-wrapper {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

pre.code-view {
  margin: 0;
  padding: 12px 0;
  background: transparent;
  color: var(--code-ink);
  font-family: var(--f-mono);
  font-size: 0.84rem;
  line-height: 1.68;
  overflow-x: auto;
  max-height: 620px;
}

.code-line {
  display: flex;
  min-width: 100%;
  width: max-content;
  transition: background-color 0.08s ease;
}

.code-line:hover {
  background-color: var(--code-line-hover);
}

.line-no {
  user-select: none;
  min-width: 44px;
  text-align: right;
  padding: 0 12px 0 8px;
  color: var(--code-line-no);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--code-border);
  background: var(--code-gutter);
  flex-shrink: 0;
}

.line-txt {
  padding: 0 16px;
  white-space: pre;
  tab-size: 4;
}

/* Syntax Highlighting Tokens */
.tk-k { color: var(--tk-k); font-weight: 600; }
.tk-t { color: var(--tk-t); font-weight: 600; }
.tk-m { color: var(--tk-m); font-weight: 600; }
.tk-s { color: var(--tk-s); }
.tk-n { color: var(--tk-n); font-weight: 600; }
.tk-c { color: var(--tk-c); font-style: italic; opacity: 0.85; }
.tk-a { color: var(--tk-a); font-weight: 600; }
.tk-op { color: var(--tk-op); font-weight: 700; }
.tk-b { color: var(--tk-b); font-weight: 600; }
.tk-v { color: var(--tk-v); }

/* Terminal Output Styling */
.term-line {
  display: block;
}
.term-cmd { color: #38bdf8; font-weight: 600; }
.term-head { color: #fde047; font-weight: 700; }
.term-div { color: #475569; }
.term-val { color: #4ade80; font-weight: 600; }
.term-key { color: #c084fc; }
.term-bool-true { color: #4ade80; font-weight: 700; }
.term-bool-false { color: #f87171; font-weight: 700; }

/* Terminal Console View */
.terminal-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.terminal-window {
  background: #090d12;
  border: 1px solid #1f2937;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.terminal-top-bar {
  background: #161f2e;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }

.terminal-title {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  color: #93a0af;
  margin-left: 8px;
}

pre.terminal-body {
  margin: 0;
  padding: 16px;
  font-family: var(--f-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #6fd49b;
  overflow-x: auto;
  min-height: 200px;
  max-height: 520px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Explanation / Complexity */
.explanation-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
}

.info-card h4 {
  margin: 0 0 8px 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.info-card h3 {
  margin: 14px 0 6px 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.info-card h3:first-child {
  margin-top: 0;
}

.info-card p {
  margin: 0 0 10px 0;
  line-height: 1.6;
  color: var(--ink);
}

.info-card ul {
  margin: 0 0 10px 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-card li {
  font-size: 0.88rem;
  color: var(--ink);
}

.info-card pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--f-mono);
  font-size: 0.82rem;
  color: var(--code-ink);
  margin: 10px 0;
}

.info-card code {
  font-family: var(--f-mono);
  font-size: 0.88em;
  background: var(--surface-3);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--accent);
}

/* Modal for Cheat Sheet */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-content {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.modal-table th, .modal-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.modal-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-table code {
  font-family: var(--f-mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}
