/* Profile and bio are pinned to the top left, everything else flows around them */
@media (width >= 640px) {
  .card--profile {
    grid-column: 1;
    grid-row: 1;
  }

  .card--bio {
    grid-column: 1;
    grid-row: 2 / span 2;
  }
}

.card--profile {
  padding: 0;
  aspect-ratio: 4 / 3;
  justify-content: flex-end;

  /* Next to other tiles it takes the full height of its row instead of staying square */
  @media (width >= 640px) {
    aspect-ratio: auto;
    min-height: 280px;
  }

  & img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  & header {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xl) var(--spacing-lg) var(--spacing-md);
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  }

  & h1 {
    font-size: 1.5rem;
    line-height: 1.2;
  }

  & small {
    font-size: 1rem;
    opacity: 0.85;
  }
}

.bio-text {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  font-size: 1.05rem;
}

.skill-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-block: auto;
}

.skill-group {
  display: flex;
  flex-direction: column;
  gap: 6px;

  @media (width >= 640px) {
    display: grid;
    grid-template-columns: 112px 1fr;
    align-items: center;
    gap: var(--spacing-sm);
  }
}

.skill-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;

  @media (width >= 640px) {
    gap: var(--spacing-xs);
  }
}

/* The tooltips reach past the tile edge on narrow screens */
.card--skills {
  overflow: visible;
}

.skill {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  color: var(--skill-color, var(--clr-text));
  --fa-primary-color: currentColor;
  --fa-secondary-color: currentColor;
  background: var(--clr-surface-hover);
  border: 1px solid var(--clr-border);
  border-radius: calc(var(--border-radius) - 6px);

  @media (width >= 640px) {
    width: 48px;
  }

  & svg {
    width: auto;
    max-width: 80%;
    height: 1em;
    transition: scale 0.15s ease;
  }

  &:hover svg {
    scale: 1.12;
  }

  /* Pill-shaped name tag; screen readers already get the name from the .sr-only span */
  &::after {
    content: attr(data-tooltip) / "";
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: 10;
    padding: 4px var(--spacing-sm);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    color: var(--clr-main-text);
    background: color-mix(in srgb, var(--clr-main) 16%, var(--clr-surface));
    border-radius: 999px;
    box-shadow: var(--shadow);
    opacity: 0;
    translate: -50% 4px;
    pointer-events: none;
    transition: opacity 0.15s ease, translate 0.15s ease;
  }

  &:hover::after {
    opacity: 1;
    translate: -50% 0;
  }

  @media (prefers-reduced-motion: reduce) {
    & svg,
    &::after {
      transition: none;
    }
  }
}

.card--freelance {
  --clr-status: var(--clr-success);

  &[data-status="unavailable"] {
    --clr-status: var(--clr-danger);
  }
}

.status {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: 1.1rem;
  font-weight: 600;
}

.freelance-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  margin-block: auto;
  text-align: center;
}

.freelance-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--spacing-xs);
  font-size: 1.75rem;
  --fa-primary-color: var(--clr-status);
  --fa-secondary-color: var(--clr-status);
  background: color-mix(in srgb, var(--clr-status) 14%, transparent);
  border-radius: 50%;

  [data-status="available"] & {
    animation: pulse 2s infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    animation: none !important;
  }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--clr-status) 40%, transparent); }
  70% { box-shadow: 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.freelance-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}

.employer {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-block: auto;
}

.employer-logo {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 88px;
  height: 88px;
  color: light-dark(#2b344b, var(--clr-text));
  background: var(--clr-surface-hover);
  border: 1px solid var(--clr-border);
  border-radius: calc(var(--border-radius) - 4px);

  & svg {
    width: auto;
    height: 56px;
  }
}

.employer-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  text-wrap: balance;
}

.employer-name {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
}

