/* =====================================================
   TABLE OF CONTENTS
   1.  Variables
   2.  Reset
   3.  Base elements
   4.  Layout (container, page grid)
   5.  Header (logo, toggle button, navigation)
   6.  Footer
   7.  Sidebar
   8.  Blog intro (heading box)
   9.  Blog cards
   10. Blog detail (single article)
   11. Article content (rich text)
   12. Tags (blog cards and article)
   13. Author profile (base, main content, sidebar)
   14. Post meta (author photo + name + date)
   15. Author box (end of article, for later)
   16. Authors index (grid of author cards)
   17. Tablet  (768px and wider)
   18. Desktop (1024px and wider)
   19. Full width layout override (must stay last)
   ===================================================== */


/* ---------- 1. Variables (Wagtail light theme colors) ---------- */
:root {
  /* --- Wagtail light theme palette (official Wagtail design tokens) --- */
  --color-primary: #2e1f5e;       /* Wagtail purple: branding, panels, headings, buttons */
  --color-primary-200: #261a4e;   /* darker purple accent */

  --color-secondary: #007d7e;     /* Wagtail teal: action links, primary buttons */
  --color-secondary-600: #004345; /* hover for two-tone buttons */
  --color-secondary-400: #005b5e; /* hover states */
  --color-secondary-100: #00b0b1; /* highlights over dark backgrounds */
  --color-secondary-75: #80d7d8;  /* highlights over dark text */
  --color-secondary-50: #f2fcfc;  /* light backgrounds, highlighted fields */

  --color-white: #ffffff;         /* page and panel backgrounds, button text */
  --color-grey-600: #262626;      /* body copy */
  --color-grey-400: #5c5c5c;      /* help text, meta text */
  --color-grey-200: #929292;      /* dividers, button borders */
  --color-grey-150: #c8c8c8;      /* field borders */
  --color-grey-100: #e0e0e0;      /* dividers, panel borders */
  --color-grey-50: #f6f6f8;       /* panel backgrounds, row highlights */

  --color-info: #1d7792;          /* information messages */
  --color-info-bg: #e2f5fc;
  --color-positive: #1b8666;      /* success messages */
  --color-positive-bg: #e0fbf4;
  --color-warning: #faa500;       /* warnings */
  --color-warning-bg: #fff5d8;
  --color-critical: #ca3b3b;      /* errors, dangerous actions */
  --color-critical-bg: #fef0f0;

  /* --- Roles: use these in the rules below, so one change updates the whole site --- */
  --color-text: var(--color-grey-600);         /* main text */
  --color-text-muted: var(--color-grey-400);   /* dates, small meta text */
  --color-bg: var(--color-grey-50);            /* page background: lightest Wagtail grey */
  --color-surface: var(--color-white);         /* cards and widgets */
  --color-border: var(--color-grey-100);       /* lines between sections */
  --color-link: var(--color-secondary);        /* links */
  --color-link-hover: var(--color-secondary-400);

  /* --- Layout and spacing --- */
  --card-space: 1.6rem;        /* one spacing value used everywhere in cards */
  --page-width: 120rem;        /* one width used by header AND content */
  --page-width-full: 100%;
  --page-top-space: 3rem;      /* one top space used by left content AND sidebar */

  /* --- Shape --- */
  --radius-pill: 10rem;        /* fully rounded ends for category badges and tags */
}


/* ---------- 2. Reset ---------- */
*,
*::before,
*::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;   /* padding and border stay inside the width */
}


/* ---------- 3. Base elements ---------- */
/* 62.5% of the browser's 16px = 10px, so 1rem = 10px (easy math: 1.8rem = 18px).
   A percentage (not px) keeps the user's browser font-size setting working. */
html {
  font-size: 62.5%;
}

/* Stops the left/right scrollbar: anything wider than the screen is cut off */
html,
body {
  overflow-x: clip;
}

body {
  font-family: "Source Sans 3", sans-serif;
  font-size: 1.8rem;
  color: var(--color-text);              /* Wagtail body copy color */
  background-color: var(--color-bg);     /* page background */
}

a {
  text-decoration: none;
  color: var(--color-text);
}

