/**
 * QuickRef Card Waterfall Layout (Dense Grid Masonry) & Minimalist Light Theme
 *
 * Features:
 * 1. Supports 2-column wide cards (.qr-card-wide) for complex tables and code.
 * 2. Dense packing (grid-auto-flow: dense) ensures zero empty gaps when cards span 2 columns.
 * 3. Border-free & noise-free aesthetic.
 * 4. Pixel-perfect 3D tactile physical keycaps.
 */

/* ==========================================================================
   Full-width Article Container (No TOC / Sidebar)
   ========================================================================== */

.quickref-mode .article-layout-quickref {
  display: block;
  width: 100%;
}

.quickref-mode .newspaper-article {
  padding: 0;
  max-width: 100%;
  width: 100%;
}

.quickref-mode .article-header {
  text-align: left;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--home-line, #e2e8f0);
}

.quickref-mode .article-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: clamp(24px, 2.5vw, 30px);
  font-weight: 700;
  color: var(--home-ink, #0f172a);
  letter-spacing: -0.5px;
  margin: 0 0 10px;
}

.quickref-mode .article-meta {
  color: #64748b;
  font-size: 13px;
}

.quickref-mode .article-content {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* ==========================================================================
   Section Title
   ========================================================================== */

.quickref-mode .qr-section {
  margin-top: 32px;
  margin-bottom: 32px;
}

.quickref-mode .qr-section-title,
.quickref-mode h2.qr-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 650;
  color: #0f172a;
  margin: 0 0 18px 0;
  padding: 0 0 8px 0;
  border-bottom: 1px solid #e2e8f0;
  letter-spacing: -0.3px;
}

.quickref-mode .qr-section-title::before {
  content: '#';
  display: inline-block;
  color: #10b981;
  font-weight: 700;
  font-size: 20px;
}

/* ==========================================================================
   Dense Grid Masonry Layout
   Cards pack seamlessly with auto-fill and dense flow for span-2 cards.
   ========================================================================== */

.quickref-mode .qr-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  grid-auto-flow: dense;
  align-items: start;
  width: 100%;
}

.quickref-mode .qr-grid.qr-masonry-active {
  grid-auto-rows: 8px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .quickref-mode .qr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 680px) {
  .quickref-mode .qr-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ==========================================================================
   Card Styling: Minimalist, Airy & Border-free
   ========================================================================== */

.quickref-mode .qr-card {
  grid-column: span 1;
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 12px;
  padding: 16px 18px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  height: max-content;
  box-sizing: border-box;
}

.quickref-mode .qr-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

/* Wide card spans 2 columns */
.quickref-mode .qr-card.qr-card-wide {
  grid-column: span 2;
}

/* Full-width card spans 3 columns */
.quickref-mode .qr-card.qr-card-full,
.quickref-mode .qr-card.qr-card-span-3 {
  grid-column: span 3;
}

@media (max-width: 1100px) {
  .quickref-mode .qr-card.qr-card-full,
  .quickref-mode .qr-card.qr-card-span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .quickref-mode .qr-card.qr-card-wide,
  .quickref-mode .qr-card.qr-card-full,
  .quickref-mode .qr-card.qr-card-span-3 {
    grid-column: span 1;
  }
}

/* Full-width (3-column) table optimizations: left aligned, allow descriptions to wrap */
.quickref-mode .qr-card.qr-card-full table {
  width: 100%;
}

.quickref-mode .qr-card.qr-card-full thead th,
.quickref-mode .qr-card.qr-card-full tbody td {
  text-align: left !important;
  white-space: normal !important;
  word-break: break-word;
}

.quickref-mode .qr-card.qr-card-full thead th:first-child,
.quickref-mode .qr-card.qr-card-full tbody td:first-child {
  white-space: nowrap !important;
  width: 1%;
  padding-right: 14px;
}

/* Header & Pill Badge: Clean, no divider lines */
.quickref-mode .qr-card-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 24px;
}

.quickref-mode .qr-card-header:has(.qr-card-title) {
  justify-content: space-between;
}

.quickref-mode .qr-card-title {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.4;
  color: #0f172a;
}

.quickref-mode .qr-card-title-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Soft Mint Pill Badge */
.quickref-mode .qr-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 2.5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  color: #0f766e;
  background-color: #f0fdfa;
  border: 1px solid rgba(153, 246, 228, 0.6);
  border-radius: 9999px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Card Body */
