/* ==========================================================================
   principal.css — Principal detail page components
   Layers on top of home.css (nav, footer, buttons, cards, grids).
   All values pull from variables.css / typography.css.
   ========================================================================== */

/* Keep page content clear of the fixed bottom CTA bar */
body.has-sticky-cta { padding-bottom: 80px; }

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */
.breadcrumb {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font: var(--text-small);
  color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb li { display: flex; align-items: center; gap: 0.5rem; }
.breadcrumb li:not(:last-child)::after {
  content: "/";
  color: var(--color-border);
}
.breadcrumb [aria-current="page"] { color: var(--color-charcoal); font-weight: var(--weight-medium); }

/* --------------------------------------------------------------------------
   Principal hero (white)
   -------------------------------------------------------------------------- */
.principal-hero { background: var(--color-white); padding-block: var(--space-xl); }
.principal-hero__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
}
.principal-hero__main { max-width: 640px; }

/* Small supporting logo mark — the H1 below is the dominant identity.
   Sits above the category pill. Kept deliberately compact and frameless so
   it works consistently across all 19 principals regardless of logo format. */
.principal-logo {
  display: inline-flex;
  align-items: center;
  height: 68px;
  margin-bottom: var(--space-md);
  /* styling for the text fallback if the logo image is missing */
  font: var(--text-h3);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
}
.principal-logo img {
  height: 100%;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  object-position: left center;
}
/* Non-destructive logo fallback. On error the <img> is only HIDDEN (it stays
   in the DOM with its src, so a broken logo can still be inspected) and this
   sibling text is revealed instead. Canonical markup for every principal page:
     <span class="principal-logo">
       <img src="…/logo.svg" alt="X logo"
            onerror="this.style.display='none'; this.nextElementSibling.hidden=false;">
       <span class="principal-logo__fallback" hidden>X</span>
     </span>
   The fallback inherits the display font/weight/colour from .principal-logo. */
/* `:not([hidden])` so the hidden attribute's display:none still wins when the
   image loads OK — otherwise this rule would show the fallback text always. */
.principal-logo__fallback:not([hidden]) { display: inline-flex; align-items: center; }

.pill {
  display: inline-block;
  font: var(--text-caption);
  letter-spacing: var(--tracking-caption);
  text-transform: uppercase;
  font-weight: var(--weight-semibold);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}
.pill--category {
  color: var(--color-primary);
  background: rgba(204, 21, 22, 0.10); /* light red tint of --color-primary */
}

.principal-hero h1 { margin: 0.75rem 0 0.5rem; }
.principal-hero__tagline {
  color: var(--color-text-muted);
  max-width: 52ch;
  margin-bottom: var(--space-md);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font: var(--text-small);
  color: var(--color-charcoal);
}
.meta-row li { display: flex; align-items: center; gap: 0.75rem; }
.meta-row li:not(:last-child)::after {
  content: "·";
  color: var(--color-text-muted);
}

.principal-hero__note {
  font: var(--text-small);
  color: var(--color-text-muted);
  margin-top: 0.6rem;
}

.principal-hero__actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 200px;
}

/* --------------------------------------------------------------------------
   Key products — grouped
   -------------------------------------------------------------------------- */
.product-group + .product-group { margin-top: var(--space-lg); }
.product-group__title {
  font: var(--text-h3);
  color: var(--color-charcoal);
  padding-bottom: 0.5rem;
  margin-bottom: var(--space-md);
  border-bottom: 2px solid var(--color-border);
}
.product-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}
.product-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}
.product-card__media {
  aspect-ratio: 16 / 10;
  overflow: hidden;   /* resets automatic min-height to 0 so aspect-ratio wins */
  min-height: 0;      /* height is derived from width × ratio, never from the image */
  background: var(--color-surface); /* grey placeholder until image is added */
  border-bottom: 1px solid var(--color-border);
}
.product-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;  /* taller/wider images are cropped to the fixed box */
}
/* Opt-in modifier for portrait / odd-ratio product photos: show the WHOLE
   image (contain) letterboxed on a light field, instead of cropping (cover).
   Apply to an individual .product-card__media only — never global. */
