:root {
  --bachelor-text: #1E8F3B;
  --bachelor-badge: rgba(77, 217, 114, 0.4);

  --master-text: #B54706;
  --master-badge: rgba(248, 174, 110, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bachelor-text: #B5FFB2; 
    --bachelor-badge: rgba(50, 180, 80, 0.45);

    --master-text: #ffb648; 
    --master-badge: rgba(255, 140, 0, 0.35);
  }
}

html, body {
    height: auto;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* `hidden` only clips visually — see the matching comment in
       style.css for why `clip` (which forbids scrolling outright) is
       also needed here. This rule duplicates style.css's html/body
       block and loads after it, so it was silently overriding the
       fix there for every page that includes this stylesheet. */
    overflow-x: clip;

    flex-direction: column;
    background-color: var(--background-color);
  
    transition: background-color 0.4s ease;
    will-change: background-color;

    scroll-behavior: initial;
  }


  .projects-hero-container {
    display: flex;
    flex-direction: column;
    gap: 0;

    min-height: 75vh;
    height: auto;

    justify-content: center;
  }

  .projects-intro {
    max-width: 44rem;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--text-color-secondary);
  }

  .projects-intro p {
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-color-secondary);
  }

  .projects-hero-title {
    font-size: clamp(3rem, 8vw, 4.5rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-color-primary);

    position: relative;
    display: inline-block;

    margin-top: 7rem;
    margin-bottom: 0.5rem;
  }

  /* Thin brand-gradient underline — same treatment as the homepage hero */
  .projects-hero-title::after {
    content: "";
    display: block;
    width: 3.5rem;
    height: 0.25rem;
    margin: 0.875rem auto 0;

    background: var(--hero-gradient);
    border-radius: var(--radius-pill);
  }

/* ── Hero entrance — same hero-ready orchestration as the homepage ─────────
   Portrait pops first, title and intro rise in behind it, while the icon
   constellation blooms as soon as the logos have decoded (~0.35s floor). */

.projects-hero-title,
.projects-intro p {
  opacity: 0;
  transform: translateY(0.75rem);
  filter: blur(12px);
}

/* Entrance: rise + unblur (same keyframes as hero.css, which isn't loaded here) */
@keyframes riseIn {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* scaleIn variant that keeps the portrait's centering translate */
@keyframes heroPortraitIn {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    filter: blur(12px);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0.6;
    filter: blur(2px);
  }
  80% {
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0.8;
    filter: blur(0);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    filter: blur(0);
  }
}

html.hero-ready .projects-page-hero-profile-picture {
  animation: heroPortraitIn 0.5s forwards;
}

html.hero-ready .projects-hero-title {
  animation: riseIn 0.5s forwards;
  animation-delay: 0.15s;
}

html.hero-ready .projects-intro p {
  animation: riseIn 0.5s forwards;
}

html.hero-ready .projects-intro p:nth-child(1) { animation-delay: 0.3s; }
html.hero-ready .projects-intro p:nth-child(2) { animation-delay: 0.4s; }

.projects-hero-icons-container {
  position: relative;
  width: 100%;
  height: 18.75rem;
  min-height: 18.75rem;
  overflow: visible;
}

.projects-page-hero-profile-picture {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(0deg);

  /* Hidden until the hero-ready entrance animation runs */
  opacity: 0;

  width: 12.5rem;
  height: 12.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 
    0 69px 19px rgba(0,0,0,0),
    0 44px 18px rgba(0, 0, 0, 0.01),
    0 25px 15px rgba(0, 0, 0, 0.05),
    0 11px 11px rgba(0, 0, 0, 0.09),
    0 3px 6px rgba(0, 0, 0, 0.10);
  max-width: 100%;

  /* Prevent any pointer interaction on the image itself */
  pointer-events: none;
  
  /* Prevent long-press menus on iOS / Safari */
  -webkit-touch-callout: none;

  /* Prevent image dragging */
  -webkit-user-drag: none;
  user-drag: none;

  /* Prevent selection */
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 500px) {
  .projects-page-hero-profile-picture {
    width: 10rem;
    height: 10rem;
  }
}


