/* ==========================================================================
   Pharos help - tier layer (Cloud)

   One mechanism, three levels of emphasis.

   The mechanism is the data-pharos-tier ATTRIBUTE, and nothing else. No class is
   required to hide or show. That is what makes `invisible` possible: content can
   be conditional while carrying no styling hooks whatsoever.

   Emphasis is a separate, opt-in decision expressed as a class:

     (no class)              invisible - reads as ordinary prose
     .pharos-tier--quiet     a thin rule and a small margin label
     .pharos-tier--loud      boxed, tinted, chipped

   Pick by asking what a Site user's experience should be. If the content is
   purely additive - an extra field, an extra step - they need never know it
   existed: invisible. If its absence would leave them hunting for a setting that
   is not there, they need telling it is Portal-only: loud.
   ========================================================================== */

:root {
  /* Portal has no assigned palette in the brand guide - it is a Cloud feature
     tier, not a brand. The purple used before was invented and is not a Pharos
     colour, so this now works entirely inside the Brand Palette.

     Escalation is by WEIGHT rather than by hue: quiet uses Pharos Grey, loud
     uses Pharos Blue. Keeping quiet grey also stops a marked block from reading
     as an interactive region, since blue is the interactive colour everywhere
     else.

     If Portal is ever to have its own colour, that is a marketing decision
     rather than one to make in a stylesheet. */
  --pharos-portal:       var(--ph-blue, #0080ff);
  --pharos-portal-text:  var(--ph-blue-text, #0061c2);
  --pharos-portal-soft:  var(--ph-wash, #f0f0f0);
  --pharos-portal-line:  var(--ph-line, #dadada);
  --pharos-portal-quiet: var(--ph-grey, #575a5b);
}

/* ---- 1. The mechanism ---------------------------------------------------- */

:root[data-tier="site"]   [data-pharos-tier="portal"] { display: none; }
:root[data-tier="portal"] [data-pharos-tier="site"]   { display: none; }

/* ---- 2. Loud - boxed, tinted, chipped ----------------------------------- */

.pharos-tier--loud {
  position: relative;
  margin: 1.2rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--pharos-portal-line);
  border-left: 3px solid var(--pharos-portal);
  border-radius: 2px;
  background: var(--pharos-portal-soft);
}

.pharos-tier--loud > :first-child { margin-top: 0; }
.pharos-tier--loud > :last-child { margin-bottom: 0; }

/* White on full-strength Pharos Blue measures 3.80:1, which fails AA at this
   size, so the chip is filled with the darkened blue instead. */
.pharos-tier--loud[data-label]::before {
  content: attr(data-label);
  display: inline-block;
  margin-bottom: 0.55rem;
  padding: 0.1rem 0.45rem;
  border-radius: 2px;
  background: var(--pharos-portal-text);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
}

/* ---- 3. Quiet - a rule and a small label, no box, no fill ---------------

   The label sits above the content rather than hanging in the left margin. The
   margin was the first idea and it measured badly: with .md-grid centring the
   content column, there are only 23px between the sidebar and the text at every
   desktop width, so a hanging label collided with the nav. Above the content it
   costs one tight line and works at every viewport.
   ------------------------------------------------------------------------- */

.pharos-tier--quiet {
  margin: 1.1rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--pharos-portal-quiet);
}

.pharos-tier--quiet > :first-child { margin-top: 0; }
.pharos-tier--quiet > :last-child { margin-bottom: 0; }

.pharos-tier--quiet[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--pharos-portal-quiet);
}

/* ---- 4. Invisible ------------------------------------------------------- */
/* Nothing here on purpose. There is no class to hang a rule on.             */

/* ---- 5. Inline ---------------------------------------------------------- */
/* A clause inside a sentence. Undecorated by default, matching `invisible`;
   add .pharos-tier-inline for a light mark.                                 */

.pharos-tier-inline[data-pharos-tier="portal"] {
  background: var(--pharos-portal-soft);
  border-bottom: 1px dotted var(--pharos-portal-quiet);
  padding: 0 0.15em;
}

/* ---- 7. Page-level filtering (set by scripts/tier_nav.py) ---------------- */

:root[data-tier="site"]   .md-nav__item[data-tier="portal"] { display: none; }
:root[data-tier="portal"] .md-nav__item[data-tier="site"]   { display: none; }
:root[data-tier="site"]   .md-footer__link[data-tier="portal"] { display: none; }

.pharos-tier-notice { display: none; }

:root[data-tier="site"][data-page-tier="portal"] .pharos-tier-notice {
  display: block;
  margin: 0 0 1.4rem;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--pharos-portal);
  background: var(--pharos-portal-soft);
  font-size: 0.78rem;
  color: var(--ph-ink-soft, #566169);
}

/* ---- 8. Switcher controls ----------------------------------------------- */

.pharos-tier-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--ph-ink-soft, #566169);
  white-space: nowrap;
}

.pharos-tier-switch input { margin: 0; cursor: pointer; }
.pharos-tier-switch label { cursor: pointer; user-select: none; }

:root[data-tier="portal"] .pharos-tier-switch--tier label {
  color: var(--pharos-portal);
  font-weight: 600;
}

.md-header__inner .pharos-tier-switch--tier {
  margin-left: auto;
  padding-left: 0.8rem;
  border-left: 1px solid var(--ph-line, #dde4e7);
  height: 1.2rem;
}



@media screen and (max-width: 59.9375em) {
  .md-header__inner .pharos-tier-switch label { display: none; }
}

@media print {
  .pharos-tier-switch { display: none; }
}

/* ---- 9. Settings menu ---------------------------------------------------

   A cog to the right of search, opening a small panel. Deliberately discreet:
   most readers are Site owners and should not be invited to fiddle. It is the
   fallback path anyway, since a CSH link from Cloud carries ?tier= and sets the
   audience without anyone touching this.
   ------------------------------------------------------------------------- */

.ph-settings {
  position: relative;
  margin-left: 0.35rem;
  margin-right: 0.3rem;
  border: none;
  background: none;
  padding: 0;
}

.ph-settings__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 2px;
  color: var(--ph-ink-soft, #575a5b);
  cursor: pointer;
  list-style: none;
  transition: color 90ms, background-color 90ms;
}

.ph-settings__button::-webkit-details-marker { display: none; }
.ph-settings__button::marker { content: ''; }

.ph-settings__button:hover { color: var(--ph-ink, #14181b); background: var(--ph-wash, #f0f0f0); }
.ph-settings[open] .ph-settings__button { color: var(--ph-ink, #14181b); background: var(--ph-wash, #f0f0f0); }

.ph-settings__button:focus-visible {
  outline: 2px solid var(--ph-blue, #0080ff);
  outline-offset: 2px;
}

.ph-settings__panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 10;
  min-width: 14.5rem;
  padding: 0.65rem 0.8rem 0.75rem;
  background: var(--ph-white, #fff);
  border: 1px solid var(--ph-line, #dadada);
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(30, 33, 36, 0.09);
  text-align: left;
}

.ph-settings__group { border: none; margin: 0; padding: 0; }
.ph-settings__group + .ph-settings__group {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--ph-line-soft, #ebebeb);
}

.ph-settings__legend {
  display: block;
  padding: 0;
  margin-bottom: 0.45rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ph-ink-soft, #575a5b);
}

.ph-settings__option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.45rem;
  align-items: baseline;
  padding: 0.2rem 0;
}

.ph-settings__option input { margin: 0; cursor: pointer; }

.ph-settings__label {
  font-size: 0.72rem;
  color: var(--ph-ink, #14181b);
  cursor: pointer;
}

.ph-settings__hint {
  grid-column: 2;
  font-size: 0.64rem;
  line-height: 1.4;
  color: var(--ph-ink-soft, #575a5b);
}

@media print { .ph-settings { display: none; } }

/* Search-term highlighting, off. Material still wraps matches in
   <mark data-md-highlight>; this just stops them looking like anything, which is
   more robust than trying to prevent the mark being applied. */
:root[data-highlight="off"] mark[data-md-highlight] {
  background: none;
  color: inherit;
  padding: 0;
  box-shadow: none;
}
