/*
 * Site-wide design tweaks layered on top of the original WordPress theme styles.
 * Loaded last on every page so these rules win over the inline theme CSS.
 */

:root {
  --pk-radius: 20px;
  --pk-red: #F87060;          /* theme custom-color-2 */
  --pk-red-strong: #FF6453;   /* theme custom-color-7 */
  --pk-red-gradient: linear-gradient(135deg, var(--pk-red), var(--pk-red-strong));
  --pk-card-bg: #1e1e29;      /* one step lighter than the page (#171720) */

  /* orange trim used on every grey box (first set on the home-page project cards) */
  --pk-trim: rgba(248, 112, 96, 0.18);
  --pk-trim-hover: rgba(248, 112, 96, 0.7);
  --pk-trim-glow: 0 12px 32px rgba(255, 100, 83, 0.18);
}

/* ------------------------------------------------------------------
 * Sticky header: pinned and compact once the page is scrolled
 * (body.pk-header-stuck is toggled by /assets/js/header.js)
 * No backdrop-filter/transform on the bar: either would trap the
 * mobile menu overlay (position: fixed) inside the bar.
 * ------------------------------------------------------------------ */
.site-bar {
  transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  border-bottom: 1px solid transparent;
}

.site-bar > .alignfull {
  transition: padding 0.3s ease;
}

.site-bar .wp-block-site-logo img,
.site-bar .custom-social-links a,
.site-bar .btn-contact a {
  transition: width 0.3s ease, font-size 0.3s ease, padding 0.3s ease, transform 0.2s ease, color 0.2s ease;
}

