/*
 * Entry page styles (PRD, Entry layout; issue #111). Loaded after base.css. Mobile-first: read on
 * a phone, outdoors, sometimes mid-incident. On a phone the call buttons come first and the PDF
 * buttons stay fixed to the bottom; from 64rem the call buttons move to a side column.
 */

h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin: 0 0 var(--space-3);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
}

time {
  white-space: nowrap;
}

/* Navy band: breadcrumb, title, chips and (on a wide screen) the PDF buttons. */

.entry-band .wrap {
  padding-top: var(--space-2);
  padding-bottom: var(--space-6);
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
  font-size: 1rem;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  min-height: 3rem;
  color: var(--on-navy);
  overflow-wrap: anywhere;
}

/* The separator is decoration: the list already tells a screen reader the crumbs are in order. */
.breadcrumb li + li::before {
  content: '/';
  content: '/' / '';
  padding: 0 var(--space-2);
  color: var(--on-navy-muted);
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  color: var(--on-navy);
  font-weight: 500;
}

.breadcrumb [aria-current='page'] {
  color: var(--on-navy-muted);
}

.entry-header {
  display: grid;
  gap: var(--space-5);
}

.supplier {
  margin: var(--space-1) 0 0;
  color: var(--on-navy-muted);
  font-size: 1.125rem;
}

.title-bar .recommended-use {
  margin: var(--space-1) 0 0;
  font-size: 1rem;
}

.recommended-use-label {
  color: var(--on-navy);
  font-weight: 600;
}

/* Chips: review status, issue date and DG class. Status keeps its safety colours. */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.chips p {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--pill);
  background: var(--navy-2);
  color: var(--on-navy);
  font-size: 1rem;
  font-weight: 600;
}

.chips .status-chip {
  font-weight: 700;
}

.status-chip[data-status='current'] {
  background: var(--ok);
  color: var(--on-ok);
}

.status-chip[data-status='due_soon'] {
  background: var(--caution);
  color: var(--on-caution);
}

.status-chip[data-status='out_of_date'] {
  border-color: var(--on-navy);
  background: var(--danger);
  color: var(--on-danger);
}

.status-chip[data-status='archived'] {
  background: var(--paper);
  color: var(--navy);
}

/* PDF buttons: fixed to the bottom on a phone, so they never scroll away. */