.quickref-mode .qr-card-body {
  font-size: 13px;
  line-height: 1.65;
  color: #334155;
}

.quickref-mode .qr-card-body > *:first-child {
  margin-top: 0;
}

.quickref-mode .qr-card-body > *:last-child {
  margin-bottom: 0;
}

.quickref-mode .qr-card-body p {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ==========================================================================
   Border-Free Table Styling
   No double borders, no cell lines, only clean spacing and soft row hover
   ========================================================================== */

.quickref-mode .qr-card .table-scroll {
  margin: 2px 0 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.quickref-mode .qr-card table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: none;
  font-size: 13px;
  text-align: left;
}

/* Table Header */
.quickref-mode .qr-card thead th {
  background: transparent;
  color: #94a3b8;
  font-weight: 550;
  font-size: 11px;
  padding: 4px 8px 8px;
  border: none;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.quickref-mode .qr-card thead th:not(:first-child) {
  text-align: right;
}

/* Table Rows: Zero border lines, gentle hover pill */
.quickref-mode .qr-card tbody tr {
  transition: background-color 0.12s ease;
}

.quickref-mode .qr-card tbody tr:hover td {
  background-color: #f8fafc;
}

.quickref-mode .qr-card tbody td {
  padding: 6px 7px;
  border: none;
  vertical-align: middle;
  line-height: 1.45;
  color: #334155;
}

/* Description Column: Flexible width */
.quickref-mode .qr-card tbody td:first-child {
  padding-left: 4px;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  width: auto;
  min-width: 70px;
  word-break: break-word;
}

/* Shortcut / Code Columns: Compact, right-aligned, NEVER wrap */
.quickref-mode .qr-card tbody td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
  width: 1%;
  padding-right: 4px;
  font-variant-numeric: tabular-nums;
}

.quickref-mode .qr-card tbody td:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* In wide cards, give generous spacing between columns */
.quickref-mode .qr-card-wide tbody td:not(:first-child) {
  padding-left: 14px;
}

/* ==========================================================================
   Pixel-Perfect 3D Physical Keycaps
   Clean white background, soft shadow, tactile depth
   ========================================================================== */

.quickref-mode .qr-card code:not(pre code),
.quickref-mode .qr-card kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 21px;
  padding: 0 5px;
  margin: 1px 1px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 550;
  line-height: 1;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-bottom: 2px solid #94a3b8;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  vertical-align: middle;
  white-space: nowrap;
  user-select: none;
}

.quickref-mode .qr-card code:not(pre code):hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
}

/* In table cells, ensure plus symbols between keycaps are elegant */
.quickref-mode .qr-card td code + text,
.quickref-mode .qr-card td text + code {
  color: #94a3b8;
  font-size: 11px;
}

/* ==========================================================================
   Code Blocks & Other Content
   ========================================================================== */

.quickref-mode .qr-card pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background-color: #f8fafc !important;
  font-size: 12px;
  line-height: 1.6;
}

.quickref-mode .qr-card pre code {
  display: block;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent !important;
  box-shadow: none;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
}

.quickref-mode .qr-card ul,
.quickref-mode .qr-card ol {
  margin: 6px 0;
  padding-left: 18px;
}

.quickref-mode .qr-card li {
  margin: 4px 0;
  line-height: 1.55;
}

.quickref-mode .qr-card a {
  color: #059669;
  text-decoration: none;
  font-weight: 500;
}

.quickref-mode .qr-card a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   Waterfall Ad Card Styling
   ========================================================================== */

.quickref-mode .qr-card.qr-card-ad {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  background: #ffffff;
}

.quickref-mode .qr-card-ad .qr-card-header {
  margin-bottom: 6px;
}

.quickref-mode .qr-badge-ad {
  background-color: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
  font-size: 11px;
}

.quickref-mode .qr-ad-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  overflow: hidden;
}

.quickref-mode .qr-ad-body ins.adsbygoogle {
  width: 100% !important;
  min-height: 250px;
}

.quickref-mode .qr-card-ad:has(ins[data-ad-status="unfilled"]),
.quickref-mode .qr-card-ad ins[data-ad-status="unfilled"] {
  display: none !important;
}

@media (max-width: 900px) {
  .quickref-mode .qr-card.qr-card-ad {
    display: none !important;
  }
}