.product-card__media--contain { background: var(--color-surface); }
.product-card__media--contain img { object-fit: contain; }
/* Red accent runs alongside the TEXT only — never across the photo above it
   (mirrors the .why-card treatment on the homepage). */
.product-card__body {
  padding: var(--space-lg);
  border-left: 3px solid var(--color-primary);
}
.product-card h4 {
  font: var(--text-h3);
  font-size: 1.25rem;
  color: var(--color-charcoal);
  margin-bottom: 0.35rem;
}
.product-card p { color: var(--color-text-muted); font: var(--text-small); }
/* Small muted model-code / clarifier beneath a descriptive product title. */
.product-card__code {
  display: block;
  margin-top: -0.2rem;   /* sit snug beneath the title */
  margin-bottom: 0.4rem;
  font: var(--text-small);
  font-size: 0.8rem;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Tabbed product interface
   -------------------------------------------------------------------------- */
.tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
}
.tab {
  /* reset the filled base button look */
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.75rem 1rem;
  margin-bottom: -2px; /* sit the underline on the list's border */
  font: var(--text-small);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: color var(--transition-base), border-color var(--transition-base);
}
.tab:hover { background: transparent; color: var(--color-charcoal); }
.tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-panel[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Pakistan context band (dark rounded box)
   -------------------------------------------------------------------------- */
.pak-band {
  background: var(--color-charcoal);
  color: var(--color-white);
  border-radius: var(--radius-card);
  padding: clamp(1.5rem, 4vw, 3rem);
}
.pak-band__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-white);
  margin-bottom: var(--space-lg);
}
.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--color-whatsapp);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.2);
  flex-shrink: 0;
}
.pak-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}
.pak-point__icon {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--color-primary);
  margin-bottom: 0.6rem;
}
.pak-point h4 {
  color: var(--color-white);
  font: var(--text-h3);
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}
.pak-point p { color: rgba(255, 255, 255, 0.7); font: var(--text-small); }

/* --------------------------------------------------------------------------
   Technical specs table
   -------------------------------------------------------------------------- */
.spec-note {
  font-style: italic;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}
.spec-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.spec-table th,
.spec-table td {
  text-align: left;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  font: var(--text-body);
}
.spec-table tr:last-child th,
.spec-table tr:last-child td { border-bottom: none; }
.spec-table th {
  width: 40%;
  color: var(--color-charcoal);
  font-weight: var(--weight-semibold);
  background: var(--color-surface);
}
.spec-table td { color: var(--color-text-muted); }

/* --------------------------------------------------------------------------
   Gallery
   -------------------------------------------------------------------------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
.gallery-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--color-surface); /* grey placeholder until image is added */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

/* --------------------------------------------------------------------------
   Related principals
   -------------------------------------------------------------------------- */
.related-card { display: flex; flex-direction: column; gap: 0.35rem; }
.related-card h3 { font: var(--text-h3); font-size: 1.25rem; }
.related-card p { color: var(--color-text-muted); font: var(--text-small); }
.related-card__link {
  margin-top: auto;
  padding-top: var(--space-md);
  font: var(--text-small);
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
}
.view-all-link {
  display: inline-block;
  margin-top: var(--space-lg);
  font-weight: var(--weight-semibold);
}

/* --------------------------------------------------------------------------
   Principals listing page
   -------------------------------------------------------------------------- */
.cat-tabs { margin-bottom: var(--space-lg); }

.cat-group + .cat-group { margin-top: var(--space-xl); }
.cat-group__head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-bottom: 0.6rem;
  margin-bottom: var(--space-lg);
  border-bottom: 2px solid var(--color-border);
}
.cat-group__head h2 { font: var(--text-h2); font-size: 1.9rem; }
.cat-group__count { font: var(--text-small); color: var(--color-text-muted); }

