:root {
  color-scheme: dark light;
  --bg: #0b0d12;
  --bg-elevated: #161a24;
  --surface: #1d2433;
  --text: #e8ecf4;
  --muted: #9aa3b5;
  --accent: #5ee1d5;
  --accent-dim: #3aa89f;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --text: #12151c;
    --muted: #5c6575;
    --border: rgba(15, 20, 30, 0.1);
    --shadow: 0 16px 40px rgba(15, 20, 30, 0.12);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  overflow-x: hidden;
}

a {
  color: var(--accent-dim);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent);
}

kbd {
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* Ambient motion */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: drift 28s ease-in-out infinite;
}

.orb-a {
  width: 42vmin;
  height: 42vmin;
  background: #3d5a8a;
  top: -10%;
  left: -5%;
  animation-delay: 0s;
}

.orb-b {
  width: 36vmin;
  height: 36vmin;
  background: #2a6f6b;
  bottom: 5%;
  right: -8%;
  animation-delay: -9s;
}

.orb-c {
  width: 28vmin;
  height: 28vmin;
  background: #5b4d8a;
  top: 40%;
  left: 35%;
  animation-delay: -14s;
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(4vw, 6vh) scale(1.08);
  }
  66% {
    transform: translate(-3vw, -4vh) scale(0.95);
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .reveal,
  .flip-inner,
  .portrait-ring,
  .portrait-ring img {
    animation: none !important;
    transition: none !important;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .portrait-ring,
  .portrait-ring img {
    transform: none !important;
    box-shadow: none !important;
  }
}

.site-header {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 5vw, 4rem) 0;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
  display: inline-block;
  background-image: linear-gradient(90deg, #5ee1d5, #7c6cf0, #ff7ad9, #5ee1d5);
  background-size: 280% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.title.reveal {
  animation: rise-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards, text-flow 7.5s linear infinite;
  animation-delay: var(--d, 0ms), 0ms;
}

.subtitle {
  margin: 0.5rem 0 0;
  font-size: 1.15rem;
  color: var(--muted);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 5vw, 4rem) 4rem;
}

.hero {
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
}

.hero-grid {
  display: grid;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  align-items: start;
  grid-template-columns: 1fr;
}

@media (min-width: 880px) {
  .hero-grid {
    grid-template-columns: minmax(220px, 280px) 1fr;
    column-gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
  }
}

.hero-portrait {
  justify-self: center;
}

@media (min-width: 880px) {
  .hero-portrait {
    justify-self: start;
  }
}

.portrait-ring {
  position: relative;
  border-radius: 50%;
  padding: 8px;
  background: transparent;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.portrait-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #5ee1d5, #7c6cf0, #ff7ad9, #5ee1d5);
  animation: border-flow 8s linear infinite;
  z-index: 0;
}

@keyframes border-flow {
  to {
    transform: rotate(360deg);
  }
}

.portrait-ring img {
  position: relative;
  z-index: 1;
  display: block;
  width: min(300px, 76vw);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  transform: none;
  transition: none;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.35);
}

.hero-copy h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.hero-copy strong {
  font-weight: 650;
  display: inline-block;
  background-image: linear-gradient(90deg, #5ee1d5, #7c6cf0, #ff7ad9, #5ee1d5);
  background-size: 280% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: text-flow 7.5s linear infinite;
}

@keyframes text-flow {
  to {
    background-position: 280% 50%;
  }
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .title,
  .hero-copy strong {
    color: var(--accent);
  }
}

.lead {
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
  .title,
  .hero-copy strong {
    animation: none !important;
    background-size: 100% 100%;
  }
}

.section-head {
  margin-bottom: 1.5rem;
}

.section-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.project-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .project-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Flip card */
.project-card {
  --card-h: 300px;
  perspective: 1100px;
  min-height: var(--card-h);
  border: none;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
  outline: none;
}

.project-card:focus-visible {
  box-shadow: 0 0 0 3px var(--accent);
}

.flip-inner {
  position: relative;
  width: 100%;
  height: var(--card-h);
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: var(--radius);
}

.project-card:not(.flipped) .flip-inner {
  transform: rotateY(0deg);
}

.project-card.flipped .flip-inner {
  transform: rotateY(180deg);
}

@media (hover: hover) and (pointer: fine) {
  .project-card:not(.flipped):hover .flip-inner {
    transform: rotateY(180deg) translateY(-4px);
  }

  .project-card.flipped:hover .flip-inner {
    transform: rotateY(180deg) translateY(-4px);
  }
}

.flip-front,
.flip-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.flip-front {
  gap: 0.35rem;
}

.flip-back {
  transform: rotateY(180deg);
  overflow-y: auto;
}

.card-top {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.card-dates {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
  white-space: nowrap;
}

.card-company {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}

.card-place {
  font-size: 0.85rem;
  color: var(--muted);
}

.card-logo-wrap {
  width: 112px;
  height: 112px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 0.9rem;
  overflow: hidden;
}

.card-logo-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-logo-fallback {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.card-name {
  margin-top: auto;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--muted);
}

.flip-back h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.flip-back .role {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.tech-tags span {
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.task-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.task-list li {
  margin-bottom: 0.25rem;
}

.outro {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.outro h2 {
  margin-top: 0;
}

.site-footer {
  padding: 1.5rem clamp(1.25rem, 5vw, 4rem);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: rise-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-card {
  opacity: 0;
  animation: rise-in 0.6s ease forwards;
}

.project-card:nth-child(1) {
  animation-delay: 0.05s;
}
.project-card:nth-child(2) {
  animation-delay: 0.1s;
}
.project-card:nth-child(3) {
  animation-delay: 0.15s;
}
.project-card:nth-child(4) {
  animation-delay: 0.2s;
}
.project-card:nth-child(5) {
  animation-delay: 0.25s;
}
.project-card:nth-child(6) {
  animation-delay: 0.3s;
}
.project-card:nth-child(7) {
  animation-delay: 0.35s;
}
.project-card:nth-child(8) {
  animation-delay: 0.4s;
}
.project-card:nth-child(9) {
  animation-delay: 0.45s;
}
.project-card:nth-child(10) {
  animation-delay: 0.5s;
}
.project-card:nth-child(n + 11) {
  animation-delay: 0.55s;
}

@media (prefers-reduced-motion: reduce) {
  .project-card {
    opacity: 1;
    animation: none;
  }
}

/* Kontakt / Meta */
.contact-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) 1fr;
  gap: 0.65rem 1.25rem;
  font-size: 0.92rem;
  align-items: baseline;
}

.meta-grid dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.meta-grid dd {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(94, 225, 213, 0.12);
  color: var(--accent);
  border: 1px solid rgba(94, 225, 213, 0.35);
}

@media (min-width: 560px) {
  .contact-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
