/* ===========================================================================
   PRODUCT CONSOLE — /product2 (src/product2.js)

   The "GRC OS" treatment: a near-black telemetry hero over a tabbed module
   console. Everything is scoped under .p2 so it cannot leak into the rest of
   the site while the two product pages sit side by side.

   The reference this came from was Tailwind-on-a-CDN with utility classes; the
   CSP here allows neither the CDN script nor an inline <style>, so the same
   look is rebuilt on the site's own tokens. The palette already matched —
   cyan #00D2FF is --color-tertiary, #000F24 is --color-primary — so only the
   console greys and the three status colours are new, and they stay local.
   =========================================================================== */

.p2 {
  --p2-void: #060d17;
  --p2-surface: #061426;
  --p2-lowest: #020e21;
  --p2-container: #132033;
  --p2-high: #1d2a3e;
  --p2-highest: #28354a;

  --p2-border: rgb(var(--color-tertiary-rgb) / 0.15);
  --p2-hairline: rgb(var(--color-secondary-rgb) / 0.06);

  --p2-emerald: #10b981;
  --p2-amber: #f59e0b;
  --p2-crimson: #ef4444;
  --p2-outline: #8e9097;

  background: var(--p2-surface);
  color: var(--on-surface, var(--ink));
}

.p2-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--content-pad);
}

/* --- Shared atoms ---------------------------------------------------------- */

.p2-text--cyan {
  color: var(--accent);
}
.p2-text--emerald {
  color: var(--p2-emerald);
}
.p2-text--amber {
  color: var(--p2-amber);
}
.p2-text--crimson {
  color: var(--p2-crimson);
}

.p2-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}
.p2-icon--cyan {
  color: var(--accent);
}
.p2-icon--emerald {
  color: var(--p2-emerald);
}

/* Monospace, uppercase, tight — the console register. */
.p2-kicker,
.p2-chip,
.p2-ribbon-label,
.p2-widget-title,
.p2-widget-meta,
.p2-stat-label,
.p2-tab {
  font-family: var(--font-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.p2-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  font-size: 0.66rem;
  font-weight: 700;
  white-space: nowrap;
}
.p2-chip--cyan {
  color: var(--accent);
  background: rgb(var(--color-tertiary-rgb) / 0.12);
}
.p2-chip--emerald {
  color: var(--p2-emerald);
  background: rgb(16 185 129 / 0.12);
}
.p2-chip--amber {
  color: var(--p2-amber);
  background: rgb(245 158 11 / 0.12);
}
.p2-chip--crimson {
  color: var(--p2-crimson);
  background: rgb(239 68 68 / 0.12);
}
.p2-chip--ghost {
  color: var(--p2-outline);
  background: var(--p2-highest);
  border-color: var(--p2-hairline);
}

.p2-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.78rem 1.25rem;
  border-radius: 6px;
  font-family: var(--font-headline);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    background-color 0.2s,
    color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}
.p2-btn--primary {
  background: var(--accent);
  color: var(--color-primary);
  box-shadow: 0 0 24px rgb(var(--color-tertiary-rgb) / 0.4);
}
.p2-btn--primary:hover {
  background: var(--color-secondary);
  color: var(--color-primary);
  transform: translateY(-1px);
}
.p2-btn--ghost {
  background: rgb(var(--color-secondary-rgb) / 0.05);
  border: 1px solid var(--p2-border);
  color: var(--ink);
}
.p2-btn--ghost:hover {
  background: var(--p2-highest);
  color: var(--accent);
}
.p2-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ===========================================================================
   HERO
   =========================================================================== */

.p2-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(3rem, 7vw, 5rem);
  background: var(--p2-void);
  border-bottom: 1px solid var(--p2-border);
}

/* The reference pulled a remote telemetry image; img-src is 'self', so this
   uses the artwork the site already ships. */
.p2-hero-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--p2-void) 15%, rgb(6 13 23 / 0.9) 45%, transparent 100%),
    radial-gradient(
      ellipse 70% 50% at 20% 20%,
      rgb(var(--color-tertiary-rgb) / 0.14),
      transparent 70%
    ),
    url('/assets/img/img-herogb.png') right center / cover no-repeat;
  opacity: 0.85;
  pointer-events: none;
}

.p2-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}
.p2-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  background: rgb(29 42 62 / 0.8);
  border: 1px solid var(--p2-border);
  color: var(--accent);
  font-family: var(--font-label);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.p2-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  animation: p2-pulse 2s ease-in-out infinite;
}
@keyframes p2-pulse {
  50% {
    opacity: 0.3;
  }
}
.p2-status-note {
  color: var(--p2-outline);
  font-family: var(--font-label);
  font-size: 0.7rem;
}

