/* ── Reset & base ──────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6fb;
  color: #1a1a2e;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Viewer shell ───────────────────────────────────────────────────────────── */

.viewer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.viewer-header {
  margin-bottom: 2rem;
}

.viewer-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.02em;
}

.viewer-header p {
  color: #888;
  margin-top: 0.3rem;
  font-size: 0.95rem;
}

/* ── Filters ────────────────────────────────────────────────────────────────── */

.filters {
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-wrap input[type="search"] {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1.5px solid #dde1eb;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.15s;
  background: #fafbfd;
}

.search-wrap input[type="search"]:focus {
  border-color: #3b5bdb;
  background: #fff;
}

.filter-group {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ── Multi-select filter dropdowns ──────────────────────────────────────────── */

.fd { position: relative; }

.fd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #dde1eb;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #333;
  background: #fafbfd;
  cursor: pointer;
  white-space: nowrap;
  min-width: 160px;
  transition: border-color 0.15s;
}

.fd-btn:hover  { border-color: #9ca3af; }
.fd-btn:focus  { outline: none; border-color: #3b5bdb; box-shadow: 0 0 0 3px rgba(59,91,219,.1); }

.fd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-caret { font-size: 10px; color: #9ca3af; flex-shrink: 0; }

.fd-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 400;
  background: #fff;
  border: 1.5px solid #dde1eb;
  border-radius: 8px;
  min-width: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
}

.fd-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 0.875rem;
  color: #374151;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.fd-opt:hover { background: #f3f4f6; }
.fd-opt input[type=checkbox] { accent-color: #3b5bdb; cursor: pointer; margin: 0; flex-shrink: 0; }

.fd-all {
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 8px;
  margin-bottom: 2px;
}

@media (max-width: 600px) {
  .fd-panel { min-width: 220px; max-width: calc(100vw - 32px); }
}

/* ── Results meta ───────────────────────────────────────────────────────────── */

.results-meta {
  font-size: 0.83rem;
  color: #999;
  margin-bottom: 1rem;
}

/* ── Loading spinner ────────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #888;
  font-size: 0.9rem;
  padding: 1.5rem 0;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid #dde1eb;
  border-top-color: #3b5bdb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Cards grid ─────────────────────────────────────────────────────────────── */

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s, transform 0.18s;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.11);
  transform: translateY(-3px);
}

/* Card image strip */
.card-img {
  height: 130px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #eef0f8;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-img--placeholder {
  background: linear-gradient(135deg, #3b5bdb18, #3b5bdb36);
}

.card-initial {
  font-size: 2.75rem;
  font-weight: 800;
  color: #3b5bdb;
  opacity: 0.5;
  user-select: none;
}

/* Card body */
.card-body {
  padding: 1rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

/* Meta row (badge + source + sectors) */
.card-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* ── View toggle ─────────────────────────────────────────────────────────────── */

.view-toggle {
  display: flex;
  background: #fff;
  border-radius: 22px;
  padding: 4px;
  gap: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.25rem;
  width: fit-content;
}

.view-btn {
  padding: 0.45rem 1.5rem;
  border-radius: 18px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.view-btn.active {
  background: #3b5bdb;
  color: #fff;
  box-shadow: 0 1px 4px rgba(59, 91, 219, 0.3);
}

.view-btn:not(.active):hover {
  color: #1a1a2e;
}

.card-source {
  font-size: 0.78rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Edu badges overlay (top-right of image) ────────────────────────────────── */

.edu-tags-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}

.edu-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.edu-mbo { background: rgba(59, 91, 219, 0.82); color: #fff; }
.edu-hbo { background: rgba(13, 148, 136, 0.82); color: #fff; }
.edu-wo  { background: rgba(124, 58, 237, 0.82); color: #fff; }

/* ── Topic tags ──────────────────────────────────────────────────────────────── */

.item-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.topic-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.67rem;
  font-weight: 600;
  white-space: nowrap;
  background: #f3f4f6;
  color: #6b7280;
}

/* Title */
.card-title {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 0.1rem;
}

.card-title a {
  color: #1a1a2e;
  text-decoration: none;
}

.card-title a:hover {
  color: #3b5bdb;
}

/* Date + separator in meta row (news only) */
.card-date {
  font-size: 0.78rem;
  color: #aaa;
}

.card-separator {
  font-size: 0.78rem;
  color: #ccc;
  user-select: none;
}

/* Summary */
.card-summary {
  font-size: 0.875rem;
  color: #555;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Read more */
.card-link {
  display: inline-block;
  margin-top: auto;
  padding-top: 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #3b5bdb;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
}

/* ── Load more ──────────────────────────────────────────────────────────────── */

.load-more-wrap {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.load-more-wrap button {
  padding: 0.7rem 2.5rem;
  background: #3b5bdb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.load-more-wrap button:hover {
  background: #2f4ac4;
}

.load-more-wrap button:disabled {
  background: #c0c8e8;
  cursor: not-allowed;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #bbb;
  font-size: 0.95rem;
}

/* ── Event card layout (55% image + 45% body) ───────────────────────────────── */

.card--event .card-img {
  flex: none;
  height: 187px;
}

.card--event .card-body {
  flex: 1;
  padding: 0.75rem 1rem 0.9rem;
  gap: 0.3rem;
  overflow: visible;
}

.card--event .card-title {
  font-size: 0.9rem;
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.card--event .event-details {
  margin-top: 0.35rem;
}

.card--event .card-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.82rem;
}

/* ── Event details block (⏰ 📍 🌐) ─────────────────────────────────────────── */

.event-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.event-detail {
  font-size: 0.75rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Event card date overlay ─────────────────────────────────────────────────── */

.card-img {
  position: relative;
}

.event-date-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  padding: 0.4rem 0.3rem;
  background: rgba(15, 15, 30, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 7px;
  color: #fff;
  line-height: 1;
  gap: 0.15rem;
  pointer-events: none;
  user-select: none;
}

.event-date-overlay__month {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
}

.event-date-overlay__day {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.event-date-overlay__weekday {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Range variant: start → end month */
.event-date-overlay__sep {
  font-size: 0.55rem;
  opacity: 0.55;
  line-height: 1;
  margin: 0.05rem 0;
}

.event-date-overlay__end-month {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
}

.event-date-overlay__end-day {
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .viewer {
    padding: 1.25rem 1rem 3rem;
  }

  .viewer-header h1 {
    font-size: 1.5rem;
  }

  .items-grid {
    grid-template-columns: 1fr;
  }

  .filter-group select {
    flex: 1 1 100%;
  }
}
