/* Site-wide additions loaded through site-css in _config.yml */

:root {
  /* Keep in step with the colour settings in _config.yml. */
  --fc-text: #2b2f33;
  --fc-heading: #1f2328;
  --fc-muted: #57606a;
  --fc-accent: #0a64c8;
  --fc-accent-hover: #084c9e;
  --fc-border: #d8dee4;
  --fc-surface: #f6f8fa;
  --fc-tint: #eef4fc;
}

.archive-note,
.post-notice {
  margin: 0 0 1.5em;
  padding: 0.75em 1em;
  border-left: 4px solid #8a94a6;
  background: #f6f8fa;
  color: #404040;
  font-size: 0.9em;
  line-height: 1.5;
}

/* Animated demo figures in project posts */
figure.demo-figure {
  margin: 1.5em 0;
}
figure.demo-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid #d0d7de;
  border-radius: 6px;
}
figure.demo-figure figcaption {
  margin-top: 0.5em;
  color: #595959;
  font-size: 0.85em;
  line-height: 1.5;
}

/* --- Navbar dropdown (About menu) --- */

.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-toggle::after {
  border-width: 0.3em;
  border-bottom-width: 0;
  margin-left: 0.4em;
}

.navbar-custom .navbar-nav .nav-item.dropdown.show {
  background: rgba(10, 100, 200, 0.07);
}

