/* ghost2zola theme: clean, responsive, dark by default with a light option. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elevated: #f6f7f9;
  --text: #1a1d21;
  --text-muted: #5f6670;
  --border: #e2e5ea;
  --border2: #cdd2d9;
  --link: #0b5fff;
  --link-hover: #0842b8;
  --accent: #15171a;
  --input: #ffffff;
  --input-line: #cdd2d9;
  --scrim: rgba(0, 0, 0, 0.55);
  --code-bg: #f2f3f5;
  --max-width: 46rem;
  --radius: 10px;
}

/* One set of dark tokens, used by an explicit choice and by the OS. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --text: #e6e8eb;
  --text-muted: #9aa0a6;
  --border: #2a2f3a;
  --border2: #3a4150;
  --link: #7ab3ff;
  --link-hover: #a8ccff;
  --accent: #15171a;
  --input: #171a21;
  --input-line: #3a4150;
  --code-bg: #1c2029;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --bg-elevated: #171a21;
    --text: #e6e8eb;
    --text-muted: #9aa0a6;
    --border: #2a2f3a;
    --border2: #3a4150;
    --link: #7ab3ff;
    --link-hover: #a8ccff;
    --accent: #15171a;
    --input: #171a21;
    --input-line: #3a4150;
    --code-bg: #1c2029;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* The photo band is 100vw wide, which is wider than the layout viewport when
     a browser shows a classic scrollbar. Kept as a guard: it does not stop
     horizontal scrolling caused by content that is itself too wide, and the
     scrollbar case cannot be reproduced in headless Chromium (scrollbar width
     measures 0). */
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.65;
  font-size: 17px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header.
   Every page floats the header over the photo band (see .site-header-overlay),
   so it carries no bottom border: a border there draws a hairline across the top
   of every page, over the photograph. */
.site-header {
  padding: 0.875rem 0;
}

/* The header column is the content column, so its text lines up with the cards
   and the article text below it. The nav is centred and may wrap onto rows. */
.site-header .inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem 1rem;
  max-width: var(--max-width);
}

/* The header floats over the hero instead of sitting above it. Over a
   photograph the nav cannot use the page colours, so it is set in white. The
   darkening behind it is part of the band itself (.hero::before), because a
   background on the header ends at its own edge and can show as a line there. */
.site-header-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding-top: 1.25rem;
}

.site-header-overlay .site-nav a,
.site-header-overlay .theme-toggle {
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.site-header-overlay .site-nav a:hover,
.site-header-overlay .theme-toggle:hover {
  color: #fff;
}

.site-header-overlay .search-box input[type="search"] {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.site-header-overlay .search-box input[type="search"]::placeholder {
  color: rgba(255, 255, 255, 0.8);
}

.site-header-overlay .theme-toggle {
  border-color: rgba(255, 255, 255, 0.55);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
}

.theme-toggle {
  height: 2.5rem;
  width: 2.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.theme-toggle .icon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-light,
:root[data-theme="dark"] .theme-toggle .icon-dark {
  display: block;
}

/* With no stored choice the page follows the OS, so show the contrast glyph for
   `auto`. The glyph is the state, not what the page looks like: under a dark OS
   `auto` looks dark but is still `auto`. */
:root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .icon-auto {
  display: block;
}

.theme-toggle:focus-visible,
.site-nav a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Main */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  min-height: 60vh;
}

/* Feed / post cards */
/* The photo band: the site cover image, edge to edge, with the page title over
   it. The title sits under the floating header, not in the middle of the photo,
   so the band starts at the top and the header keeps its clearance. */
.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  min-height: 272px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  background-size: cover;
  background-position: center;
  color: #fff;
  margin-top: -2rem;
  margin-bottom: 2rem;
  padding-top: 4.75rem;
}

/* One scrim over the whole band, darkest where the nav sits. Held inside this
   element, the fade cannot end on an edge of its own. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.72),
    rgba(0, 0, 0, 0.45) 40%,
    rgba(0, 0, 0, 0.45)
  );
}

.hero .hero-text {
  position: relative;
  max-width: 42rem;
  /* A flex item defaults to min-width: auto, which refuses to shrink below the
     longest unbreakable run in the title, so the band hung off both edges. */
  min-width: 0;
  padding: 1.75rem 1.25rem;
}

.hero h1 {
  font-size: 2.75rem;
  margin: 0 0 0.5rem;
}

.hero p {
  margin: 0;
  opacity: 0.9;
}

/* A shadow, because on surf and sky the scrim alone does not hold the type. */
.hero h1,
.hero p {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  /* Titles are copied from the source site and one of them is full of
     "Schools.Sane Boundaries.Thriving": unbreakable, and on a 320px phone it
     pushed the band past both edges. */
  overflow-wrap: anywhere;
}

/* Phones wrap the nav onto two rows, so the header is taller there and the
   title has to start further down. */