.principal-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  color: inherit;
  transition: box-shadow var(--transition-base), transform var(--transition-base),
    border-color var(--transition-base);
}
.principal-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: var(--color-primary);
  color: inherit;
}
.principal-card__logo {
  width: 100%;
  height: 84px;
  display: grid;
  place-items: center;
  background: transparent;   /* no visible box around real logos */
  border-radius: var(--radius-button);
  font: var(--text-h2);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--color-charcoal);
}
/* Placeholder cards (text initials, no <img>) keep the grey box for now. */
.principal-card__logo:not(:has(img)) { background: var(--color-surface); }
/* Real logo image: fill the container confidently (contain = no crop).
   Fixed px max-height (not %) — percentage max-height is unreliable on a grid
   item and lets tall-aspect logos overflow the box. */
.principal-card__logo img {
  max-width: 100%;
  max-height: 76px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.principal-card__name {
  font: var(--text-h3);
  font-size: 1.2rem;
  color: var(--color-charcoal);
}
.principal-card__link {
  margin-top: auto;
  font: var(--text-small);
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   "Coming soon" placeholder page
   -------------------------------------------------------------------------- */
.coming-soon {
  min-height: 58vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding-block: var(--space-xl);
}
.coming-soon__inner { max-width: 46ch; }
.coming-soon h1 { margin-bottom: var(--space-md); }
.coming-soon p { color: var(--color-text-muted); margin-bottom: var(--space-lg); }
.coming-soon a.btn { text-decoration: none; }

/* --------------------------------------------------------------------------
   Sticky bottom CTA bar (fixed)
   -------------------------------------------------------------------------- */
.sticky-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: var(--color-primary);
  color: var(--color-white);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
}
.sticky-cta__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 64px;
  padding-block: 0.75rem;
}
.sticky-cta__text { font: var(--text-h3); font-size: 1.15rem; color: var(--color-white); }

/* --------------------------------------------------------------------------
   RFQ modal (native <dialog>)
   -------------------------------------------------------------------------- */
.rfq-dialog {
  width: min(560px, 92vw);
  border: none;
  border-radius: var(--radius-card);
  padding: 0;
  box-shadow: var(--shadow-card-hover);
  color: var(--color-text);
}
.rfq-dialog::backdrop { background: rgba(26, 26, 26, 0.55); }
.rfq-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
}
.rfq-dialog__head h2 { font: var(--text-h2); font-size: 1.6rem; }
.rfq-close {
  background: none;
  color: var(--color-text-muted);
  border: none;
  padding: 0.25rem;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.rfq-close:hover { background: none; color: var(--color-charcoal); }
.rfq-form { padding: 0 var(--space-lg) var(--space-lg); }
.rfq-prefill {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-button);
  padding: 0.75rem 1rem;
  margin-bottom: var(--space-md);
  font: var(--text-small);
}
.rfq-prefill span {
  display: block;
  font-weight: var(--weight-semibold);
  color: var(--color-charcoal);
  font-size: 1rem;
}
.field { margin-bottom: var(--space-md); }
.field label {
  display: block;
  font: var(--text-small);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
  margin-bottom: 0.35rem;
}
.field input,
.field textarea {
  width: 100%;
  font: var(--text-body);
  font-family: var(--font-body);
  color: var(--color-charcoal);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-button);
  padding: 0.7rem 0.9rem;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(204, 21, 22, 0.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.rfq-form .btn { width: 100%; margin-top: 0.25rem; }
.rfq-note {
  text-align: center;
  font: var(--text-small);
  color: var(--color-text-muted);
  margin-top: 0.75rem;
}
.rfq-success { padding: var(--space-lg); text-align: center; }
.rfq-success h2 { margin-bottom: 0.5rem; }
.rfq-success p { color: var(--color-text-muted); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .principal-hero__actions { width: 100%; }
  .product-list,
  .pak-grid,
  .gallery-grid,
  .field-row { grid-template-columns: 1fr; }
  .sticky-cta__text { font-size: 1rem; }
  .sticky-cta__inner { gap: 0.75rem; }
}
