/* =========================================================================
   leret.me — shared stylesheet
   One file, plain CSS, no framework. Loaded by every page via
   <link rel="stylesheet" href="/style.css">.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Color themes (CSS custom properties)
   -------------------------------------------------------------------------
   Every color used anywhere on the site is defined here as a CSS variable,
   in two sets: light and dark. Which set applies is decided in three
   layers, from weakest to strongest:

     a) Default: the light values on :root.
     b) System preference: if the visitor's OS is set to dark mode, the
        @media (prefers-color-scheme: dark) block applies the dark values
        — unless they've manually picked light (data-theme="light").
     c) Manual override: script.js sets data-theme="dark" or "light" on
        the <html> element when the header toggle is clicked (and
        remembers the choice in localStorage). An explicit attribute
        selector like :root[data-theme="dark"] beats the media query.

   The dark block is intentionally written twice (once for the manual
   override, once inside the media query) — plain CSS has no way to say
   "reuse that block here", and duplicating ~10 lines is simpler than
   any workaround.

   Palette: calm, muted green (sage/forest) as the single accent, with
   softened neutrals — no pure black or pure white anywhere. Light mode
   is warm off-white paper with dark charcoal text; dark mode is soft
   charcoal with warm cream text and a slightly brighter version of the
   same green so it still reads clearly on the dark background.
   ------------------------------------------------------------------------- */
:root {
  --color-bg: #f4f3ec;          /* warm off-white, not stark #fff */
  --color-bg-alt: #e9eae0;      /* slightly deeper paper tone */
  --color-surface: #fbfaf5;     /* cards, inputs */
  --color-text: #2b302b;        /* dark charcoal, not pure #000 */
  --color-text-muted: #5f675f;
  --color-accent: #4d7358;      /* muted forest/sage green */
  --color-accent-strong: #3c5b46; /* hover/darker variant */
  --color-border: #d8dbce;

  --font-heading: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  --max-width: 820px; /* narrower than before: this is a reading site now */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;

  --radius: 6px;
}

/* Manual dark mode (header toggle) — see layer (c) above. */
:root[data-theme="dark"] {
  --color-bg: #22261f;
  --color-bg-alt: #2a2f27;
  --color-surface: #292e26;
  --color-text: #e7e5d8;        /* warm cream, not pure #fff */
  --color-text-muted: #a7ae9e;
  --color-accent: #8fb896;      /* brighter sage for dark backgrounds */
  --color-accent-strong: #a8caae;
  --color-border: #3a4036;
}

/* System dark mode — applies only when the visitor hasn't manually
   chosen light. Values identical to the block above. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #22261f;
    --color-bg-alt: #2a2f27;
    --color-surface: #292e26;
    --color-text: #e7e5d8;
    --color-text-muted: #a7ae9e;
    --color-accent: #8fb896;
    --color-accent-strong: #a8caae;
    --color-border: #3a4036;
  }
}

/* -------------------------------------------------------------------------
   2. Reset / base
   -------------------------------------------------------------------------
   box-sizing: border-box means padding and border are counted *inside* an
   element's declared width, instead of added on top of it — this avoids
   a lot of accidental layout overflow, so almost every site sets it
   globally via the universal selector (*).
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  /* Ease the swap when the theme toggles rather than snapping. */
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  line-height: 1.2;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 var(--space-2);
}

a {
  color: var(--color-accent);
}

a:hover {
  color: var(--color-accent-strong);
}

img {
  max-width: 100%;
  display: block;
}

/* A visually-hidden helper for text that should still be read by screen
   readers but shouldn't take up visible space. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   3. Layout helpers
   ------------------------------------------------------------------------- */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

main {
  display: block;
}

section {
  padding: var(--space-4) 0;
}

/* -------------------------------------------------------------------------
   4. Header: logo, search, theme toggle, About link
   ------------------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background-color 0.2s ease;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}

.site-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.site-logo__mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.site-header__tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0; /* lets the search input shrink on small screens */
}

.site-search {
  width: 180px;
  max-width: 40vw;
  padding: 0.4em 0.8em;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9rem;
}

.site-search:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--color-text);
  flex-shrink: 0;
}

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