.p2-title {
  max-width: 18ch;
  margin: 0 0 1rem;
  font-family: var(--font-headline);
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--ink);
}
/* Gradient text needs a colour fallback: if background-clip: text is not
   honoured, transparent text would disappear entirely. */
.p2-title-accent {
  color: var(--accent);
}
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .p2-title-accent {
    background: linear-gradient(90deg, var(--accent), var(--tertiary-300), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.p2-lede {
  max-width: 62ch;
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  line-height: 1.65;
}

.p2-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 2rem;
}
.p2-proof {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--p2-hairline);
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 0.72rem;
}

/* --- Telemetry ribbon ------------------------------------------------------ */

.p2-ribbon {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border-radius: 8px;
  background: rgb(2 14 33 / 0.8);
  border: 1px solid var(--p2-border);
}
.p2-ribbon li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.5rem;
  border-radius: 5px;
  background: rgb(19 32 51 / 0.5);
  border: 1px solid var(--p2-hairline);
  text-align: center;
  font-family: var(--font-label);
  font-size: 0.72rem;
  font-weight: 700;
}
.p2-ribbon-label {
  color: var(--p2-outline);
  font-size: 0.6rem;
  font-weight: 500;
}

/* ===========================================================================
   CONSOLE
   =========================================================================== */

.p2-console {
  padding: var(--section-y) 0;
  scroll-margin-top: 96px;
}

.p2-console-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.p2-console-head h2 {
  max-width: 24ch;
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 2rem);
}
.p2-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
}
.p2-console-note {
  max-width: 30ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* --- Tab strip -------------------------------------------------------------
   Hidden until main.js confirms scripting: without it every panel is shown in
   sequence instead, so no content depends on JS. */

.p2-tabs {
  display: none;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--p2-border);
  scrollbar-width: none;
}
.p2-tabs::-webkit-scrollbar {
  display: none;
}
.js .p2-tabs {
  display: flex;
}

.p2-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
}
.p2-tab-num {
  color: var(--p2-outline);
}
.p2-tab:hover {
  background: var(--p2-high);
  color: var(--ink);
}
.p2-tab[aria-selected='true'] {
  background: var(--accent);
  color: var(--color-primary);
  box-shadow: 0 0 12px rgb(var(--color-tertiary-rgb) / 0.4);
}
.p2-tab[aria-selected='true'] .p2-tab-num {
  color: rgb(var(--color-primary-rgb) / 0.6);
}
.p2-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Stage and panels ------------------------------------------------------ */

.p2-stage {
  padding: clamp(1rem, 2.5vw, 1.75rem);
  border-radius: 12px;
  background: var(--p2-lowest);
  border: 1px solid var(--p2-border);
  box-shadow: var(--shadow-lg);
}

.p2-panel {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: center;
  gap: clamp(1.25rem, 3vw, 2rem);
}
/* With scripting, only the selected panel is in the document flow. Without it,
   every panel stacks and the whole page is still readable. */
.js .p2-panel:not(.is-active) {
  display: none;
}
.js .p2-panel + .p2-panel {
  margin-top: 0;
}
.p2-panel + .p2-panel {
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--p2-hairline);
}

.p2-panel-copy h3 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  line-height: 1.25;
}
.p2-panel-body {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

.p2-points {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.p2-points li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.85rem;
  line-height: 1.45;
}
.p2-points .p2-icon {
  margin-top: 0.1em;
}

/* --- Widget panes ---------------------------------------------------------- */

.p2-widget {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: clamp(0.85rem, 2vw, 1.25rem);
  border-radius: 8px;
  background: var(--p2-container);
  border: 1px solid var(--p2-hairline);
  font-family: var(--font-label);
  font-size: 0.75rem;
}

.p2-widget-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--p2-hairline);
}
.p2-widget-title {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
}
.p2-widget-meta {
  color: var(--p2-outline);
  font-size: 0.62rem;
}
.p2-widget-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.68rem;
}

/* Risk matrix */
.p2-matrix {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
}
.p2-cell {
  display: grid;
  place-items: center;
  height: 2rem;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 700;
}
.p2-cell--emerald {
  background: rgb(16 185 129 / 0.2);
  color: var(--p2-emerald);
}
.p2-cell--amber {
  background: rgb(245 158 11 / 0.22);
  color: var(--p2-amber);
}
.p2-cell--crimson {
  background: rgb(239 68 68 / 0.55);
  color: var(--color-secondary);
}
.p2-cell--crit {
  background: var(--p2-crimson);
  color: var(--color-secondary);
  box-shadow: 0 0 10px rgb(239 68 68 / 0.7);
}

/* Rows, callouts, files */
.p2-row,
.p2-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border-radius: 5px;
  background: var(--p2-lowest);
  border: 1px solid var(--p2-hairline);
}
.p2-callout {
  border-color: rgb(var(--color-tertiary-rgb) / 0.3);
}
.p2-row-main,
.p2-callout > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.p2-row-title,
.p2-callout-title {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.72rem;
}
.p2-callout-title {
  color: var(--accent);
}
.p2-row-sub,
.p2-callout-sub {
  color: var(--p2-outline);
  font-size: 0.64rem;
}