body.pk-header-stuck .site-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(4, 4, 9, 0.94) !important;
  border-bottom-color: var(--pk-trim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.pk-header-stuck .site-bar > .alignfull {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

body.pk-header-stuck .site-bar .wp-block-site-logo.is-default-size img {
  width: 52px;
}

body.pk-header-stuck .site-bar .custom-social-links a {
  font-size: 24px;
}

body.pk-header-stuck .site-bar .btn-contact a {
  padding-top: 8px;
  padding-bottom: 8px;
}

/* ------------------------------------------------------------------
 * Every grey box: rounded corners + orange trim that brightens on hover
 * ------------------------------------------------------------------ */
.has-custom-color-9-background-color.has-background,
.break-row > .wp-block-cover {
  border-radius: var(--pk-radius);
  border: 1px solid var(--pk-trim) !important;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.has-custom-color-9-background-color.has-background:hover,
.break-row > .wp-block-cover:hover {
  border-color: var(--pk-trim-hover) !important;
  box-shadow: var(--pk-trim-glow);
}

/* Trade War box on the home page clips its content to the rounded corners */
.wp-block-columns.has-custom-color-9-background-color {
  overflow: hidden;
}

/* Skills panel with the code background, next to "About me..." */
.break-row > .wp-block-cover {
  overflow: hidden;
}

/* Grey buttons ("Get in touch" in the header, "Not Open Source", ...) */
.has-custom-color-8-background-color.wp-block-button__link {
  border-radius: 10px;
}

/* ------------------------------------------------------------------
 * Projects, Experience & Articles: show each entry as a raised card
 * (the boxes already existed, but matched the page background)
 * ------------------------------------------------------------------ */
body.page-template-projects .break-row.has-custom-color-9-background-color,
body.page-template-experience .break-row.has-custom-color-9-background-color,
body.page-template-articles .break-row.has-custom-color-9-background-color {
  width: calc(100% - 48px);
  max-width: 1200px;
  margin-left: auto !important;
  margin-right: auto !important;
  box-sizing: border-box;
  padding-top: var(--wp--preset--spacing--60) !important;
  padding-bottom: var(--wp--preset--spacing--60) !important;
  background-color: var(--pk-card-bg) !important;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.page-template-projects .break-row.has-custom-color-9-background-color:hover,
body.page-template-experience .break-row.has-custom-color-9-background-color:hover,
body.page-template-articles .break-row.has-custom-color-9-background-color:hover {
  box-shadow: var(--pk-trim-glow), 0 24px 48px rgba(0, 0, 0, 0.45);
}

body.page-template-projects .break-row.has-custom-color-9-background-color img,
body.page-template-experience .break-row.has-custom-color-9-background-color img,
body.page-template-articles .break-row.has-custom-color-9-background-color img {
  border-radius: 12px;
}

/* Several screenshots stacked in one project card, centred against the text */
.image-stack {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: center;
  gap: 20px;
}

.image-stack img {
  display: block;
  width: 100%;
  height: auto;
}

/* ------------------------------------------------------------------
 * Home: larger image in "Let's get in touch."
 * ------------------------------------------------------------------ */
body.home .break-row.has-custom-color-9-background-color > .wp-block-image {
  flex: 0 1 46%;
  align-self: center;
}

body.home .break-row.has-custom-color-9-background-color > .wp-block-image img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1024 / 674;
  border-radius: 14px;
}

@media (max-width: 781px) {
  /* stack text above the image on phones instead of squeezing them into one row */
  body.home .break-row.has-custom-color-9-background-color:has(> .wp-block-image) {
    flex-wrap: wrap !important;
    padding-bottom: var(--wp--preset--spacing--60) !important;
  }

  body.home .break-row.has-custom-color-9-background-color > .wp-block-image {
    flex: 1 1 100%;
    width: 100%;
    height: auto;
  }

  /* same for the "About me..." + skills row */
  body.home .break-row:has(> .wp-block-cover) {
    flex-wrap: wrap !important;
  }

  body.home .break-row:has(> .wp-block-cover) > * {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ------------------------------------------------------------------
 * Home: equal spacing between sections
 * The section wrapper becomes a flex column with one fixed gap; the
 * wrappers' own vertical margins/paddings are removed so only the gap counts.
 * (The full-screen hero keeps its original spacing to "aim big".)
 * ------------------------------------------------------------------ */
body.home {
  --pk-section-gap: clamp(48px, 6vw, 80px);
}

body.home .wp-site-blocks > .has-custom-color-1-background-color {
  display: flex;
  flex-direction: column;
  row-gap: var(--pk-section-gap);
}

body.home .wp-site-blocks > .has-custom-color-1-background-color > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* wrappers that added their own top/bottom padding */
body.home .wp-site-blocks > .has-custom-color-1-background-color > .has-global-padding {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.home .break-row:has(> .wp-block-cover) {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* keep the hero -> "aim big" spacing as it was */
body.home .wp-site-blocks > .has-custom-color-1-background-color > .wp-block-cover.has-parallax {
  margin-top: calc(24px - var(--pk-section-gap)) !important;
}

/* separator lines sit in the middle of a gap instead of adding a second one */
body.home .wp-site-blocks > .has-custom-color-1-background-color > hr {
  margin-top: calc(var(--pk-section-gap) / -2) !important;
  margin-bottom: calc(var(--pk-section-gap) / -2) !important;
}

/* "OTHER RECENT PROJECTS" heading belongs with its carousel */
body.home .wp-site-blocks > .has-custom-color-1-background-color > h2 {
  margin-bottom: calc(32px - var(--pk-section-gap)) !important;
}

/* a little room inside the track for the cards' float animation, cancelled
   out below so it doesn't count toward the section gap */
body.home .projects-scroll-container {
  padding-top: 16px !important;
  padding-bottom: 16px !important;
}

body.home .wp-site-blocks > .has-custom-color-1-background-color > .projects-carousel {
  margin-bottom: -16px !important;
}

/* zero-height background glow before the footer shouldn't add a gap */
body.home .wp-site-blocks > .has-custom-color-1-background-color > .light-darkblue:empty {
  margin-top: calc(-1 * var(--pk-section-gap)) !important;
}

/* footer: start at its divider line */
body.home footer > .wp-block-group > .wp-block-group.alignfull {
  padding-top: 0 !important;
}

body.home footer .break-row {
  margin-top: 0 !important;
}

/* ------------------------------------------------------------------
 * Articles: the whole article sits in one card with the orange trim
 * ------------------------------------------------------------------ */
.article-card {
  --pk-article-width: calc(var(--wp--style--global--content-size, 620px) + 2 * var(--wp--preset--spacing--50, 24px));
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: var(--pk-article-width);
  margin: 0 auto var(--wp--preset--spacing--80, 64px);
  padding: var(--wp--preset--spacing--50, 24px) 0 var(--wp--preset--spacing--40, 16px);
  background-color: var(--pk-card-bg);
  border: 1px solid var(--pk-trim);
  border-radius: var(--pk-radius);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* long reference URLs must wrap instead of widening the page */
.article-card {
  overflow-wrap: anywhere;
}

/* phones: the content fills the card, so give the card its own side padding */
@media (max-width: 700px) {
  .article-card {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* the article ends with a 100px spacer; inside the card that is just empty space */
.article-card main .wp-block-spacer:last-child {
  height: 24px !important;
}

/* ------------------------------------------------------------------
 * Articles: "Back to Articles" link at the top-left of an article
 * ------------------------------------------------------------------ */
.article-back {
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: var(--wp--style--global--content-size, 620px);
  margin: 0 auto;
  padding: var(--wp--preset--spacing--70, 48px) 0 var(--wp--preset--spacing--40, 16px);
  font-family: var(--wp--preset--font-family--outfit, Outfit, sans-serif);
}

/* with the card, line the link up with the card's left edge */
.article-back:has(+ .article-card) {
  max-width: calc(var(--wp--style--global--content-size, 620px) + 2 * var(--wp--preset--spacing--50, 24px));
}

/* the theme gives image blocks height: 55vh, which left a big gap under the image */
.article-card > header .wp-block-image {
  height: auto;
  margin-bottom: var(--wp--preset--spacing--50, 24px);
}

.article-card > header .wp-block-image img {
  border-radius: 14px;
}

.article-back a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--pk-red);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.2s ease, gap 0.2s ease;
}

.article-back a:hover,
.article-back a:focus-visible {
  color: var(--pk-red-strong);
  gap: 12px;
}
