/*
  SFS template shell: shared header, navigation, footer, and legacy site chrome.
  Page layout, forms, buttons, cards, and admin/public surfaces stay in their
  own owner files.
  Docs: _deploy/css-compartmentalisation-readable-map-20260704.md
  Related: _deploy/css-compartmentalisation-worklog-20260704.md; _deploy/css-compartmentalisation-verification-20260704.md
*/

/* Header: calm service identity, not decoration. */
header,
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px 10px;
}

header h1,
.site-header h1 {
  max-width: var(--content-width);
  margin: 0 auto 9px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
}

header h1 a,
header h1 a:visited,
.site-header h1 a,
.site-header h1 a:visited {
  color: var(--text);
  text-decoration: none;
}

header h1 a:hover,
.site-header h1 a:hover {
  color: var(--brand);
}

/* Navigation: compact map. */
nav {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

nav a,
nav a:visited {
  display: inline-block;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

nav a:hover,
nav a:focus {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: var(--brand-line);
}

/* Footer: low priority. */
footer,
.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 18px 28px 28px;
  color: var(--muted);
  font-size: 12px;
  background: transparent;
}

/* Header logo layout. */
header h1,
.site-header h1 {
  margin-bottom: 8px;
}

.site-brand,
.site-brand:visited {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.site-brand:hover {
  color: var(--brand-strong);
  text-decoration: none;
}

.site-logo {
  display: block;
  width: min(178px, 42vw);
  height: auto;
  flex: 0 0 auto;
}

.site-logo-for-dark {
  display: none;
}

.site-title {
  display: inline-block;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

@media (prefers-color-scheme: dark) {
  .site-logo-for-light {
    display: none;
  }

  .site-logo-for-dark {
    display: block;
  }
}

/* Warm accent only on interaction. */
nav a:hover,
nav a:focus {
  color: var(--accent-warm);
  border-color: color-mix(in srgb, var(--accent-warm) 45%, var(--line));
}

/* Small screens: avoid logo crowding. */
@media (max-width: 640px) {
  .site-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .site-title {
    padding-left: 0;
    border-left: 0;
    font-size: 14px;
  }

  .site-logo {
    width: min(170px, 68vw);
  }
}

/* style-pass-2e: make the file-manager header navigation human-readable. */
header,
.site-header {
  display: block;
  min-height: auto;
  padding-top: 12px;
  padding-bottom: 10px;
}

header h1,
.site-header h1 {
  margin-bottom: 10px;
}

nav {
  justify-content: flex-start;
  gap: 7px;
}

nav a,
nav a:visited {
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

nav a:hover,
nav a:focus {
  background: var(--brand-soft);
  color: var(--accent-warm);
  border-color: color-mix(in srgb, var(--accent-warm) 45%, var(--line));
  text-decoration: none;
}

/* Keep logo calm and prevent it dominating the working area. */
.site-logo {
  width: min(170px, 40vw);
}

.site-title {
  font-size: 14px;
  color: var(--muted);
}

/* Dark mode header/nav tuning. */
@media (prefers-color-scheme: dark) {
  nav a,
  nav a:visited {
    background: #181a18;
    border-color: #30342f;
    color: #a6aaa4;
  }

  nav a:hover,
  nav a:focus {
    background: #20231f;
    color: var(--accent-warm);
    border-color: color-mix(in srgb, var(--accent-warm) 45%, #30342f);
  }
}

/* On small screens, keep navigation obvious and tappable. */
@media (max-width: 640px) {
  nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  nav a,
  nav a:visited {
    text-align: center;
  }
}

/* style-pass-2i: header balance polish. */
header,
.site-header {
  padding-top: 10px;
  padding-bottom: 9px;
}

header h1,
.site-header h1 {
  margin-bottom: 9px;
}

.site-brand {
  gap: 10px;
}

.site-logo {
  width: min(154px, 36vw);
}

.site-title {
  padding-left: 10px;
  border-left-color: color-mix(in srgb, var(--line) 70%, transparent);
  font-size: 14px;
  line-height: 1.2;
}

nav a,
nav a:visited {
  min-height: 30px;
  padding: 6px 10px;
}

@media (max-width: 640px) {
  .site-logo {
    width: min(150px, 64vw);
  }
}

/* style-pass-2j: final header correction. */
header,
.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "brand nav";
  align-items: start;
  column-gap: 26px;
  row-gap: 0;
  padding: 11px 28px 10px;
}

header h1,
.site-header h1 {
  grid-area: brand;
  max-width: none;
  margin: 0;
}

.site-brand,
.site-brand:visited {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  align-items: start;
  color: var(--text);
  text-decoration: none;
}

.site-logo {
  display: block !important;
  width: 158px;
  max-width: 42vw;
  height: auto;
}

.site-title {
  display: block;
  padding-left: 0;
  border-left: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.15;
}

.site-logo-for-light,
.site-logo-for-dark {
  display: none !important;
}

nav {
  grid-area: nav;
  max-width: none;
  margin: 4px 0 0;
  justify-content: flex-start;
  align-self: start;
}

nav a,
nav a:visited {
  min-height: 30px;
  padding: 6px 10px;
}

/* Dark mode: keep the light logo visible and text readable. */
@media (prefers-color-scheme: dark) {
  .site-logo {
    display: block !important;
  }

  .site-title {
    color: #f2f1eb;
  }
}

/* Small screens: stack naturally. */
@media (max-width: 700px) {
  header,
  .site-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav";
    row-gap: 10px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .site-logo {
    width: 156px;
    max-width: 70vw;
  }

  nav {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
  }
}

/* style-pass-2k: logo/title correction. */
.site-brand,
.site-brand:visited {
  justify-items: center;
  text-align: center;
}

.site-logo {
  width: 158px;
  max-width: 42vw;
}

.site-title {
  width: 100%;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0;
  text-align: center;
}

.site-brand:hover .site-title {
  color: var(--accent-warm);
}

@media (prefers-color-scheme: dark) {
  .site-title {
    color: #a6aaa4;
  }

  .site-brand:hover .site-title {
    color: var(--accent-warm);
  }
}

@media (max-width: 700px) {
  .site-brand,
  .site-brand:visited {
    justify-items: start;
    text-align: left;
  }

  .site-title {
    text-align: left;
  }
}

/* style-pass-2l: centre nav buttons with the logo. */
header,
.site-header {
  align-items: start;
  column-gap: 28px;
}

header h1,
.site-header h1 {
  line-height: 1;
}

.site-brand,
.site-brand:visited {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.site-logo {
  width: 158px;
  max-width: 42vw;
}

.site-title {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 450;
  line-height: 1.15;
}

/* Nav top offset is tuned to align with the vertical centre of the logo image, not the caption. */
nav {
  margin-top: 21px;
  align-self: start;
}

nav a,
nav a:visited {
  min-height: 30px;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Slightly smaller logo means slightly less nav offset. */
@media (max-width: 700px) {
  nav {
    margin-top: 0;
  }
}

/* style-pass-2n: keep template nav and caption quiet. */
nav a,
nav a:visited {
  color: var(--muted);
  font-weight: 620;
}

nav a:hover,
nav a:focus {
  color: var(--accent-warm);
}

.site-title {
  color: var(--muted);
  font-weight: 430;
}

@media (max-width: 760px) {
  header,
  .site-header,
  footer,
  .site-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  header h1,
  .site-header h1,
  nav {
    max-width: none;
  }
}