a:hover {
  color: var(--color-text-muted);
}

li {
  list-style-type: none;   /* no bullets by default */
}


/* ---------- 4. Layout ---------- */
.site-container {
  width: 100%;
}

/* Header content: same width and centering as .page-layout */
.inner {
  max-width: var(--page-width-full);
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* Page with sidebar (phone: one column) */
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* phone: one column */
  gap: 2.4rem;
  width: 100%;
  max-width: var(--page-width);   /* same as .inner */
  margin: 0 auto;
  padding: var(--page-top-space) 2rem 0;   /* top space is set HERE only */
}

.page-main {
  min-width: 0;   /* stops wide content from pushing the sidebar out */
}

/* The first item on the left and the first item in the sidebar
   have no top margin, so both start at exactly the same height */
.page-main > :first-child,
.sidebar > :first-child {
  margin-top: 0;
}


/* ---------- 5. Header ---------- */
.site-header {
  background-color: var(--color-surface);   /* white header */
}

/* Logo */
.site-logo {
  flex-basis: 70%;
}

.logo-text {
  display: flex;
  flex-flow: column;
  line-height: 1;
  padding: 2.4rem 0;
}

.logo-title {
  font-size: 2.2rem;
  font-weight: 600;
  display: block;
  width: 100%;
}

.logo-tagline {
  font-size: 1.3rem;
  font-weight: normal;
  display: block;
  width: 100%;
}

/* Toggle button (hamburger, mobile only) */
.toggle-btn {
  flex-basis: 30%;
  display: flex;
  align-items: center;
  justify-content: end;
  cursor: pointer;
  user-select: none;                          /* text cannot be selected */
  -webkit-user-select: none;                  /* same, for Safari / iPhone */
  -webkit-tap-highlight-color: transparent;   /* removes the colored flash when tapping */
}

.toggle-btn-wrapper {
  height: 1.3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.toggle-btn-label {
  margin-left: 1rem;
}

.toggle-btn-bar {
  display: block;
  height: 0.2rem;
  background-color: var(--color-text);
  width: 1.8rem;
  transition: translate 0.1s ease, rotate 0.1s ease, scale 0.1s ease;
}

/* CLOSING (back to hamburger) */
.btn-bar-1,
.btn-bar-3 {
  transition-delay: 0.2s, 0s, 0s; /* translate, rotate, scale */
}

.btn-bar-2 {
  transition-delay: 0s, 0s, 0.1s;
}

/* OPENING (when .active is added) */

/* Top and bottom bars move to the middle, then rotate */
.toggle-btn.active .btn-bar-1 {
  translate: 0 0.55rem;
  rotate: 45deg;
  transition-delay: 0s, 0.2s, 0s;
}

.toggle-btn.active .btn-bar-3 {
  translate: 0 -0.55rem;
  rotate: -45deg;
  transition-delay: 0s, 0.2s, 0s;
}

/* Middle bar shrinks */
.toggle-btn.active .btn-bar-2 {
  scale: 0 1;
  transition-delay: 0s, 0s, 0.1s;
}

/* Navigation (mobile first) */
.header-nav {
  display: grid;
  grid-template-rows: 0fr;   /* height 0 = closed */
  opacity: 0;
  visibility: hidden;
  flex-basis: 100%;
  transition:
    grid-template-rows 0.3s ease,
    opacity 0.3s ease,
    visibility 0s linear 0.3s;   /* hide links after the animation ends */
}

.header-nav.open {
  grid-template-rows: 1fr;   /* full height = open */
  opacity: 1;
  visibility: visible;
  transition:
    grid-template-rows 0.3s ease,
    opacity 0.3s ease,
    visibility 0s linear 0s;
}

.header-nav .nav-menu {
  overflow: hidden;   /* hide the links while the height is small */
  min-height: 0;      /* allow the list to shrink to 0 */
}

.header-nav .menu-item {
  display: block;
  margin: 1rem 0;
}

.header-nav .menu-item:last-child {
  margin-bottom: 3rem;   /* space under Contact */
}


/* ---------- 6. Footer ---------- */
.footer-nav {
  background-color: var(--color-surface);   /* white footer */
}

.footer-menu {
  display: flex;
  justify-content: center;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 1.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-grey-50);
}

