/*
 * Supplier public profile page (/supplier/{slug}).
 *
 * Layout follows the /company/{slug}/news article-page pattern: main content
 * card on the left, sticky sidebar on the right holding a Contact card + an
 * At-a-glance stats card. Coverage polygons + office pins live in one shared
 * map inside the main card so a visitor sees WHERE the supplier operates and
 * WHERE their offices sit in a single glance.
 *
 * Palette mirrors the advanced-map supplier surface (teal #0f766e) — pin
 * classes below duplicate what map-page-new.css defines for `.suppliers-hq-pin`
 * / `.suppliers-marker` since that stylesheet isn't loaded on this page and
 * the shell embeds suppliers-layer.js standalone.
 */

/* ---------- Page shell ---------- */

.sup-page {
  max-width: 1240px;
  margin: 0 auto;
  /* body { padding-top: 65px } in /css/style.css already clears the fixed
     nav; only the breathing room + horizontal + bottom padding lives here. */
  padding: 20px 24px 48px;
  color: #0f172a;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (max-width: 640px) {
  .sup-page {
    padding: 16px 16px 40px;
  }
}

/* ---------- Preview banner ---------- */

/* :not([hidden]) is load-bearing — see prior commit note. */
.sup-preview-banner:not([hidden]) {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.sup-preview-banner__inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}

.sup-preview-banner__dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.18);
}

.sup-preview-banner strong {
  color: #92400e;
  margin-right: 4px;
}

/* ---------- Breadcrumb ---------- */

.sup-breadcrumb {
  margin-bottom: 16px;
  font-size: 13px;
  color: #64748b;
}

.sup-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sup-breadcrumb a {
  color: #475569;
  text-decoration: none;
}

.sup-breadcrumb a:hover {
  color: #0f766e;
  text-decoration: underline;
}

.sup-breadcrumb .sup-sep {
  color: #cbd5e1;
}

.sup-breadcrumb li:last-child {
  color: #0f172a;
  font-weight: 500;
}

/* ---------- Grid + main card + sidebar ---------- */

.sup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .sup-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.sup-main-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  min-width: 0;
}

@media (max-width: 640px) {
  .sup-main-card {
    padding: 20px;
    border-radius: 10px;
  }
}

.sup-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  /* 65px fixed nav + 24px breathing room */
  top: 89px;
  align-self: start;
}

@media (max-width: 960px) {
  .sup-sidebar {
    position: static;
    top: auto;
  }
}

/* ---------- Hero (inside the main card) ---------- */

.sup-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px 20px;
  align-items: center;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
}

.sup-hero-brand {
  grid-column: 1 / span 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.sup-hero-logo {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #0f766e;
  overflow: hidden;
}

/* Monogram fallback: only the initials tile gets the tinted background so
   suppliers who haven't uploaded a logo still show a branded fill. Actual
   logos render on transparent so the artwork isn't boxed in. */
.sup-hero-logo:not(:has(img)) {
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
}

.sup-hero-logo.is-wide-logo {
  /* Wide banner-style logos (e.g. Major Drilling) — keep aspect ratio. */
  width: 180px;
  height: 88px;
  border-radius: 12px;
}

.sup-hero-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sup-hero-brand__text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.sup-hero-name {
  margin: 0;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.sup-hero-primary-cat {
  align-self: flex-start;
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: transparent;
  color: #1e40af;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.sup-hero-ticker {
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
}

.sup-hero-meta {
  grid-column: 1 / span 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  color: #475569;
  font-size: 13.5px;
}

.sup-hero-meta__row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.sup-hero-meta__row i {
  color: #0f766e;
  width: 14px;
  text-align: center;
}

.sup-hero-meta__hqicon {
  display: inline-flex;
  width: 18px;
  height: 22px;
  flex-shrink: 0;
}
.sup-hero-meta__hqicon .suppliers-hq-pin {
  width: 18px;
  height: 22px;
}
.sup-hero-meta__hqicon .suppliers-hq-pin-label {
  top: 3px;
  font-size: 5px;
  line-height: 10px;
}

.sup-hero-meta__svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #0f766e;
  flex-shrink: 0;
}
.sup-hero-meta__svg svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sup-hero-meta__text {
  color: #334155;
  font-weight: 500;
}

/* ---------- Shared buttons ---------- */

.sup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  font-family: inherit;
}

.sup-btn--primary {
  background: #0f766e;
  color: #ffffff;
  border-color: #0f766e;
}

