/* ==========================================================================
   The Shared Housing System - Manual Wiki
   Brand palette and callout styling.

   Palette matches the live site at thesharedhousingsystem.com so the wiki
   and the main site read as one property.
   Source: GHL Infrastructure Design 1.2 (live-site values are canonical
   for deployed surfaces).
   ========================================================================== */

/* Web fonts. This must stay the first rule in the file: CSS requires @import
   to precede all other rules, and browsers silently drop it otherwise. */
@import url("https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  /* Brand */
  --shs-navy:            #152238;  /* primary, headings, dark sections */
  --shs-navy-op:         #1F3A5F;  /* operational navy, doc chrome */
  --shs-gold:            #D9B079;  /* page accents, links, rules */
  --shs-gold-submit:     #C3A368;  /* deeper gold, borders */
  --shs-cream:           #F7F4EE;  /* light section background */
  --shs-cream-doc:       #F5E6C8;  /* gold-cream, document chrome */
  --shs-charcoal:        #42413F;  /* body text */
  --shs-body-mid:        #4A5568;  /* secondary text on light */

  /* Heading typeface. Lora is the SHS heading serif, Georgia the fallback.
     Body copy stays sans-serif. */
  --shs-font-heading: "Lora", Georgia, serif;

  /* Callout fills - match print treatments in Style Master 3.4 */
  --shs-callout-template:   #E8EEF4;  /* light blue */
  --shs-callout-livein:     #F5F5F5;  /* light gray */
  --shs-callout-keyconcept: #E8F5E9;  /* light green */
  --shs-callout-tip:        #FFF3E0;  /* light amber */
  --shs-callout-example:    #F3EFF8;  /* light purple - print treatment TBD */
  --shs-callout-watchout:   #FDECEA;  /* light red - print treatment TBD */
  --shs-callout-companionsop: #FAF8F2;  /* cream - print treatment TBD */
}

/* --------------------------------------------------------------------------
   Light scheme
   -------------------------------------------------------------------------- */

[data-md-color-scheme="shs"] {
  --md-primary-fg-color:        var(--shs-navy);
  --md-primary-fg-color--light: var(--shs-navy-op);
  --md-primary-fg-color--dark:  var(--shs-navy);
  --md-accent-fg-color:         var(--shs-gold-submit);

  --md-default-bg-color:        #FFFFFF;
  --md-default-fg-color:        var(--shs-charcoal);
  --md-default-fg-color--light: var(--shs-body-mid);

  --md-typeset-color:           var(--shs-charcoal);
  --md-typeset-a-color:         var(--shs-gold-submit);

  --md-footer-bg-color:         var(--shs-navy);
  --md-footer-bg-color--dark:   var(--shs-navy);
}

/* --------------------------------------------------------------------------
   Typography
   Lora for headings, Open Sans for body. Matches the live site.
   Print artifact uses Calibri; that is a separate output and not styled here.
   -------------------------------------------------------------------------- */

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
  font-weight: 600;
}

/* Heading scale. H1 is the numbered chapter title, H2 sections, H3
   subsections, H4 available but rare. Starting values, tune on sight. */

.md-typeset h1 {
  /* Heaviest thing on the page: the chapter title must outrank a
     wrapping h2, which inherits 600 from the shared heading rule. */
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 2.2rem;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 1.4rem;
  /* Gold rule, moved here from h2: h1 is now the chapter title. */
  border-bottom: 2px solid var(--shs-gold);
  padding-bottom: 0.3em;
}

.md-typeset h2 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin-top: 2.6rem;
  margin-bottom: 0.9rem;
  /* Lighter rule, subordinate to the chapter rule above. */
  border-bottom: 1px solid rgba(217, 176, 121, 0.5);
  padding-bottom: 0.25em;
}

.md-typeset h3 {
  font-size: 1.3rem;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.7rem;
}

.md-typeset h4 {
  font-size: 1.1rem;
  margin-top: 1.6rem;
  margin-bottom: 0.5rem;
}

.md-typeset {
  font-size: 0.8rem;
  line-height: 1.7;
}

.md-nav__title,
.md-header__title {
  font-family: var(--shs-font-heading);
}

/* Lead sentence: the first paragraph after the HOMEPAGE H1 reads slightly
   larger than body copy. Typographic emphasis only, not a banner or hero
   block. Scoped by the homepage H1's slug so it cannot leak onto chapter
   or Part index pages; update this id if the homepage title changes. */
.md-typeset h1#the-shared-housing-system + p {
  font-size: 1.15em;
  font-style: italic;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Figures
   Diagrams are SVG in docs/assets/diagrams/. Two problems to solve: a tall
   figure must not exceed a laptop viewport, and a wide figure must not
   shrink its labels into illegibility on a phone.

   Specificity note: Material sets `.md-typeset img { max-width: 100% }`
   (0,1,1). The attribute selector below is (0,2,1), so these win without
   !important.
   -------------------------------------------------------------------------- */

.md-typeset img[src*="/assets/diagrams/"] {
  max-height: 560px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 1.5rem auto;
}

