/* ── Card Grid ── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  align-items: stretch;
}

/* ── Document Card ── */
.doc-card {
  background: var(--color-card);
  border-radius: 12px;
  box-shadow: rgba(0, 0, 0, 0.035) 0px 4px 20px 0px,
              rgba(31, 31, 30, 0.12) 0px 0px 0px 0.5px;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 180ms ease;
  position: relative;
}

.doc-card:hover {
  box-shadow: rgba(0, 0, 0, 0.06) 0px 4px 24px 0px,
              rgba(31, 31, 30, 0.18) 0px 0px 0px 0.5px;
}

.doc-card:has(.doc-overflow-menu.active) {
  z-index: 20;
}

/* ── Card Header (icon + title + overflow) ── */
.doc-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.doc-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--card-accent-bg, rgba(0, 0, 0, 0.04));
}

.doc-card-icon svg {
  width: 20px;
  height: 20px;
  color: var(--card-accent, rgb(115, 113, 108));
}

.doc-card-title {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}

/* ── Preview Text ── */
.doc-card-preview {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* ── Card Footer (meta + label) ── */
.doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-wrap: nowrap;
  min-width: 0;
}

.doc-card-meta {
  font-size: var(--font-size-xs);
  color: rgb(115, 113, 108);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.doc-card-meta-divider {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgb(143, 142, 138);
}

/* ── Score Label (encouraging, not numeric) ── */
.doc-score-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.doc-score-label.score-great {
  background: rgba(113, 221, 55, 0.12);
  color: #3d8a10;
}

.doc-score-label.score-good {
  background: rgba(105, 108, 255, 0.12);
  color: #696cff;
}

.doc-score-label.score-ok {
  background: rgba(255, 171, 0, 0.1);
  color: #b07800;
}

/* Dark mode score labels */
[data-theme="dark"] .doc-score-label.score-great {
  background: rgba(113, 221, 55, 0.15);
  color: #8ae65c;
}

[data-theme="dark"] .doc-score-label.score-good {
  background: rgba(105, 108, 255, 0.15);
  color: #9b9eff;
}

[data-theme="dark"] .doc-score-label.score-ok {
  background: rgba(255, 171, 0, 0.12);
  color: #ffbd3d;
}

/* Adult edition: hide score labels — no real logic behind them */
.v-voksen .doc-score-label { display: none; }

/* Below 40: no label shown — just word count */

/* ── Card Action Bar (pin + tag + overflow grouped) ── */
.doc-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.doc-card:hover .doc-card-actions,
.doc-card:focus-within .doc-card-actions,
.doc-card-actions:has([data-pinned="true"]) {
  opacity: 1;
}

/* Shared style for all action buttons in the bar */
.doc-card-actions > button,
.doc-card-actions > .doc-card-overflow > button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.doc-card-actions > button:hover,
.doc-card-actions > .doc-card-overflow > button:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.doc-card-actions > button:focus-visible,
.doc-card-actions > .doc-card-overflow > button:focus-visible {
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: -2px;
}

.doc-card-actions svg {
  width: 14px;
  height: 14px;
}

/* ── Overflow Menu ── */
.doc-card-overflow {
  position: relative;
}

.doc-overflow-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.doc-overflow-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.doc-overflow-btn:focus-visible {
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: -2px;
}

.doc-overflow-menu {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 210px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(31, 31, 30, 0.2);
  border-radius: 12px;
  box-shadow: rgba(0, 0, 0, 0.08) 0px 2px 8px 0px;
  z-index: 50;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px) scale(0.98);
  transition: opacity 120ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-overflow-menu.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 100;
}

.doc-overflow-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: rgb(55, 55, 52);
  font-size: 14px;
  font-weight: 430;
  font-family: var(--font-family);
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 75ms ease;
  white-space: nowrap;
}

.doc-overflow-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.doc-overflow-item:focus-visible {
  background: rgba(0, 0, 0, 0.04);
  outline: 2px solid rgba(31, 31, 30, 0.3);
  outline-offset: -2px;
}

.doc-overflow-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.doc-overflow-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
}

.doc-overflow-sep {
  height: 0.5px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 6px;
}

[data-theme="dark"] .doc-overflow-menu {
  background: rgba(30, 30, 30, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .doc-overflow-item {
  color: rgba(255, 255, 255, 0.85);
}

[data-theme="dark"] .doc-overflow-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.doc-overflow-gdocs .doc-overflow-icon svg {
  fill: initial;
  stroke: none;
  opacity: 1;
}

.doc-overflow-gdocs:hover {
  background: rgba(66, 133, 244, 0.08);
}

.doc-overflow-delete {
  color: #ff3e1d;
}

.doc-overflow-delete:hover {
  background: rgba(255, 62, 29, 0.08);
}

/* ═══════════════════════════════════════════════════════
   TIER 1 + QUICK WINS — Dokumenter Upgrades
   ═══════════════════════════════════════════════════════ */

/* ── 1.6 Card Active/Pressed State ── */
.doc-card:active {
  transform: scale(0.985);
}

/* ── Responsive: Cards ── */
@media (max-width: 767px) {
  .doc-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .doc-card {
    min-height: auto;
    padding: var(--space-4);
    border-radius: 12px;
  }

  /* overflow btn visible on mobile — handled by .doc-card-actions */
}