.footer-link {
  text-decoration: none;
  color: inherit;
}

.footer-text {
  text-align: center;
  padding: 1.5rem;
  font-size: 1.6rem;
  opacity: 0.8;
}


/* ---------- 7. Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2.4rem;               /* same space between every widget */
  margin: 0 0 3rem;        /* same outer space as the blog cards */
}

.sidebar-widget {
  padding: 2rem;
  background-color: var(--color-surface);                         /* white, like your cards */
  border-radius: 1.2rem;
}

/* Widget title: purple text with a bottom border, no background */
.sidebar-widget-title {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  color: var(--color-primary);                     /* Wagtail purple text */
  padding-bottom: 1.2rem;                          /* space between text and border */
  border-bottom: 1px solid var(--color-grey-50);    /* thin line under the title */
  margin-bottom: var(--card-space);                /* space between border and content */
}


/* ---------- 8. Blog intro (heading box) ---------- */
/* Used by the blog index, categories, tags and authors headings */
.blog-intro {
  display: flex;
  flex-direction: column;                   /* mobile: image on top, text below */
  gap: var(--card-space);
  margin: 3rem 0;
  padding: 2rem;
  background-color: var(--color-surface);   /* white background */
  border-radius: 1.2rem;                    /* rounded corners */
}

.blog-intro-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0.8rem;
}

.blog-intro-text {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);
}

.blog-intro-title {
  font-size: 2.8rem;
  line-height: 1.2;
}

.blog-intro-description {
  line-height: 1.6;
}

/* Space between rich text paragraphs (the reset removed all margins) */
.blog-intro-description p + p {
  margin-top: var(--card-space);
}


/* ---------- 9. Blog cards ---------- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
  margin: 3rem 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);          /* same space between every item in the card */
  padding: 2rem;
  background-color: var(--color-surface);
  border-radius: 1.2rem;
}

/* Category badges (also used on the blog detail page) */
.card-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.card-category {
  display: inline-block;                    /* keeps padding even when it is a link */
  background-color: var(--color-primary);
  color: var(--color-white);
  font-size: 1.3rem;
  line-height: 1.4;
  padding: 0.4rem 1.4rem;
  border-radius: var(--radius-pill);        /* fully rounded (pill) */
  transition: background-color 0.2s ease;   /* smooth hover color change */
}

/* Category is now a link: keep the text white on hover (a:hover would turn it grey) */
.card-category:hover {
  color: var(--color-white);
  background-color: var(--color-secondary);   /* Wagtail teal on hover */
}

/* Featured image (16:9 ratio) */
.card-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 0.8rem;
}

/* Title and excerpt (the date is now .post-date in section 14) */
.card-title {
  font-size: 2.4rem;
  line-height: 1.3;
}

.card-excerpt {
  line-height: 1.6;
}

/* Read more link (margin-top: auto keeps it at the bottom of the card) */
.card-link {
  color: var(--color-link);
  font-weight: 600;
  margin-top: auto;
}

.card-link:hover {
  color: var(--color-link-hover);
}


/* ---------- 10. Blog detail (single article) ---------- */
.article {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);
  margin: 3rem 0;
  padding: 2rem;
  background-color: var(--color-surface);
  border-radius: 1.2rem;
}

.article-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 0.8rem;
}

.article-title {
  font-size: 3.2rem;
  line-height: 1.3;
}

/* Back link */
.article-back {
  color: var(--color-link);
  font-weight: 600;
}

.article-back:hover {
  color: var(--color-link-hover);
}


/* ---------- 11. Article content (rich text) ---------- */
/* The reset removed margins and list bullets,
   so we add them back only inside the article. */
.article-content {
  line-height: 1.7;
}

.article-content > * + * {
  margin-top: var(--card-space);   /* same space between every block */
}

.article-content h2 {
  font-size: 2.6rem;
  line-height: 1.3;
  margin-top: 3.2rem;
}

.article-content h3 {
  font-size: 2.1rem;
  line-height: 1.3;
  margin-top: 2.4rem;
}

