@import url('fonts.css');

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2230;
  --border: #21262d;
  --border2: #30363d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --text-mute: #484f58;
  --accent: #58a6ff;
  --tag-bg: #161b22;
  --mark-bg: rgba(88,166,255,0.18);
  --danger: #f85149;
  --success: #3fb950;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --header-h: 3.25rem;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-header h1 {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-header .subtitle {
  font-family: var(--font-mono);
  font-size: .85rem;
  font-weight: 400;
  color: var(--text-dim);
}

.header-right {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--text-mute);
}

/* ─── Toolbar ──────────────────────────────────────────── */

.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-wrap svg {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  fill: var(--text-mute);
}

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.5rem 0.7rem 0.5rem 2.2rem;
  outline: none;
  transition: border-color .15s;
}

.search-input:focus {
  border-color: var(--accent);
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 0;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  color: #0d1117;
  font-weight: 600;
  border-color: var(--accent);
}

/* ─── Search ───────────────────────────────────────────── */

.search-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 99;
  background: var(--bg);
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
}

.search-bar.with-back {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.search-bar.with-back .back-link {
  flex-shrink: 0;
  margin: 0;
}

.search-bar.with-back input {
  flex: 1;
}

.search-bar input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.8rem;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-result-list {
  list-style: none;
  padding: 1rem 2rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.search-result {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.search-result:hover {
  border-color: var(--accent);
}

.search-sep {
  color: var(--text-mute);
  margin: 0 0.3rem;
}

.section-blurb {
  font-size: .95rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

#companyListBlurb {
  margin: 1rem 2rem 0;
}

@media (max-width: 600px) {
  #companyListBlurb {
    margin: 1rem;
  }
}

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(480px, 100%), 1fr));
  gap: 1.25rem;
  padding: 1.5rem 2rem;
}

@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
    justify-items: center;
  }
  .card {
    width: 100%;
    max-width: 28rem;
  }
  .search-bar {
    padding: 0.75rem 1rem;
  }
  .site-header {
    padding: 0 1rem;
  }
  .detail-container {
    padding: 1rem;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  padding: 1.25rem 1.4rem 1.1rem;
  transition: background .15s, border-color .15s;
  cursor: pointer;
  position: relative;
}

.card:hover {
  background: var(--surface2);
  border-color: var(--border2);
}

/* Card entrance animation */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeUp 0.3s ease both;
}

.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.card-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  flex-shrink: 0;
}

.card-logo-placeholder {
  width: 150px;
  height: 150px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-logo-placeholder svg {
  width: 32px;
  height: 32px;
  fill: var(--text-mute);
}

.card-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--text-dim);
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 0.8rem;
}

/* ─── Certification Badge ──────────────────────────────── */

.cert-badge {
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  padding: 0.2rem 0.5rem;
  opacity: 0.7;
}

.cert-badge.device-analysis {
  color: var(--accent);
}

.cert-badge.accessory-analysis {
  color: var(--success);
}

/* ─── Device/Accessory type backgrounds ────────────────── */

.cert-device {
  background: rgba(88, 166, 255, 0.06);
  border-left: 3px solid var(--accent);
}

.cert-accessory {
  background: rgba(63, 185, 80, 0.06);
  border-left: 3px solid var(--success);
}

/* ─── Certification Pip ────────────────────────────────── */

.cert-pip {
  width: 3px;
  height: 100%;
  min-height: 1.4rem;
  flex-shrink: 0;
}

.cert-pip.device-analysis {
  background: var(--accent);
}

.cert-pip.accessory-analysis {
  background: var(--success);
}

/* ─── Tags ─────────────────────────────────────────────── */

.tag {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-mute);
  background: var(--tag-bg);
  border: 1px solid var(--border);
  padding: 0.15rem 0.4rem;
}

/* ─── Company Detail Page ──────────────────────────────── */

.detail-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.company-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.company-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  flex-shrink: 0;
}

.company-logo-placeholder {
  width: 150px;
  height: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.company-logo-placeholder svg {
  width: 48px;
  height: 48px;
  fill: var(--text-mute);
}

.company-name {
  font-size: 1.6rem;
  font-weight: 600;
}

.company-notes {
  font-size: 1.05rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.5;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

/* ─── Certification Sections ───────────────────────────── */

.cert-section {
  margin-bottom: 2rem;
  padding: 1rem;
}

.cert-section-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.cert-type {
  font-family: var(--font-mono);
  font-size: .95rem;
  font-weight: 600;
  text-transform: uppercase;
}

.cert-type.device-analysis {
  color: var(--accent);
}

.cert-type.accessory-analysis {
  color: var(--success);
}

.cert-meta {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-dim);
}

/* ─── Certification 3-Column Detail ────────────────────── */

.cert-detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr 220px;
  gap: 1.5rem;
  align-items: start;
  padding: 1rem 0;
}

@media (max-width: 900px) {
  .cert-detail-grid {
    grid-template-columns: 1fr;
  }
}

.cert-badge-col {
  display: flex;
  align-items: flex-start;
}

.cert-badge-svg {
  width: 100%;
  max-width: 340px;
  height: auto;
}

.cert-fields-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cert-field {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.cert-field-label {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cert-field-value {
  font-size: 1rem;
  color: var(--text);
}

.cert-photo-col {
  display: flex;
  justify-content: flex-end;
}

.cert-item-photo {
  width: 200px;
  height: 200px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
}

.cert-notes {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ─── Device Cards ─────────────────────────────────────── */

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

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.25rem;
}

.device-photo {
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin-bottom: 0.8rem;
  background: var(--bg);
}

.device-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.device-part {
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.device-notes {
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── Accessory Cards ──────────────────────────────────── */

.accessory-section {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.accessory-section-title {
  font-family: var(--font-mono);
  font-size: .8rem;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 0.6rem;
  letter-spacing: 0.05em;
}

.accessory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
}

.accessory-card {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.9rem;
}

.accessory-photo {
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin-bottom: 0.5rem;
  background: var(--surface);
}

.accessory-name {
  font-weight: 600;
  font-size: 1rem;
}

.accessory-part {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-dim);
}

.accessory-notes {
  font-size: .95rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
}

/* ─── Footer ───────────────────────────────────────────── */

.site-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-dim);
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ─── Loading / Empty States ───────────────────────────── */

.loading {
  text-align: center;
  padding: 3rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-dim);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
}

.empty-state h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-family: var(--font-mono);
  font-size: .95rem;
}