.sup-btn--primary:hover {
  background: #0d5f58;
  border-color: #0d5f58;
  color: #ffffff;
}

.sup-btn--outline {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

.sup-btn--outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.sup-btn--block {
  width: 100%;
}

/* ---------- Sections (inside main card) ---------- */

.sup-section {
  padding: 24px 0;
  border-top: 1px solid #e2e8f0;
}

.sup-section:first-of-type,
.sup-hero + .sup-section {
  border-top: none;
  padding-top: 0;
}

.sup-section-title {
  margin: 0 0 16px;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.005em;
}

.sup-section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sup-section-title-row .sup-section-title {
  margin: 0;
}

.sup-section-meta {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

/* ---------- About ---------- */

.sup-about-wrap {
  position: relative;
  max-width: 860px;
}

.sup-about-wrap.is-clamped {
  max-height: 220px;
  overflow: hidden;
}

.sup-about-wrap.is-expanded {
  max-height: none;
}

.sup-about {
  font-size: 15px;
  line-height: 1.65;
  color: #334155;
}

.sup-about p {
  margin: 0 0 12px;
}

.sup-about p:last-child {
  margin-bottom: 0;
}

.sup-about a {
  color: #0f766e;
  text-decoration: underline;
}

/* Bottom fade only when clamped — signals "there's more below" without
   drawing a chrome-heavy overlay. */
.sup-about-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #ffffff 90%);
  opacity: 0;
  transition: opacity 0.15s;
}

.sup-about-wrap.is-clamped .sup-about-fade {
  opacity: 1;
}

.sup-about-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f766e;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}

.sup-about-toggle:hover {
  background: #f0fdfa;
  border-color: #99f6e4;
}

/* Swap labels based on wrapper state — the wrap is a sibling so we use
   :has() on the section. Fallback: both labels are shown at 0 width when
   :has() isn't supported, still functional via textContent switch. */
.sup-about-toggle__less { display: none; }
.sup-section:has(.sup-about-wrap.is-expanded) .sup-about-toggle__more { display: none; }
.sup-section:has(.sup-about-wrap.is-expanded) .sup-about-toggle__less { display: inline; }

/* ---------- Services (chips grouped by root category) ---------- */