.article-content ul,
.article-content ol {
  padding-left: 2.4rem;
}

.article-content ul li {
  list-style-type: disc;
}

.article-content ol li {
  list-style-type: decimal;
}

.article-content a {
  color: var(--color-link);
  text-decoration: underline;
}

.article-content a:hover {
  color: var(--color-link-hover);
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.8rem;
}


/* ---------- 12. Tags (blog cards and article) ---------- */
/* Row of tags under a card or article (wraps on small screens) */
.card-tags,
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;                              /* tight space between tags */
}

/* One tag pill (outlined, fully rounded) */
.card-tag,
.article-tag {
  display: inline-block;
  font-size: 1.2rem;
  line-height: 1.4;
  padding: 0.2rem 1rem;
  border: 1px solid var(--color-link);
  border-radius: var(--radius-pill);        /* fully rounded (pill) */
  color: var(--color-link);
  transition: background-color 0.2s ease, color 0.2s ease;   /* smooth hover */
}

/* Hover and keyboard focus: fill with teal, keep text white (a:hover would turn it grey) */
.card-tag:hover,
.card-tag:focus-visible,
.article-tag:hover,
.article-tag:focus-visible {
  color: var(--color-white);
  background-color: var(--color-link);
}


/* ---------- 13. Author profile ---------- */
/* Shared base (mobile: image on top, text below) */
.author-profile {
  padding: 2rem;
  background-color: var(--color-surface);
  border-radius: 1.2rem;
}

.author-profile-title {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-primary);
  margin-bottom: var(--card-space);
}

.author-profile-body {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);
}

.author-photo {
  display: block;
  width: 100%;
  max-width: 16rem;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 0.8rem;
}

.author-profile-text {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.author-name {
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.2;
}

.author-description {
  line-height: 1.6;
}

.author-link {
  color: var(--color-link);
  font-weight: 600;
}

.author-link:hover {
  color: var(--color-link-hover);
}

/* In the main content (home page) */
.page-main .author-profile {
  margin: 3rem 0;   /* same outer space as the blog cards */
}

/* In the sidebar: title gets a bottom border, same as the other sidebar widgets */
.sidebar .author-profile-title {
  padding-bottom: 1.2rem;                          /* space between text and border */
  border-bottom: 1px solid var(--color-grey-50);    /* thin line under the title */
}

/* everything centered: round image, name, bio, link */
.sidebar .author-profile-body {
  align-items: center;
  text-align: center;
}

.sidebar .author-photo {
  width: 14rem;
  border-radius: 50%;   /* round image */
}

.sidebar .author-profile-text {
  align-items: center;
}


/* ---------- 14. Post meta (author photo + name + date) ---------- */
/* Used on every post card (blog index, categories, tags, authors)
   and on the blog detail page.
   One row at every screen size: [photo] Name · Date */
.post-meta {
  display: flex;
  flex-wrap: wrap;            /* wraps only if the row runs out of space */
  align-items: center;        /* photo, name and date share the same middle line */
  gap: 0.8rem;
}

/* Author chip: photo + name (a link when the Authors page exists) */
.post-author {
  display: flex;
  align-items: center;        /* photo and name on the same line */
  gap: 0.8rem;                /* space between photo and name */
}

/* Small round avatar with a teal border */
.post-author-photo {
  display: block;
  width: 4rem;
  height: 4rem;
  flex-shrink: 0;                              /* never squeeze the photo in the flex row */
  object-fit: cover;                           /* crop instead of stretching */
  border: 2px solid var(--color-secondary);    /* 2px Wagtail teal (#007d7e) border */
  border-radius: 50%;                          /* round image, same as the sidebar author */
}

.post-author-name {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-text);   /* normal text color, not muted */
}

/* Hover and keyboard focus anywhere on the chip: teal name (a:hover would turn it grey) */
a.post-author:hover .post-author-name,
a.post-author:focus-visible .post-author-name {
  color: var(--color-link);
}

.post-date {
  font-size: 1.4rem;
  color: var(--color-text-muted);
}

/* Dot between author and date; only shows when an author exists */
.post-author + .post-date::before {
  content: "·";               /* middle dot separator */
  margin-right: 0.8rem;       /* space between the dot and the date */
}