.pdf-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) max(var(--space-3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: 0 -4px 16px rgb(24 34 66 / 10%);
}

/* Room under the page for the fixed bar, so it never covers the footer, and scroll padding so
   it never hides the element that has keyboard focus (WCAG 2.2, 2.4.11). */
body:has(.pdf-actions) {
  padding-bottom: 5.5rem;
}

html:has(.pdf-actions) {
  scroll-padding-bottom: 6.5rem;
}

.pdf-button {
  flex: 1 1 0;
  min-height: 3.25rem;
  padding-right: var(--space-3);
  padding-left: var(--space-3);
}

.pdf-button--view {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-button--download {
  border-color: var(--navy);
  background: var(--paper);
  color: var(--navy);
}

.pdf-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Body: notices, then the cards. */

.entry-body {
  padding-top: var(--space-4);
}

.banner {
  display: flex;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--notice-rule);
  border-radius: var(--radius);
  background: var(--notice);
  color: var(--on-notice);
  font-weight: 600;
}

.banner::before {
  content: '';
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  background: currentColor;
  mask: url('/icons/alert.svg') center / contain no-repeat;
}

/* Over 5 years old: the caution yellow it had before, so it is not mistaken for a soft notice. */
.banner--out-of-date {
  border-color: var(--on-caution);
  background: var(--caution);
  color: var(--on-caution);
}

.banner--archived {
  border-color: var(--rule);
  background: var(--paper);
  color: var(--text);
  font-weight: 400;
}

.banner--archived::before {
  display: none;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.hazard,
.transport,
.sds-sections,
.full-sds {
  padding: var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

/* Call buttons: 000 in emergency red, never SMC blue. On a phone, 000 and Poisons Information sit
   side by side at the top of the page, with the supplier's line under them. */

.calls .eyebrow,
.calls h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.calls ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.calls li:nth-child(n + 3) {
  grid-column: 1 / -1;
}

.call {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 4.5rem;
  height: 100%;
  margin: 0;
  padding: var(--space-3) 2.75rem var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--on-navy);
  text-decoration: none;
}

a.call:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.call--000 {
  background: var(--danger);
  color: var(--on-danger);
}

/* The supplier's line: a white card, after 000 and Poisons Information. */
.calls li:nth-child(3) .call {
  border: 2px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
}

.call-icon {
  position: absolute;
  top: 50%;
  right: var(--space-4);
  transform: translateY(-50%);
}

.call-label {
  font-size: 1rem;
  font-weight: 600;
}

.call-number {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}

/* The supplier's number can be long: smaller, and let it wrap. */
.calls li:nth-child(3) .call-number {
  font-size: 1.25rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Not a button: a plain notice in the supplier slot when the SDS has no emergency number, or
   prints one that can't be read as a single clear number. */
.call-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
}

.call-printed {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.call-note {
  flex-basis: 100%;
  font-size: 1rem;
  font-weight: 500;
}

/* Hazard block */

.signal-word {
  display: inline-block;
  margin: 0;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-word--danger {
  background: var(--danger);
  color: var(--on-danger);
}

.signal-word--warning {
  background: var(--caution);
  color: var(--on-caution);
  outline: 2px solid var(--on-caution);
}

.pictograms {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-2);
  margin: var(--space-4) 0;
  padding: 0;
  list-style: none;
}

/* Diamond above its name, three across on a 375 px phone. */
.pictogram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: 5.75rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

/* Placeholder GHS diamond (white, red border) with the code until the official artwork is added. */
.pictogram-symbol {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  isolation: isolate;
}

.pictogram-symbol::before {
  content: '';
  position: absolute;
  inset: 0.7rem;
  z-index: -1;
  border: 0.3rem solid var(--danger);
  background: var(--paper);
  transform: rotate(45deg);
}

.hazard-statements {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-3);
  padding: 0;
  list-style: none;
  color: var(--ink);
}

.hazard-statements li {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.hazard-code {
  display: inline-block;
  min-width: 3.25rem;
  font-weight: 800;
}

.hazard-more,
.not-hazardous {
  margin: var(--space-2) 0 0;
  color: var(--muted);
}

.not-hazardous {
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 600;
}

/* Transport: by road and by sea, side by side when there is room. */

.dg {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.dg div {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    'icon mode'
    'icon value';
  align-items: center;
  column-gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

/* The span is the tile; its icon is masked on a pseudo-element, so the tile keeps its colour. */
.dg .icon {
  position: relative;
  grid-area: icon;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
  background: var(--tile);
  color: var(--link);
  mask: none;
}

.dg .icon::after {
  content: '';
  position: absolute;
  inset: 0.75rem;
  background: currentColor;
  mask: var(--icon) center / contain no-repeat;
}

.dg dt {
  grid-area: mode;
  color: var(--muted);
  font-size: 1rem;
}

.dg dd {
  grid-area: value;
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* SDS sections: native <details>, collapsed by default, so they open without JavaScript. */

.sds-sections {
  padding-right: 0;
  padding-left: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.sds-sections > .eyebrow,
.sds-sections > h2 {
  padding: 0 var(--space-5);
}

/* The "don't rely on the summaries" notice (issue #93): set apart from body text, never hidden. */
.summaries-notice {
  margin: 0 var(--space-5) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--notice-rule);
  border-radius: var(--radius);
  background: var(--notice);
  color: var(--on-notice);
  font-weight: 700;
}

.sds-sections details {
  border-top: 1px solid var(--rule);
}

.sds-sections summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.5rem;
  padding: var(--space-2) var(--space-5);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.sds-sections summary::-webkit-details-marker {
  display: none;
}

.sds-sections summary:hover {
  background: var(--panel);
}

.sds-sections summary:focus-visible {
  outline-offset: -3px;
}

.section-number {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--tile);
  color: var(--link);
  font-size: 1rem;
  font-weight: 700;
}

.section-title {
  flex: 1 1 auto;
  min-width: 0;
}

/* The chevron turns when open, so the state is not shown by colour alone. */
.section-chevron {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.sds-sections details[open] > summary .section-chevron {
  transform: rotate(180deg);
}

.sds-sections details > :not(summary) {
  margin-left: 2.75rem;
}

.essential {
  padding: var(--space-2) var(--space-5) var(--space-3);
}

.aquatic-hazard {
  margin: 0;
  padding: var(--space-2) var(--space-5);
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.aquatic-hazard + .essential,
.essential + .essential {
  border-top: 1px solid var(--rule);
}

.essential-label {
  margin-bottom: var(--space-1);
  color: var(--ink);
  font-weight: 700;
}

.essential p {
  overflow-wrap: anywhere;
}

.essential-source {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.essential-source a,
.section-empty a,
.aquatic-hazard a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: 700;
}

.section-empty {
  margin: 0;
  padding: 0 var(--space-5) var(--space-2);
  color: var(--muted);
}

/* Full SDS */

.full-sds h3 {
  margin: var(--space-4) 0 var(--space-1);
  font-size: 1rem;
}

.sds-links,
.related {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sds-links a,
.related a {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
  min-height: var(--tap);
  overflow-wrap: anywhere;
}

.sds-links a {
  font-weight: 700;
}

.sds-link-host {
  color: var(--muted);
  font-weight: 400;
}

@media (min-width: 40rem) {
  .dg {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Wide screen: PDF buttons in the band, call buttons in a navy side panel. */
@media (min-width: 64rem) {
  .entry-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .pdf-actions {
    position: static;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  body:has(.pdf-actions) {
    padding-bottom: 0;
  }

  html:has(.pdf-actions) {
    scroll-padding-bottom: 0;
  }

  .pdf-button {
    flex: 0 0 auto;
    padding-right: var(--space-6);
    padding-left: var(--space-6);
  }

  .pdf-button--download {
    border-color: rgb(255 255 255 / 60%);
    background: transparent;
    color: var(--on-navy);
  }

  .pdf-button:focus-visible {
    outline-color: var(--focus-on-navy);
  }

  .entry-body {
    padding-top: var(--space-6);
  }

  .entry-grid {
    grid-template-columns: minmax(0, 1fr) 20rem;
    align-items: start;
    gap: var(--space-5) var(--space-6);
  }

  .entry-grid > * {
    grid-column: 1;
  }

  .entry-grid > .calls {
    grid-column: 2;
    grid-row: 1 / span 4;
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    background: var(--navy);
    color: var(--on-navy);
  }

  .entry-grid > .calls .eyebrow,
  .entry-grid > .calls h2 {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }

  .entry-grid > .calls .eyebrow {
    color: var(--on-navy-accent);
  }

  .entry-grid > .calls h2 {
    color: var(--on-navy);
  }

  .entry-grid > .calls ul {
    grid-template-columns: minmax(0, 1fr);
  }

  .entry-grid > .calls li:nth-child(2) .call {
    background: var(--paper);
    color: var(--navy);
  }

  .entry-grid > .calls li:nth-child(3) .call,
  .entry-grid > .calls .call-notice {
    border: 1px dashed rgb(255 255 255 / 50%);
    background: transparent;
    color: var(--on-navy);
  }

  .entry-grid > .calls a.call:focus-visible {
    outline-color: var(--focus-on-navy);
  }
}