/* Below this width a wide figure keeps its size and the reader pans instead
   of shrinking its labels into illegibility. Portrait diagrams are exempt:
   one still fits the column with readable labels, so widening it would make
   it scroll for nothing.

   The exemption is keyed on "-portrait" rather than the rule being keyed on
   "-landscape", so a new wide diagram gets the panning behaviour by default
   instead of silently missing it because of what it is called. */
@media screen and (max-width: 700px) {
  .md-typeset p:has(> img[src*="/assets/diagrams/"]) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .md-typeset img[src*="/assets/diagrams/"]:not([src*="-portrait"]) {
    min-width: 620px;
    max-width: none;
  }
}

/* --------------------------------------------------------------------------
   Heading permalinks
   The pilcrow is replaced with a small chain icon, hidden until the heading
   is hovered or the link is focused. The anchor itself is untouched, so
   keyboard navigation and copy-link behaviour still work.
   -------------------------------------------------------------------------- */

.md-typeset .headerlink {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  vertical-align: middle;
  font-size: 0;                      /* suppresses the pilcrow glyph */
  background-color: var(--shs-gold-submit);
  -webkit-mask-image: var(--shs-icon-link);
          mask-image: var(--shs-icon-link);
  -webkit-mask-size: contain;
          mask-size: contain;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  opacity: 0;
  transition: opacity 125ms;
}

.md-typeset h1:hover .headerlink,
.md-typeset h2:hover .headerlink,
.md-typeset h3:hover .headerlink,
.md-typeset h4:hover .headerlink,
.md-typeset h5:hover .headerlink,
.md-typeset h6:hover .headerlink {
  opacity: 0.4;
}