.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu {
  min-width: 12rem;
  padding: 0.375rem 0;
  text-align: left;
  background-color: #ffffff;
  border: 1px solid var(--fc-border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item {
  padding: 0.7rem 1.25rem;
  background-color: transparent;
  border: 0;
  white-space: nowrap;
}

.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item:hover,
.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item:focus {
  background-color: var(--fc-tint);
  color: var(--fc-accent-hover);
}

.navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: -2px;
}

@media (max-width: 1199px) {
  .navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu {
    min-width: 0;
    padding: 0 0 0.375rem;
    background-color: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item {
    padding: 0.6rem 1rem 0.6rem 2rem;
  }

  .navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item:hover,
  .navbar-custom .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item:focus {
    background-color: rgba(0, 0, 0, 0.05);
  }
}

/* --- Lab series: intro and previous/next navigation --- */

.lab-series-intro {
  margin: 0 0 1.5em;
  color: #404040;
  font-size: 1em;
  line-height: 1.5;
}

.lab-series-nav {
  margin: 2.5em 0 1.5em;
  padding: 1em 1.25em;
  border: 1px solid var(--fc-border);
  border-left: 4px solid var(--fc-accent);
  border-radius: 6px;
  background: #f6f8fa;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
}

.lab-series-nav .lab-series-label {
  margin: 0 0 0.75em;
  color: #595959;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lab-series-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em 1.5em;
  justify-content: space-between;
}

.lab-series-links a {
  font-weight: 600;
}

.lab-series-links .lab-series-next {
  margin-left: auto;
  text-align: right;
}

/* --- Typography and focus --- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
}

/* Headings in the page content use the heading color. The header banner sets its
   own text color (white over a cover image), so it is left to inherit. */
.blog-post h1,
.blog-post h2,
.blog-post h3,
.blog-post h4,
.blog-post h5,
.blog-post h6 {
  color: var(--fc-heading);
}

h1 {
  letter-spacing: -0.01em;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.page-link:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 2px;
}

.navbar-custom {
  box-shadow: 0 1px 2px rgba(27, 31, 36, 0.06);
}

.navbar-custom .navbar-brand {
  letter-spacing: 0.01em;
}

.blog-post blockquote {
  padding: 0.25em 1em;
  border-left: 4px solid var(--fc-border);
  color: var(--fc-muted);
}

/* --- Homepage introduction --- */

.failclosed-intro {
  max-width: 700px;
  margin: 0 auto 40px;
  padding: 0 20px;
  text-align: center;
}

.failclosed-intro h2 {
  margin-top: 0;
  text-wrap: balance;        /* no one-word last lines */
}

.failclosed-intro p {
  color: #4a5058;
  text-wrap: balance;
}

.failclosed-intro .nowrap {
  white-space: nowrap;       /* keeps "Ko-fi" from breaking at its hyphen */
}

.intro-subscribe-btn {
  display: inline-block;
  background: var(--fc-accent);
  color: #ffffff !important;
  border-radius: 999px;
  padding: 2px 14px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.2s;
}

.intro-subscribe-btn:hover,
.intro-subscribe-btn:focus {
  background: var(--fc-accent-hover);
}

/* --- Section tiles (homepage, Home Lab, Cybersecurity, CTF Writeups) --- */

.homepage-grid,
.homelab-grid,
.projects-grid,
.ctf-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;   /* rows of tiles, including a short last row, sit in the middle of the page */
  gap: 24px;
  max-width: 1140px;         /* room for four 250px tiles and their gaps in a row */
  margin: 24px auto;
  padding: 0 20px;
}

.homepage-tile,
.homelab-tile,
.projects-tile,
.ctf-tile {
  display: flex;
  flex-direction: column;
  flex: 0 1 250px;
  width: 250px;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--fc-heading);
  text-decoration: none !important;
  background: #ffffff;
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(27, 31, 36, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.homepage-tile:hover,
.homelab-tile:hover,
.projects-tile:hover,
.ctf-tile:hover,
.homepage-tile:focus-visible,
.homelab-tile:focus-visible,
.projects-tile:focus-visible,
.ctf-tile:focus-visible {
  color: var(--fc-heading);
  border-color: var(--fc-accent);
  box-shadow: 0 6px 16px rgba(27, 31, 36, 0.12);
  transform: translateY(-3px);
}

.homepage-thumb,
.homelab-thumb,
.projects-thumb,
.ctf-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 170px;
  padding: 16px;
  background: var(--fc-surface);
  border-bottom: 1px solid var(--fc-border);
  overflow: hidden;
}

.homepage-thumb img,
.homelab-thumb img,
.projects-thumb img,
.ctf-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.homepage-placeholder,
.homelab-placeholder,
.projects-placeholder,
.ctf-placeholder {
  color: var(--fc-muted);
  font-size: 0.9rem;
}

.homepage-title,
.homelab-title,
.projects-title,
.ctf-title {
  padding: 14px 14px 2px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.homepage-count,
.homelab-count,
.projects-count,
.ctf-count {
  padding: 0 14px 14px;
  color: var(--fc-muted);
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  text-align: center;
}

/* Phones: two tiles per row instead of one very tall column. */
@media (max-width: 599px) {
  .homepage-grid,
  .homelab-grid,
  .projects-grid,
  .ctf-grid {
    gap: 14px;
    padding: 0 14px;
  }

  .homepage-tile,
  .homelab-tile,
  .projects-tile,
  .ctf-tile {
    flex: 0 1 calc(50% - 7px);
    width: calc(50% - 7px);
  }

  .homepage-thumb,
  .homelab-thumb,
  .projects-thumb,
  .ctf-thumb {
    height: 120px;
    padding: 10px;
  }

  .homepage-title,
  .homelab-title,
  .projects-title,
  .ctf-title {
    padding: 10px 8px 2px;
    font-size: 0.95rem;
  }

  .homepage-count,
  .homelab-count,
  .projects-count,
  .ctf-count {
    padding: 0 8px 12px;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .homepage-tile,
  .homelab-tile,
  .projects-tile,
  .ctf-tile {
    transition: none;
  }

  .homepage-tile:hover,
  .homelab-tile:hover,
  .projects-tile:hover,
  .ctf-tile:hover {
    transform: none;
  }
}

/* --- Cover banners --- */

/* Cover text stays white and gets a stronger shadow so it holds up on any image. */
.intro-header.big-img .page-heading,
.intro-header.big-img .post-heading {
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65), 0 0 14px rgba(0, 0, 0, 0.4);
}

.intro-header.big-img h1,
.intro-header.big-img h2 {
  color: inherit;
}

/* The generated covers carry an accent stripe on the left. It is drawn here because
   the image is cropped to the middle on narrow screens, which cuts off any
   stripe painted at the image edge. */
.intro-header.big-img.generated-cover::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 10px;
  background: var(--cover-accent, #008aff);
}

/* A thin strip runs along the bottom edge of the banner. The image carries one too, but the
   banner crops the image to its middle, which cuts the image's own bottom edge off. */
.intro-header.big-img.generated-cover::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  height: 4px;
  background: var(--cover-accent, #008aff);
  opacity: 0.6;
}

/* Stripe colors follow the post type, matching the colors drawn into the cover images. */
.cover-blog      { --cover-accent: #64b5f6; }
.cover-blueteam  { --cover-accent: #1f4fff; }
.cover-redteam   { --cover-accent: #ff2222; }
.cover-ctfwriteups { --cover-accent: #7c4dff; }
.cover-labs      { --cover-accent: #4caf50; }
.cover-homelab   { --cover-accent: #00bcd4; }

@media (max-width: 767px) {
  /* Keep the cover text clear of the stripe on phones. */
  .intro-header.big-img.generated-cover .container-md {
    padding-left: 28px;
  }
}

/* --- Resources, Speaking, and download pages --- */

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  margin: 16px 0 32px;
}

/* The Portfolio page is full width so the cards get room, and this keeps its text and grid in one
   centered column that matches the homepage tiles. */
.portfolio-wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.portfolio-wrap h2 {
  margin-top: 28px;
}

/* Category headings inside a section (the Apps section is grouped by what the tools are for). */
.portfolio-wrap h3.portfolio-category {
  margin: 26px 0 12px;
  font-size: 1.1rem;
}

/* Portfolio grid: a fixed column count so cards stay readable and group cleanly by type,
   instead of the auto-fit grid cramming a whole row of narrow cards on wide screens.
   Three across on wide screens, two on tablets, one on phones. Four across left each card about
   230px wide, which wrapped the descriptions into long narrow strips. Other .resource-grid pages
   keep the default auto-fit behavior. */
.portfolio-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

@media (min-width: 992px) {
  .portfolio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 575px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
  }
}

/* A page with only a few cards (the unlisted portfolio pages): the cards keep a readable width and sit
   in the middle of the page instead of crowding into the left-hand columns of the grid. */
.portfolio-grid.portfolio-grid-centered {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.portfolio-grid-centered > .portfolio-card {
  flex: 1 1 320px;
  max-width: 440px;
}

.resource-card,
.talk-card {
  display: block;
  padding: 18px 20px;
  color: inherit;
  text-decoration: none !important;
  background: #ffffff;
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(27, 31, 36, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.resource-card:hover,
.resource-card:focus-visible,
.talk-card:hover,
.talk-card:focus-visible {
  color: inherit;
  border-color: var(--fc-accent);
  box-shadow: 0 6px 16px rgba(27, 31, 36, 0.12);
  transform: translateY(-3px);
}

/* Portfolio cards: the whole card opens the app. The title link is stretched over the card,
   and the source link sits above it so both stay separate links. */
.portfolio-card {
  position: relative;
  padding: 22px 24px; /* roomier than the default card; this rule comes after .resource-card so it wins */
}

.portfolio-main-link {
  color: inherit;
  text-decoration: none !important;
}

.portfolio-main-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.portfolio-card:focus-within {
  border-color: var(--fc-accent);
  box-shadow: 0 6px 16px rgba(27, 31, 36, 0.12);
}

.portfolio-links {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  font-size: 0.9em;
  font-weight: 600;
}

/* Portfolio cards start collapsed: badge, title and one line. "Details" opens the rest, so a row of cards stays
   short and more can be added. The cards size to their own content, so opening one does not stretch its neighbours. */
.portfolio-grid {
  align-items: start;
}

/* A picture at the top of a card: a screenshot of the demo, cropped to a fixed shape so a row lines up. */
.portfolio-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
  margin: 0 0 14px;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: 6px;
}

.portfolio-more {
  position: relative;
  z-index: 2; /* above the stretched title link, so the toggle and the text are not part of the card link */
  margin-top: 10px;
}

.portfolio-more summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  cursor: pointer;
  list-style: none;
  color: var(--fc-accent);
  font-size: 0.88em;
  font-weight: 600;
}

.portfolio-more summary::-webkit-details-marker {
  display: none;
}

.portfolio-more summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.portfolio-more[open] summary::before {
  transform: rotate(45deg);
}

.portfolio-more summary:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.portfolio-more > .resource-card-desc,
.portfolio-more > .resource-card-note {
  margin-top: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-more summary::before {
    transition: none;
  }
}

.resource-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.resource-badge-free  { background: #d4edda; color: #166534; }
.resource-badge-buy   { background: #fff3cd; color: #8a6516; }
.resource-badge-skill { background: #d6e4ff; color: #1e3a8a; }
.resource-badge-lab   { background: #e9ddff; color: #4c2a85; }
.resource-badge-site  { background: #d3f1ec; color: #0b5c52; }

.resource-card-title,
.talk-title {
  color: var(--fc-accent);
  font-weight: 700;
}

.resource-card-title {
  margin-bottom: 8px;
}

.resource-card-desc {
  color: #4a5058;
  font-size: 0.95em;
}

.resource-card-note {
  margin-top: 10px;
  color: #6a737d;
  font-size: 0.8em;
  font-style: italic;
}

.talk-card {
  max-width: 600px;
  margin: 16px 0;
}

.talk-conference {
  margin-bottom: 4px;
  color: var(--fc-muted);
  font-size: 0.85em;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.talk-title {
  font-size: 1.2em;
}

.talk-extra {
  max-width: 600px;
  margin: -8px 0 16px;
  padding: 0 20px;
  color: var(--fc-muted);
  font-size: 0.85em;
}

.talk-extra a {
  color: var(--fc-accent);
}

.confirmation-container {
  max-width: 480px;
  margin: 20px auto;
  text-align: center;
}

.confirmation-download-link {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 24px;
  color: #ffffff;
  text-decoration: none;
  background: var(--fc-accent);
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
}

.confirmation-download-link:hover,
.confirmation-download-link:focus {
  color: #ffffff;
  text-decoration: none;
  background: var(--fc-accent-hover);
}

.not-found {
  margin: 4rem 0;
}

/* Links inside running text are underlined. Their color alone (the link blue against dark grey text) is only about 2.4:1,
   which is not enough to tell a link from the surrounding words (WCAG 1.4.1). Cards, tiles, buttons, navigation, and post
   lists carry a class or sit outside paragraphs, so they keep their own styles. */
[role="main"] :is(p, li:not(.post-preview), td, blockquote) a:not([class]),
footer p a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