/* Icons to use in the Hero section of the Projects page */

/* Common base for all hero icons */
.projects-hero-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  opacity: 0;
  filter: blur(12px);

  /* Prevent any pointer interaction on the image itself */
  pointer-events: none;
  
  /* Prevent long-press menus on iOS / Safari */
  -webkit-touch-callout: none;

  /* Prevent image dragging */
  -webkit-user-drag: none;
  user-drag: none;

  /* Prevent selection */
  user-select: none;
  -webkit-user-select: none;
}

.projects-hero-icons-container.animate .projects-hero-icon {
  top: var(--final-top);
  left: var(--final-left);
  right: var(--final-right); /* if used */
  opacity: 1;
  transform: scale(1) rotate(var(--rotation, 0deg));
  transition: all 1s cubic-bezier(0.25, 1, 0.5, 1);
  filter: blur(0);
}

/* Size modifiers */
.projects-hero-icon.large {
  width: 7.5rem;
  aspect-ratio: 1;
}

.projects-hero-icon.medium {
  width: 5.5rem;
  aspect-ratio: 1;
}

.projects-hero-icon.small {
  width: 3rem;
  aspect-ratio: 1;
}

/* Tighter icon constellation on phones so it doesn't crowd the profile picture */
@media (max-width: 500px) {
  .projects-hero-icon.large {
    width: 5.5rem;
    height: 5.5rem;
  }

  .projects-hero-icon.medium {
    width: 4rem;
    height: 4rem;
  }

  .projects-hero-icon.small {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Position slots */
.projects-hero-icon:nth-child(1) { --final-top: 6%;  --final-left: 8%;  }
.projects-hero-icon:nth-child(2) { --final-top: 12%; --final-right: 12%; }
.projects-hero-icon:nth-child(3) { --final-top: 50%; --final-left: 25%; }
.projects-hero-icon:nth-child(4) { --final-top: 45%; --final-right: 10%; }
.projects-hero-icon:nth-child(5) { --final-top: 85%; --final-left: 65%; }
.projects-hero-icon:nth-child(6) { --final-top: 60%; --final-left: 10%; }
.projects-hero-icon:nth-child(7) { --final-top: 15%; --final-right: 35%; }
.projects-hero-icon:nth-child(8) { --final-top: 70%; --final-right: 15%; }
.projects-hero-icon:nth-child(9) { --final-top: 82%; --final-left: 25%; }

/* Post pop-in animation */
.projects-hero-icon.floating {
  animation: floatAround 6s infinite ease-in-out;
}

@keyframes floatAround {
  0%   { transform: translate(0, 0) rotate(var(--rotation)); }
  25%  { transform: translate(5px, -10px) rotate(calc(var(--rotation) + 3deg)); }
  50%  { transform: translate(-5px, 10px) rotate(calc(var(--rotation) - 2deg)); }
  75%  { transform: translate(8px, 5px) rotate(calc(var(--rotation) + 1deg)); }
  100% { transform: translate(0, 0) rotate(var(--rotation)); }
}

/* Projects Grid */
.projects-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;

  width: 100%;

  padding: 1.25rem;
  box-sizing: border-box;
}

.project-grid-card {
  border-radius: var(--radius-panel);
  box-sizing: border-box;
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  transition: transform ease 0.3s, box-shadow ease 0.3s;

  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;

  cursor: pointer;
}

/* Light mode variant (default) */
@media (prefers-color-scheme: light) {
  .project-grid-card {
    background: radial-gradient(
      circle at top right,
      color-mix(in srgb, var(--accent-color) 60%, var(--popup-background) 40%) 0%,
      color-mix(in srgb, var(--accent-color) 15%, var(--popup-background) 85%) 60%,
      var(--popup-background) 100%
    );
  }
}

/* Dark mode variant — accent tempered to match the homepage's quieter surfaces */
@media (prefers-color-scheme: dark) {
  .project-grid-card {
    background: radial-gradient(
      circle at top right,
      color-mix(in srgb, var(--accent-color) 60%, var(--popup-background) 40%) 0%,
      color-mix(in srgb, var(--accent-color) 20%, var(--popup-background) 80%) 60%,
      var(--popup-background) 100%
    );
  }
}

.project-grid-card:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-raised);
}

