/* ============================================================
   cards.css — Card-based page styles
   Used by: index.html, code-tricks.html, edge-cases.html
   ============================================================ */

/* Tab content switching (index.html only, harmless elsewhere) */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Section title — card page variant */
.section-title {
  padding: 18px 0 6px;
  margin-bottom: 10px;
  grid-column: 1 / -1;
}
.section-intro {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.55;
  margin: -4px 0 6px;
}
.section-intro b { color: var(--text); }
.section-intro code {
  font-size: 0.8rem;
  padding: 0;
  background: none;
  border: none;
}

/* ---- Card grid ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
  gap: 10px;
  align-items: stretch;
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover { border-color: #484f58; }

.card-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.card-title {
  font-weight: 600;
  font-size: 0.88rem;
  flex: 1;
  line-height: 1.3;
}
.card-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ---- Tags ---- */
.tag {
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 12px;
  background: var(--tag-bg);
  color: var(--text2);
  white-space: nowrap;
}
.tag.go { background: #003d4d; color: var(--accent2); }
.tag.java { background: #3d2200; color: #f8b500; }
.tag.warn { background: #3d2e00; color: var(--warn); }
.tag.danger { background: #3d1010; color: var(--danger); }

/* ---- Card body ---- */
.card-body {
  padding: 10px 14px 14px;
  flex: 1;
}
.card-body p {
  color: var(--text2);
  font-size: 0.84rem;
  margin-bottom: 8px;
  line-height: 1.5;
}
.card-body pre {
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  overflow-x: auto;
}
.card-body pre code.hljs {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}
.card-body .note {
  background: #1a1f2e;
  border-left: 3px solid var(--accent);
  padding: 7px 11px;
  border-radius: 0 6px 6px 0;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 8px;
  line-height: 1.6;
}
.card-body .note b { color: var(--text); font-size: 0.78rem; }
.card-body .note ul {
  margin: 2px 0 6px 0;
  padding-left: 18px;
  font-size: 0.76rem;
  list-style: disc;
}
.card-body .note ul li {
  margin-bottom: 1px;
  display: list-item;
}
.card-body .warn-note {
  background: #2a2000;
  border-left: 3px solid var(--warn);
  padding: 7px 11px;
  border-radius: 0 6px 6px 0;
  font-size: 0.8rem;
  color: var(--warn);
  margin-bottom: 8px;
}

/* ---- Complexity table (java-collections) ---- */
.ctable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.ctable thead th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
}
.ctable thead th:nth-child(2) { text-align: center; }
.ctable tbody td {
  padding: 4px 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  vertical-align: baseline;
}
.ctable tbody tr:last-child td { border-bottom: none; }
.ctable tbody tr.grp td {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 8px 4px;
  border-bottom: 1px solid var(--border);
  background: none;
}
.ctable tbody td:first-child code {
  font-size: 0.78rem;
  background: none;
  padding: 0;
  border: none;
}
.ctable tbody td:nth-child(2) {
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: 3px;
}
.ctable tbody td:nth-child(3) {
  font-size: 0.73rem;
  color: var(--text2);
  font-style: italic;
}

/* Comparison variant: From | Method | Impl1 | Impl2 | … */
.ctable-cmp { grid-column: 1 / -1; }
.ctable-cmp thead th:nth-child(1),
.ctable-cmp thead th:nth-child(2) { text-align: left; }
.ctable-cmp thead th:nth-child(n+3) { text-align: center; }
.ctable-cmp tbody td:first-child {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  opacity: 0.75;
}
.ctable-cmp tbody td:nth-child(2) {
  text-align: left;
  font-weight: normal;
  font-size: inherit;
}
.ctable-cmp tbody td:nth-child(2) code {
  font-size: 0.78rem;
  background: none;
  padding: 0;
  border: none;
}
.ctable-cmp tbody td:nth-child(n+3) {
  text-align: center;
  font-size: 0.74rem;
  white-space: nowrap;
}
.ctable-cmp tbody td:nth-child(n+3) .cmt {
  font-size: 0.65rem;
  color: var(--text2);
  font-style: italic;
  display: block;
  line-height: 1.2;
}
.ctable-cmp .na { color: var(--text2); opacity: 0.35; }

/* String table: 4-col with Example/Note before Time */
.ctable-str tbody td:nth-child(2),
.ctable-str tbody td:nth-child(3) { white-space: normal; }
.ctable-str tbody td:nth-child(3) {
  text-align: left;
  font-size: 0.72rem;
  color: var(--text2);
  font-style: italic;
}
.ctable-str tbody td:nth-child(4) {
  text-align: center;
  font-size: 0.74rem;
  white-space: nowrap;
}

/* Complexity color classes */
.tc-1    { color: var(--success); background: rgba(63,185,80,0.08); }
.tc-logn { color: var(--accent2); background: rgba(0,173,216,0.08); }
.tc-n    { color: var(--warn);    background: rgba(210,153,34,0.08); }
.tc-nlogn{ color: #e8873b;       background: rgba(232,135,59,0.08); }

/* ---- Hierarchy SVG diagram (java-collections) ---- */
.hierarchy-card { grid-column: 1 / -1; }
.hierarchy-svg { width: 100%; height: auto; display: block; }
.hierarchy-svg .ibox { fill: rgba(0,140,210,0.18); stroke: rgba(0,140,210,0.5); stroke-width: 1.5; }
.hierarchy-svg .cbox { fill: rgba(63,185,80,0.15); stroke: rgba(63,185,80,0.45); stroke-width: 1.5; }
.hierarchy-svg .itxt { fill: var(--accent2); font: 600 13px/1 -apple-system,'Segoe UI',sans-serif; }
.hierarchy-svg .ctxt { fill: var(--success); font: 600 12.5px/1 -apple-system,'Segoe UI',sans-serif; }
.hierarchy-svg .ln-ext  { stroke: var(--text2); stroke-width: 1.3; fill: none; }
.hierarchy-svg .ln-impl { stroke: var(--text2); stroke-width: 1.3; fill: none; stroke-dasharray: 4,3; }
.hierarchy-svg .arr { fill: var(--text2); }
.hierarchy-svg .ltxt { fill: var(--text2); font: 11px/1 -apple-system,'Segoe UI',sans-serif; }
.hierarchy-svg .sep  { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3,5; }

/* Interface method cards */
.iface-card { grid-column: 1 / -1; }
.iface-card .card-body { padding: 8px 14px 10px; }
.iface-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.iface-methods code {
  font-size: 0.76rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.iface-note {
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.5;
}

/* ---- Light theme — card overrides ---- */
[data-theme="light"] .card:hover { border-color: #afb8c1; }
[data-theme="light"] .card-body pre code.hljs { background: #f6f8fa; }
[data-theme="light"] .card-body .note { background: #ddf4ff; }
[data-theme="light"] .card-body .warn-note { background: #fff8c5; }
[data-theme="light"] .tag.go { background: #ddf4ff; color: #0078a8; }
[data-theme="light"] .tag.java { background: #fff3e0; color: #b07219; }
[data-theme="light"] .tag.warn { background: #fff8c5; color: var(--warn); }
[data-theme="light"] .tag.danger { background: #ffebe9; color: var(--danger); }
[data-theme="light"] .tc-1    { color: var(--success); background: rgba(26,127,55,0.09); }
[data-theme="light"] .tc-logn { color: var(--accent2); background: rgba(5,80,174,0.07); }
[data-theme="light"] .tc-n    { color: var(--warn);    background: rgba(154,103,0,0.09); }
[data-theme="light"] .tc-nlogn{ color: #b35c1e;       background: rgba(179,92,30,0.09); }
[data-theme="light"] .hierarchy-svg .ibox { fill: rgba(0,140,210,0.12); stroke: rgba(0,140,210,0.4); }
[data-theme="light"] .hierarchy-svg .cbox { fill: rgba(26,127,55,0.1);  stroke: rgba(26,127,55,0.35); }
[data-theme="light"] .iface-methods code { background: var(--surface2); }

/* ---- Responsive — card overrides ---- */
@media (max-width: 900px) {
  .cards-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .main { padding: 16px 12px 80px; }
  .card-tags { display: none; }
  .htree-wrap { gap: 18px; }
}