.sup-services {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sup-services-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sup-services-group__title {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sup-services-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sup-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #ffffff;
  color: #1e40af;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}

.sup-chip--commodity {
  border-color: #bfdbfe;
  color: #1e40af;
}

/* ---------- Coverage + offices (combined) ---------- */

.sup-coverage-map {
  position: relative;
  margin: 0 0 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.sup-coverage-map-canvas {
  width: 100%;
  height: 340px;
}

@media (max-width: 640px) {
  .sup-coverage-map-canvas {
    height: 240px;
  }
}

.sup-coverage-map-label:not([hidden]) {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  pointer-events: none;
  z-index: 500;
}

/* Coverage polygon rendering — mirrors the advanced-map details panel
   light-basemap symbology (teal, low fill opacity). */
.supplier-coverage-poly {
  transition: fill-opacity 0.12s;
}

/* Suppliers pin classes duplicated from
   static/advanced-map/styles/map-page-new.css so the profile page's map
   picks up the branded HQ + branch pins without loading the full advanced-
   map stylesheet. Keep in sync if the map's pin design ships an update. */

.suppliers-marker,
.suppliers-marker-hq {
  background: transparent;
  border: 0;
}

.suppliers-hq-pin {
  position: relative;
  width: 24px;
  height: 32px;
  overflow: visible;
  filter: drop-shadow(0 1.5px 2px rgba(15, 23, 42, 0.35));
}

.suppliers-hq-pin svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.suppliers-hq-pin-label {
  position: absolute;
  /* Matches map-page-new.css — SVG path centers the white inner circle at
     (16,16) with radius 11 in the 32×44 base viewBox (+2 margin → 36×48).
     Scaled to 24×32 the circle sits ~4px from the top with a ~16.5px
     diameter; line-height matches to center vertically on the circle. */
  top: 4px;
  left: 0;
  right: 0;
  text-align: center;
  color: #0f766e;
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 7px;
  font-weight: 800;
  line-height: 16px;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* Branch (non-HQ) pin colours — the SVG carries the fill inline so this is
   only a defensive fallback. */
.suppliers-pin-body {
  fill: #0f766e;
}

/* Tooltip inside the profile map — smaller + tighter than the main
   supplier tooltip since the profile map is used for context, not filtering. */
.sup-map-tooltip {
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.sup-map-tooltip::before {
  border-top-color: rgba(15, 23, 42, 0.92);
}

.sup-map-tip__label {
  font-weight: 600;
}

.sup-map-tip__addr {
  opacity: 0.8;
  margin-top: 2px;
}

/* ---------- Offices (row-per-office list below the map) ---------- */

.sup-offices {
  margin: 0;
}

.sup-offices-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.sup-office-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
}

.sup-office-row:first-child {
  border-top: none;
}

.sup-office-row__pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: #0f766e;
}

.sup-office-row__pin .suppliers-hq-pin {
  width: 20px;
  height: 26px;
}

.sup-office-row__pin svg {
  width: 20px;
  height: 26px;
  display: block;
}

/* HQ label scaled to the 20×26 row pin — shrink font/line-height and lift
   the top offset so the "HQ" text sits inside the (smaller) white circle
   rather than dropping onto the teal body below. */
.sup-office-row__pin .suppliers-hq-pin-label {
  top: 3px;
  font-size: 5.5px;
  line-height: 13px;
}

.sup-office-row__body {
  min-width: 0;
}

.sup-office-row__primary {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
}

.sup-office-row__secondary {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
  margin-top: 2px;
}

.sup-office-row__role {
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.sup-office-row__role.is-hq {
  color: #0f766e;
  background: #f0fdfa;
  border-color: #99f6e4;
}

/* ---------- Areas + commodities ---------- */

.sup-commodities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Projects (recent experience, table view) ---------- */

.sup-project-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.sup-project-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.sup-project-table thead th {
  text-align: left;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sup-project-table tbody td {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: top;
}

.sup-project-table tbody tr:first-child td {
  border-top: none;
}

.sup-project-row__name {
  font-weight: 600;
  color: #0f172a;
}

.sup-project-row__commodities,
.sup-project-row__location,
.sup-project-row__date {
  color: #475569;
  white-space: nowrap;
}

.sup-project-row__commodities {
  white-space: normal;
}

@media (max-width: 640px) {
  .sup-project-table-wrap {
    overflow-x: auto;
  }
  .sup-project-table {
    min-width: 520px;
  }
}

/* ---------- Sidebar cards ---------- */

.sup-side-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 18px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.sup-side-card__label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Contact card body */

.sup-side-contact__body {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-bottom: 14px;
}

.sup-contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.sup-contact-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sup-contact-name {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}

.sup-contact-role {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.3;
}

.sup-side-contact__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* At-a-glance stats — one row per fact, icon + label + value stacked. Icons
   make the card scannable at a glance rather than reading a wall of text. */

.sup-glance-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sup-glance-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.sup-glance-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f0fdfa;
  color: #0f766e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sup-glance-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sup-glance-text {
  min-width: 0;
}

.sup-glance-label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
}

.sup-glance-value {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  margin-top: 1px;
  word-break: break-word;
}

/* ---------- Skeleton loaders ---------- */

.sup-skel {
  display: inline-block;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: sup-skel-shimmer 1.4s ease-in-out infinite;
}

.sup-skel-logo {
  width: 88px;
  height: 88px;
  border-radius: 14px;
}

.sup-skel-name {
  display: block;
  width: 260px;
  height: 30px;
  border-radius: 8px;
}

@keyframes sup-skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sup-skel {
    animation: none;
  }
}

/* ---------- Loading / error states ---------- */

.sup-loading,
.sup-error {
  padding: 60px 24px;
  text-align: center;
  color: #475569;
}

.sup-loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid #e2e8f0;
  border-top-color: #0f766e;
  border-radius: 50%;
  animation: sup-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .sup-loading-spinner {
    animation: none;
  }
}

.sup-error strong {
  color: #b91c1c;
}

/* ---------- Mobile layout ---------- */

@media (max-width: 720px) {
  .sup-hero {
    grid-template-columns: 1fr;
  }
  .sup-hero-brand {
    grid-column: 1;
    grid-template-columns: 1fr;
    gap: 12px;
    text-align: left;
  }
  .sup-hero-logo {
    width: 64px;
    height: 64px;
    font-size: 22px;
  }
  .sup-hero-logo.is-wide-logo {
    width: 140px;
    height: 64px;
  }
  .sup-hero-name {
    font-size: 22px;
  }
  .sup-hero-meta {
    grid-column: 1;
  }
}