.p2-files {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.p2-file {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.7rem;
  border-radius: 5px;
  background: var(--p2-lowest);
  border: 1px solid var(--p2-hairline);
  min-width: 0;
}
.p2-file-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}
.p2-file-name {
  color: var(--ink);
  font-weight: 700;
}
.p2-file-hash {
  color: var(--p2-outline);
  font-size: 0.62rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p2-file-link {
  color: var(--accent);
  font-size: 0.62rem;
}

/* Cross-walk */
.p2-maps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.p2-map {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem;
  border-radius: 5px;
  background: rgb(29 42 62 / 0.6);
  border: 1px solid var(--p2-hairline);
  min-width: 0;
}
.p2-map-norm {
  display: block;
  color: var(--tertiary-300);
  font-size: 0.6rem;
}
.p2-map-clause {
  display: block;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.7rem;
}

/* Clock */
.p2-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 1rem 0.75rem;
  border-radius: 6px;
  background: var(--p2-lowest);
  border: 1px solid var(--p2-hairline);
  text-align: center;
}
.p2-clock-label,
.p2-clock-unit {
  color: var(--p2-outline);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.p2-clock-time {
  color: var(--p2-crimson);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* Meters */
.p2-meter {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.p2-meter-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 600;
}
.p2-meter-value {
  font-weight: 700;
}
.p2-meter-track {
  height: 0.35rem;
  border-radius: 999px;
  background: var(--p2-high);
  overflow: hidden;
}
.p2-meter-track--lg {
  height: 0.5rem;
}
.p2-meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.p2-meter-fill--emerald {
  background: var(--p2-emerald);
}
.p2-meter-fill--cyan {
  background: var(--accent);
}
.p2-meter-fill--spectrum {
  background: linear-gradient(90deg, var(--p2-emerald), var(--p2-amber), var(--p2-crimson));
}
/* Widths as classes, because an inline style attribute would fail the build
   and be refused by style-src 'self'. */
.p2-w-57 {
  width: 57%;
}
.p2-w-94 {
  width: 94%;
}
.p2-w-96 {
  width: 96%;
}
.p2-w-100 {
  width: 100%;
}

/* Stats */
.p2-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
.p2-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.5rem;
  border-radius: 5px;
  background: var(--p2-high);
  text-align: center;
}
.p2-stat-label {
  color: var(--p2-outline);
  font-size: 0.58rem;
}
.p2-stat-value {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Table */
.p2-table-wrap {
  overflow-x: auto;
}
.p2-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.p2-table th {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--p2-hairline);
  color: var(--p2-outline);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.p2-table td {
  padding: 0.45rem 0.5rem 0.45rem 0;
  border-bottom: 1px solid var(--p2-hairline);
  font-size: 0.7rem;
  white-space: nowrap;
}
.p2-table td:first-child {
  color: var(--ink);
  font-weight: 700;
}

/* ===========================================================================
   CLOSING BAND
   =========================================================================== */

.p2-close {
  padding: 0 0 var(--section-y);
}
.p2-close-card {
  padding: clamp(1.75rem, 4vw, 3rem);
  border-radius: 12px;
  text-align: center;
  background:
    radial-gradient(80% 140% at 50% 0%, rgb(var(--color-tertiary-rgb) / 0.14), transparent 60%),
    var(--p2-container);
  border: 1px solid var(--p2-border);
}
.p2-close-card h2 {
  margin: 0 0 0.6rem;
}
.p2-close-card p {
  max-width: 52ch;
  margin: 0 auto 1.5rem;
  color: var(--muted);
}
.p2-close-card .p2-actions {
  justify-content: center;
  margin-bottom: 0;
}

/* ===========================================================================
   RESPONSIVE
   =========================================================================== */

@media (max-width: 1100px) {
  .p2-ribbon {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  /* The widget is illustrative; the copy is the content, so it leads. */
  .p2-panel {
    grid-template-columns: minmax(0, 1fr);
  }
  .p2-console-head {
    align-items: flex-start;
  }
  .p2-console-note {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .p2-ribbon {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .p2-maps,
  .p2-stats {
    grid-template-columns: minmax(0, 1fr);
  }
  .p2-proof {
    padding-left: 0;
    border-left: 0;
  }
  .p2-actions .p2-btn {
    width: 100%;
    justify-content: center;
  }
  .p2-matrix {
    gap: 0.2rem;
  }
  .p2-cell {
    height: 1.75rem;
    font-size: 0.58rem;
  }
  .p2-hero-bg {
    opacity: 0.4;
  }
}

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