.card--project {
  & .project-image {
    width: calc(100% + 2 * var(--spacing-lg));
    height: auto;
    margin: calc(-1 * var(--spacing-lg)) calc(-1 * var(--spacing-lg)) var(--spacing-xs);
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid var(--clr-border);
  }

  /* Wide tiles put the image on the left half instead of on top */
  @media (width >= 640px) {
    &:is(.card--wide, .card--full):has(.project-image) {
      padding-left: calc(50% + var(--spacing-lg));

      & .project-image {
        position: absolute;
        inset: 0 auto 0 0;
        width: 50%;
        height: 100%;
        margin: 0;
        aspect-ratio: auto;
        border-bottom: 0;
        border-right: 1px solid var(--clr-border);
      }
    }
  }

  &.card--big {
    background:
      radial-gradient(circle at 100% 0%, var(--clr-main-soft), transparent 60%),
      var(--clr-surface);

    & .project-category {
  --clr-category: var(--clr-text-muted);

  margin-left: auto;
  padding: 2px var(--spacing-xs);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--clr-category);
  background: color-mix(in srgb, var(--clr-category) 14%, transparent);
  border-radius: 999px;

  &[data-category="employment"] {
    --clr-category: light-dark(#3178c6, #5b9be0);
  }

  &[data-category="freelance"] {
    --clr-category: var(--clr-main-text);
  }

  &[data-category="personal"] {
    --clr-category: light-dark(#1f8a4c, #4ade80);
  }
}

.project-name {
      font-size: 2rem;
    }
  }
}

.project-category {
  --clr-category: var(--clr-text-muted);

  margin-left: auto;
  padding: 2px var(--spacing-xs);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--clr-category);
  background: color-mix(in srgb, var(--clr-category) 14%, transparent);
  border-radius: 999px;

  &[data-category="employment"] {
    --clr-category: light-dark(#3178c6, #5b9be0);
  }

  &[data-category="freelance"] {
    --clr-category: var(--clr-main-text);
  }

  &[data-category="personal"] {
    --clr-category: light-dark(#1f8a4c, #4ade80);
  }
}

.project-name {
  font-size: 1.35rem;
  line-height: 1.2;
}

.project-description {
  color: var(--clr-text-muted);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  --fa-secondary-color: #fff;
  padding: 2px var(--spacing-xs);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  background: #e91916;
  border-radius: 4px;
}

.card--twitch[data-live="true"] {
  border-color: #e91916;
}

.twitch-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--spacing-xs);
  font-weight: 600;
}

.twitch-title,
.twitch-teaser {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.twitch-game,
.twitch-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.twitch-stat {
  font-size: 0.875rem;
}

.twitch-last {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--spacing-sm);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--clr-border);
  border-radius: calc(var(--border-radius) - 4px);

  &:hover {
    background: var(--clr-surface-hover);
    border-color: var(--clr-main);
  }

  & small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--clr-text-muted);
  }

  & span:not(.sr-only) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
  }
}

.twitch-footer {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.toots {
  display: flex;
  flex-direction: column;
  list-style: none;
}

.toot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-block: var(--spacing-sm);

  & + & {
    border-top: 1px solid var(--clr-border);
  }

  & summary {
    font-weight: 600;
    cursor: pointer;
  }
}

.toot-content {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;

  & p + p {
    margin-top: var(--spacing-xs);
  }

  & a {
    color: var(--clr-main-text);
  }
}

.toot-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.setup-group {
  & h3 {
    margin-bottom: 4px;
    font-size: 0.95rem;
    color: var(--clr-main-text);
  }

  & ul {
    list-style: none;
  }

  & li {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-xs);
    padding-block: 2px;
  }

  & .svg-inline--fa {
    flex-shrink: 0;
    width: 1.25em;
    margin-top: 0.25em;
  }
}

.socials {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  list-style: none;
}

.social {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--spacing-sm);
  align-items: center;
  padding: var(--spacing-sm);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--clr-border);
  border-radius: calc(var(--border-radius) - 4px);

  &:hover {
    background: var(--clr-surface-hover);
    border-color: var(--clr-main);
  }

  & .social-icon {
    grid-row: span 2;
    width: 1.5em;
    font-size: 1.5rem;
    color: var(--clr-text-muted);
  }

  &:hover .social-icon {
    color: var(--clr-main-text);
  }

  & .external-icon {
    grid-column: 3;
    grid-row: 1 / span 2;
    color: var(--clr-text-muted);
  }

  & span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: var(--clr-text-muted);
  }
}

/* Beyond four columns the home tiles change size, so the grid still closes without gaps.
   Worked out by simulating the dense placement; the classes decide, not single projects. */
@media (width >= 1600px) {
  .main-grid > .card.card--project.card--full {
    grid-column: span 3;
  }

  .main-grid > .card.card--socials {
    grid-column: span 2;
  }
}

@media (width >= 2000px) {
  .main-grid > .card.card--skills {
    grid-column: span 3;
  }

  .main-grid > .card.card--twitch,
  .main-grid > .card.card--setup {
    grid-column: span 2;
  }

  .main-grid > .card.card--project.card--full {
    grid-column: span 4;
  }
}

@media (width >= 2400px) {
  .main-grid > .card.card--skills,
  .main-grid > .card.card--employer,
  .main-grid > .card.card--freelance {
    grid-column: span 2;
  }

  .main-grid > .card.card--project.card--wide,
  .main-grid > .card.card--mastodon {
    grid-column: span 3;
  }
}
