/* ---------- Variables ---------- */
:root {
  --color-purple: #2e1f5e;   /* Wagtail dark purple */
  --color-link: #007d7e;     /* Wagtail light theme green (teal) */
  --color-link-hover: #005f60;
  --card-space: 16px;        /* one spacing value used everywhere in cards */
  --page-width: 1200px;      /* one width used by header AND content */
  --page-width-full: 100%;
  --page-top-space: 30px;    /* one top space used by left content AND sidebar */
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

/* 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: 18px;
}

a {
  text-decoration: none;
  color: #333;
}

a:hover {
  color: #777;
}

li {
  list-style-type: none;
}

/* ---------- 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 20px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
}

.site-header {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* ---------- Logo ---------- */
.site-logo {
  flex-basis: 70%;
}

.logo-text {
  display: flex;
  flex-flow: column;
  line-height: 1;
  padding: 24px 0;
}

.logo-title {
  font-size: 22px;
  font-weight: 600;
  display: block;
  width: 100%;
}

.logo-tagline {
  font-size: 13px;
  font-weight: normal;
  display: block;
  width: 100%;
}

/* ---------- Toggle button ---------- */
.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: 13px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.toggle-btn-label {
  margin-left: 10px;
}

.toggle-btn-bar {
  display: block;
  height: 2px;
  background-color: #333;
  width: 18px;
  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 5.5px;
  rotate: 45deg;
  transition-delay: 0s, 0.2s, 0s;
}

.toggle-btn.active .btn-bar-3 {
  translate: 0 -5.5px;
  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: 10px 0;
}

.header-nav .menu-item:last-child {
  margin-bottom: 30px;   /* space under Contact */
}

/* ---------- Page layout with sidebar ---------- */
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* phone: one column */
  gap: 24px;
  width: 100%;
  max-width: var(--page-width);   /* same as .inner */
  margin: 0 auto;
  padding: var(--page-top-space) 20px 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;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;               /* same space between every widget */
  margin: 0 0 30px;        /* same outer space as the blog cards */
}

.sidebar-widget {
  padding: 20px;
  background-color: #fff;                         /* white, like your cards */
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
  overflow: hidden;                               /* keeps the purple title inside the rounded corners */
}

/* Widget title: purple bar at the top of the widget */
.sidebar-widget-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  color: #fff;
  background-color: var(--color-purple);          /* Wagtail purple */
  padding: 14px 20px;
  margin: -20px -20px var(--card-space);          /* stretch to the widget edges */
}

/* ---------- Blog Intro (image left, text right) ---------- */
.blog-intro {
  display: flex;
  flex-direction: column;          /* mobile: image on top, text below */
  gap: var(--card-space);
  margin: 30px 0;
  padding: 20px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.blog-intro-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
}

.blog-intro-text {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);
}

.blog-intro-title {
  font-size: 28px;
  line-height: 1.2;
}

/* "Our Blog" title with no box around it: no top margin */
.blog-intro-title--plain {
  margin: 0;
}

.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);
}

/* ---------- Blog Cards ---------- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 30px 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);          /* same space between every item in the card */
  padding: 20px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* Category */
.card-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-category {
  background-color: var(--color-purple);
  color: #fff;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 8px;
}

/* Featured image (16:9 ratio) */
.card-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
}

/* Title, date, excerpt */
.card-title {
  font-size: 24px;
  line-height: 1.3;
}

.card-date {
  font-size: 14px;
  color: #777;
}

.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);
}

/* ---------- Blog Detail (single article) ---------- */
.article {
  display: flex;
  flex-direction: column;
  gap: var(--card-space);
  margin: 30px 0;
  padding: 20px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.article-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
}

.article-title {
  font-size: 32px;
  line-height: 1.3;
}

.article-date {
  font-size: 14px;
  color: #777;
}

/* Tags */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.article-tag {
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid var(--color-link);
  border-radius: 8px;
  color: var(--color-link);
}

/* Back link */
.article-back {
  color: var(--color-link);
  font-weight: 600;
}

.article-back:hover {
  color: var(--color-link-hover);
}

/* ---------- 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: 26px;
  line-height: 1.3;
  margin-top: 32px;
}

.article-content h3 {
  font-size: 21px;
  line-height: 1.3;
  margin-top: 24px;
}

.article-content ul,
.article-content ol {
  padding-left: 24px;
}

.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: 8px;
}

/* ---------- 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 20px;
  }

  .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;
  }
}

/* ---------- 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) 300px;
  }
}

/* ---------- 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 */
}

/* ---------- Author Profile (shared base) ---------- */
.author-profile {
  padding: 20px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

.author-profile-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-purple);
  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: 160px;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
}

.author-profile-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.author-name {
  font-size: 24px;
  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);
}

/* ---------- Author Profile: in the main content (home page) ---------- */
.page-main .author-profile {
  margin: 30px 0;   /* same outer space as the blog cards */
}

@media screen and (min-width: 768px) {
  /* image on the left, name + bio + link on the right */
  .page-main .author-profile-body {
    flex-direction: row;
    align-items: flex-start;
  }

  .page-main .author-photo {
    flex: 0 0 160px;
    width: 160px;
  }

  .page-main .author-profile-text {
    flex: 1;
  }
}

/* ---------- Author Profile: in the sidebar ---------- */
.sidebar .author-profile {
  overflow: hidden;   /* keeps the purple title inside the rounded corners */
}

/* purple title bar, same as your other sidebar widgets */
.sidebar .author-profile-title {
  color: #fff;
  background-color: var(--color-purple);
  padding: 14px 20px;
  margin: -20px -20px var(--card-space);
}

/* everything centered: round image, name, bio, link */
.sidebar .author-profile-body {
  align-items: center;
  text-align: center;
}

.sidebar .author-photo {
  width: 140px;
  border-radius: 50%;   /* round image */
}

.sidebar .author-profile-text {
  align-items: center;
}