.site-header__link {
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.site-header__link:hover {
  color: var(--color-accent);
}

/* -------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------
   Button text uses var(--color-bg) rather than white: in light mode
   that's the cream page color on a deep green button; in dark mode it
   flips to dark charcoal on a light sage button — readable both ways
   without any pure white.
   ------------------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.6em 1.3em;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-bg);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid var(--color-accent);
  cursor: pointer;
  font-size: 0.95rem;
}

.btn:hover {
  background: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
  color: var(--color-bg);
}

.btn--outline {
  background: transparent;
  color: var(--color-accent);
}

.btn--outline:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* -------------------------------------------------------------------------
   6. Hero (homepage intro)
   ------------------------------------------------------------------------- */
.hero {
  padding: var(--space-4) 0 var(--space-2);
}

.hero p.lede {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  max-width: 640px;
}

/* -------------------------------------------------------------------------
   7. Tag filters + post list (homepage)
   -------------------------------------------------------------------------
   The filter row is a set of small pill buttons generated by build.py.
   script.js toggles .is-active and hides non-matching list items.
   Tags are metadata, not the main event — so both the filter pills and
   the per-post labels stay small and quiet.
   ------------------------------------------------------------------------- */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.tag-filter {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.25em 0.9em;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--color-text-muted);
  cursor: pointer;
  text-transform: capitalize;
}

.tag-filter:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tag-filter.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
}

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

.post-list__item {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

/* The [hidden] attribute is what script.js sets on filtered-out posts;
   this rule makes sure it always wins. */
.post-list__item[hidden] {
  display: none;
}

.post-list__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.post-list__head a {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: bold;
  text-decoration: none;
  color: var(--color-text);
}

.post-list__head a:hover {
  color: var(--color-accent);
}

.post-date {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.post-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin: 0.4rem 0 0;
}

.post-tags li {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
  border-radius: 999px;
  padding: 0.1em 0.7em;
  text-transform: capitalize;
}

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

/* Shown by script.js when a search/filter combination matches nothing. */
.no-results {
  color: var(--color-text-muted);
  padding: var(--space-3) 0;
}

/* -------------------------------------------------------------------------
   8. Post pages
   ------------------------------------------------------------------------- */
.post-body {
  max-width: 680px;
  margin-top: var(--space-2);
}

.post-body h2 {
  margin-top: var(--space-4);
}

/* -------------------------------------------------------------------------
   9. Tag/pill list used inside posts (tools, credentials)
   ------------------------------------------------------------------------- */
.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: 0;
  margin: var(--space-2) 0;
}

.tag-list li {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.3em 0.9em;
  font-size: 0.9rem;
}

/* -------------------------------------------------------------------------
   10. Photo gallery grid + lightbox (used inside modeling posts)
   -------------------------------------------------------------------------
   The grid is CSS Grid with auto-fill: as many 200px+ columns as fit.
   The lightbox is one hidden overlay <div> that script.js shows and
   fills with whichever image was clicked.
   ------------------------------------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.gallery__item {
  border: none;
  padding: 0;
  background: none;
  cursor: zoom-in;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 4;
}

.gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.gallery__item:hover img {
  transform: scale(1.04);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 15, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-3);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius);
}

.lightbox__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: none;
  color: #e7e5d8;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox__caption {
  position: absolute;
  bottom: var(--space-3);
  left: 0;
  right: 0;
  text-align: center;
  color: #cfd4c9;
  font-size: 0.9rem;
}

/* -------------------------------------------------------------------------
   11. Responsive video embed (16:9 iframe wrapper)
   ------------------------------------------------------------------------- */
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: var(--space-3) 0;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius);
}

/* -------------------------------------------------------------------------
   12. Forms (book signup etc.)
   ------------------------------------------------------------------------- */
form {
  max-width: 480px;
  margin-top: var(--space-3);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3em;
  margin-top: var(--space-2);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.6em 0.8em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

form .btn {
  margin-top: var(--space-3);
}

/* -------------------------------------------------------------------------
   13. Placeholder / notice boxes
   ------------------------------------------------------------------------- */
.notice-box {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3);
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
}

/* -------------------------------------------------------------------------
   14. Footer — site-wide contact lives here
   ------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) 0 var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: var(--space-4);
}

.site-footer__contact {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
}

.site-footer__heading {
  font-size: 1rem;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.social-links {
  list-style: none;
  display: flex;
  gap: var(--space-3);
  padding: 0;
  margin: var(--space-1) 0 0;
}

.social-links a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.social-links a:hover {
  color: var(--color-accent);
}

.site-footer__copyright {
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
   15. Small screens
   -------------------------------------------------------------------------
   The header is compact enough that no hamburger menu is needed — the
   search input just shrinks, and if space is still tight the tools wrap
   onto their own line under the logo.
   ------------------------------------------------------------------------- */
@media (max-width: 560px) {
  .site-header__inner {
    flex-wrap: wrap;
  }

  .site-header__tools {
    width: 100%;
    justify-content: flex-end;
  }

  .site-search {
    flex: 1;
    max-width: none;
  }

  .post-list__head {
    flex-direction: column;
    gap: 0.2rem;
  }
}