.project-card-icon {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: contain;
  aspect-ratio: 1;

  padding: 8px;
  aspect-ratio: 1;

  /* Prevent any pointer interaction on the image itself */
  pointer-events: none;
  
  /* Prevent long-press menus on iOS / Safari */
  -webkit-touch-callout: none;

  /* Prevent image dragging */
  -webkit-user-drag: none;
  user-drag: none;

  /* Prevent selection */
  user-select: none;
  -webkit-user-select: none;
}

.project-card-title {
  font-size: 1.125rem;
  font-weight: 800; /* keeps the previous h1 weight after the h3 swap */
  margin: 0;
  padding: 0;
}

.project-type-container {
  display: inline-flex;
  gap: 0.25rem;

  align-items: center;
  justify-self: baseline;
}

.project-type-icon {
  font-family: 'Material Symbols Outlined';
  font-size: 0.875rem;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0.75;
}

.project-type-text {
  font-size: 0.875rem;
  opacity: 0.75;
}

.degree-badge-container {
  padding: 0.25rem 1rem;
  display: inline-block;
  border-radius: 9999px;

  width: fit-content;

  margin-left: auto;
  margin-right: auto;

  opacity: 0.7;
}

.bachelor-badge {
  background: var(--bachelor-badge);
}

.master-badge {
  background: var(--master-badge)
}

.degree-badge-text {
  font-size: 0.875rem;
  font-weight: bold;
  margin: 0;
}

.bachelor-text {
  color: var(--bachelor-text);
}

.master-text {
  color: var(--master-text);
}

.project-card-details-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  margin-top: -0.625rem;
}

.popup-content {
  padding: 2rem;
  font-size: 1.1rem;
}

.popup-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, transform 0.2s ease;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.85);

}

.popup-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.project-popup-icon {
  width: 10rem;
  height: 10rem;
  object-fit: contain;

  /* Shared-element scaling (open/close animations) grows from the top edge,
     keeping the icon anchored where the card's icon sits */
  transform-origin: top center;

  /* Prevent any pointer interaction on the image itself */
  pointer-events: none;
  
  /* Prevent long-press menus on iOS / Safari */
  -webkit-touch-callout: none;

  /* Prevent image dragging */
  -webkit-user-drag: none;
  user-drag: none;

  /* Prevent selection */
  user-select: none;
  -webkit-user-select: none;

  view-transition-name: project-icon;
}

.project-popup-title-container {
  display: flex;
  flex-direction: column;
  gap: 0;

  justify-content: center;
  align-items: center;
}

.project-popup-title-container > h2 {
  margin: 0;
  padding: 0;

  /* Shared-element scaling (open/close animations) grows from the top edge,
     staying anchored below the icon like the card's title */
  transform-origin: top center;

  view-transition-name: project-title;
}

.project-popup-skill-pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;

  margin: 1.25rem;
  height: fit-content;

  justify-content: center;
}

.project-popup-description {
  text-align: left;
  margin: 0;
}

.project-skill-text {
  font-weight: bold;
  font-size: 0.75rem;
}

.project-skill-icon {
  font-family: 'Material Symbols Outlined';
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Popup link badges — same language as the homepage hero badges */
.github-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background-color: rgba(22, 35, 59, 0.08);
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-weight: 600;
  color: var(--text-color-primary);

  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.github-badge:hover {
  transform: scale(1.04);
  background-color: rgba(22, 35, 59, 0.14);
  box-shadow: var(--shadow-soft);
}

.open-button-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background-color: var(--text-color-accent);
  color: #FFFFFF;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.open-button-badge:hover {
  background-color: #123C86;
  transform: scale(1.04);
  box-shadow: var(--shadow-soft);
}

.open-button-badge:active {
  transform: scale(1);
}

/* Icon inside the badge */
.open-button-badge .button-icon {
  width: 1.4rem;
  height: 1.4rem;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.2s ease;
}