@media (max-width: 880px) {
  .hero {
    padding-top: 7.5rem;
  }
}

/* Below about 380px the nav wraps onto a third row, which makes the floating
   header 155px tall instead of 93px, so the band has to start further down. */
@media (max-width: 380px) {
  .hero {
    padding-top: 11rem;
  }
}

/* Pages other than the feed show a title with nothing under it. Held to the
   top it reads too high next to the feed, whose title is followed by the
   tagline, so these centre in the band: the single title then sits where the
   feed's title and tagline sit together. Long headlines fill the band and are
   unaffected, since there is nothing left to centre them in. */
.hero--page {
  align-items: center;
}

/* Every page shows a title in the band, not just the home feed, and article
   headlines run to three or four lines, so the face for them is smaller. */
.hero--page h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  max-width: 40rem;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.post-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.post-card-image img {
  width: 100%;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.post-card-title {
  font-size: 1.4rem;
  margin: 0 0 0.35rem;
  line-height: 1.25;
}

.post-card-title a {
  color: var(--text);
}

.post-card-title a:hover {
  color: var(--link);
  text-decoration: none;
}

.post-card-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.post-card-tagline {
  margin: 0 0 0.35rem;
}

.post-card-excerpt {
  margin: 0 0 0.5rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.tag {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--link);
  margin-right: 0.5rem;
}

/* Search */
.search-box {
  display: inline-flex;
}

.search-box input[type="search"] {
  font: inherit;
  font-size: 0.9rem;
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--input-line);
  border-radius: 999px;
  background: var(--input);
  color: var(--text);
  width: 9rem;
}

.search-box input[type="search"]::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* The width does not change on focus: the nav is centred, so a growing field
   would slide every other item in the row sideways. */
.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--link);
}

.search-page-box {
  margin-bottom: 1.5rem;
}

.search-page-box input[type="search"] {
  font: inherit;
  padding: 0.6rem 1rem;
  border: 1px solid var(--input-line);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--text);
  width: 100%;
  max-width: 30rem;
}

.search-results__items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results__items li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.search-result-title {
  font-weight: 600;
  color: var(--text);
}

.search-result-snippet {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.pager-info {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Post / page */
.post-header {
  margin-bottom: 1.5rem;
}

.post-meta {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.post-byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.byline-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.byline-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.author-name {
  font-weight: 600;
  color: var(--text);
}

.share-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
}

.share-btn:hover {
  border-color: var(--text-muted);
}

.post-tags {
  margin: 0 0 0.25rem;
}

.post-feature {
  margin: 0 0 1.75rem;
}

.post-feature img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.post-content {
  font-size: 1.05rem;
  /* Posts link to PDFs and reports by bare URL; one long URL in a paragraph
     otherwise stretches the whole page sideways on a phone. */
  overflow-wrap: anywhere;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Gallery: one main image over a row of thumbnails. */
.gallery {
  margin: 1.5rem 0;
}

.gallery-main {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.gallery-main img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
}

.gallery-main:hover img {
  opacity: 0.9;
}

.gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.gallery-thumb {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  border: 2px solid transparent;
}

.gallery-thumb img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

.gallery-thumb:hover img {
  opacity: 0.85;
}

.gallery-thumb.active {
  border-color: #e8a33d;
}

/* Lightbox: full-size image overlay for gallery links. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lb-img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  cursor: default;
}

.lb-close,
.lb-prev,
.lb-next {
  position: fixed;
  background: none;
  border: 0;
  color: #fff;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem 1rem;
  opacity: 0.7;
}

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover {
  opacity: 1;
}

.lb-close {
  top: 0.25rem;
  right: 0.5rem;
  font-size: 3rem;
}

.lb-prev {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}

.lb-next {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}

.lb-count {
  position: fixed;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  opacity: 0.7;
  font-size: 0.9rem;
}

body.lb-open {
  overflow: hidden;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}

.post-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

.post-content :not(pre) > code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--link);
  color: var(--text-muted);
}

/* Post navigation */
.post-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.nav-link {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--link);
}

.nav-back {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Section (tag) pages */
.tag-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.5rem 1rem;
}

.tag-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

.tag-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 404 */
/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (min-width: 640px) {
  .post-card {
    grid-template-columns: 14rem 1fr;
    align-items: start;
  }

  .post-card-image {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: var(--radius);
  }

  .post-card-image img {
    height: 100%;
    object-fit: cover;
    border: none;
  }

  .post-card-body {
    padding-top: 0.25rem;
  }

  /* Vertical cards (tag pages) stay one column; image on top. */
  .post-card-vertical {
    grid-template-columns: 1fr;
  }

  .post-card-vertical .post-card-image {
    aspect-ratio: auto;
    max-height: 18rem;
  }

  .post-card-vertical .post-card-body {
    padding-top: 0.75rem;
  }
}

@media (min-width: 900px) {
  .tag-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