/* ---------- 15. Author box (end of article, for later) ---------- */
/* Not used yet: kept for when the author box is added back under the post */
/* Mobile: photo on top, text below. The row layout is in the tablet section. */
.author-box {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);                   /* the article gap already adds space above */
  padding: 2rem;
  background-color: var(--color-bg);        /* light grey box inside the white article */
  border-radius: 0.8rem;
}

.author-box-photo {
  display: block;
  width: 9.6rem;
  height: 9.6rem;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 50%;                       /* round image */
}

.author-box-body {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.author-box-label {
  font-size: 1.3rem;
  color: var(--color-text-muted);
}

.author-box-name {
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-primary);              /* Wagtail purple, like other titles */
}

.author-box-bio {
  line-height: 1.6;
}

.author-box-link {
  color: var(--color-link);
  font-weight: 600;
}

.author-box-link:hover {
  color: var(--color-link-hover);
}


/* ---------- 16. Authors index (grid of author cards) ---------- */
/* Authors index (/authors/): grid of author cards.
   The page heading uses .blog-intro, the same as categories and tags. */
.author-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);    /* mobile: one column */
  gap: 2.4rem;                              /* same space as .card-list */
  margin: 3rem 0;
}

.author-card {
  display: flex;
  flex-direction: column;
  align-items: center;                      /* everything centered */
  text-align: center;
  gap: 0.8rem;
  padding: 2rem;
  background-color: var(--color-surface);
  border-radius: 1.2rem;
}

.author-card-photo {
  display: block;
  width: 9.6rem;
  height: 9.6rem;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.8rem;                    /* extra room under the photo */
}

.author-card-name {
  font-size: 2.2rem;
  line-height: 1.3;
}

.author-card-count {
  font-size: 1.4rem;
  color: var(--color-text-muted);           /* "3 posts" like a date */
}


/* =====================================================
   MEDIA QUERIES (all small-screen styles are above)
   ===================================================== */

/* ---------- 17. Tablet (768px and wider) ---------- */
@media screen and (min-width: 768px) {

  /* Header */
  .site-logo {
    flex-basis: auto;
  }

  .header-nav {
    display: flex;
    align-items: center;
    flex-basis: auto;
    opacity: 1;
    visibility: visible;
    transition: none;
  }

  .header-nav .nav-menu {
    display: flex;
    overflow: visible;
  }

  .header-nav .menu-item {
    display: inline-block;
    margin: 0 0 0 2rem;
  }

  .header-nav .menu-item:last-child {
    margin-bottom: 0;   /* no extra space on desktop */
  }

  .toggle-btn {
    display: none;      /* no button on desktop */
  }

  /* Blog intro: image left, text right */
  .blog-intro {
    flex-direction: row;
    align-items: center;
  }

  .blog-intro-image {
    flex: 0 0 40%;
    width: 40%;
  }

  .blog-intro-text {
    flex: 1;
  }

  /* Author profile in main content: image left, name + bio + link right */
  .page-main .author-profile-body {
    flex-direction: row;
    align-items: flex-start;
  }

  .page-main .author-photo {
    flex: 0 0 16rem;
    width: 16rem;
  }

  .page-main .author-profile-text {
    flex: 1;
  }

  /* Author box: photo left, text right */
  .author-box {
    flex-direction: row;
    align-items: flex-start;
  }

  /* Authors index: two columns */
  .author-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* ---------- 18. Desktop (1024px and wider) ---------- */
@media screen and (min-width: 1024px) {

  /* Content on the left, 300px sidebar on the right (sidebar is NOT sticky) */
  .page-layout {
    grid-template-columns: minmax(0, 1fr) 30rem;
  }

  /* Authors index: three columns */
  .author-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Author box: a little more space on large screens */
  .author-box {
    padding: 2.4rem;
  }
}


/* ---------- 19. Full width layout (home page, no sidebar) ---------- */
/* Keep this at the very end so it wins over the desktop rule above */
.page-layout.page-layout--full {
  grid-template-columns: minmax(0, 1fr);   /* always one column */
}