.open-button-badge:hover .button-icon {
  transform: translateX(3px); /* subtle right movement */
}

/* Dark mode — accent-on-ink like the homepage primary badge */
@media (prefers-color-scheme: dark) {
  .open-button-badge {
    background-color: var(--text-color-accent);
    color: #0D1524;
  }
  .open-button-badge:hover {
    background-color: #8CC4FF;
  }
  .open-button-badge .open-button-icon {
    color: #0D1524;
  }
}

.github-icon {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--text-color-primary);
}

.open-button-icon {
  width: 1.4rem;
  height: 1.4rem;
  color: #fff;
}

.github-text {
  font-size: 0.9rem;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .github-badge {
      background-color: rgba(255, 255, 255, 0.08);
  }
  .github-badge:hover {
      background-color: rgba(255, 255, 255, 0.15);
  }
}

.project-popup-buttons-container {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: center;
  gap: 0.75rem;
}

.project-exam-course {
  font-size: 1rem;
  font-weight: bold;
  opacity: 0.75;
  text-align: left;

  margin: 0;
}

.project-university-details-container {
  display: flex;
  flex-direction: column;

  gap: 0.5rem;
}

/* Popup shell background — same as the card gradient */
.project-popup {
  background:
    radial-gradient(
      circle at top right,
      color-mix(in srgb, var(--accent-color) 60%, var(--popup-background) 40%) 0%,
      color-mix(in srgb, var(--accent-color) 15%, var(--popup-background) 85%) 60%,
      var(--popup-background) 100%
    ),
    var(--background-color); /* opaque base underneath */
}

/* Must match the dark .project-grid-card gradient for a seamless morph */
@media (prefers-color-scheme: dark) {
  .project-popup {
    background:
      radial-gradient(
        circle at top right,
        color-mix(in srgb, var(--accent-color) 60%, var(--popup-background) 40%) 0%,
        color-mix(in srgb, var(--accent-color) 20%, var(--popup-background) 80%) 60%,
        var(--popup-background) 100%
      ),
      var(--background-color); /* opaque base underneath */
  }
}
/* Container-transform reveal: the content is laid out at the popup's FINAL
   size from the first frame (80vw × 80dvh mirrors morph-card's popupTarget
   for default popups) and anchored to the box's top-center. The animating
   box just clips through it — nothing reflows mid-morph, and the destination
   content stays visible during both the open and the close animation. */
.project-popup .morph-popup__inner {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;
  width: 80vw;
  height: 80dvh;

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /* Resting / pre-open state: content enters from a soft-focus blur.
     (The close path pins filter to none — see the closing rules.) */
  opacity: 0;
  filter: blur(12px);
  transition: opacity 0.3s ease 0.08s, filter 0.42s ease;
}

/* Opening: content appears immediately and sharpens as the box lands
   (overrides morph-card.css's fade-in-after-morph default) */
.project-popup.morph-popup--open .morph-popup__inner {
  opacity: 1;
  filter: blur(0);
  transition: opacity 0.2s ease, filter 0.35s ease;
}

/* The icon is the true shared element: it scales between the card's icon size
   and its own in sync with the geometry animation (0.75 = 7.5rem card icon
   ÷ 10rem popup icon — keep in sync if either size changes). Timing/easing
   mirror morph-card.js's DURATION and EASING. */