.md-typeset .headerlink:hover,
.md-typeset .headerlink:focus {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   CALLOUT TAXONOMY - closed set of six.
   Source syntax and semantics: SHS Manual Style Spec 6.
   Do not add types without updating that document first.
   -------------------------------------------------------------------------- */

/* Callout icons (Material Design Icons paths, same set the theme ships).
   Material only defines mask variables for its own built-in types, so the
   custom types need their own. Each is a mask: the SVG gives the shape, the
   background-color on the ::before rule gives the colour.
   Watch Out is deliberately absent: it keeps Material's warning triangle. */
:root {
  --shs-icon-template:   url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17,9H7V7H17M17,13H7V11H17M14,17H7V15H14M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M19,3H14.82C14.4,1.84 13.3,1 12,1C10.7,1 9.6,1.84 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3Z"/></svg>');
  --shs-icon-livein:     url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z"/></svg>');
  --shs-icon-keyconcept: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7,14A2,2 0 0,1 5,12A2,2 0 0,1 7,10A2,2 0 0,1 9,12A2,2 0 0,1 7,14M12.65,10C11.83,7.67 9.61,6 7,6A6,6 0 0,0 1,12A6,6 0 0,0 7,18C9.61,18 11.83,16.33 12.65,14H17V18H21V14H23V10H12.65Z"/></svg>');
  --shs-icon-tip:        url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,2A7,7 0 0,0 5,9C5,11.38 6.19,13.47 8,14.74V17A1,1 0 0,0 9,18H15A1,1 0 0,0 16,17V14.74C17.81,13.47 19,11.38 19,9A7,7 0 0,0 12,2M9,21A1,1 0 0,0 10,22H14A1,1 0 0,0 15,21V20H9V21Z"/></svg>');
  --shs-icon-example:    url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M6,7H18V9H6V7M6,11H15V13H6V11Z"/></svg>');
  --shs-icon-companionsop: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3,5H9V11H3V5M5,7V9H7V7H5M11,7H21V9H11V7M11,15H21V17H11V15M5,20L1.5,16.5L2.91,15.09L5,17.17L9.59,12.59L11,14L5,20Z"/></svg>');
  --shs-icon-link:       url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z"/></svg>');
}

/* Shared shape for the five custom types */
.md-typeset .admonition.template,
.md-typeset .admonition.livein,
.md-typeset .admonition.keyconcept,
.md-typeset .admonition.watchout,
.md-typeset .admonition.companionsop,
.md-typeset details.template,
.md-typeset details.livein,
.md-typeset details.keyconcept,
.md-typeset details.watchout,
.md-typeset details.companionsop {
  border-width: 0 0 0 4px;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* --- Template Reference ---------------------------------------------------
   The path from free content to paid tools. Present at chapter level.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.template,
.md-typeset details.template {
  border-left-color: var(--shs-navy-op);
  background-color: var(--shs-callout-template);
}
.md-typeset .template > .admonition-title,
.md-typeset .template > summary {
  background-color: rgba(31, 58, 95, 0.12);
  border-left-color: var(--shs-navy-op);
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .template > .admonition-title::before,
.md-typeset .template > summary::before {
  background-color: var(--shs-navy-op);
  -webkit-mask-image: var(--shs-icon-template);
          mask-image: var(--shs-icon-template);
}

/* --- Live-In Operator Note ------------------------------------------------
   Inline, only where the process genuinely differs. Style Master 3.6.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.livein,
.md-typeset details.livein {
  border-left-color: #757575;
  background-color: var(--shs-callout-livein);
}
.md-typeset .livein > .admonition-title,
.md-typeset .livein > summary {
  background-color: rgba(117, 117, 117, 0.12);
  border-left-color: #757575;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .livein > .admonition-title::before,
.md-typeset .livein > summary::before {
  background-color: #757575;
  -webkit-mask-image: var(--shs-icon-livein);
          mask-image: var(--shs-icon-livein);
}

/* --- Key Concept ----------------------------------------------------------
   A principle the reader needs to understand.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.keyconcept,
.md-typeset details.keyconcept {
  border-left-color: #2E7D32;
  background-color: var(--shs-callout-keyconcept);
}
.md-typeset .keyconcept > .admonition-title,
.md-typeset .keyconcept > summary {
  background-color: rgba(46, 125, 50, 0.12);
  border-left-color: #2E7D32;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .keyconcept > .admonition-title::before,
.md-typeset .keyconcept > summary::before {
  background-color: #2E7D32;
  -webkit-mask-image: var(--shs-icon-keyconcept);
          mask-image: var(--shs-icon-keyconcept);
}

/* --- Watch Out ------------------------------------------------------------
   A mistake the reader is likely to make. Distinct from Key Concept.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.watchout,
.md-typeset details.watchout {
  border-left-color: #C62828;
  background-color: var(--shs-callout-watchout);
}
.md-typeset .watchout > .admonition-title,
.md-typeset .watchout > summary {
  background-color: rgba(198, 40, 40, 0.12);
  border-left-color: #C62828;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .watchout > .admonition-title::before,
.md-typeset .watchout > summary::before {
  background-color: #C62828;
  -webkit-mask-image: var(--md-admonition-icon--warning);
          mask-image: var(--md-admonition-icon--warning);
}

/* --- Companion SOP --------------------------------------------------------
   The paid SOP that pairs with this chapter. Same paid-path signal as
   Template Reference, so it carries the brand gold.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.companionsop,
.md-typeset details.companionsop {
  border-left-color: var(--shs-gold-submit);
  background-color: var(--shs-callout-companionsop);
}
.md-typeset .companionsop > .admonition-title,
.md-typeset .companionsop > summary {
  background-color: rgba(195, 163, 104, 0.16);
  border-left-color: var(--shs-gold-submit);
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .companionsop > .admonition-title::before,
.md-typeset .companionsop > summary::before {
  background-color: var(--shs-gold-submit);
  -webkit-mask-image: var(--shs-icon-companionsop);
          mask-image: var(--shs-icon-companionsop);
}

/* --- Built-in types, brand-aligned ---------------------------------------
   Pro Tip uses `tip`. Example uses `example`.
   -------------------------------------------------------------------------- */

.md-typeset .admonition.tip,
.md-typeset details.tip {
  background-color: var(--shs-callout-tip);
  border-width: 0 0 0 4px;
  border-left-color: #C77E00;
  border-radius: 4px;
  font-size: 0.78rem;
}
/* Title bar and icon take the callout's own amber. Material's default teal is
   not an SHS colour. */
.md-typeset .tip > .admonition-title,
.md-typeset .tip > summary {
  background-color: rgba(199, 126, 0, 0.14);
  border-left-color: #C77E00;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
.md-typeset .tip > .admonition-title::before,
.md-typeset .tip > summary::before {
  background-color: #C77E00;
  -webkit-mask-image: var(--shs-icon-tip);
          mask-image: var(--shs-icon-tip);
}

.md-typeset .admonition.example,
.md-typeset details.example {
  background-color: var(--shs-callout-example);
  border-width: 0 0 0 4px;
  border-left-color: #5B4B8A;
  border-radius: 4px;
  font-size: 0.78rem;
}
.md-typeset .example > .admonition-title,
.md-typeset .example > summary {
  background-color: rgba(91, 75, 138, 0.14);
  border-left-color: #5B4B8A;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}
/* Speech bubble, replacing Material's list glyph. */
.md-typeset .example > .admonition-title::before,
.md-typeset .example > summary::before {
  background-color: #5B4B8A;
  -webkit-mask-image: var(--shs-icon-example);
          mask-image: var(--shs-icon-example);
}

/* --------------------------------------------------------------------------
   Tables - keep readable on mobile
   -------------------------------------------------------------------------- */

.md-typeset table:not([class]) {
  font-size: 0.72rem;
  border: 1px solid rgba(21, 34, 56, 0.15);
}

.md-typeset table:not([class]) th {
  background-color: var(--shs-cream);
  color: var(--shs-navy);
  font-family: var(--shs-font-heading);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Email capture block
   Offered, never gating. Sits beside content, never in front of it.
   -------------------------------------------------------------------------- */

.shs-subscribe {
  background-color: var(--shs-cream);
  border: 1px solid rgba(21, 34, 56, 0.15);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2.5rem 0 1rem;
}

.shs-subscribe h3 {
  margin-top: 0;
  font-family: var(--shs-font-heading);
  color: var(--shs-navy);
}

.shs-subscribe p {
  color: var(--shs-body-mid);
  font-size: 0.75rem;
}