.project-popup.morph-popup--open .project-popup-icon {
  animation: popupIconIn 420ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes popupIconIn {
  from { scale: 0.75; }
  to   { scale: 1; }
}

/* Same treatment for the title (0.5 = 1.125rem card title ÷ 2.25rem popup h2
   — keep in sync if either size changes) */
.project-popup.morph-popup--open .project-popup-title-container > h2 {
  animation: popupTitleIn 420ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes popupTitleIn {
  from { scale: 0.5; }
  to   { scale: 1; }
}

/* ── Card face ────────────────────────────────────────────────────────────────
   A replica of the grid card's content (same markup, same classes) that the
   popup wears at card size: visible for the first frames of the open and the
   last stretch of the close, so the box always launches from — and lands on —
   the exact card look. Sized via --card-face-width/height, set from the real
   card at click time. */
.project-popup .popup-card-face {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;
  width: var(--card-face-width, 100%);
  height: var(--card-face-height, auto);
  box-sizing: border-box;
  padding: 1.25rem;

  display: flex;
  flex-direction: column;
  align-items: center;

  pointer-events: none;
  z-index: 2;

  opacity: 1;
  transition: opacity 0.25s ease;
}

/* Open: the face fades away as the real content blurs in */
.project-popup.morph-popup--open .popup-card-face {
  opacity: 0;
}

/* ── Close handoff: dissolve into the real card ──────────────────────────────
   While closing (class added by the MutationObserver in the page script):
   - the grid card underneath is made visible again, so the popup flies onto it
   - the popup's content stays fully visible during the flight
   - the whole popup fades out over the last stretch of the landing, dissolving
     into the identical-looking card instead of swapping at the end.
   Duration must match morph-card.js's DURATION (420ms). */

.project-grid-card.morph-card--open.morph-reveal {
  visibility: visible;
  animation: cardRevealIn 420ms ease forwards;
}

/* The card materializes just ahead of the arriving popup: hidden while the
   trajectory is still long, fully formed at 65% — the moment the popup
   begins dissolving on top of it (see popupCloseFade) */
@keyframes cardRevealIn {
  0%, 40%   { opacity: 0; }
  65%, 100% { opacity: 1; }
}

.project-popup.project-popup--closing {
  animation: popupCloseFade 420ms ease forwards;
}

/* Closing: the real content stays visible through the first stretch of the
   flight, then fades and hands off to the card face. No blur — the scaled
   icon/title land on the face's sizes, so the crossfade carries itself. */
.project-popup.project-popup--closing .morph-popup__inner {
  animation: popupInnerOut 420ms ease forwards;
  filter: none;
}

@keyframes popupInnerOut {
  0%, 35%   { opacity: 1; }
  75%, 100% { opacity: 0; }
}

/* Closing: the card face fades in as the box approaches card size, so the
   popup lands wearing exactly what the revealed card looks like */
.project-popup.project-popup--closing .popup-card-face {
  animation: cardFaceIn 420ms ease forwards;
}

@keyframes cardFaceIn {
  0%, 45%   { opacity: 0; }
  80%, 100% { opacity: 1; }
}

@keyframes popupCloseFade {
  0%, 65% { opacity: 1; }
  100%    { opacity: 0; }
}

/* Closing: shrink the icon back to the card's icon size as the box lands */
.project-popup.project-popup--closing .project-popup-icon {
  animation: popupIconOut 420ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes popupIconOut {
  from { scale: 1; }
  to   { scale: 0.75; }
}

/* Closing: shrink the title back to the card's title size as the box lands */
.project-popup.project-popup--closing .project-popup-title-container > h2 {
  animation: popupTitleOut 420ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes popupTitleOut {
  from { scale: 1; }
  to   { scale: 0.5; }
}
 
/* Close button — keep it in the top-right corner while scrolling */
.project-popup .popup-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  float: none;
  margin: 0;
}

/* Keep inner scrolling from rubber-banding/chaining past the popup */
.project-popup .morph-popup__inner {
  overscroll-behavior-y: contain;
}

/* Grabber — swipe-down-to-dismiss affordance, touch screens only */
.project-popup-grabber {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;

  width: 4rem;
  height: 1.75rem;
  z-index: 11;

  display: none;

  /* Fades in with the popup content, after the morph settles */
  opacity: 0;
  transition: opacity 0.18s ease;
}

.project-popup-grabber::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  left: 50%;
  translate: -50% 0;

  width: 2.25rem;
  height: 0.3125rem;
  border-radius: 9999px;
  background: rgba(127, 127, 127, 0.5);
}

.morph-popup--open .project-popup-grabber {
  opacity: 1;
}

@media (max-width: 600px), (pointer: coarse) {
  .project-popup-grabber {
    display: block;
  }
}